@@ -7,17 +7,17 @@ |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'wordpoints_init_app-apps', 'wordpoints_hooks_register_admin_apps' ); |
|
10 | +add_action('wordpoints_init_app-apps', 'wordpoints_hooks_register_admin_apps'); |
|
11 | 11 | |
12 | -add_action( 'admin_menu', 'wordpoints_hooks_api_admin_menu' ); |
|
12 | +add_action('admin_menu', 'wordpoints_hooks_api_admin_menu'); |
|
13 | 13 | |
14 | -if ( is_wordpoints_network_active() ) { |
|
15 | - add_action( 'network_admin_menu', 'wordpoints_hooks_api_admin_menu' ); |
|
14 | +if (is_wordpoints_network_active()) { |
|
15 | + add_action('network_admin_menu', 'wordpoints_hooks_api_admin_menu'); |
|
16 | 16 | } |
17 | 17 | |
18 | -add_action( 'admin_init', 'wordpoints_hooks_admin_register_scripts' ); |
|
19 | -add_action( 'admin_init', 'wordpoints_hooks_admin_ajax' ); |
|
18 | +add_action('admin_init', 'wordpoints_hooks_admin_register_scripts'); |
|
19 | +add_action('admin_init', 'wordpoints_hooks_admin_ajax'); |
|
20 | 20 | |
21 | -add_filter( 'script_loader_tag', 'wordpoints_script_templates_filter', 10, 2 ); |
|
21 | +add_filter('script_loader_tag', 'wordpoints_script_templates_filter', 10, 2); |
|
22 | 22 | |
23 | 23 | // EOF |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | public function hooks() { |
63 | 63 | |
64 | 64 | /* Load the JavaScript needed for the settings screen. */ |
65 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
66 | - add_action( "admin_footer-{$this->id}", array( $this, 'footer_scripts' ) ); |
|
65 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
66 | + add_action("admin_footer-{$this->id}", array($this, 'footer_scripts')); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | |
99 | 99 | <div class="wrap"> |
100 | 100 | |
101 | - <h1><?php echo esc_html( $this->get_title() ); ?></h1> |
|
101 | + <h1><?php echo esc_html($this->get_title()); ?></h1> |
|
102 | 102 | |
103 | 103 | <?php settings_errors(); ?> |
104 | 104 | |
105 | - <?php if ( ! empty( $this->tabs ) ) : ?> |
|
106 | - <?php wordpoints_admin_show_tabs( $this->tabs, false ); ?> |
|
105 | + <?php if ( ! empty($this->tabs)) : ?> |
|
106 | + <?php wordpoints_admin_show_tabs($this->tabs, false); ?> |
|
107 | 107 | <?php endif; ?> |
108 | 108 | |
109 | 109 | <?php $this->display_content(); ?> |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @since 1.0.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'current_screen', array( $this, 'set_current_screen' ) ); |
|
30 | + add_action('current_screen', array($this, 'set_current_screen')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -37,23 +37,23 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param WP_Screen $current_screen The WP_Screen object for the current screen. |
39 | 39 | */ |
40 | - public function set_current_screen( $current_screen ) { |
|
40 | + public function set_current_screen($current_screen) { |
|
41 | 41 | |
42 | 42 | $screen_id = $current_screen->id; |
43 | 43 | |
44 | - if ( is_network_admin() ) { |
|
45 | - $screen_id = substr( $screen_id, 0, -8 /* -network */ ); |
|
44 | + if (is_network_admin()) { |
|
45 | + $screen_id = substr($screen_id, 0, -8 /* -network */); |
|
46 | 46 | } |
47 | 47 | |
48 | - $screen = $this->get( $screen_id ); |
|
48 | + $screen = $this->get($screen_id); |
|
49 | 49 | |
50 | - if ( ! ( $screen instanceof WordPoints_Admin_Screen ) ) { |
|
50 | + if ( ! ($screen instanceof WordPoints_Admin_Screen)) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $this->current_screen = $screen; |
55 | 55 | |
56 | - add_action( "load-{$screen_id}", array( $this->current_screen, 'load' ) ); |
|
56 | + add_action("load-{$screen_id}", array($this->current_screen, 'load')); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -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,15 +98,15 @@ 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' ), |
|
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 | 110 | ) |
111 | 111 | ); |
112 | 112 | |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | <div class="view"> |
119 | 119 | <div class="title"></div> |
120 | 120 | <button type="button" class="edit button-secondary"> |
121 | - ' . esc_html__( 'Edit', 'wordpoints' ) . ' |
|
121 | + ' . esc_html__('Edit', 'wordpoints').' |
|
122 | 122 | </button> |
123 | 123 | <button type="button" class="close button-secondary"> |
124 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
124 | + ' . esc_html__('Close', 'wordpoints').' |
|
125 | 125 | </button> |
126 | 126 | </div> |
127 | 127 | <div class="form"> |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | </div> |
141 | 141 | <div class="action-buttons"> |
142 | 142 | <button type="button" class="save button-primary" disabled> |
143 | - ' . esc_html__( 'Save', 'wordpoints' ) . ' |
|
143 | + ' . esc_html__('Save', 'wordpoints').' |
|
144 | 144 | </button> |
145 | 145 | <button type="button" class="cancel button-secondary"> |
146 | - ' . esc_html__( 'Cancel', 'wordpoints' ) . ' |
|
146 | + ' . esc_html__('Cancel', 'wordpoints').' |
|
147 | 147 | </button> |
148 | 148 | <button type="button" class="close button-secondary"> |
149 | - ' . esc_html__( 'Close', 'wordpoints' ) . ' |
|
149 | + ' . esc_html__('Close', 'wordpoints').' |
|
150 | 150 | </button> |
151 | 151 | <button type="button" class="delete button-secondary"> |
152 | - ' . esc_html__( 'Delete', 'wordpoints' ) . ' |
|
152 | + ' . esc_html__('Delete', 'wordpoints').' |
|
153 | 153 | </button> |
154 | 154 | </div> |
155 | 155 | </div> |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | |
198 | 198 | wp_register_script( |
199 | 199 | 'wordpoints-hooks-reactor-points' |
200 | - , $assets_url . '/js/hooks/reactors/points.js' |
|
201 | - , array( 'wordpoints-hooks-views' ) |
|
200 | + , $assets_url.'/js/hooks/reactors/points.js' |
|
201 | + , array('wordpoints-hooks-views') |
|
202 | 202 | , WORDPOINTS_VERSION |
203 | 203 | ); |
204 | 204 | |
205 | 205 | wp_register_script( |
206 | 206 | 'wordpoints-hooks-extension-conditions' |
207 | - , $assets_url . '/js/hooks/extensions/conditions.js' |
|
208 | - , array( 'wordpoints-hooks-views' ) |
|
207 | + , $assets_url.'/js/hooks/extensions/conditions.js' |
|
208 | + , array('wordpoints-hooks-views') |
|
209 | 209 | , WORDPOINTS_VERSION |
210 | 210 | ); |
211 | 211 | |
@@ -215,25 +215,25 @@ discard block |
||
215 | 215 | , ' |
216 | 216 | <script type="text/template" id="tmpl-wordpoints-hook-condition-groups"> |
217 | 217 | <div class="conditions-title section-title"> |
218 | - <h4>' . esc_html__( 'Conditions', 'wordpoints' ) . '</h4> |
|
218 | + <h4>' . esc_html__('Conditions', 'wordpoints').'</h4> |
|
219 | 219 | <button type="button" class="add-new button-secondary button-link"> |
220 | - <span class="screen-reader-text">' . esc_html__( 'Add New Condition', 'wordpoints' ) . '</span> |
|
220 | + <span class="screen-reader-text">' . esc_html__('Add New Condition', 'wordpoints').'</span> |
|
221 | 221 | <span class="dashicons dashicons-plus"></span> |
222 | 222 | </button> |
223 | 223 | </div> |
224 | 224 | <div class="add-condition-form hidden"> |
225 | 225 | <div class="no-conditions hidden"> |
226 | - ' . esc_html__( 'No conditions available.', 'wordpoints' ) . ' |
|
226 | + ' . esc_html__('No conditions available.', 'wordpoints').' |
|
227 | 227 | </div> |
228 | 228 | <div class="condition-selectors"> |
229 | 229 | <div class="arg-selectors"></div> |
230 | 230 | <div class="condition-selector"></div> |
231 | 231 | </div> |
232 | - <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__( 'Add Condition', 'wordpoints' ) . '"> |
|
233 | - ' . esc_html_x( 'Add', 'reaction condition', 'wordpoints' ) . ' |
|
232 | + <button type="button" class="confirm-add-new button-secondary" disabled aria-label="' . esc_attr__('Add Condition', 'wordpoints').'"> |
|
233 | + ' . esc_html_x('Add', 'reaction condition', 'wordpoints').' |
|
234 | 234 | </button> |
235 | - <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__( 'Cancel Adding New Condition', 'wordpoints' ) . '"> |
|
236 | - ' . esc_html_x( 'Cancel', 'reaction condition', 'wordpoints' ) . ' |
|
235 | + <button type="button" class="cancel-add-new button-secondary" aria-label="' . esc_attr__('Cancel Adding New Condition', 'wordpoints').'"> |
|
236 | + ' . esc_html_x('Cancel', 'reaction condition', 'wordpoints').' |
|
237 | 237 | </button> |
238 | 238 | </div> |
239 | 239 | <div class="condition-groups section-content"></div> |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | <div class="condition-controls"> |
248 | 248 | <div class="condition-title"></div> |
249 | 249 | <button type="button" class="delete button-secondary button-link"> |
250 | - <span class="screen-reader-text">' . esc_html__( 'Remove Condition', 'wordpoints' ) . '</span> |
|
250 | + <span class="screen-reader-text">' . esc_html__('Remove Condition', 'wordpoints').'</span> |
|
251 | 251 | <span class="dashicons dashicons-no"></span> |
252 | 252 | </button> |
253 | 253 | </div> |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | |
266 | 266 | wp_register_script( |
267 | 267 | 'wordpoints-hooks-extension-periods' |
268 | - , $assets_url . '/js/hooks/extensions/periods.js' |
|
269 | - , array( 'wordpoints-hooks-views' ) |
|
268 | + , $assets_url.'/js/hooks/extensions/periods.js' |
|
269 | + , array('wordpoints-hooks-views') |
|
270 | 270 | , WORDPOINTS_VERSION |
271 | 271 | ); |
272 | 272 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | , ' |
277 | 277 | <script type="text/template" id="tmpl-wordpoints-hook-periods"> |
278 | 278 | <div class="periods-title section-title"> |
279 | - <h4>' . esc_html__( 'Rate Limit', 'wordpoints' ) . '</h4> |
|
279 | + <h4>' . esc_html__('Rate Limit', 'wordpoints').'</h4> |
|
280 | 280 | </div> |
281 | 281 | <div class="periods section-content"></div> |
282 | 282 | </script> |
@@ -295,32 +295,32 @@ discard block |
||
295 | 295 | |
296 | 296 | $extensions_data = array(); |
297 | 297 | |
298 | - foreach ( $hooks->extensions->get_all() as $slug => $extension ) { |
|
298 | + foreach ($hooks->extensions->get_all() as $slug => $extension) { |
|
299 | 299 | |
300 | - if ( $extension instanceof WordPoints_Hook_Extension ) { |
|
301 | - $extensions_data[ $slug ] = $extension->get_ui_script_data(); |
|
300 | + if ($extension instanceof WordPoints_Hook_Extension) { |
|
301 | + $extensions_data[$slug] = $extension->get_ui_script_data(); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) { |
|
305 | - wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" ); |
|
304 | + if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) { |
|
305 | + wp_enqueue_script("wordpoints-hooks-extension-{$slug}"); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | $reactor_data = array(); |
310 | 310 | |
311 | - foreach ( $hooks->reactors->get_all() as $slug => $reactor ) { |
|
311 | + foreach ($hooks->reactors->get_all() as $slug => $reactor) { |
|
312 | 312 | |
313 | - if ( $reactor instanceof WordPoints_Hook_Reactor ) { |
|
314 | - $reactor_data[ $slug ] = array( |
|
313 | + if ($reactor instanceof WordPoints_Hook_Reactor) { |
|
314 | + $reactor_data[$slug] = array( |
|
315 | 315 | 'slug' => $reactor->get_slug(), |
316 | 316 | 'fields' => $reactor->get_settings_fields(), |
317 | 317 | 'arg_types' => $reactor->get_arg_types(), |
318 | - 'target_label' => __( 'Award To', 'wordpoints' ), |
|
318 | + 'target_label' => __('Award To', 'wordpoints'), |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | |
322 | - if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) { |
|
323 | - wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" ); |
|
322 | + if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) { |
|
323 | + wp_enqueue_script("wordpoints-hooks-reactor-{$slug}"); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -332,28 +332,28 @@ discard block |
||
332 | 332 | $entity_children = $entities->children; |
333 | 333 | |
334 | 334 | /** @var WordPoints_Entity $entity */ |
335 | - foreach ( $entities->get_all() as $slug => $entity ) { |
|
335 | + foreach ($entities->get_all() as $slug => $entity) { |
|
336 | 336 | |
337 | 337 | $child_data = array(); |
338 | 338 | |
339 | 339 | /** @var WordPoints_EntityishI $child */ |
340 | - foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) { |
|
340 | + foreach ($entity_children->get_children($slug) as $child_slug => $child) { |
|
341 | 341 | |
342 | - $child_data[ $child_slug ] = array( |
|
342 | + $child_data[$child_slug] = array( |
|
343 | 343 | 'slug' => $child_slug, |
344 | 344 | 'title' => $child->get_title(), |
345 | 345 | ); |
346 | 346 | |
347 | - if ( $child instanceof WordPoints_Entity_Attr ) { |
|
347 | + if ($child instanceof WordPoints_Entity_Attr) { |
|
348 | 348 | |
349 | - $child_data[ $child_slug ]['_type'] = 'attr'; |
|
350 | - $child_data[ $child_slug ]['data_type'] = $child->get_data_type(); |
|
349 | + $child_data[$child_slug]['_type'] = 'attr'; |
|
350 | + $child_data[$child_slug]['data_type'] = $child->get_data_type(); |
|
351 | 351 | |
352 | - } elseif ( $child instanceof WordPoints_Entity_Relationship ) { |
|
352 | + } elseif ($child instanceof WordPoints_Entity_Relationship) { |
|
353 | 353 | |
354 | - $child_data[ $child_slug ]['_type'] = 'relationship'; |
|
355 | - $child_data[ $child_slug ]['primary'] = $child->get_primary_entity_slug(); |
|
356 | - $child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug(); |
|
354 | + $child_data[$child_slug]['_type'] = 'relationship'; |
|
355 | + $child_data[$child_slug]['primary'] = $child->get_primary_entity_slug(); |
|
356 | + $child_data[$child_slug]['secondary'] = $child->get_related_entity_slug(); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | * @param array $data The data for the entity child. |
365 | 365 | * @param WordPoints_Entityish $child The child's object. |
366 | 366 | */ |
367 | - $child_data[ $child_slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity_child', $child_data[ $child_slug ], $child ); |
|
367 | + $child_data[$child_slug] = apply_filters('wordpoints_hooks_ui_data_entity_child', $child_data[$child_slug], $child); |
|
368 | 368 | } |
369 | 369 | |
370 | - $entities_data[ $slug ] = array( |
|
370 | + $entities_data[$slug] = array( |
|
371 | 371 | 'slug' => $slug, |
372 | 372 | 'title' => $entity->get_title(), |
373 | 373 | 'children' => $child_data, |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | '_type' => 'entity', |
376 | 376 | ); |
377 | 377 | |
378 | - if ( $entity instanceof WordPoints_Entity_EnumerableI ) { |
|
378 | + if ($entity instanceof WordPoints_Entity_EnumerableI) { |
|
379 | 379 | |
380 | 380 | $values = array(); |
381 | 381 | |
382 | - foreach ( $entity->get_enumerated_values() as $value ) { |
|
383 | - if ( $entity->set_the_value( $value ) ) { |
|
382 | + foreach ($entity->get_enumerated_values() as $value) { |
|
383 | + if ($entity->set_the_value($value)) { |
|
384 | 384 | $values[] = array( |
385 | 385 | 'value' => $entity->get_the_id(), |
386 | 386 | 'label' => $entity->get_the_human_id(), |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | - $entities_data[ $slug ]['values'] = $values; |
|
391 | + $entities_data[$slug]['values'] = $values; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * @param array $data The data for the entity. |
398 | 398 | * @param WordPoints_Entity $entity The entity object. |
399 | 399 | */ |
400 | - $entities_data[ $slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity', $entities_data[ $slug ], $entity ); |
|
400 | + $entities_data[$slug] = apply_filters('wordpoints_hooks_ui_data_entity', $entities_data[$slug], $entity); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | $data = array( |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param array $data The data. |
420 | 420 | */ |
421 | - $data = apply_filters( 'wordpoints_hooks_ui_data', $data ); |
|
421 | + $data = apply_filters('wordpoints_hooks_ui_data', $data); |
|
422 | 422 | |
423 | 423 | wp_localize_script( |
424 | 424 | 'wordpoints-hooks-models' |
@@ -443,13 +443,13 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return string The HTML with templates appended. |
445 | 445 | */ |
446 | -function wordpoints_script_templates_filter( $html, $handle ) { |
|
446 | +function wordpoints_script_templates_filter($html, $handle) { |
|
447 | 447 | |
448 | 448 | global $wp_scripts; |
449 | 449 | |
450 | - $templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' ); |
|
450 | + $templates = $wp_scripts->get_data($handle, 'wordpoints-templates'); |
|
451 | 451 | |
452 | - if ( $templates ) { |
|
452 | + if ($templates) { |
|
453 | 453 | $html .= $templates; |
454 | 454 | } |
455 | 455 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | function wordpoints_hooks_admin_ajax() { |
467 | 467 | |
468 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
468 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
469 | 469 | new WordPoints_Admin_Ajax_Hooks; |
470 | 470 | } |
471 | 471 | } |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | - public function do_event( $event_slug, WordPoints_Hook_Event_Args $event_args ) { |
|
20 | + public function do_event($event_slug, WordPoints_Hook_Event_Args $event_args) { |
|
21 | 21 | |
22 | 22 | $hooks = wordpoints_hooks(); |
23 | 23 | |
24 | 24 | /** @var WordPoints_Hook_Reactor $reactor */ |
25 | - foreach ( $hooks->reactors->get_all() as $reactor ) { |
|
25 | + foreach ($hooks->reactors->get_all() as $reactor) { |
|
26 | 26 | |
27 | - foreach ( $reactor->get_all_reactions_to_event( $event_slug ) as $reaction ) { |
|
27 | + foreach ($reactor->get_all_reactions_to_event($event_slug) as $reaction) { |
|
28 | 28 | |
29 | 29 | $validator = new WordPoints_Hook_Reaction_Validator( |
30 | 30 | $reaction |
@@ -34,26 +34,26 @@ discard block |
||
34 | 34 | |
35 | 35 | $validator->validate(); |
36 | 36 | |
37 | - if ( $validator->had_errors() ) { |
|
37 | + if ($validator->had_errors()) { |
|
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | - $event_args->set_validator( $validator ); |
|
41 | + $event_args->set_validator($validator); |
|
42 | 42 | $reaction = $validator; |
43 | 43 | |
44 | 44 | /** @var WordPoints_Hook_Extension[] $extensions */ |
45 | 45 | $extensions = $hooks->extensions->get_all(); |
46 | 46 | |
47 | - foreach ( $extensions as $extension ) { |
|
48 | - if ( ! $extension->should_hit( $reaction, $event_args ) ) { |
|
47 | + foreach ($extensions as $extension) { |
|
48 | + if ( ! $extension->should_hit($reaction, $event_args)) { |
|
49 | 49 | continue 2; |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - $reactor->hit( $event_args, $reaction ); |
|
53 | + $reactor->hit($event_args, $reaction); |
|
54 | 54 | |
55 | - foreach ( $extensions as $extension ) { |
|
56 | - $extension->after_hit( $reaction, $event_args ); |
|
55 | + foreach ($extensions as $extension) { |
|
56 | + $extension->after_hit($reaction, $event_args); |
|
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | public function get_ui_script_data() { |
26 | 26 | |
27 | 27 | $periods = array( |
28 | - MINUTE_IN_SECONDS => __( 'Minute', 'wordpoints' ), |
|
29 | - HOUR_IN_SECONDS => __( 'Hour', 'wordpoints' ), |
|
30 | - DAY_IN_SECONDS => __( 'Day', 'wordpoints' ), |
|
31 | - WEEK_IN_SECONDS => __( 'Week', 'wordpoints' ), |
|
32 | - 30 * DAY_IN_SECONDS => __( 'Month', 'wordpoints' ), |
|
28 | + MINUTE_IN_SECONDS => __('Minute', 'wordpoints'), |
|
29 | + HOUR_IN_SECONDS => __('Hour', 'wordpoints'), |
|
30 | + DAY_IN_SECONDS => __('Day', 'wordpoints'), |
|
31 | + WEEK_IN_SECONDS => __('Week', 'wordpoints'), |
|
32 | + 30 * DAY_IN_SECONDS => __('Month', 'wordpoints'), |
|
33 | 33 | ); |
34 | 34 | |
35 | 35 | return array( |
36 | 36 | 'periods' => $periods, |
37 | 37 | 'l10n' => array( |
38 | 38 | // TODO this should be supplied per-reactor |
39 | - 'label' => __( 'Award each user no more than once per:', 'wordpoints' ), |
|
39 | + 'label' => __('Award each user no more than once per:', 'wordpoints'), |
|
40 | 40 | ), |
41 | 41 | ); |
42 | 42 | } |
@@ -50,25 +50,25 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return array The validated periods. |
52 | 52 | */ |
53 | - protected function validate_periods( $periods ) { |
|
53 | + protected function validate_periods($periods) { |
|
54 | 54 | |
55 | - if ( ! is_array( $periods ) ) { |
|
55 | + if ( ! is_array($periods)) { |
|
56 | 56 | |
57 | 57 | $this->validator->add_error( |
58 | - __( 'Periods do not match expected format.', 'wordpoints' ) |
|
58 | + __('Periods do not match expected format.', 'wordpoints') |
|
59 | 59 | ); |
60 | 60 | |
61 | 61 | return array(); |
62 | 62 | } |
63 | 63 | |
64 | - foreach ( $periods as $index => $period ) { |
|
64 | + foreach ($periods as $index => $period) { |
|
65 | 65 | |
66 | - $this->validator->push_field( $index ); |
|
66 | + $this->validator->push_field($index); |
|
67 | 67 | |
68 | - $period = $this->validate_period( $period ); |
|
68 | + $period = $this->validate_period($period); |
|
69 | 69 | |
70 | - if ( $period ) { |
|
71 | - $periods[ $index ] = $period; |
|
70 | + if ($period) { |
|
71 | + $periods[$index] = $period; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $this->validator->pop_field(); |
@@ -86,30 +86,30 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return array|false The validated period, or false if invalid. |
88 | 88 | */ |
89 | - protected function validate_period( $period ) { |
|
89 | + protected function validate_period($period) { |
|
90 | 90 | |
91 | - if ( ! is_array( $period ) ) { |
|
91 | + if ( ! is_array($period)) { |
|
92 | 92 | $this->validator->add_error( |
93 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
93 | + __('Period does not match expected format.', 'wordpoints') |
|
94 | 94 | ); |
95 | 95 | |
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if ( isset( $period['args'] ) ) { |
|
100 | - $this->validate_period_args( $period['args'] ); |
|
99 | + if (isset($period['args'])) { |
|
100 | + $this->validate_period_args($period['args']); |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( ! isset( $period['length'] ) ) { |
|
103 | + if ( ! isset($period['length'])) { |
|
104 | 104 | |
105 | 105 | $this->validator->add_error( |
106 | - __( 'Period length setting is missing.', 'wordpoints' ) |
|
106 | + __('Period length setting is missing.', 'wordpoints') |
|
107 | 107 | ); |
108 | 108 | |
109 | - } elseif ( false === wordpoints_posint( $period['length'] ) ) { |
|
109 | + } elseif (false === wordpoints_posint($period['length'])) { |
|
110 | 110 | |
111 | 111 | $this->validator->add_error( |
112 | - __( 'Period length must be a positive integer.', 'wordpoints' ) |
|
112 | + __('Period length must be a positive integer.', 'wordpoints') |
|
113 | 113 | , 'length' |
114 | 114 | ); |
115 | 115 | |
@@ -126,34 +126,34 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @param mixed $args The args the period is related to. |
128 | 128 | */ |
129 | - protected function validate_period_args( $args ) { |
|
129 | + protected function validate_period_args($args) { |
|
130 | 130 | |
131 | - if ( ! is_array( $args ) ) { |
|
131 | + if ( ! is_array($args)) { |
|
132 | 132 | |
133 | 133 | $this->validator->add_error( |
134 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
134 | + __('Period does not match expected format.', 'wordpoints') |
|
135 | 135 | , 'args' |
136 | 136 | ); |
137 | 137 | |
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | - $this->validator->push_field( 'args' ); |
|
141 | + $this->validator->push_field('args'); |
|
142 | 142 | |
143 | - foreach ( $args as $index => $hierarchy ) { |
|
143 | + foreach ($args as $index => $hierarchy) { |
|
144 | 144 | |
145 | - $this->validator->push_field( $index ); |
|
145 | + $this->validator->push_field($index); |
|
146 | 146 | |
147 | - if ( ! is_array( $hierarchy ) ) { |
|
147 | + if ( ! is_array($hierarchy)) { |
|
148 | 148 | |
149 | 149 | $this->validator->add_error( |
150 | - __( 'Period does not match expected format.', 'wordpoints' ) |
|
150 | + __('Period does not match expected format.', 'wordpoints') |
|
151 | 151 | ); |
152 | 152 | |
153 | - } elseif ( ! $this->event_args->get_from_hierarchy( $hierarchy ) ) { |
|
153 | + } elseif ( ! $this->event_args->get_from_hierarchy($hierarchy)) { |
|
154 | 154 | |
155 | 155 | $this->validator->add_error( |
156 | - __( 'Invalid period.', 'wordpoints' ) // TODO better error message |
|
156 | + __('Invalid period.', 'wordpoints') // TODO better error message |
|
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
@@ -171,16 +171,16 @@ discard block |
||
171 | 171 | WordPoints_Hook_Event_Args $event_args |
172 | 172 | ) { |
173 | 173 | |
174 | - $periods = $reaction->get_meta( 'periods' ); |
|
174 | + $periods = $reaction->get_meta('periods'); |
|
175 | 175 | |
176 | - if ( empty( $periods ) ) { |
|
176 | + if (empty($periods)) { |
|
177 | 177 | return true; |
178 | 178 | } |
179 | 179 | |
180 | 180 | $this->event_args = $event_args; |
181 | 181 | |
182 | - foreach ( $periods as $period ) { |
|
183 | - if ( ! $this->has_period_ended( $period, $reaction ) ) { |
|
182 | + foreach ($periods as $period) { |
|
183 | + if ( ! $this->has_period_ended($period, $reaction)) { |
|
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | } |
@@ -204,23 +204,23 @@ discard block |
||
204 | 204 | ) { |
205 | 205 | |
206 | 206 | $period = $this->get_period_by_reaction( |
207 | - $this->get_period_signature( $settings, $reaction ) |
|
207 | + $this->get_period_signature($settings, $reaction) |
|
208 | 208 | , $reaction |
209 | 209 | ); |
210 | 210 | |
211 | 211 | // If the period isn't found, we know that we can still fire. |
212 | - if ( ! $period ) { |
|
212 | + if ( ! $period) { |
|
213 | 213 | return true; |
214 | 214 | } |
215 | 215 | |
216 | - $now = current_time( 'timestamp' ); |
|
216 | + $now = current_time('timestamp'); |
|
217 | 217 | |
218 | - if ( ! empty( $settings['relative'] ) ) { |
|
219 | - return ( $period->hit_time < $now - $settings['length'] ); |
|
218 | + if ( ! empty($settings['relative'])) { |
|
219 | + return ($period->hit_time < $now - $settings['length']); |
|
220 | 220 | } else { |
221 | 221 | return ( |
222 | - (int) ( $period->hit_time / $settings['length'] ) |
|
223 | - < (int) ( $now / $settings['length'] ) |
|
222 | + (int) ($period->hit_time / $settings['length']) |
|
223 | + < (int) ($now / $settings['length']) |
|
224 | 224 | ); |
225 | 225 | } |
226 | 226 | } |
@@ -234,21 +234,21 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return array The arg values. |
236 | 236 | */ |
237 | - protected function get_arg_values( array $period_args ) { |
|
237 | + protected function get_arg_values(array $period_args) { |
|
238 | 238 | |
239 | 239 | $values = array(); |
240 | 240 | |
241 | - foreach ( $period_args as $arg_hierarchy ) { |
|
241 | + foreach ($period_args as $arg_hierarchy) { |
|
242 | 242 | |
243 | 243 | $arg = $this->event_args->get_from_hierarchy( |
244 | 244 | $arg_hierarchy |
245 | 245 | ); |
246 | 246 | |
247 | - if ( ! $arg instanceof WordPoints_EntityishI ) { |
|
247 | + if ( ! $arg instanceof WordPoints_EntityishI) { |
|
248 | 248 | continue; |
249 | 249 | } |
250 | 250 | |
251 | - $values[ implode( '.', $arg_hierarchy ) ] = $arg->get_the_value(); |
|
251 | + $values[implode('.', $arg_hierarchy)] = $arg->get_the_value(); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | return $values; |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return object|false The period data, or false if not found. |
265 | 265 | */ |
266 | - protected function get_period( $period_id ) { |
|
266 | + protected function get_period($period_id) { |
|
267 | 267 | |
268 | - $period = wp_cache_get( $period_id, 'wordpoints_hook_period' ); |
|
268 | + $period = wp_cache_get($period_id, 'wordpoints_hook_period'); |
|
269 | 269 | |
270 | - if ( ! $period ) { |
|
270 | + if ( ! $period) { |
|
271 | 271 | |
272 | 272 | global $wpdb; |
273 | 273 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | ) |
283 | 283 | ); |
284 | 284 | |
285 | - if ( ! $period ) { |
|
285 | + if ( ! $period) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | , 'wordpoints_hook_period_ids' |
293 | 293 | ); |
294 | 294 | |
295 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
295 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | return $period; |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | $cache_key = "{$reaction_id}-{$signature}"; |
320 | 320 | |
321 | 321 | // Before we run the query, we try to lookup the ID in the cache. |
322 | - $period_id = wp_cache_get( $cache_key, 'wordpoints_hook_period_ids' ); |
|
322 | + $period_id = wp_cache_get($cache_key, 'wordpoints_hook_period_ids'); |
|
323 | 323 | |
324 | 324 | // If we found it, we can retrieve the period by ID instead. |
325 | - if ( $period_id ) { |
|
326 | - return $this->get_period( $period_id ); |
|
325 | + if ($period_id) { |
|
326 | + return $this->get_period($period_id); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | global $wpdb; |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | ) |
343 | 343 | ); |
344 | 344 | |
345 | - if ( ! $period ) { |
|
345 | + if ( ! $period) { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | |
349 | - wp_cache_set( $cache_key, $period->id, 'wordpoints_hook_period_ids' ); |
|
350 | - wp_cache_set( $period->id, $period, 'wordpoints_hook_periods' ); |
|
349 | + wp_cache_set($cache_key, $period->id, 'wordpoints_hook_period_ids'); |
|
350 | + wp_cache_set($period->id, $period, 'wordpoints_hook_periods'); |
|
351 | 351 | |
352 | 352 | return $period; |
353 | 353 | } |
@@ -360,18 +360,18 @@ discard block |
||
360 | 360 | WordPoints_Hook_Event_Args $event_args |
361 | 361 | ) { |
362 | 362 | |
363 | - $periods = $reaction->get_meta( 'periods' ); |
|
363 | + $periods = $reaction->get_meta('periods'); |
|
364 | 364 | |
365 | - if ( empty( $periods ) ) { |
|
365 | + if (empty($periods)) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | 368 | |
369 | 369 | $this->event_args = $event_args; |
370 | 370 | |
371 | - foreach ( $periods as $settings ) { |
|
371 | + foreach ($periods as $settings) { |
|
372 | 372 | |
373 | 373 | $this->add_period( |
374 | - $this->get_period_signature( $settings, $reaction ) |
|
374 | + $this->get_period_signature($settings, $reaction) |
|
375 | 375 | , $reaction |
376 | 376 | ); |
377 | 377 | } |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | WordPoints_Hook_Reaction_Validator $reaction |
397 | 397 | ) { |
398 | 398 | |
399 | - if ( isset( $settings['args'] ) ) { |
|
399 | + if (isset($settings['args'])) { |
|
400 | 400 | $period_args = $settings['args']; |
401 | 401 | } else { |
402 | - $period_args = array( $reaction->get_meta( 'target' ) ); |
|
402 | + $period_args = array($reaction->get_meta('target')); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | return wordpoints_hash( |
406 | - wp_json_encode( $this->get_arg_values( $period_args ) ) |
|
406 | + wp_json_encode($this->get_arg_values($period_args)) |
|
407 | 407 | ); |
408 | 408 | } |
409 | 409 | |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | , array( |
432 | 432 | 'reaction_id' => $reaction_id, |
433 | 433 | 'signature' => $signature, |
434 | - 'hit_time' => current_time( 'timestamp' ), |
|
434 | + 'hit_time' => current_time('timestamp'), |
|
435 | 435 | ) |
436 | - , array( '%d', '%s', '%d' ) |
|
436 | + , array('%d', '%s', '%d') |
|
437 | 437 | ); |
438 | 438 | |
439 | - if ( ! $inserted ) { |
|
439 | + if ( ! $inserted) { |
|
440 | 440 | return false; |
441 | 441 | } |
442 | 442 |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * @param bool $fail_fast Whether to fail as soon as |
105 | 105 | * the first error is found. |
106 | 106 | */ |
107 | - public function __construct( $settings, WordPoints_Hook_Reactor $reactor, $fail_fast = false ) { |
|
107 | + public function __construct($settings, WordPoints_Hook_Reactor $reactor, $fail_fast = false) { |
|
108 | 108 | |
109 | 109 | $this->reactor = $reactor; |
110 | 110 | $this->fail_fast = $fail_fast; |
111 | 111 | $this->hooks = wordpoints_hooks(); |
112 | 112 | |
113 | - if ( $settings instanceof WordPoints_Hook_ReactionI ) { |
|
113 | + if ($settings instanceof WordPoints_Hook_ReactionI) { |
|
114 | 114 | |
115 | 115 | $this->reaction = $settings; |
116 | 116 | $this->settings = $this->reaction->get_all_meta(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $this->settings = $settings; |
122 | 122 | |
123 | - if ( isset( $this->settings['event'] ) ) { |
|
123 | + if (isset($this->settings['event'])) { |
|
124 | 124 | $this->event_slug = $this->settings['event']; |
125 | 125 | } |
126 | 126 | } |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | $fail_fast = $this->fail_fast; |
145 | 145 | $this->fail_fast = true; |
146 | 146 | |
147 | - if ( ! isset( $this->event_slug ) ) { |
|
148 | - $this->add_error( __( 'Event is missing.', 'wordpoints' ), 'event' ); |
|
149 | - } elseif ( ! $this->hooks->events->is_registered( $this->event_slug ) ) { |
|
150 | - $this->add_error( __( 'Event is invalid.', 'wordpoints' ), 'event' ); |
|
147 | + if ( ! isset($this->event_slug)) { |
|
148 | + $this->add_error(__('Event is missing.', 'wordpoints'), 'event'); |
|
149 | + } elseif ( ! $this->hooks->events->is_registered($this->event_slug)) { |
|
150 | + $this->add_error(__('Event is invalid.', 'wordpoints'), 'event'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // From here on out we can collect errors as they come (unless we are |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | $this->event_slug |
159 | 159 | ); |
160 | 160 | |
161 | - $this->event_args = new WordPoints_Hook_Event_Args( $event_args ); |
|
162 | - $this->event_args->set_validator( $this ); |
|
161 | + $this->event_args = new WordPoints_Hook_Event_Args($event_args); |
|
162 | + $this->event_args->set_validator($this); |
|
163 | 163 | |
164 | - $this->settings = $this->reactor->validate_settings( $this->settings, $this, $this->event_args ); |
|
164 | + $this->settings = $this->reactor->validate_settings($this->settings, $this, $this->event_args); |
|
165 | 165 | |
166 | 166 | /** @var WordPoints_Hook_Extension $extension */ |
167 | - foreach ( $this->hooks->extensions->get_all() as $extension ) { |
|
168 | - $this->settings = $extension->validate_settings( $this->settings, $this, $this->event_args ); |
|
167 | + foreach ($this->hooks->extensions->get_all() as $extension) { |
|
168 | + $this->settings = $extension->validate_settings($this->settings, $this, $this->event_args); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * @param WordPoints_Hook_Reaction_Validator $validator The validator object. |
176 | 176 | * @param WordPoints_Hook_Event_Args $args The event args object. |
177 | 177 | */ |
178 | - $this->settings = apply_filters( 'wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args ); |
|
178 | + $this->settings = apply_filters('wordpoints_hook_reaction_validate', $this->settings, $this, $this->event_args); |
|
179 | 179 | |
180 | - } catch ( WordPoints_Hook_Validator_Exception $e ) { |
|
180 | + } catch (WordPoints_Hook_Validator_Exception $e) { |
|
181 | 181 | |
182 | 182 | // Do nothing. |
183 | - unset( $e ); |
|
183 | + unset($e); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | return $this->settings; |
@@ -208,17 +208,17 @@ discard block |
||
208 | 208 | * @throws WordPoints_Hook_Validator_Exception If the validator is configured to |
209 | 209 | * fail as soon as an error is found. |
210 | 210 | */ |
211 | - public function add_error( $message, $field = null ) { |
|
211 | + public function add_error($message, $field = null) { |
|
212 | 212 | |
213 | 213 | $field_stack = $this->field_stack; |
214 | 214 | |
215 | - if ( null !== $field ) { |
|
215 | + if (null !== $field) { |
|
216 | 216 | $field_stack[] = $field; |
217 | 217 | } |
218 | 218 | |
219 | - $this->errors[] = array( 'message' => $message, 'field' => $field_stack ); |
|
219 | + $this->errors[] = array('message' => $message, 'field' => $field_stack); |
|
220 | 220 | |
221 | - if ( $this->fail_fast ) { |
|
221 | + if ($this->fail_fast) { |
|
222 | 222 | throw new WordPoints_Hook_Validator_Exception; |
223 | 223 | } |
224 | 224 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @return bool Whether the validator found any errors. |
232 | 232 | */ |
233 | 233 | public function had_errors() { |
234 | - return ! empty( $this->errors ); |
|
234 | + return ! empty($this->errors); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @param string $field The field. |
254 | 254 | */ |
255 | - public function push_field( $field ) { |
|
255 | + public function push_field($field) { |
|
256 | 256 | $this->field_stack[] = $field; |
257 | 257 | } |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @since 1.0.0 |
263 | 263 | */ |
264 | 264 | public function pop_field() { |
265 | - array_pop( $this->field_stack ); |
|
265 | + array_pop($this->field_stack); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function get_id() { |
309 | 309 | |
310 | - if ( ! $this->reaction ) { |
|
310 | + if ( ! $this->reaction) { |
|
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | |
@@ -345,13 +345,13 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return mixed The meta value. |
347 | 347 | */ |
348 | - public function get_meta( $key ) { |
|
348 | + public function get_meta($key) { |
|
349 | 349 | |
350 | - if ( ! isset( $this->settings[ $key ] ) ) { |
|
350 | + if ( ! isset($this->settings[$key])) { |
|
351 | 351 | return null; |
352 | 352 | } |
353 | 353 | |
354 | - return $this->settings[ $key ]; |
|
354 | + return $this->settings[$key]; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | protected function init() { |
47 | 47 | |
48 | 48 | $sub_apps = $this->sub_apps; |
49 | - $sub_apps->register( 'router', 'WordPoints_Hook_Router' ); |
|
50 | - $sub_apps->register( 'actions', 'WordPoints_Hook_Actions' ); |
|
51 | - $sub_apps->register( 'events', 'WordPoints_Hook_Events' ); |
|
52 | - $sub_apps->register( 'firers', 'WordPoints_Class_Registry_Persistent' ); |
|
53 | - $sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' ); |
|
54 | - $sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' ); |
|
55 | - $sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' ); |
|
49 | + $sub_apps->register('router', 'WordPoints_Hook_Router'); |
|
50 | + $sub_apps->register('actions', 'WordPoints_Hook_Actions'); |
|
51 | + $sub_apps->register('events', 'WordPoints_Hook_Events'); |
|
52 | + $sub_apps->register('firers', 'WordPoints_Class_Registry_Persistent'); |
|
53 | + $sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent'); |
|
54 | + $sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent'); |
|
55 | + $sub_apps->register('conditions', 'WordPoints_Class_Registry_Children'); |
|
56 | 56 | |
57 | 57 | parent::init(); |
58 | 58 | } |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function get_network_mode() { |
68 | 68 | |
69 | - if ( ! isset( $this->network_mode ) ) { |
|
69 | + if ( ! isset($this->network_mode)) { |
|
70 | 70 | $this->network_mode = is_network_admin(); |
71 | 71 | |
72 | 72 | // See https://core.trac.wordpress.org/ticket/22589 |
73 | 73 | if ( |
74 | - defined( 'DOING_AJAX' ) |
|
74 | + defined('DOING_AJAX') |
|
75 | 75 | && DOING_AJAX |
76 | 76 | && is_multisite() |
77 | - && isset( $_SERVER['HTTP_REFERER'] ) |
|
77 | + && isset($_SERVER['HTTP_REFERER']) |
|
78 | 78 | && preg_match( |
79 | - '#^' . preg_quote( network_admin_url(), '#' ) . '#i' |
|
80 | - , esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) |
|
79 | + '#^'.preg_quote(network_admin_url(), '#').'#i' |
|
80 | + , esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])) |
|
81 | 81 | ) |
82 | 82 | ) { |
83 | 83 | $this->network_mode = true; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @param bool $on Whether network-wide mode should be on (or off). |
123 | 123 | */ |
124 | - public function _set_network_mode( $on = true ) { |
|
124 | + public function _set_network_mode($on = true) { |
|
125 | 125 | $this->network_mode = (bool) $on; |
126 | 126 | } |
127 | 127 | } |