@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @since 1.0.0 |
28 | 28 | */ |
29 | - public function __construct( $slug ) { |
|
29 | + public function __construct($slug) { |
|
30 | 30 | $this->slug = $slug; |
31 | 31 | } |
32 | 32 | |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @since 1.0.0 |
42 | 42 | */ |
43 | - public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) { |
|
43 | + public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) { |
|
44 | 44 | |
45 | 45 | $hooks = wordpoints_hooks(); |
46 | 46 | |
47 | 47 | /** @var WordPoints_Hook_Reactor $reactor */ |
48 | - foreach ( $hooks->reactors->get_all() as $reactor ) { |
|
48 | + foreach ($hooks->reactors->get_all() as $reactor) { |
|
49 | 49 | |
50 | - foreach ( $reactor->get_all_reactions_to_event( $event_slug ) as $reaction ) { |
|
50 | + foreach ($reactor->get_all_reactions_to_event($event_slug) as $reaction) { |
|
51 | 51 | |
52 | 52 | $validator = new WordPoints_Hook_Reaction_Validator( |
53 | 53 | $reaction |
@@ -57,29 +57,29 @@ discard block |
||
57 | 57 | |
58 | 58 | $validator->validate(); |
59 | 59 | |
60 | - if ( $validator->had_errors() ) { |
|
60 | + if ($validator->had_errors()) { |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | |
64 | - unset( $validator ); |
|
64 | + unset($validator); |
|
65 | 65 | |
66 | - $fire = new WordPoints_Hook_Fire( $this, $event_args, $reaction ); |
|
66 | + $fire = new WordPoints_Hook_Fire($this, $event_args, $reaction); |
|
67 | 67 | |
68 | 68 | /** @var WordPoints_Hook_Extension[] $extensions */ |
69 | 69 | $extensions = $hooks->extensions->get_all(); |
70 | 70 | |
71 | - foreach ( $extensions as $extension ) { |
|
72 | - if ( ! $extension->should_hit( $fire ) ) { |
|
71 | + foreach ($extensions as $extension) { |
|
72 | + if ( ! $extension->should_hit($fire)) { |
|
73 | 73 | continue 2; |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | $fire->hit(); |
78 | 78 | |
79 | - $reactor->hit( $fire ); |
|
79 | + $reactor->hit($fire); |
|
80 | 80 | |
81 | - foreach ( $extensions as $extension ) { |
|
82 | - $extension->after_hit( $fire ); |
|
81 | + foreach ($extensions as $extension) { |
|
82 | + $extension->after_hit($fire); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return mixed The entity, or false if not found. |
108 | 108 | */ |
109 | - protected function get_entity( $id ) { |
|
109 | + protected function get_entity($id) { |
|
110 | 110 | |
111 | - $entity = call_user_func( $this->getter, $id ); |
|
111 | + $entity = call_user_func($this->getter, $id); |
|
112 | 112 | |
113 | - if ( ! $this->is_entity( $entity ) ) { |
|
113 | + if ( ! $this->is_entity($entity)) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return bool Whether the passed value is an entity. |
128 | 128 | */ |
129 | - protected function is_entity( $entity ) { |
|
129 | + protected function is_entity($entity) { |
|
130 | 130 | |
131 | - if ( ! is_object( $entity ) && ! is_array( $entity ) ) { |
|
131 | + if ( ! is_object($entity) && ! is_array($entity)) { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
135 | - return (bool) $this->get_entity_id( $entity ); |
|
135 | + return (bool) $this->get_entity_id($entity); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return mixed The value of the attribute of the entity. |
147 | 147 | */ |
148 | - protected function get_attr_value( $entity, $attr ) { |
|
148 | + protected function get_attr_value($entity, $attr) { |
|
149 | 149 | |
150 | - if ( is_array( $entity ) ) { |
|
151 | - if ( isset( $entity[ $attr ] ) ) { |
|
152 | - return $entity[ $attr ]; |
|
150 | + if (is_array($entity)) { |
|
151 | + if (isset($entity[$attr])) { |
|
152 | + return $entity[$attr]; |
|
153 | 153 | } |
154 | 154 | } else { |
155 | - if ( isset( $entity->{$attr} ) ) { |
|
155 | + if (isset($entity->{$attr} )) { |
|
156 | 156 | return $entity->{$attr}; |
157 | 157 | } |
158 | 158 | } |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return mixed The ID of the entity. |
171 | 171 | */ |
172 | - protected function get_entity_id( $entity ) { |
|
173 | - return $this->get_attr_value( $entity, $this->get_id_field() ); |
|
172 | + protected function get_entity_id($entity) { |
|
173 | + return $this->get_attr_value($entity, $this->get_id_field()); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return mixed The human ID of the entity. |
188 | 188 | */ |
189 | - protected function get_entity_human_id( $entity ) { |
|
190 | - return $this->get_attr_value( $entity, $this->human_id_field ); |
|
189 | + protected function get_entity_human_id($entity) { |
|
190 | + return $this->get_attr_value($entity, $this->human_id_field); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return string|int|float|false The human identifier for the entity, or false. |
233 | 233 | */ |
234 | - public function get_human_id( $id ) { |
|
234 | + public function get_human_id($id) { |
|
235 | 235 | |
236 | - $entity = $this->get_entity( $id ); |
|
236 | + $entity = $this->get_entity($id); |
|
237 | 237 | |
238 | - if ( ! $entity ) { |
|
238 | + if ( ! $entity) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | - return $this->get_entity_human_id( $entity ); |
|
242 | + return $this->get_entity_human_id($entity); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return bool Whether or not an entity with that ID exists. |
253 | 253 | */ |
254 | - public function exists( $id ) { |
|
255 | - return (bool) $this->get_entity( $id ); |
|
254 | + public function exists($id) { |
|
255 | + return (bool) $this->get_entity($id); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return WordPoints_Entityish|false The child's object, or false if not found. |
269 | 269 | */ |
270 | - public function get_child( $child_slug ) { |
|
270 | + public function get_child($child_slug) { |
|
271 | 271 | |
272 | 272 | $children = wordpoints_entities()->children; |
273 | 273 | |
274 | - $child = $children->get( $this->slug, $child_slug ); |
|
274 | + $child = $children->get($this->slug, $child_slug); |
|
275 | 275 | |
276 | 276 | if ( |
277 | - isset( $this->the_value ) |
|
277 | + isset($this->the_value) |
|
278 | 278 | && $child instanceof WordPoints_Entity_ChildI |
279 | 279 | ) { |
280 | - $child->set_the_value_from_entity( $this ); |
|
280 | + $child->set_the_value_from_entity($this); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $child; |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return bool Whether the value was set. |
301 | 301 | */ |
302 | - public function set_the_value( $value ) { |
|
302 | + public function set_the_value($value) { |
|
303 | 303 | |
304 | 304 | $this->the_value = $this->the_entity = $this->the_context = null; |
305 | 305 | |
306 | - if ( $this->is_entity( $value ) ) { |
|
306 | + if ($this->is_entity($value)) { |
|
307 | 307 | |
308 | 308 | $entity = $value; |
309 | - $value = $this->get_entity_id( $value ); |
|
309 | + $value = $this->get_entity_id($value); |
|
310 | 310 | |
311 | 311 | } else { |
312 | 312 | |
313 | - $entity = $this->get_entity( $value ); |
|
313 | + $entity = $this->get_entity($value); |
|
314 | 314 | |
315 | - if ( ! $entity ) { |
|
315 | + if ( ! $entity) { |
|
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | } |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return mixed The value of the attribute. |
337 | 337 | */ |
338 | - public function get_the_attr_value( $attr ) { |
|
339 | - return $this->get_attr_value( $this->the_entity, $attr ); |
|
338 | + public function get_the_attr_value($attr) { |
|
339 | + return $this->get_attr_value($this->the_entity, $attr); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return string|int|float|null The human identifier for the entity, or null. |
361 | 361 | */ |
362 | 362 | public function get_the_human_id() { |
363 | - return $this->get_entity_human_id( $this->the_entity ); |
|
363 | + return $this->get_entity_human_id($this->the_entity); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | |
395 | 395 | $guid = $this->get_the_context(); |
396 | 396 | |
397 | - if ( ! is_array( $guid ) ) { |
|
397 | + if ( ! is_array($guid)) { |
|
398 | 398 | return $guid; |
399 | 399 | } |
400 | 400 | |
401 | - $guid = array( $this->slug => $this->get_the_id() ) + $guid; |
|
401 | + $guid = array($this->slug => $this->get_the_id()) + $guid; |
|
402 | 402 | |
403 | 403 | return $guid; |
404 | 404 | } |
@@ -16,16 +16,16 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @param WordPoints_App $app The main WordPoints app. |
18 | 18 | */ |
19 | -function wordpoints_hooks_register_admin_apps( $app ) { |
|
19 | +function wordpoints_hooks_register_admin_apps($app) { |
|
20 | 20 | |
21 | 21 | $apps = $app->sub_apps; |
22 | 22 | |
23 | - $apps->register( 'admin', 'WordPoints_App' ); |
|
23 | + $apps->register('admin', 'WordPoints_App'); |
|
24 | 24 | |
25 | 25 | /** @var WordPoints_App $admin */ |
26 | - $admin = $apps->get( 'admin' ); |
|
26 | + $admin = $apps->get('admin'); |
|
27 | 27 | |
28 | - $admin->sub_apps->register( 'screen', 'WordPoints_Admin_Screens' ); |
|
28 | + $admin->sub_apps->register('screen', 'WordPoints_Admin_Screens'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | // Hooks page. |
47 | 47 | $id = add_submenu_page( |
48 | 48 | $wordpoints_menu |
49 | - , __( 'WordPoints — Points Types', 'wordpoints' ) |
|
50 | - , __( 'Points Types', 'wordpoints' ) |
|
49 | + , __('WordPoints — Points Types', 'wordpoints') |
|
50 | + , __('Points Types', 'wordpoints') |
|
51 | 51 | , 'manage_options' |
52 | 52 | , 'wordpoints_points_types' |
53 | - , array( $admin_screens, 'display' ) |
|
53 | + , array($admin_screens, 'display') |
|
54 | 54 | ); |
55 | 55 | |
56 | - if ( $id ) { |
|
57 | - $admin_screens->register( $id, 'WordPoints_Admin_Screen_Points_Types' ); |
|
56 | + if ($id) { |
|
57 | + $admin_screens->register($id, 'WordPoints_Admin_Screen_Points_Types'); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | */ |
68 | 68 | function wordpoints_hooks_admin_register_scripts() { |
69 | 69 | |
70 | - $assets_url = wordpoints_modules_url( '/assets', dirname( __FILE__ ) ); |
|
70 | + $assets_url = wordpoints_modules_url('/assets', dirname(__FILE__)); |
|
71 | 71 | |
72 | 72 | // CSS |
73 | 73 | |
74 | 74 | wp_register_style( |
75 | 75 | 'wordpoints-hooks-admin' |
76 | - , $assets_url . '/css/hooks.css' |
|
77 | - , array( 'dashicons', 'wp-jquery-ui-dialog' ) |
|
76 | + , $assets_url.'/css/hooks.css' |
|
77 | + , array('dashicons', 'wp-jquery-ui-dialog') |
|
78 | 78 | , WORDPOINTS_VERSION |
79 | 79 | ); |
80 | 80 | |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | |
83 | 83 | wp_register_script( |
84 | 84 | 'wordpoints-hooks-models' |
85 | - , $assets_url . '/js/hooks/models.js' |
|
86 | - , array( 'backbone', 'jquery-ui-dialog', 'wp-util' ) |
|
85 | + , $assets_url.'/js/hooks/models.js' |
|
86 | + , array('backbone', 'jquery-ui-dialog', 'wp-util') |
|
87 | 87 | , WORDPOINTS_VERSION |
88 | 88 | ); |
89 | 89 | |
90 | 90 | wp_register_script( |
91 | 91 | 'wordpoints-hooks-views' |
92 | - , $assets_url . '/js/hooks/views.js' |
|
93 | - , array( 'wordpoints-hooks-models' ) |
|
92 | + , $assets_url.'/js/hooks/views.js' |
|
93 | + , array('wordpoints-hooks-models') |
|
94 | 94 | , WORDPOINTS_VERSION |
95 | 95 | ); |
96 | 96 | |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | 'wordpoints-hooks-views' |
99 | 99 | , 'WordPointsHooksAdminL10n' |
100 | 100 | , array( |
101 | - 'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
102 | - 'changesSaved' => __( 'Your changes have been saved.', 'wordpoints' ), |
|
101 | + 'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
102 | + 'changesSaved' => __('Your changes have been saved.', 'wordpoints'), |
|
103 | 103 | /* translators: the name of the field that cannot be empty */ |
104 | - 'emptyField' => sprintf( __( '%s cannot be empty.', 'wordpoints' ), '{{ data.label }}' ), |
|
105 | - 'confirmDelete' => __( 'Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints' ), |
|
106 | - 'confirmTitle' => __( 'Are you sure?', 'wordpoints' ), |
|
107 | - 'deleteText' => __( 'Delete', 'wordpoints' ), |
|
108 | - 'cancelText' => __( 'Cancel', 'wordpoints' ), |
|
109 | - 'separator' => __( ' » ', 'wordpoints' ), |
|
110 | - 'target_label' => __( 'Target', 'wordpoints' ), |
|
104 | + 'emptyField' => sprintf(__('%s cannot be empty.', 'wordpoints'), '{{ data.label }}'), |
|
105 | + 'confirmDelete' => __('Are you sure that you want to delete this reaction? This action cannot be undone.', 'wordpoints'), |
|
106 | + 'confirmTitle' => __('Are you sure?', 'wordpoints'), |
|
107 | + 'deleteText' => __('Delete', 'wordpoints'), |
|
108 | + 'cancelText' => __('Cancel', 'wordpoints'), |
|
109 | + 'separator' => __(' » ', 'wordpoints'), |
|
110 | + 'target_label' => __('Target', 'wordpoints'), |
|
111 | 111 | ) |
112 | 112 | ); |
113 | 113 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | <div class="view"> |
120 | 120 | <div class="title"></div> |
121 | 121 | <button type="button" class="edit button-secondary"> |
122 | - ' . esc_html__( 'Edit', 'wordpoints' ) . ' |
|
122 | + ' . esc_html__('Edit', 'wordpoints').' |
|
123 | 123 | </button> |
124 | 124 | <button type="button" class="close button-secondary"> |
125 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
125 | + ' . esc_html__('Close', 'wordpoints').' |
|
126 | 126 | </button> |
127 | 127 | </div> |
128 | 128 | <div class="form"> |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | </div> |
142 | 142 | <div class="action-buttons"> |
143 | 143 | <button type="button" class="save button-primary" disabled> |
144 | - ' . esc_html__( 'Save', 'wordpoints' ) . ' |
|
144 | + ' . esc_html__('Save', 'wordpoints').' |
|
145 | 145 | </button> |
146 | 146 | <button type="button" class="cancel button-secondary"> |
147 | - ' . esc_html__( 'Cancel', 'wordpoints' ) . ' |
|
147 | + ' . esc_html__('Cancel', 'wordpoints').' |
|
148 | 148 | </button> |
149 | 149 | <button type="button" class="close button-secondary"> |
150 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
150 | + ' . esc_html__('Close', 'wordpoints').' |
|
151 | 151 | </button> |
152 | 152 | <button type="button" class="delete button-secondary"> |
153 | - ' . esc_html__( 'Delete', 'wordpoints' ) . ' |
|
153 | + ' . esc_html__('Delete', 'wordpoints').' |
|
154 | 154 | </button> |
155 | 155 | </div> |
156 | 156 | </div> |
@@ -198,15 +198,15 @@ discard block |
||
198 | 198 | |
199 | 199 | wp_register_script( |
200 | 200 | 'wordpoints-hooks-reactor-points' |
201 | - , $assets_url . '/js/hooks/reactors/points.js' |
|
202 | - , array( 'wordpoints-hooks-views' ) |
|
201 | + , $assets_url.'/js/hooks/reactors/points.js' |
|
202 | + , array('wordpoints-hooks-views') |
|
203 | 203 | , WORDPOINTS_VERSION |
204 | 204 | ); |
205 | 205 | |
206 | 206 | wp_register_script( |
207 | 207 | 'wordpoints-hooks-extension-conditions' |
208 | - , $assets_url . '/js/hooks/extensions/conditions.js' |
|
209 | - , array( 'wordpoints-hooks-views' ) |
|
208 | + , $assets_url.'/js/hooks/extensions/conditions.js' |
|
209 | + , array('wordpoints-hooks-views') |
|
210 | 210 | , WORDPOINTS_VERSION |
211 | 211 | ); |
212 | 212 | |
@@ -216,25 +216,25 @@ discard block |
||
216 | 216 | , ' |
217 | 217 | <script type="text/template" id="tmpl-wordpoints-hook-condition-groups"> |
218 | 218 | <div class="conditions-title section-title"> |
219 | - <h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4> |
|
219 | + <h4>' . esc_html__('Conditions', 'wordpoints').'</h4> |
|
220 | 220 | <button type="button" class="add-new button-secondary button-link"> |
221 | - <span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span> |
|
221 | + <span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span> |
|
222 | 222 | <span class="dashicons dashicons-plus"></span> |
223 | 223 | </button> |
224 | 224 | </div> |
225 | 225 | <div class="add-condition-form hidden"> |
226 | 226 | <div class="no-conditions hidden"> |
227 | - ' . esc_html__( 'No conditions available.', 'wordpoints' ) . ' |
|
227 | + ' . esc_html__('No conditions available.', 'wordpoints').' |
|
228 | 228 | </div> |
229 | 229 | <div class="condition-selectors"> |
230 | 230 | <div class="arg-selectors"></div> |
231 | 231 | <div class="condition-selector"></div> |
232 | 232 | </div> |
233 | - <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '"> |
|
234 | - ' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . ' |
|
233 | + <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'"> |
|
234 | + ' . esc_html_x('Add', 'reaction condition', 'wordpoints').' |
|
235 | 235 | </button> |
236 | - <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '"> |
|
237 | - ' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . ' |
|
236 | + <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'"> |
|
237 | + ' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').' |
|
238 | 238 | </button> |
239 | 239 | </div> |
240 | 240 | <div class="condition-groups section-content"></div> |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | <div class="condition-controls"> |
249 | 249 | <div class="condition-title"></div> |
250 | 250 | <button type="button" class="delete button-secondary button-link"> |
251 | - <span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span> |
|
251 | + <span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span> |
|
252 | 252 | <span class="dashicons dashicons-no"></span> |
253 | 253 | </button> |
254 | 254 | </div> |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | |
267 | 267 | wp_register_script( |
268 | 268 | 'wordpoints-hooks-extension-periods' |
269 | - , $assets_url . '/js/hooks/extensions/periods.js' |
|
270 | - , array( 'wordpoints-hooks-views' ) |
|
269 | + , $assets_url.'/js/hooks/extensions/periods.js' |
|
270 | + , array('wordpoints-hooks-views') |
|
271 | 271 | , WORDPOINTS_VERSION |
272 | 272 | ); |
273 | 273 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | , ' |
278 | 278 | <script type="text/template" id="tmpl-wordpoints-hook-periods"> |
279 | 279 | <div class="periods-title section-title"> |
280 | - <h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4> |
|
280 | + <h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4> |
|
281 | 281 | </div> |
282 | 282 | <div class="periods section-content"></div> |
283 | 283 | </script> |
@@ -296,27 +296,27 @@ discard block |
||
296 | 296 | |
297 | 297 | $extensions_data = array(); |
298 | 298 | |
299 | - foreach ( $hooks->extensions->get_all() as $slug => $extension ) { |
|
299 | + foreach ($hooks->extensions->get_all() as $slug => $extension) { |
|
300 | 300 | |
301 | - if ( $extension instanceof WordPoints_Hook_Extension ) { |
|
302 | - $extensions_data[ $slug ] = $extension->get_ui_script_data(); |
|
301 | + if ($extension instanceof WordPoints_Hook_Extension) { |
|
302 | + $extensions_data[$slug] = $extension->get_ui_script_data(); |
|
303 | 303 | } |
304 | 304 | |
305 | - if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) { |
|
306 | - wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" ); |
|
305 | + if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) { |
|
306 | + wp_enqueue_script("wordpoints-hooks-extension-{$slug}"); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | 310 | $reactor_data = array(); |
311 | 311 | |
312 | - foreach ( $hooks->reactors->get_all() as $slug => $reactor ) { |
|
312 | + foreach ($hooks->reactors->get_all() as $slug => $reactor) { |
|
313 | 313 | |
314 | - if ( $reactor instanceof WordPoints_Hook_Reactor ) { |
|
315 | - $reactor_data[ $slug ] = $reactor->get_ui_script_data(); |
|
314 | + if ($reactor instanceof WordPoints_Hook_Reactor) { |
|
315 | + $reactor_data[$slug] = $reactor->get_ui_script_data(); |
|
316 | 316 | } |
317 | 317 | |
318 | - if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) { |
|
319 | - wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" ); |
|
318 | + if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) { |
|
319 | + wp_enqueue_script("wordpoints-hooks-reactor-{$slug}"); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -328,28 +328,28 @@ discard block |
||
328 | 328 | $entity_children = $entities->children; |
329 | 329 | |
330 | 330 | /** @var WordPoints_Entity $entity */ |
331 | - foreach ( $entities->get_all() as $slug => $entity ) { |
|
331 | + foreach ($entities->get_all() as $slug => $entity) { |
|
332 | 332 | |
333 | 333 | $child_data = array(); |
334 | 334 | |
335 | 335 | /** @var WordPoints_EntityishI $child */ |
336 | - foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) { |
|
336 | + foreach ($entity_children->get_children($slug) as $child_slug => $child) { |
|
337 | 337 | |
338 | - $child_data[ $child_slug ] = array( |
|
338 | + $child_data[$child_slug] = array( |
|
339 | 339 | 'slug' => $child_slug, |
340 | 340 | 'title' => $child->get_title(), |
341 | 341 | ); |
342 | 342 | |
343 | - if ( $child instanceof WordPoints_Entity_Attr ) { |
|
343 | + if ($child instanceof WordPoints_Entity_Attr) { |
|
344 | 344 | |
345 | - $child_data[ $child_slug ]['_type'] = 'attr'; |
|
346 | - $child_data[ $child_slug ]['data_type'] = $child->get_data_type(); |
|
345 | + $child_data[$child_slug]['_type'] = 'attr'; |
|
346 | + $child_data[$child_slug]['data_type'] = $child->get_data_type(); |
|
347 | 347 | |
348 | - } elseif ( $child instanceof WordPoints_Entity_Relationship ) { |
|
348 | + } elseif ($child instanceof WordPoints_Entity_Relationship) { |
|
349 | 349 | |
350 | - $child_data[ $child_slug ]['_type'] = 'relationship'; |
|
351 | - $child_data[ $child_slug ]['primary'] = $child->get_primary_entity_slug(); |
|
352 | - $child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug(); |
|
350 | + $child_data[$child_slug]['_type'] = 'relationship'; |
|
351 | + $child_data[$child_slug]['primary'] = $child->get_primary_entity_slug(); |
|
352 | + $child_data[$child_slug]['secondary'] = $child->get_related_entity_slug(); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | * @param array $data The data for the entity child. |
361 | 361 | * @param WordPoints_Entityish $child The child's object. |
362 | 362 | */ |
363 | - $child_data[ $child_slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity_child', $child_data[ $child_slug ], $child ); |
|
363 | + $child_data[$child_slug] = apply_filters('wordpoints_hooks_ui_data_entity_child', $child_data[$child_slug], $child); |
|
364 | 364 | } |
365 | 365 | |
366 | - $entities_data[ $slug ] = array( |
|
366 | + $entities_data[$slug] = array( |
|
367 | 367 | 'slug' => $slug, |
368 | 368 | 'title' => $entity->get_title(), |
369 | 369 | 'children' => $child_data, |
@@ -371,12 +371,12 @@ discard block |
||
371 | 371 | '_type' => 'entity', |
372 | 372 | ); |
373 | 373 | |
374 | - if ( $entity instanceof WordPoints_Entity_EnumerableI ) { |
|
374 | + if ($entity instanceof WordPoints_Entity_EnumerableI) { |
|
375 | 375 | |
376 | 376 | $values = array(); |
377 | 377 | |
378 | - foreach ( $entity->get_enumerated_values() as $value ) { |
|
379 | - if ( $entity->set_the_value( $value ) ) { |
|
378 | + foreach ($entity->get_enumerated_values() as $value) { |
|
379 | + if ($entity->set_the_value($value)) { |
|
380 | 380 | $values[] = array( |
381 | 381 | 'value' => $entity->get_the_id(), |
382 | 382 | 'label' => $entity->get_the_human_id(), |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | - $entities_data[ $slug ]['values'] = $values; |
|
387 | + $entities_data[$slug]['values'] = $values; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param array $data The data for the entity. |
394 | 394 | * @param WordPoints_Entity $entity The entity object. |
395 | 395 | */ |
396 | - $entities_data[ $slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity', $entities_data[ $slug ], $entity ); |
|
396 | + $entities_data[$slug] = apply_filters('wordpoints_hooks_ui_data_entity', $entities_data[$slug], $entity); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | $data = array( |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @param array $data The data. |
416 | 416 | */ |
417 | - $data = apply_filters( 'wordpoints_hooks_ui_data', $data ); |
|
417 | + $data = apply_filters('wordpoints_hooks_ui_data', $data); |
|
418 | 418 | |
419 | 419 | wp_localize_script( |
420 | 420 | 'wordpoints-hooks-models' |
@@ -439,13 +439,13 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return string The HTML with templates appended. |
441 | 441 | */ |
442 | -function wordpoints_script_templates_filter( $html, $handle ) { |
|
442 | +function wordpoints_script_templates_filter($html, $handle) { |
|
443 | 443 | |
444 | 444 | global $wp_scripts; |
445 | 445 | |
446 | - $templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' ); |
|
446 | + $templates = $wp_scripts->get_data($handle, 'wordpoints-templates'); |
|
447 | 447 | |
448 | - if ( $templates ) { |
|
448 | + if ($templates) { |
|
449 | 449 | $html .= $templates; |
450 | 450 | } |
451 | 451 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function wordpoints_hooks_admin_ajax() { |
463 | 463 | |
464 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
464 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
465 | 465 | new WordPoints_Admin_Ajax_Hooks; |
466 | 466 | } |
467 | 467 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function get_settings_fields() { |
55 | 55 | |
56 | - $this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' ); |
|
57 | - $this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' ); |
|
58 | - $this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' ); |
|
56 | + $this->settings_fields['points']['label'] = _x('Points', 'form label', 'wordpoints'); |
|
57 | + $this->settings_fields['log_text']['label'] = _x('Log Text', 'form label', 'wordpoints'); |
|
58 | + $this->settings_fields['description']['label'] = _x('Description', 'form label', 'wordpoints'); |
|
59 | 59 | |
60 | 60 | return parent::get_settings_fields(); |
61 | 61 | } |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | |
68 | 68 | $data = parent::get_ui_script_data(); |
69 | 69 | |
70 | - $data['target_label'] = __( 'Award To', 'wordpoints' ); |
|
71 | - $data['periods_label'] = __( 'Award each user no more than once per:', 'wordpoints' ); |
|
70 | + $data['target_label'] = __('Award To', 'wordpoints'); |
|
71 | + $data['periods_label'] = __('Award each user no more than once per:', 'wordpoints'); |
|
72 | 72 | |
73 | 73 | return $data; |
74 | 74 | } |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | WordPoints_Hook_Event_Args $event_args |
83 | 83 | ) { |
84 | 84 | |
85 | - if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) { |
|
86 | - $validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' ); |
|
85 | + if ( ! isset($settings['points']) || false === wordpoints_int($settings['points'])) { |
|
86 | + $validator->add_error(__('Points must be an integer.', 'wordpoints'), 'points'); |
|
87 | 87 | } |
88 | 88 | |
89 | - if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
90 | - $validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' ); |
|
89 | + if ( ! isset($settings['points_type']) || ! wordpoints_is_points_type($settings['points_type'])) { |
|
90 | + $validator->add_error(__('Invalid points type.', 'wordpoints'), 'points_type'); |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( ! isset( $settings['description'] ) ) { |
|
94 | - $validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' ); |
|
93 | + if ( ! isset($settings['description'])) { |
|
94 | + $validator->add_error(__('Description is required.', 'wordpoints'), 'description'); |
|
95 | 95 | } |
96 | 96 | |
97 | - if ( ! isset( $settings['log_text'] ) ) { |
|
98 | - $validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' ); |
|
97 | + if ( ! isset($settings['log_text'])) { |
|
98 | + $validator->add_error(__('Log Text is required.', 'wordpoints'), 'log_text'); |
|
99 | 99 | } |
100 | 100 | |
101 | - return parent::validate_settings( $settings, $validator, $event_args ); |
|
101 | + return parent::validate_settings($settings, $validator, $event_args); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -109,49 +109,49 @@ discard block |
||
109 | 109 | array $settings |
110 | 110 | ) { |
111 | 111 | |
112 | - parent::update_settings( $reaction, $settings ); |
|
112 | + parent::update_settings($reaction, $settings); |
|
113 | 113 | |
114 | - $reaction->update_meta( 'points', $settings['points'] ); |
|
115 | - $reaction->update_meta( 'points_type', $settings['points_type'] ); |
|
116 | - $reaction->update_meta( 'description', $settings['description'] ); |
|
117 | - $reaction->update_meta( 'log_text', $settings['log_text'] ); |
|
114 | + $reaction->update_meta('points', $settings['points']); |
|
115 | + $reaction->update_meta('points_type', $settings['points_type']); |
|
116 | + $reaction->update_meta('description', $settings['description']); |
|
117 | + $reaction->update_meta('log_text', $settings['log_text']); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @since 1.0.0 |
122 | 122 | */ |
123 | - public function hit( WordPoints_Hook_Fire $fire ) { |
|
123 | + public function hit(WordPoints_Hook_Fire $fire) { |
|
124 | 124 | |
125 | 125 | $reaction = $fire->reaction; |
126 | 126 | |
127 | 127 | $target = $fire->event_args->get_from_hierarchy( |
128 | - $reaction->get_meta( 'target' ) |
|
128 | + $reaction->get_meta('target') |
|
129 | 129 | ); |
130 | 130 | |
131 | - if ( ! $target instanceof WordPoints_Entity ) { |
|
131 | + if ( ! $target instanceof WordPoints_Entity) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | 135 | $meta = array(); |
136 | 136 | |
137 | - foreach ( $fire->event_args->get_entities() as $entity ) { |
|
138 | - $meta[ $entity->get_slug() ] = $entity->get_the_id(); |
|
137 | + foreach ($fire->event_args->get_entities() as $entity) { |
|
138 | + $meta[$entity->get_slug()] = $entity->get_the_id(); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | wordpoints_alter_points( |
142 | 142 | $target->get_the_id() |
143 | - , $reaction->get_meta( 'points' ) |
|
144 | - , $reaction->get_meta( 'points_type' ) |
|
143 | + , $reaction->get_meta('points') |
|
144 | + , $reaction->get_meta('points_type') |
|
145 | 145 | , $reaction->get_event_slug() |
146 | 146 | , $meta |
147 | - , $reaction->get_meta( 'log_text' ) |
|
147 | + , $reaction->get_meta('log_text') |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | 152 | * @since 1.0.0 |
153 | 153 | */ |
154 | - public function reverse_hit( WordPoints_Hook_Fire $fire ) { |
|
154 | + public function reverse_hit(WordPoints_Hook_Fire $fire) { |
|
155 | 155 | |
156 | 156 | $meta_queries = array( |
157 | 157 | array( |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ), |
163 | 163 | ); |
164 | 164 | |
165 | - foreach ( $fire->event_args->get_entities() as $slug => $entity ) { |
|
165 | + foreach ($fire->event_args->get_entities() as $slug => $entity) { |
|
166 | 166 | |
167 | 167 | $meta_queries[] = array( |
168 | 168 | 'key' => $slug, |
@@ -179,35 +179,35 @@ discard block |
||
179 | 179 | |
180 | 180 | $logs = $query->get(); |
181 | 181 | |
182 | - if ( ! $logs ) { |
|
182 | + if ( ! $logs) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | 186 | global $wpdb; |
187 | 187 | |
188 | - add_filter( 'wordpoints_points_log', '__return_false' ); |
|
188 | + add_filter('wordpoints_points_log', '__return_false'); |
|
189 | 189 | |
190 | - foreach ( $logs as $log ) { |
|
190 | + foreach ($logs as $log) { |
|
191 | 191 | |
192 | 192 | wordpoints_alter_points( |
193 | 193 | $log->user_id |
194 | 194 | , -$log->points |
195 | 195 | , $log->points_type |
196 | 196 | , "reverse-{$log->log_type}" |
197 | - , array( 'original_log_id' => $log->id ) |
|
197 | + , array('original_log_id' => $log->id) |
|
198 | 198 | ); |
199 | 199 | |
200 | - wordpoints_points_log_delete_all_metadata( $log->id ); |
|
200 | + wordpoints_points_log_delete_all_metadata($log->id); |
|
201 | 201 | |
202 | 202 | // Now delete the log. |
203 | 203 | $wpdb->delete( |
204 | 204 | $wpdb->wordpoints_points_logs |
205 | - , array( 'id' => $log->id ) |
|
205 | + , array('id' => $log->id) |
|
206 | 206 | , '%d' |
207 | 207 | ); // WPCS: cache OK, cleaned by wordpoints_alter_points(). |
208 | 208 | } |
209 | 209 | |
210 | - remove_filter( 'wordpoints_points_log', '__return_false' ); |
|
210 | + remove_filter('wordpoints_points_log', '__return_false'); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @since 1.0.0 |
57 | 57 | */ |
58 | 58 | protected function get_title() { |
59 | - return _x( 'Points Types', 'page title', 'wordpoints' ); |
|
59 | + return _x('Points Types', 'page title', 'wordpoints'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | |
67 | 67 | parent::hooks(); |
68 | 68 | |
69 | - add_action( 'add_meta_boxes', array( $this, 'add_points_settings_meta_box' ) ); |
|
70 | - add_action( 'add_meta_boxes', array( $this, 'add_event_meta_boxes' ) ); |
|
69 | + add_action('add_meta_boxes', array($this, 'add_points_settings_meta_box')); |
|
70 | + add_action('add_meta_boxes', array($this, 'add_event_meta_boxes')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function enqueue_scripts() { |
77 | 77 | |
78 | - wp_enqueue_style( 'wordpoints-hooks-admin' ); |
|
78 | + wp_enqueue_style('wordpoints-hooks-admin'); |
|
79 | 79 | |
80 | - wp_enqueue_script( 'postbox' ); |
|
80 | + wp_enqueue_script('postbox'); |
|
81 | 81 | |
82 | 82 | wordpoints_hooks_ui_setup_script_data(); |
83 | 83 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | .addClass( 'closed' ); |
98 | 98 | |
99 | 99 | postboxes.add_postbox_toggles( |
100 | - <?php echo wp_json_encode( $this->id ); ?> |
|
100 | + <?php echo wp_json_encode($this->id); ?> |
|
101 | 101 | ); |
102 | 102 | } ); |
103 | 103 | </script> |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function add_points_settings_meta_box() { |
114 | 114 | |
115 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
115 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | 119 | add_meta_box( |
120 | 120 | 'settings' |
121 | - , __( 'Settings', 'wordpoints' ) |
|
122 | - , array( $this, 'display_points_settings_meta_box' ) |
|
121 | + , __('Settings', 'wordpoints') |
|
122 | + , array($this, 'display_points_settings_meta_box') |
|
123 | 123 | , $this->id |
124 | 124 | , 'side' |
125 | 125 | , 'default' |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function display_points_settings_meta_box() { |
135 | 135 | |
136 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
136 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | |
142 | 142 | $add_new = 0; |
143 | 143 | |
144 | - $points_type = wordpoints_get_points_type( $slug ); |
|
144 | + $points_type = wordpoints_get_points_type($slug); |
|
145 | 145 | |
146 | - if ( ! $points_type ) { |
|
146 | + if ( ! $points_type) { |
|
147 | 147 | |
148 | 148 | $points_type = array(); |
149 | - $add_new = wp_create_nonce( 'wordpoints_add_new_points_type' ); |
|
149 | + $add_new = wp_create_nonce('wordpoints_add_new_points_type'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | $points_type = array_merge( |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | ?> |
162 | 162 | |
163 | 163 | <form method="post"> |
164 | - <?php if ( $slug ) : ?> |
|
164 | + <?php if ($slug) : ?> |
|
165 | 165 | <p> |
166 | 166 | <span class="wordpoints-points-slug"> |
167 | 167 | <em> |
168 | - <?php echo esc_html( sprintf( __( 'Slug: %s', 'wordpoints' ), $slug ) ); ?> |
|
168 | + <?php echo esc_html(sprintf(__('Slug: %s', 'wordpoints'), $slug)); ?> |
|
169 | 169 | </em> |
170 | 170 | </span> |
171 | 171 | </p> |
172 | - <?php wp_nonce_field( "wordpoints_update_points_type-$slug", 'update_points_type' ); ?> |
|
172 | + <?php wp_nonce_field("wordpoints_update_points_type-$slug", 'update_points_type'); ?> |
|
173 | 173 | <?php endif; ?> |
174 | 174 | |
175 | 175 | <?php |
@@ -183,45 +183,45 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param string $points_type The slug of the points type. |
185 | 185 | */ |
186 | - do_action( 'wordpoints_points_type_form_top', $slug ); |
|
186 | + do_action('wordpoints_points_type_form_top', $slug); |
|
187 | 187 | |
188 | - if ( $add_new ) { |
|
188 | + if ($add_new) { |
|
189 | 189 | |
190 | 190 | // Mark the prefix and suffix optional on the add new form. |
191 | - $prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' ); |
|
192 | - $suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' ); |
|
191 | + $prefix = _x('Prefix (optional):', 'points type', 'wordpoints'); |
|
192 | + $suffix = _x('Suffix (optional):', 'points type', 'wordpoints'); |
|
193 | 193 | |
194 | 194 | } else { |
195 | 195 | |
196 | - $prefix = _x( 'Prefix:', 'points type', 'wordpoints' ); |
|
197 | - $suffix = _x( 'Suffix:', 'points type', 'wordpoints' ); |
|
196 | + $prefix = _x('Prefix:', 'points type', 'wordpoints'); |
|
197 | + $suffix = _x('Suffix:', 'points type', 'wordpoints'); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | ?> |
201 | 201 | |
202 | 202 | <p> |
203 | 203 | <label |
204 | - for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label> |
|
204 | + for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label> |
|
205 | 205 | <input class="widefat" type="text" |
206 | - id="points-name-<?php echo esc_attr( $slug ); ?>" |
|
206 | + id="points-name-<?php echo esc_attr($slug); ?>" |
|
207 | 207 | name="points-name" |
208 | - value="<?php echo esc_attr( $points_type['name'] ); ?>"/> |
|
208 | + value="<?php echo esc_attr($points_type['name']); ?>"/> |
|
209 | 209 | </p> |
210 | 210 | <p> |
211 | 211 | <label |
212 | - for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label> |
|
212 | + for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label> |
|
213 | 213 | <input class="widefat" type="text" |
214 | - id="points-prefix-<?php echo esc_attr( $slug ); ?>" |
|
214 | + id="points-prefix-<?php echo esc_attr($slug); ?>" |
|
215 | 215 | name="points-prefix" |
216 | - value="<?php echo esc_attr( $points_type['prefix'] ); ?>"/> |
|
216 | + value="<?php echo esc_attr($points_type['prefix']); ?>"/> |
|
217 | 217 | </p> |
218 | 218 | <p> |
219 | 219 | <label |
220 | - for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label> |
|
220 | + for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label> |
|
221 | 221 | <input class="widefat" type="text" |
222 | - id="points-suffix-<?php echo esc_attr( $slug ); ?>" |
|
222 | + id="points-suffix-<?php echo esc_attr($slug); ?>" |
|
223 | 223 | name="points-suffix" |
224 | - value="<?php echo esc_attr( $points_type['suffix'] ); ?>"/> |
|
224 | + value="<?php echo esc_attr($points_type['suffix']); ?>"/> |
|
225 | 225 | </p> |
226 | 226 | |
227 | 227 | <?php |
@@ -235,28 +235,28 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param string $points_type The slug of the points type. |
237 | 237 | */ |
238 | - do_action( 'wordpoints_points_type_form_bottom', $slug ); |
|
238 | + do_action('wordpoints_points_type_form_bottom', $slug); |
|
239 | 239 | |
240 | 240 | ?> |
241 | 241 | |
242 | 242 | <input type="hidden" name="points-slug" |
243 | - value="<?php echo esc_attr( $slug ); ?>"/> |
|
243 | + value="<?php echo esc_attr($slug); ?>"/> |
|
244 | 244 | <input type="hidden" name="add_new" class="add_new" |
245 | - value="<?php echo esc_attr( $add_new ); ?>"/> |
|
245 | + value="<?php echo esc_attr($add_new); ?>"/> |
|
246 | 246 | |
247 | 247 | <div class="hook-control-actions"> |
248 | 248 | <div class="alignleft"> |
249 | 249 | <?php |
250 | 250 | |
251 | - if ( ! $add_new ) { |
|
252 | - wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' ); |
|
253 | - submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) ); |
|
251 | + if ( ! $add_new) { |
|
252 | + wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce'); |
|
253 | + submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}")); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | ?> |
257 | 257 | </div> |
258 | 258 | <div class="alignright"> |
259 | - <?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?> |
|
259 | + <?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?> |
|
260 | 260 | <span class="spinner"></span> |
261 | 261 | </div> |
262 | 262 | <br class="clear"/> |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function add_event_meta_boxes() { |
275 | 275 | |
276 | - if ( ! $this->current_points_type ) { |
|
276 | + if ( ! $this->current_points_type) { |
|
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | 280 | /** @var WordPoints_Hook_EventI $event */ |
281 | - foreach ( $this->hooks->events->get_all() as $slug => $event ) { |
|
281 | + foreach ($this->hooks->events->get_all() as $slug => $event) { |
|
282 | 282 | |
283 | 283 | add_meta_box( |
284 | 284 | "{$this->current_points_type}-{$slug}" |
285 | 285 | , $event->get_title() |
286 | - , array( $this, 'display_event_meta_box' ) |
|
286 | + , array($this, 'display_event_meta_box') |
|
287 | 287 | , $this->id |
288 | 288 | , 'events' |
289 | 289 | , 'default' |
@@ -304,55 +304,55 @@ discard block |
||
304 | 304 | * @param array $points_type The points type this meta-box relates to. |
305 | 305 | * @param array $meta_box The data the meta-box was created with. |
306 | 306 | */ |
307 | - public function display_event_meta_box( $points_type, $meta_box ) { |
|
307 | + public function display_event_meta_box($points_type, $meta_box) { |
|
308 | 308 | |
309 | 309 | $event_slug = $meta_box['args']['slug']; |
310 | 310 | |
311 | 311 | /** @var WordPoints_Hook_Reactor $points_reactor */ |
312 | - $points_reactor = $this->hooks->reactors->get( 'points' ); |
|
312 | + $points_reactor = $this->hooks->reactors->get('points'); |
|
313 | 313 | |
314 | 314 | $data = array(); |
315 | 315 | |
316 | - foreach ( $points_reactor->reactions->get_reactions_to_event( $event_slug ) as $id => $reaction ) { |
|
317 | - if ( $reaction->get_meta( 'points_type' ) === $this->current_points_type ) { |
|
316 | + foreach ($points_reactor->reactions->get_reactions_to_event($event_slug) as $id => $reaction) { |
|
317 | + if ($reaction->get_meta('points_type') === $this->current_points_type) { |
|
318 | 318 | $data[] = WordPoints_Admin_Ajax_Hooks::prepare_hook_reaction( |
319 | 319 | $reaction |
320 | 320 | ); |
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
324 | - $args = $this->hooks->events->args->get_children( $event_slug ); |
|
324 | + $args = $this->hooks->events->args->get_children($event_slug); |
|
325 | 325 | |
326 | - $event_data = array( 'args' => array() ); |
|
326 | + $event_data = array('args' => array()); |
|
327 | 327 | |
328 | - foreach ( $args as $slug => $arg ) { |
|
328 | + foreach ($args as $slug => $arg) { |
|
329 | 329 | |
330 | - $event_data['args'][ $slug ] = array( |
|
330 | + $event_data['args'][$slug] = array( |
|
331 | 331 | 'slug' => $slug, |
332 | 332 | ); |
333 | 333 | |
334 | - if ( $arg instanceof WordPoints_Hook_Arg ) { |
|
335 | - $event_data['args'][ $slug ]['title'] = $arg->get_title(); |
|
336 | - $event_data['args'][ $slug ]['is_stateful'] = $arg->is_stateful(); |
|
334 | + if ($arg instanceof WordPoints_Hook_Arg) { |
|
335 | + $event_data['args'][$slug]['title'] = $arg->get_title(); |
|
336 | + $event_data['args'][$slug]['is_stateful'] = $arg->is_stateful(); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | ?> |
341 | 341 | |
342 | 342 | <script> |
343 | - WordPointsHooksAdminData.events[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $event_data ); ?>; |
|
344 | - WordPointsHooksAdminData.reactions[<?php echo wp_json_encode( $event_slug ); ?>] = <?php echo wp_json_encode( $data ); ?>; |
|
343 | + WordPointsHooksAdminData.events[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($event_data); ?>; |
|
344 | + WordPointsHooksAdminData.reactions[<?php echo wp_json_encode($event_slug); ?>] = <?php echo wp_json_encode($data); ?>; |
|
345 | 345 | </script> |
346 | 346 | |
347 | 347 | <div class="wordpoints-hook-reaction-group-container"> |
348 | 348 | <p class="description wordpoints-hook-reaction-group-description"> |
349 | - <?php echo esc_html( $meta_box['args']['event']->get_description() ); ?> |
|
349 | + <?php echo esc_html($meta_box['args']['event']->get_description()); ?> |
|
350 | 350 | </p> |
351 | 351 | |
352 | 352 | <div class="wordpoints-hook-reaction-group" |
353 | - data-wordpoints-hooks-hook-event="<?php echo esc_attr( $event_slug ); ?>" |
|
354 | - data-wordpoints-hooks-points-type="<?php echo esc_attr( $this->current_points_type ); ?>" |
|
355 | - data-wordpoints-hooks-create-nonce="<?php echo esc_attr( WordPoints_Admin_Ajax_Hooks::get_create_nonce( $points_reactor ) ); ?>" |
|
353 | + data-wordpoints-hooks-hook-event="<?php echo esc_attr($event_slug); ?>" |
|
354 | + data-wordpoints-hooks-points-type="<?php echo esc_attr($this->current_points_type); ?>" |
|
355 | + data-wordpoints-hooks-create-nonce="<?php echo esc_attr(WordPoints_Admin_Ajax_Hooks::get_create_nonce($points_reactor)); ?>" |
|
356 | 356 | data-wordpoints-hooks-reactor="points"> |
357 | 357 | </div> |
358 | 358 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | <div class="controls"> |
368 | 368 | <button type="button" class="button-primary add-reaction"> |
369 | - <?php esc_html_e( 'Add New', 'wordpoints' ); ?> |
|
369 | + <?php esc_html_e('Add New', 'wordpoints'); ?> |
|
370 | 370 | </button> |
371 | 371 | </div> |
372 | 372 | </div> |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | // Show a tab for each points type. |
387 | 387 | $tabs = array(); |
388 | 388 | |
389 | - foreach ( $points_types as $slug => $settings ) { |
|
390 | - $tabs[ $slug ] = $settings['name']; |
|
389 | + foreach ($points_types as $slug => $settings) { |
|
390 | + $tabs[$slug] = $settings['name']; |
|
391 | 391 | } |
392 | 392 | |
393 | - $tabs['add-new'] = __( 'Add New', 'wordpoints' ); |
|
393 | + $tabs['add-new'] = __('Add New', 'wordpoints'); |
|
394 | 394 | |
395 | - $tab = wordpoints_admin_get_current_tab( $tabs ); |
|
395 | + $tab = wordpoints_admin_get_current_tab($tabs); |
|
396 | 396 | |
397 | - if ( 'add-new' !== $tab ) { |
|
397 | + if ('add-new' !== $tab) { |
|
398 | 398 | $this->current_points_type = $tab; |
399 | 399 | } |
400 | 400 | |
401 | - do_action( 'add_meta_boxes', $this->id ); |
|
401 | + do_action('add_meta_boxes', $this->id); |
|
402 | 402 | |
403 | 403 | $this->tabs = $tabs; |
404 | 404 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function save_points_type() { |
412 | 412 | |
413 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
413 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
414 | 414 | return; |
415 | 415 | } |
416 | 416 | |
@@ -425,43 +425,43 @@ discard block |
||
425 | 425 | |
426 | 426 | $settings = array(); |
427 | 427 | |
428 | - $settings['name'] = trim( sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) ); // WPCS: CSRF OK |
|
429 | - $settings['prefix'] = ltrim( sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) ); // WPCS: CSRF OK |
|
430 | - $settings['suffix'] = rtrim( sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) ); // WPCS: CSRF OK |
|
428 | + $settings['name'] = trim(sanitize_text_field(wp_unslash($_POST['points-name']))); // WPCS: CSRF OK |
|
429 | + $settings['prefix'] = ltrim(sanitize_text_field(wp_unslash($_POST['points-prefix']))); // WPCS: CSRF OK |
|
430 | + $settings['suffix'] = rtrim(sanitize_text_field(wp_unslash($_POST['points-suffix']))); // WPCS: CSRF OK |
|
431 | 431 | |
432 | 432 | if ( |
433 | - isset( $_POST['points-slug'] ) |
|
434 | - && wordpoints_verify_nonce( 'update_points_type', 'wordpoints_update_points_type-%s', array( 'points-slug' ), 'post' ) |
|
433 | + isset($_POST['points-slug']) |
|
434 | + && wordpoints_verify_nonce('update_points_type', 'wordpoints_update_points_type-%s', array('points-slug'), 'post') |
|
435 | 435 | ) { |
436 | 436 | |
437 | 437 | // - We are updating an existing points type. |
438 | 438 | |
439 | - $points_type = sanitize_key( $_POST['points-slug'] ); |
|
439 | + $points_type = sanitize_key($_POST['points-slug']); |
|
440 | 440 | |
441 | - $old_settings = wordpoints_get_points_type( $points_type ); |
|
441 | + $old_settings = wordpoints_get_points_type($points_type); |
|
442 | 442 | |
443 | - if ( false === $old_settings ) { |
|
443 | + if (false === $old_settings) { |
|
444 | 444 | |
445 | 445 | add_settings_error( |
446 | 446 | '' |
447 | 447 | , 'wordpoints_points_type_update' |
448 | - , __( 'Error: failed updating points type.', 'wordpoints' ) |
|
448 | + , __('Error: failed updating points type.', 'wordpoints') |
|
449 | 449 | , 'updated' |
450 | 450 | ); |
451 | 451 | |
452 | 452 | return; |
453 | 453 | } |
454 | 454 | |
455 | - if ( is_array( $old_settings ) ) { |
|
456 | - $settings = array_merge( $old_settings, $settings ); |
|
455 | + if (is_array($old_settings)) { |
|
456 | + $settings = array_merge($old_settings, $settings); |
|
457 | 457 | } |
458 | 458 | |
459 | - if ( ! wordpoints_update_points_type( $points_type, $settings ) ) { |
|
459 | + if ( ! wordpoints_update_points_type($points_type, $settings)) { |
|
460 | 460 | |
461 | 461 | add_settings_error( |
462 | 462 | '' |
463 | 463 | , 'wordpoints_points_type_update' |
464 | - , __( 'Error: failed updating points type.', 'wordpoints' ) |
|
464 | + , __('Error: failed updating points type.', 'wordpoints') |
|
465 | 465 | , 'updated' |
466 | 466 | ); |
467 | 467 | |
@@ -470,23 +470,23 @@ discard block |
||
470 | 470 | add_settings_error( |
471 | 471 | '' |
472 | 472 | , 'wordpoints_points_type_update' |
473 | - , __( 'Points type updated.', 'wordpoints' ) |
|
473 | + , __('Points type updated.', 'wordpoints') |
|
474 | 474 | , 'updated' |
475 | 475 | ); |
476 | 476 | } |
477 | 477 | |
478 | - } elseif ( wordpoints_verify_nonce( 'add_new', 'wordpoints_add_new_points_type', null, 'post' ) ) { |
|
478 | + } elseif (wordpoints_verify_nonce('add_new', 'wordpoints_add_new_points_type', null, 'post')) { |
|
479 | 479 | |
480 | 480 | // - We are creating a new points type. |
481 | 481 | |
482 | - $slug = wordpoints_add_points_type( $settings ); |
|
482 | + $slug = wordpoints_add_points_type($settings); |
|
483 | 483 | |
484 | - if ( ! $slug ) { |
|
484 | + if ( ! $slug) { |
|
485 | 485 | |
486 | 486 | add_settings_error( |
487 | 487 | '' |
488 | 488 | , 'wordpoints_points_type_create' |
489 | - , __( 'Please choose a unique name for this points type.', 'wordpoints' ) |
|
489 | + , __('Please choose a unique name for this points type.', 'wordpoints') |
|
490 | 490 | ); |
491 | 491 | |
492 | 492 | } else { |
@@ -496,26 +496,26 @@ discard block |
||
496 | 496 | add_settings_error( |
497 | 497 | '' |
498 | 498 | , 'wordpoints_points_type_create' |
499 | - , __( 'Points type created.', 'wordpoints' ) |
|
499 | + , __('Points type created.', 'wordpoints') |
|
500 | 500 | , 'updated' |
501 | 501 | ); |
502 | 502 | } |
503 | 503 | } |
504 | 504 | |
505 | 505 | } elseif ( |
506 | - ! empty( $_POST['delete-points-type'] ) |
|
507 | - && isset( $_POST['points-slug'] ) |
|
508 | - && wordpoints_verify_nonce( 'delete-points-type-nonce', 'wordpoints_delete_points_type-%s', array( 'points-slug' ), 'post' ) |
|
506 | + ! empty($_POST['delete-points-type']) |
|
507 | + && isset($_POST['points-slug']) |
|
508 | + && wordpoints_verify_nonce('delete-points-type-nonce', 'wordpoints_delete_points_type-%s', array('points-slug'), 'post') |
|
509 | 509 | ) { |
510 | 510 | |
511 | 511 | // - We are deleting a points type. |
512 | 512 | |
513 | - if ( wordpoints_delete_points_type( sanitize_key( $_POST['points-slug'] ) ) ) { |
|
513 | + if (wordpoints_delete_points_type(sanitize_key($_POST['points-slug']))) { |
|
514 | 514 | |
515 | 515 | add_settings_error( |
516 | 516 | '' |
517 | 517 | , 'wordpoints_points_type_delete' |
518 | - , __( 'Points type deleted.', 'wordpoints' ) |
|
518 | + , __('Points type deleted.', 'wordpoints') |
|
519 | 519 | , 'updated' |
520 | 520 | ); |
521 | 521 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | add_settings_error( |
525 | 525 | '' |
526 | 526 | , 'wordpoints_points_type_delete' |
527 | - , __( 'Error while deleting.', 'wordpoints' ) |
|
527 | + , __('Error while deleting.', 'wordpoints') |
|
528 | 528 | ); |
529 | 529 | } |
530 | 530 | } |
@@ -540,25 +540,25 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @since 1.0.0 |
542 | 542 | */ |
543 | - do_action( 'wordpoints_admin_points_events_head' ); |
|
543 | + do_action('wordpoints_admin_points_events_head'); |
|
544 | 544 | |
545 | - if ( is_network_admin() ) { |
|
546 | - $title = __( 'Network Events', 'wordpoints' ); |
|
547 | - $description = __( 'Award points when various events happen on this network.', 'wordpoints' ); |
|
545 | + if (is_network_admin()) { |
|
546 | + $title = __('Network Events', 'wordpoints'); |
|
547 | + $description = __('Award points when various events happen on this network.', 'wordpoints'); |
|
548 | 548 | } else { |
549 | - $title = __( 'Events', 'wordpoints' ); |
|
550 | - $description = __( 'Award points when various events happen on this site.', 'wordpoints' ); |
|
549 | + $title = __('Events', 'wordpoints'); |
|
550 | + $description = __('Award points when various events happen on this site.', 'wordpoints'); |
|
551 | 551 | } |
552 | 552 | |
553 | - $points_type = wordpoints_get_points_type( $this->current_points_type ); |
|
553 | + $points_type = wordpoints_get_points_type($this->current_points_type); |
|
554 | 554 | |
555 | 555 | ?> |
556 | 556 | |
557 | 557 | <div class="wordpoints-points-type-meta-box-wrap"> |
558 | 558 | |
559 | 559 | <form> |
560 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
561 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
560 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
561 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
562 | 562 | </form> |
563 | 563 | |
564 | 564 | <div id="poststuff"> |
@@ -566,17 +566,17 @@ discard block |
||
566 | 566 | <div id="post-body" class="metabox-holder columns-<?php echo 1 === (int) get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
567 | 567 | |
568 | 568 | <div id="postbox-container-1" class="postbox-container"> |
569 | - <?php do_meta_boxes( $this->id, 'side', $points_type ); ?> |
|
569 | + <?php do_meta_boxes($this->id, 'side', $points_type); ?> |
|
570 | 570 | </div> |
571 | 571 | |
572 | - <?php if ( isset( $this->current_points_type ) ) : ?> |
|
572 | + <?php if (isset($this->current_points_type)) : ?> |
|
573 | 573 | <div class="wordpoints-hook-events-heading"> |
574 | - <h2><?php echo esc_html( $title ); ?></h2> |
|
575 | - <p class="description"><?php echo esc_html( $description ); ?></p> |
|
574 | + <h2><?php echo esc_html($title); ?></h2> |
|
575 | + <p class="description"><?php echo esc_html($description); ?></p> |
|
576 | 576 | </div> |
577 | 577 | |
578 | 578 | <div id="postbox-container-2" class="postbox-container"> |
579 | - <?php do_meta_boxes( $this->id, 'events', $points_type ); ?> |
|
579 | + <?php do_meta_boxes($this->id, 'events', $points_type); ?> |
|
580 | 580 | </div> |
581 | 581 | <?php endif; ?> |
582 | 582 | |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * |
596 | 596 | * @since 1.0.0 |
597 | 597 | */ |
598 | - do_action( 'wordpoints_admin_points_events_foot' ); |
|
598 | + do_action('wordpoints_admin_points_events_foot'); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 |
@@ -179,7 +179,7 @@ |
||
179 | 179 | * |
180 | 180 | * @param string $event_slug The slug of the event this reaction is for. |
181 | 181 | * |
182 | - * @return int|false The reaction ID, or false if not created. |
|
182 | + * @return integer The reaction ID, or false if not created. |
|
183 | 183 | */ |
184 | 184 | abstract protected function _create_reaction( $event_slug ); |
185 | 185 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * @since 1.0.0 |
62 | 62 | */ |
63 | - public function __construct( $slug, WordPoints_Hook_Reactor $reactor ) { |
|
63 | + public function __construct($slug, WordPoints_Hook_Reactor $reactor) { |
|
64 | 64 | |
65 | 65 | $this->slug = $slug; |
66 | 66 | $this->reactor = $reactor; |
@@ -84,33 +84,33 @@ discard block |
||
84 | 84 | * @since 1.0.0 |
85 | 85 | */ |
86 | 86 | public function get_context_id() { |
87 | - return wordpoints_entities_get_current_context_id( $this->context ); |
|
87 | + return wordpoints_entities_get_current_context_id($this->context); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @since 1.0.0 |
92 | 92 | */ |
93 | - public function get_reaction( $id ) { |
|
93 | + public function get_reaction($id) { |
|
94 | 94 | |
95 | - if ( ! $this->reaction_exists( $id ) ) { |
|
95 | + if ( ! $this->reaction_exists($id)) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - return new $this->reaction_class( $id, $this ); |
|
99 | + return new $this->reaction_class($id, $this); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | 103 | * @since 1.0.0 |
104 | 104 | */ |
105 | - public function create_reaction( array $settings ) { |
|
106 | - return $this->create_or_update_reaction( $settings ); |
|
105 | + public function create_reaction(array $settings) { |
|
106 | + return $this->create_or_update_reaction($settings); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @since 1.0.0 |
111 | 111 | */ |
112 | - public function update_reaction( $id, array $settings ) { |
|
113 | - return $this->create_or_update_reaction( $settings, $id ); |
|
112 | + public function update_reaction($id, array $settings) { |
|
113 | + return $this->create_or_update_reaction($settings, $id); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -125,41 +125,41 @@ discard block |
||
125 | 125 | * The reaction object if created/updated successfully. False or a |
126 | 126 | * validator instance if not. |
127 | 127 | */ |
128 | - protected function create_or_update_reaction( array $settings, $id = null ) { |
|
128 | + protected function create_or_update_reaction(array $settings, $id = null) { |
|
129 | 129 | |
130 | - $is_new = ! isset( $id ); |
|
130 | + $is_new = ! isset($id); |
|
131 | 131 | |
132 | - if ( ! $is_new && ! $this->reaction_exists( $id ) ) { |
|
132 | + if ( ! $is_new && ! $this->reaction_exists($id)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | - $validator = new WordPoints_Hook_Reaction_Validator( $settings, $this->reactor ); |
|
136 | + $validator = new WordPoints_Hook_Reaction_Validator($settings, $this->reactor); |
|
137 | 137 | $settings = $validator->validate(); |
138 | 138 | |
139 | - if ( $validator->had_errors() ) { |
|
139 | + if ($validator->had_errors()) { |
|
140 | 140 | return $validator; |
141 | 141 | } |
142 | 142 | |
143 | - if ( $is_new ) { |
|
143 | + if ($is_new) { |
|
144 | 144 | |
145 | - $id = $this->_create_reaction( $settings['event'] ); |
|
145 | + $id = $this->_create_reaction($settings['event']); |
|
146 | 146 | |
147 | - if ( ! $id ) { |
|
147 | + if ( ! $id) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - $reaction = $this->get_reaction( $id ); |
|
152 | + $reaction = $this->get_reaction($id); |
|
153 | 153 | |
154 | - $reaction->update_event_slug( $settings['event'] ); |
|
154 | + $reaction->update_event_slug($settings['event']); |
|
155 | 155 | |
156 | - unset( $settings['event'] ); |
|
156 | + unset($settings['event']); |
|
157 | 157 | |
158 | - $this->reactor->update_settings( $reaction, $settings ); |
|
158 | + $this->reactor->update_settings($reaction, $settings); |
|
159 | 159 | |
160 | 160 | /** @var WordPoints_Hook_Extension $extension */ |
161 | - foreach ( wordpoints_hooks()->extensions->get_all() as $extension ) { |
|
162 | - $extension->update_settings( $reaction, $settings ); |
|
161 | + foreach (wordpoints_hooks()->extensions->get_all() as $extension) { |
|
162 | + $extension->update_settings($reaction, $settings); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $settings The new settings for the reaction. |
170 | 170 | * @param bool $is_new Whether the reaction was just now created. |
171 | 171 | */ |
172 | - do_action( 'wordpoints_hook_reaction_save', $reaction, $settings, $is_new ); |
|
172 | + do_action('wordpoints_hook_reaction_save', $reaction, $settings, $is_new); |
|
173 | 173 | |
174 | 174 | return $reaction; |
175 | 175 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return int|false The reaction ID, or false if not created. |
188 | 188 | */ |
189 | - abstract protected function _create_reaction( $event_slug ); |
|
189 | + abstract protected function _create_reaction($event_slug); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // EOF |
@@ -7,26 +7,26 @@ |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'wordpoints_init_app-apps', 'wordpoints_apps_init' ); |
|
11 | -add_action( 'wordpoints_init_app-entities', 'wordpoints_entities_app_init' ); |
|
10 | +add_action('wordpoints_init_app-apps', 'wordpoints_apps_init'); |
|
11 | +add_action('wordpoints_init_app-entities', 'wordpoints_entities_app_init'); |
|
12 | 12 | |
13 | -add_action( 'wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init' ); |
|
14 | -add_action( 'wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init' ); |
|
13 | +add_action('wordpoints_init_app_registry-apps-entities', 'wordpoints_entities_init'); |
|
14 | +add_action('wordpoints_init_app_registry-entities-contexts', 'wordpoints_entity_contexts_init'); |
|
15 | 15 | |
16 | -add_action( 'wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init' ); |
|
16 | +add_action('wordpoints_init_app_registry-apps-data_types', 'wordpoints_data_types_init'); |
|
17 | 17 | |
18 | -add_action( 'wordpoints_init_app_registry-hooks-firers', 'wordpoints_hook_firers_init' ); |
|
19 | -add_action( 'wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init' ); |
|
20 | -add_action( 'wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init' ); |
|
21 | -add_action( 'wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init' ); |
|
22 | -add_action( 'wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_hook_reaction_stores_init' ); |
|
23 | -add_action( 'wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init' ); |
|
24 | -add_action( 'wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init' ); |
|
18 | +add_action('wordpoints_init_app_registry-hooks-firers', 'wordpoints_hook_firers_init'); |
|
19 | +add_action('wordpoints_init_app_registry-hooks-events', 'wordpoints_hook_events_init'); |
|
20 | +add_action('wordpoints_init_app_registry-hooks-actions', 'wordpoints_hook_actions_init'); |
|
21 | +add_action('wordpoints_init_app_registry-hooks-reactors', 'wordpoints_hook_reactors_init'); |
|
22 | +add_action('wordpoints_init_app_registry-hooks-reaction_stores', 'wordpoints_hook_reaction_stores_init'); |
|
23 | +add_action('wordpoints_init_app_registry-hooks-extensions', 'wordpoints_hook_extension_init'); |
|
24 | +add_action('wordpoints_init_app_registry-hooks-conditions', 'wordpoints_hook_conditions_init'); |
|
25 | 25 | |
26 | -add_action( 'wordpoints_modules_loaded', 'wordpoints_init_hooks' ); |
|
26 | +add_action('wordpoints_modules_loaded', 'wordpoints_init_hooks'); |
|
27 | 27 | |
28 | -add_action( 'init', 'wordpoints_hooks_api_add_global_cache_groups', 5 ); |
|
28 | +add_action('init', 'wordpoints_hooks_api_add_global_cache_groups', 5); |
|
29 | 29 | |
30 | -add_filter( 'wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log' ); |
|
30 | +add_filter('wordpoints_user_can_view_points_log', 'wordpoints_hooks_user_can_view_points_log'); |
|
31 | 31 | |
32 | 32 | // EOF |
@@ -35,18 +35,18 @@ |
||
35 | 35 | /** |
36 | 36 | * @since 1.0.0 |
37 | 37 | */ |
38 | - public function __construct( $id, WordPoints_Hook_Reaction_StoreI $store ) { |
|
38 | + public function __construct($id, WordPoints_Hook_Reaction_StoreI $store) { |
|
39 | 39 | |
40 | - $this->ID = wordpoints_int( $id ); |
|
40 | + $this->ID = wordpoints_int($id); |
|
41 | 41 | $this->store = $store; |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @since 1.0.0 |
46 | 46 | */ |
47 | - public function __get( $var ) { |
|
47 | + public function __get($var) { |
|
48 | 48 | |
49 | - if ( 'ID' === $var ) { |
|
49 | + if ('ID' === $var) { |
|
50 | 50 | return $this->ID; |
51 | 51 | } |
52 | 52 |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @since 1.0.0 |
26 | 26 | */ |
27 | 27 | public function get_event_slug() { |
28 | - return $this->store->get_reaction_event_from_index( $this->ID ); |
|
28 | + return $this->store->get_reaction_event_from_index($this->ID); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @since 1.0.0 |
33 | 33 | */ |
34 | - public function update_event_slug( $event_slug ) { |
|
34 | + public function update_event_slug($event_slug) { |
|
35 | 35 | return $this->store->update_reaction_event_in_index( |
36 | 36 | $this->ID |
37 | 37 | , $event_slug |
@@ -41,63 +41,63 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @since 1.0.0 |
43 | 43 | */ |
44 | - public function get_meta( $key ) { |
|
44 | + public function get_meta($key) { |
|
45 | 45 | |
46 | 46 | $settings = $this->get_settings(); |
47 | 47 | |
48 | - if ( ! is_array( $settings ) || ! isset( $settings[ $key ] ) ) { |
|
48 | + if ( ! is_array($settings) || ! isset($settings[$key])) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | - return $settings[ $key ]; |
|
52 | + return $settings[$key]; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @since 1.0.0 |
57 | 57 | */ |
58 | - public function add_meta( $key, $value ) { |
|
58 | + public function add_meta($key, $value) { |
|
59 | 59 | |
60 | 60 | $settings = $this->get_settings(); |
61 | 61 | |
62 | - if ( ! is_array( $settings ) || isset( $settings[ $key ] ) ) { |
|
62 | + if ( ! is_array($settings) || isset($settings[$key])) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
66 | - $settings[ $key ] = $value; |
|
66 | + $settings[$key] = $value; |
|
67 | 67 | |
68 | - return $this->update_settings( $settings ); |
|
68 | + return $this->update_settings($settings); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @since 1.0.0 |
73 | 73 | */ |
74 | - public function update_meta( $key, $value ) { |
|
74 | + public function update_meta($key, $value) { |
|
75 | 75 | |
76 | 76 | $settings = $this->get_settings(); |
77 | 77 | |
78 | - if ( ! is_array( $settings ) ) { |
|
78 | + if ( ! is_array($settings)) { |
|
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | |
82 | - $settings[ $key ] = $value; |
|
82 | + $settings[$key] = $value; |
|
83 | 83 | |
84 | - return $this->update_settings( $settings ); |
|
84 | + return $this->update_settings($settings); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | 88 | * @since 1.0.0 |
89 | 89 | */ |
90 | - public function delete_meta( $key ) { |
|
90 | + public function delete_meta($key) { |
|
91 | 91 | |
92 | 92 | $settings = $this->get_settings(); |
93 | 93 | |
94 | - if ( ! is_array( $settings ) || ! isset( $settings[ $key ] ) ) { |
|
94 | + if ( ! is_array($settings) || ! isset($settings[$key])) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - unset( $settings[ $key ] ); |
|
98 | + unset($settings[$key]); |
|
99 | 99 | |
100 | - return $this->update_settings( $settings ); |
|
100 | + return $this->update_settings($settings); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | protected function get_settings() { |
118 | 118 | |
119 | 119 | return $this->store->get_option( |
120 | - $this->store->get_settings_option_name( $this->ID ) |
|
120 | + $this->store->get_settings_option_name($this->ID) |
|
121 | 121 | ); |
122 | 122 | } |
123 | 123 | |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return bool Whether the settings were updated successfully. |
132 | 132 | */ |
133 | - protected function update_settings( $settings ) { |
|
133 | + protected function update_settings($settings) { |
|
134 | 134 | |
135 | 135 | return $this->store->update_option( |
136 | - $this->store->get_settings_option_name( $this->ID ) |
|
136 | + $this->store->get_settings_option_name($this->ID) |
|
137 | 137 | , $settings |
138 | 138 | ); |
139 | 139 | } |