@@ -12,17 +12,17 @@ |
||
12 | 12 | * |
13 | 13 | * @since 1.0.0 |
14 | 14 | */ |
15 | -require_once( dirname( __FILE__ ) . '/includes/functions.php' ); |
|
15 | +require_once(dirname(__FILE__).'/includes/functions.php'); |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * The admin-side actions and filters. |
19 | 19 | * |
20 | 20 | * @since 1.0.0 |
21 | 21 | */ |
22 | -require_once( dirname( __FILE__ ) . '/includes/actions.php' ); |
|
22 | +require_once(dirname(__FILE__).'/includes/actions.php'); |
|
23 | 23 | |
24 | 24 | WordPoints_Class_Autoloader::register_dir( |
25 | - dirname( __FILE__ ) . '/includes/classes' |
|
25 | + dirname(__FILE__).'/includes/classes' |
|
26 | 26 | , 'WordPoints_Admin_' |
27 | 27 | ); |
28 | 28 |
@@ -7,14 +7,14 @@ |
||
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' ); |
|
13 | -add_action( 'network_admin_menu', 'wordpoints_hooks_api_admin_menu' ); |
|
12 | +add_action('admin_menu', 'wordpoints_hooks_api_admin_menu'); |
|
13 | +add_action('network_admin_menu', 'wordpoints_hooks_api_admin_menu'); |
|
14 | 14 | |
15 | -add_action( 'admin_init', 'wordpoints_hooks_admin_register_scripts' ); |
|
16 | -add_action( 'admin_init', 'wordpoints_hooks_admin_ajax' ); |
|
15 | +add_action('admin_init', 'wordpoints_hooks_admin_register_scripts'); |
|
16 | +add_action('admin_init', 'wordpoints_hooks_admin_ajax'); |
|
17 | 17 | |
18 | -add_filter( 'script_loader_tag', 'wordpoints_script_templates_filter', 10, 2 ); |
|
18 | +add_filter('script_loader_tag', 'wordpoints_script_templates_filter', 10, 2); |
|
19 | 19 | |
20 | 20 | // EOF |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array The hook reaction data extracted into an array. |
54 | 54 | */ |
55 | - public static function prepare_hook_reaction( $reaction ) { |
|
55 | + public static function prepare_hook_reaction($reaction) { |
|
56 | 56 | |
57 | 57 | $reactor = $reaction->get_reactor_slug(); |
58 | 58 | |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | |
96 | 96 | add_action( |
97 | 97 | 'wp_ajax_wordpoints_admin_create_hook_reaction' |
98 | - , array( $this, 'create_hook_reaction' ) |
|
98 | + , array($this, 'create_hook_reaction') |
|
99 | 99 | ); |
100 | 100 | |
101 | 101 | add_action( |
102 | 102 | 'wp_ajax_wordpoints_admin_update_hook_reaction' |
103 | - , array( $this, 'update_hook_reaction' ) |
|
103 | + , array($this, 'update_hook_reaction') |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | add_action( |
107 | 107 | 'wp_ajax_wordpoints_admin_delete_hook_reaction' |
108 | - , array( $this, 'delete_hook_reaction' ) |
|
108 | + , array($this, 'delete_hook_reaction') |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | "wordpoints_create_hook_reaction|{$this->reactor_slug}" |
125 | 125 | ); |
126 | 126 | |
127 | - $reaction = $reactor->reactions->create_reaction( $this->get_data() ); |
|
127 | + $reaction = $reactor->reactions->create_reaction($this->get_data()); |
|
128 | 128 | |
129 | - $this->send_json_result( $reaction, 'create' ); |
|
129 | + $this->send_json_result($reaction, 'create'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | , $this->get_data() |
151 | 151 | ); |
152 | 152 | |
153 | - $this->send_json_result( $reaction, 'update' ); |
|
153 | + $this->send_json_result($reaction, 'update'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | "wordpoints_delete_hook_reaction|{$this->reactor_slug}|{$reaction->ID}" |
170 | 170 | ); |
171 | 171 | |
172 | - $result = $reactor->reactions->delete_reaction( $reaction->ID ); |
|
172 | + $result = $reactor->reactions->delete_reaction($reaction->ID); |
|
173 | 173 | |
174 | - if ( ! $result ) { |
|
175 | - wp_send_json_error( array( 'message' => __( 'There was an error deleting the reaction. Please try again.', 'wordpoints' ) ) ); |
|
174 | + if ( ! $result) { |
|
175 | + wp_send_json_error(array('message' => __('There was an error deleting the reaction. Please try again.', 'wordpoints'))); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | wp_send_json_success(); |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param string $debug_context Context sent with the message (for debugging). |
195 | 195 | */ |
196 | - private function unexpected_error( $debug_context ) { |
|
196 | + private function unexpected_error($debug_context) { |
|
197 | 197 | |
198 | 198 | wp_send_json_error( |
199 | 199 | array( |
200 | - 'message' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
200 | + 'message' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
201 | 201 | 'debug' => $debug_context, |
202 | 202 | ) |
203 | 203 | ); |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | */ |
214 | 214 | private function verify_user_can() { |
215 | 215 | |
216 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
217 | - wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints' ) ) ); |
|
216 | + if ( ! current_user_can('manage_options')) { |
|
217 | + wp_send_json_error(array('message' => __('You do not have permission to perform this action. Maybe you have been logged out?', 'wordpoints'))); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param string $action The action the nonce should be for. |
229 | 229 | */ |
230 | - private function verify_request( $action ) { |
|
230 | + private function verify_request($action) { |
|
231 | 231 | |
232 | 232 | if ( |
233 | - empty( $_POST['nonce'] ) |
|
234 | - || ! wordpoints_verify_nonce( 'nonce', $action, null, 'post' ) |
|
233 | + empty($_POST['nonce']) |
|
234 | + || ! wordpoints_verify_nonce('nonce', $action, null, 'post') |
|
235 | 235 | ) { |
236 | 236 | wp_send_json_error( |
237 | - array( 'message' => __( 'Your security token for this action has expired. Refresh the page and try again.', 'wordpoints' ) ) |
|
237 | + array('message' => __('Your security token for this action has expired. Refresh the page and try again.', 'wordpoints')) |
|
238 | 238 | ); |
239 | 239 | } |
240 | 240 | } |
@@ -248,16 +248,16 @@ discard block |
||
248 | 248 | */ |
249 | 249 | protected function get_reactor() { |
250 | 250 | |
251 | - if ( ! isset( $_POST['reactor'] ) ) { // WPCS: CSRF OK. |
|
252 | - $this->unexpected_error( 'reactor' ); |
|
251 | + if ( ! isset($_POST['reactor'])) { // WPCS: CSRF OK. |
|
252 | + $this->unexpected_error('reactor'); |
|
253 | 253 | } |
254 | 254 | |
255 | - $reactor_slug = sanitize_key( $_POST['reactor'] ); // WPCS: CSRF OK. |
|
255 | + $reactor_slug = sanitize_key($_POST['reactor']); // WPCS: CSRF OK. |
|
256 | 256 | |
257 | - $reactor = wordpoints_hooks()->reactors->get( $reactor_slug ); |
|
257 | + $reactor = wordpoints_hooks()->reactors->get($reactor_slug); |
|
258 | 258 | |
259 | - if ( ! $reactor instanceof WordPoints_Hook_Reactor ) { |
|
260 | - $this->unexpected_error( 'reactor_invalid' ); |
|
259 | + if ( ! $reactor instanceof WordPoints_Hook_Reactor) { |
|
260 | + $this->unexpected_error('reactor_invalid'); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | $this->reactor_slug = $reactor_slug; |
@@ -275,16 +275,16 @@ discard block |
||
275 | 275 | */ |
276 | 276 | protected function get_reaction() { |
277 | 277 | |
278 | - if ( ! isset( $_POST['id'] ) ) { // WPCS: CSRF OK. |
|
279 | - $this->unexpected_error( 'id' ); |
|
278 | + if ( ! isset($_POST['id'])) { // WPCS: CSRF OK. |
|
279 | + $this->unexpected_error('id'); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $reaction = $this->reactor->reactions->get_reaction( |
283 | - wordpoints_int( $_POST['id'] ) // WPCS: CSRF OK. |
|
283 | + wordpoints_int($_POST['id']) // WPCS: CSRF OK. |
|
284 | 284 | ); |
285 | 285 | |
286 | - if ( ! $reaction ) { |
|
287 | - wp_send_json_error( array( 'message' => __( 'The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) ); |
|
286 | + if ( ! $reaction) { |
|
287 | + wp_send_json_error(array('message' => __('The reaction ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints'))); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | return $reaction; |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function get_data() { |
301 | 301 | |
302 | - $data = wp_unslash( $_POST ); // WPCS: CSRF OK. |
|
302 | + $data = wp_unslash($_POST); // WPCS: CSRF OK. |
|
303 | 303 | |
304 | - unset( $data['id'], $data['action'], $data['nonce'], $data['reactor'] ); |
|
304 | + unset($data['id'], $data['action'], $data['nonce'], $data['reactor']); |
|
305 | 305 | |
306 | 306 | return $data; |
307 | 307 | } |
@@ -314,30 +314,30 @@ discard block |
||
314 | 314 | * @param mixed $result The result of the action. |
315 | 315 | * @param string $action The action being performed: 'create' or 'update'. |
316 | 316 | */ |
317 | - private function send_json_result( $result, $action ) { |
|
317 | + private function send_json_result($result, $action) { |
|
318 | 318 | |
319 | - if ( ! $result ) { |
|
319 | + if ( ! $result) { |
|
320 | 320 | |
321 | - if ( 'create' === $action ) { |
|
322 | - $message = __( 'There was an error adding the reaction. Please try again.', 'wordpoints' ); |
|
321 | + if ('create' === $action) { |
|
322 | + $message = __('There was an error adding the reaction. Please try again.', 'wordpoints'); |
|
323 | 323 | } else { |
324 | - $message = __( 'There was an error updating the reaction. Please try again.', 'wordpoints' ); |
|
324 | + $message = __('There was an error updating the reaction. Please try again.', 'wordpoints'); |
|
325 | 325 | } |
326 | 326 | |
327 | - wp_send_json_error( array( 'message' => $message ) ); |
|
327 | + wp_send_json_error(array('message' => $message)); |
|
328 | 328 | |
329 | - } elseif ( $result instanceof WordPoints_Hook_Reaction_Validator ) { |
|
329 | + } elseif ($result instanceof WordPoints_Hook_Reaction_Validator) { |
|
330 | 330 | |
331 | - wp_send_json_error( array( 'errors' => $result->get_errors() ) ); |
|
331 | + wp_send_json_error(array('errors' => $result->get_errors())); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | $data = null; |
335 | 335 | |
336 | - if ( 'create' === $action ) { |
|
337 | - $data = self::prepare_hook_reaction( $result ); |
|
336 | + if ('create' === $action) { |
|
337 | + $data = self::prepare_hook_reaction($result); |
|
338 | 338 | } |
339 | 339 | |
340 | - wp_send_json_success( $data ); |
|
340 | + wp_send_json_success($data); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 |
@@ -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"> |
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 button-link" 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 button-link" 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 button-link" 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 button-link" 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"></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> |
@@ -275,32 +275,32 @@ discard block |
||
275 | 275 | |
276 | 276 | $extensions_data = array(); |
277 | 277 | |
278 | - foreach ( $hooks->extensions->get_all() as $slug => $extension ) { |
|
278 | + foreach ($hooks->extensions->get_all() as $slug => $extension) { |
|
279 | 279 | |
280 | - if ( $extension instanceof WordPoints_Hook_Extension ) { |
|
281 | - $extensions_data[ $slug ] = $extension->get_ui_script_data(); |
|
280 | + if ($extension instanceof WordPoints_Hook_Extension) { |
|
281 | + $extensions_data[$slug] = $extension->get_ui_script_data(); |
|
282 | 282 | } |
283 | 283 | |
284 | - if ( wp_script_is( "wordpoints-hooks-extension-{$slug}", 'registered' ) ) { |
|
285 | - wp_enqueue_script( "wordpoints-hooks-extension-{$slug}" ); |
|
284 | + if (wp_script_is("wordpoints-hooks-extension-{$slug}", 'registered')) { |
|
285 | + wp_enqueue_script("wordpoints-hooks-extension-{$slug}"); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | 289 | $reactor_data = array(); |
290 | 290 | |
291 | - foreach ( $hooks->reactors->get_all() as $slug => $reactor ) { |
|
291 | + foreach ($hooks->reactors->get_all() as $slug => $reactor) { |
|
292 | 292 | |
293 | - if ( $reactor instanceof WordPoints_Hook_Reactor ) { |
|
294 | - $reactor_data[ $slug ] = array( |
|
293 | + if ($reactor instanceof WordPoints_Hook_Reactor) { |
|
294 | + $reactor_data[$slug] = array( |
|
295 | 295 | 'slug' => $reactor->get_slug(), |
296 | 296 | 'fields' => $reactor->get_settings_fields(), |
297 | 297 | 'arg_types' => $reactor->get_arg_types(), |
298 | - 'target_label' => __( 'Award To', 'wordpoints' ), |
|
298 | + 'target_label' => __('Award To', 'wordpoints'), |
|
299 | 299 | ); |
300 | 300 | } |
301 | 301 | |
302 | - if ( wp_script_is( "wordpoints-hooks-reactor-{$slug}", 'registered' ) ) { |
|
303 | - wp_enqueue_script( "wordpoints-hooks-reactor-{$slug}" ); |
|
302 | + if (wp_script_is("wordpoints-hooks-reactor-{$slug}", 'registered')) { |
|
303 | + wp_enqueue_script("wordpoints-hooks-reactor-{$slug}"); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
@@ -312,28 +312,28 @@ discard block |
||
312 | 312 | $entity_children = $entities->children; |
313 | 313 | |
314 | 314 | /** @var WordPoints_Entity $entity */ |
315 | - foreach ( $entities->get_all() as $slug => $entity ) { |
|
315 | + foreach ($entities->get_all() as $slug => $entity) { |
|
316 | 316 | |
317 | 317 | $child_data = array(); |
318 | 318 | |
319 | 319 | /** @var WordPoints_EntityishI $child */ |
320 | - foreach ( $entity_children->get_children( $slug ) as $child_slug => $child ) { |
|
320 | + foreach ($entity_children->get_children($slug) as $child_slug => $child) { |
|
321 | 321 | |
322 | - $child_data[ $child_slug ] = array( |
|
322 | + $child_data[$child_slug] = array( |
|
323 | 323 | 'slug' => $child_slug, |
324 | 324 | 'title' => $child->get_title(), |
325 | 325 | ); |
326 | 326 | |
327 | - if ( $child instanceof WordPoints_Entity_Attr ) { |
|
327 | + if ($child instanceof WordPoints_Entity_Attr) { |
|
328 | 328 | |
329 | - $child_data[ $child_slug ]['_type'] = 'attr'; |
|
330 | - $child_data[ $child_slug ]['data_type'] = $child->get_data_type(); |
|
329 | + $child_data[$child_slug]['_type'] = 'attr'; |
|
330 | + $child_data[$child_slug]['data_type'] = $child->get_data_type(); |
|
331 | 331 | |
332 | - } elseif ( $child instanceof WordPoints_Entity_Relationship ) { |
|
332 | + } elseif ($child instanceof WordPoints_Entity_Relationship) { |
|
333 | 333 | |
334 | - $child_data[ $child_slug ]['_type'] = 'relationship'; |
|
335 | - $child_data[ $child_slug ]['primary'] = $child->get_primary_entity_slug(); |
|
336 | - $child_data[ $child_slug ]['secondary'] = $child->get_related_entity_slug(); |
|
334 | + $child_data[$child_slug]['_type'] = 'relationship'; |
|
335 | + $child_data[$child_slug]['primary'] = $child->get_primary_entity_slug(); |
|
336 | + $child_data[$child_slug]['secondary'] = $child->get_related_entity_slug(); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | * @param array $data The data for the entity child. |
345 | 345 | * @param WordPoints_Entityish $child The child's object. |
346 | 346 | */ |
347 | - $child_data[ $child_slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity_child', $child_data[ $child_slug ], $child ); |
|
347 | + $child_data[$child_slug] = apply_filters('wordpoints_hooks_ui_data_entity_child', $child_data[$child_slug], $child); |
|
348 | 348 | } |
349 | 349 | |
350 | - $entities_data[ $slug ] = array( |
|
350 | + $entities_data[$slug] = array( |
|
351 | 351 | 'slug' => $slug, |
352 | 352 | 'title' => $entity->get_title(), |
353 | 353 | 'children' => $child_data, |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | '_type' => 'entity', |
356 | 356 | ); |
357 | 357 | |
358 | - if ( $entity instanceof WordPoints_Entity_EnumerableI ) { |
|
358 | + if ($entity instanceof WordPoints_Entity_EnumerableI) { |
|
359 | 359 | |
360 | 360 | $values = array(); |
361 | 361 | |
362 | - foreach ( $entity->get_enumerated_values() as $value ) { |
|
363 | - if ( $entity->set_the_value( $value ) ) { |
|
362 | + foreach ($entity->get_enumerated_values() as $value) { |
|
363 | + if ($entity->set_the_value($value)) { |
|
364 | 364 | $values[] = array( |
365 | 365 | 'value' => $entity->get_the_id(), |
366 | 366 | 'label' => $entity->get_the_human_id(), |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | - $entities_data[ $slug ]['values'] = $values; |
|
371 | + $entities_data[$slug]['values'] = $values; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @param array $data The data for the entity. |
378 | 378 | * @param WordPoints_Entity $entity The entity object. |
379 | 379 | */ |
380 | - $entities_data[ $slug ] = apply_filters( 'wordpoints_hooks_ui_data_entity', $entities_data[ $slug ], $entity ); |
|
380 | + $entities_data[$slug] = apply_filters('wordpoints_hooks_ui_data_entity', $entities_data[$slug], $entity); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | $data = array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @param array $data The data. |
400 | 400 | */ |
401 | - $data = apply_filters( 'wordpoints_hooks_ui_data', $data ); |
|
401 | + $data = apply_filters('wordpoints_hooks_ui_data', $data); |
|
402 | 402 | |
403 | 403 | wp_localize_script( |
404 | 404 | 'wordpoints-hooks-models' |
@@ -423,13 +423,13 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @return string The HTML with templates appended. |
425 | 425 | */ |
426 | -function wordpoints_script_templates_filter( $html, $handle ) { |
|
426 | +function wordpoints_script_templates_filter($html, $handle) { |
|
427 | 427 | |
428 | 428 | global $wp_scripts; |
429 | 429 | |
430 | - $templates = $wp_scripts->get_data( $handle, 'wordpoints-templates' ); |
|
430 | + $templates = $wp_scripts->get_data($handle, 'wordpoints-templates'); |
|
431 | 431 | |
432 | - if ( $templates ) { |
|
432 | + if ($templates) { |
|
433 | 433 | $html .= $templates; |
434 | 434 | } |
435 | 435 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | function wordpoints_hooks_admin_ajax() { |
447 | 447 | |
448 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
448 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
449 | 449 | new WordPoints_Admin_Ajax_Hooks; |
450 | 450 | } |
451 | 451 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | 37 | public function get_title() { |
38 | - return __( 'Site', 'wordpoints' ); |
|
38 | + return __('Site', 'wordpoints'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @since 1.0.0 |
57 | 57 | */ |
58 | 58 | public function get_title() { |
59 | - return __( 'Contains', 'wordpoints' ); |
|
59 | + return __('Contains', 'wordpoints'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | return array( |
67 | 67 | 'min' => array( |
68 | 68 | 'slug' => 'min', |
69 | - 'label' => __( 'Minimum number of items', 'wordpoints' ), |
|
69 | + 'label' => __('Minimum number of items', 'wordpoints'), |
|
70 | 70 | 'type' => 'number', |
71 | 71 | 'default' => 1, |
72 | 72 | ), |
73 | 73 | 'max' => array( |
74 | 74 | 'slug' => 'max', |
75 | - 'label' => __( 'Maximum number of items', 'wordpoints' ), |
|
75 | + 'label' => __('Maximum number of items', 'wordpoints'), |
|
76 | 76 | 'type' => 'number', |
77 | 77 | ), |
78 | 78 | ); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | $this->validate_count(); |
94 | 94 | |
95 | - if ( isset( $settings['conditions'] ) ) { |
|
96 | - $this->validate_conditions( $arg ); |
|
95 | + if (isset($settings['conditions'])) { |
|
96 | + $this->validate_conditions($arg); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $this->settings; |
@@ -107,31 +107,31 @@ discard block |
||
107 | 107 | protected function validate_count() { |
108 | 108 | |
109 | 109 | if ( |
110 | - ! empty( $this->settings['max'] ) |
|
111 | - && ! wordpoints_posint( $this->settings['max'] ) |
|
110 | + ! empty($this->settings['max']) |
|
111 | + && ! wordpoints_posint($this->settings['max']) |
|
112 | 112 | ) { |
113 | 113 | $this->validator->add_error( |
114 | - __( 'The maximum must be a positive integer.', 'wordpoints' ) |
|
114 | + __('The maximum must be a positive integer.', 'wordpoints') |
|
115 | 115 | , 'max' |
116 | 116 | ); |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! empty( $this->settings['min'] ) ) { |
|
119 | + if ( ! empty($this->settings['min'])) { |
|
120 | 120 | |
121 | - if ( ! wordpoints_posint( $this->settings['min'] ) ) { |
|
121 | + if ( ! wordpoints_posint($this->settings['min'])) { |
|
122 | 122 | |
123 | 123 | $this->validator->add_error( |
124 | - __( 'The minimum must be a positive integer.', 'wordpoints' ) |
|
124 | + __('The minimum must be a positive integer.', 'wordpoints') |
|
125 | 125 | , 'min' |
126 | 126 | ); |
127 | 127 | |
128 | 128 | } elseif ( |
129 | - ! empty( $this->settings['max'] ) |
|
129 | + ! empty($this->settings['max']) |
|
130 | 130 | && $this->settings['max'] < $this->settings['min'] |
131 | 131 | ) { |
132 | 132 | |
133 | 133 | $this->validator->add_error( |
134 | - __( 'The minimum must be less than the maximum.', 'wordpoints' ) |
|
134 | + __('The minimum must be less than the maximum.', 'wordpoints') |
|
135 | 135 | , 'min' |
136 | 136 | ); |
137 | 137 | } |
@@ -145,25 +145,25 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param WordPoints_EntityishI $current_arg The current arg. |
147 | 147 | */ |
148 | - protected function validate_conditions( $current_arg ) { |
|
148 | + protected function validate_conditions($current_arg) { |
|
149 | 149 | |
150 | - $args = new WordPoints_Hook_Event_Args( array() ); |
|
150 | + $args = new WordPoints_Hook_Event_Args(array()); |
|
151 | 151 | |
152 | - if ( $current_arg instanceof WordPoints_Entity_Array ) { |
|
152 | + if ($current_arg instanceof WordPoints_Entity_Array) { |
|
153 | 153 | |
154 | 154 | $entity = wordpoints_entities()->get( |
155 | 155 | $current_arg->get_entity_slug() |
156 | 156 | ); |
157 | 157 | |
158 | - if ( $entity instanceof WordPoints_Entity ) { |
|
159 | - $args->add_entity( $entity ); |
|
158 | + if ($entity instanceof WordPoints_Entity) { |
|
159 | + $args->add_entity($entity); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - $args->set_validator( $this->validator ); |
|
163 | + $args->set_validator($this->validator); |
|
164 | 164 | |
165 | 165 | $conditions = $this->conditions_extension->validate_settings( |
166 | - array( 'conditions' => $this->settings['conditions'] ) |
|
166 | + array('conditions' => $this->settings['conditions']) |
|
167 | 167 | , $this->validator |
168 | 168 | , $args |
169 | 169 | ); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @since 1.0.0 |
176 | 176 | */ |
177 | - public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) { |
|
177 | + public function is_met(array $settings, WordPoints_Hook_Event_Args $args) { |
|
178 | 178 | |
179 | 179 | $this->settings = $settings; |
180 | 180 | |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | |
183 | 183 | $entities = array(); |
184 | 184 | |
185 | - if ( $arg instanceof WordPoints_Entity_Array ) { |
|
185 | + if ($arg instanceof WordPoints_Entity_Array) { |
|
186 | 186 | |
187 | 187 | $entities = $arg->get_the_entities(); |
188 | 188 | |
189 | - if ( isset( $this->settings['conditions'] ) ) { |
|
190 | - $entities = $this->filter_entities( $entities ); |
|
189 | + if (isset($this->settings['conditions'])) { |
|
190 | + $entities = $this->filter_entities($entities); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - return $this->check_count( count( $entities ) ); |
|
194 | + return $this->check_count(count($entities)); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -203,20 +203,20 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return WordPoints_Entity[] The entities that matched the sub-conditions. |
205 | 205 | */ |
206 | - protected function filter_entities( $entities ) { |
|
206 | + protected function filter_entities($entities) { |
|
207 | 207 | |
208 | - foreach ( $entities as $index => $entity ) { |
|
208 | + foreach ($entities as $index => $entity) { |
|
209 | 209 | |
210 | - $event_args = new WordPoints_Hook_Event_Args( array() ); |
|
211 | - $event_args->add_entity( $entity ); |
|
210 | + $event_args = new WordPoints_Hook_Event_Args(array()); |
|
211 | + $event_args->add_entity($entity); |
|
212 | 212 | |
213 | 213 | $matches = $this->conditions_extension->conditions_are_met( |
214 | 214 | $this->settings['conditions'] |
215 | 215 | , $event_args |
216 | 216 | ); |
217 | 217 | |
218 | - if ( ! $matches ) { |
|
219 | - unset( $entities[ $index ] ); |
|
218 | + if ( ! $matches) { |
|
219 | + unset($entities[$index]); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return bool Whether the count met the requirements. |
234 | 234 | */ |
235 | - protected function check_count( $count ) { |
|
235 | + protected function check_count($count) { |
|
236 | 236 | |
237 | - if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) { |
|
237 | + if (isset($this->settings['max']) && $count > $this->settings['max']) { |
|
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | |
241 | - if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) { |
|
241 | + if (isset($this->settings['min']) && $count < $this->settings['min']) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | |
43 | 43 | $conditions_data = array(); |
44 | 44 | |
45 | - foreach ( $this->conditions->get_all() as $data_type => $conditions ) { |
|
46 | - foreach ( $conditions as $slug => $condition ) { |
|
45 | + foreach ($this->conditions->get_all() as $data_type => $conditions) { |
|
46 | + foreach ($conditions as $slug => $condition) { |
|
47 | 47 | |
48 | - if ( ! ( $condition instanceof WordPoints_Hook_Condition ) ) { |
|
48 | + if ( ! ($condition instanceof WordPoints_Hook_Condition)) { |
|
49 | 49 | continue; |
50 | 50 | } |
51 | 51 | |
52 | - $conditions_data[ $data_type ][ $slug ] = array( |
|
52 | + $conditions_data[$data_type][$slug] = array( |
|
53 | 53 | 'slug' => $slug, |
54 | 54 | 'data_type' => $data_type, |
55 | 55 | 'title' => $condition->get_title(), |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - return array( 'conditions' => $conditions_data ); |
|
61 | + return array('conditions' => $conditions_data); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return array The validated settings. |
72 | 72 | */ |
73 | - protected function validate_conditions( $args ) { |
|
73 | + protected function validate_conditions($args) { |
|
74 | 74 | |
75 | - if ( ! is_array( $args ) ) { |
|
75 | + if ( ! is_array($args)) { |
|
76 | 76 | |
77 | 77 | $this->validator->add_error( |
78 | - __( 'Conditions do not match expected format.', 'wordpoints' ) |
|
78 | + __('Conditions do not match expected format.', 'wordpoints') |
|
79 | 79 | ); |
80 | 80 | |
81 | 81 | return array(); |
82 | 82 | } |
83 | 83 | |
84 | - foreach ( $args as $arg_slug => $sub_args ) { |
|
84 | + foreach ($args as $arg_slug => $sub_args) { |
|
85 | 85 | |
86 | - if ( '_conditions' === $arg_slug ) { |
|
86 | + if ('_conditions' === $arg_slug) { |
|
87 | 87 | |
88 | - $this->validator->push_field( $arg_slug ); |
|
88 | + $this->validator->push_field($arg_slug); |
|
89 | 89 | |
90 | - foreach ( $sub_args as $index => $settings ) { |
|
90 | + foreach ($sub_args as $index => $settings) { |
|
91 | 91 | |
92 | - $this->validator->push_field( $index ); |
|
92 | + $this->validator->push_field($index); |
|
93 | 93 | |
94 | - $condition = $this->validate_condition( $settings ); |
|
94 | + $condition = $this->validate_condition($settings); |
|
95 | 95 | |
96 | - if ( $condition ) { |
|
97 | - $sub_args[ $index ] = $condition; |
|
96 | + if ($condition) { |
|
97 | + $sub_args[$index] = $condition; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $this->validator->pop_field(); |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | |
105 | 105 | } else { |
106 | 106 | |
107 | - if ( ! $this->event_args->descend( $arg_slug ) ) { |
|
107 | + if ( ! $this->event_args->descend($arg_slug)) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - $sub_args = $this->validate_conditions( $sub_args ); |
|
111 | + $sub_args = $this->validate_conditions($sub_args); |
|
112 | 112 | |
113 | - $args[ $arg_slug ] = $sub_args; |
|
113 | + $args[$arg_slug] = $sub_args; |
|
114 | 114 | |
115 | 115 | $this->event_args->ascend(); |
116 | 116 | } |
117 | 117 | |
118 | - $args[ $arg_slug ] = $sub_args; |
|
118 | + $args[$arg_slug] = $sub_args; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return $args; |
@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | * @return array|false The validated conditions settings, or false if unable to |
132 | 132 | * validate. |
133 | 133 | */ |
134 | - protected function validate_condition( $settings ) { |
|
134 | + protected function validate_condition($settings) { |
|
135 | 135 | |
136 | - if ( ! isset( $settings['type'] ) ) { |
|
137 | - $this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) ); |
|
136 | + if ( ! isset($settings['type'])) { |
|
137 | + $this->validator->add_error(__('Condition type is missing.', 'wordpoints')); |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $arg = $this->event_args->get_current(); |
142 | 142 | |
143 | - $data_type = $this->get_data_type( $arg ); |
|
143 | + $data_type = $this->get_data_type($arg); |
|
144 | 144 | |
145 | - if ( ! $data_type ) { |
|
145 | + if ( ! $data_type) { |
|
146 | 146 | $this->validator->add_error( |
147 | - __( 'This type of condition does not work for the selected attribute.', 'wordpoints' ) |
|
147 | + __('This type of condition does not work for the selected attribute.', 'wordpoints') |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $condition = wordpoints_hooks()->conditions->get( $data_type, $settings['type'] ); |
|
153 | + $condition = wordpoints_hooks()->conditions->get($data_type, $settings['type']); |
|
154 | 154 | |
155 | - if ( ! $condition ) { |
|
155 | + if ( ! $condition) { |
|
156 | 156 | |
157 | 157 | $this->validator->add_error( |
158 | 158 | sprintf( |
159 | - __( 'Unknown condition type “%s”.', 'wordpoints' ) |
|
159 | + __('Unknown condition type “%s”.', 'wordpoints') |
|
160 | 160 | , $settings['type'] |
161 | 161 | ) |
162 | 162 | , 'type' |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | - if ( ! isset( $settings['settings'] ) ) { |
|
169 | - $this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) ); |
|
168 | + if ( ! isset($settings['settings'])) { |
|
169 | + $this->validator->add_error(__('Condition settings are missing.', 'wordpoints')); |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - $this->validator->push_field( 'settings' ); |
|
173 | + $this->validator->push_field('settings'); |
|
174 | 174 | |
175 | 175 | // The condition may call this object's validate_settings() method to |
176 | 176 | // validate some sub-conditions. When that happens, these properties will be |
177 | 177 | // reset, so we need to back up their values and then restore them below. |
178 | - $backup = array( $this->validator, $this->event_args ); |
|
178 | + $backup = array($this->validator, $this->event_args); |
|
179 | 179 | |
180 | 180 | $settings['settings'] = $condition->validate_settings( |
181 | 181 | $arg |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | , $this->validator |
184 | 184 | ); |
185 | 185 | |
186 | - list( $this->validator, $this->event_args ) = $backup; |
|
186 | + list($this->validator, $this->event_args) = $backup; |
|
187 | 187 | |
188 | 188 | $this->validator->pop_field(); |
189 | 189 | |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | WordPoints_Hook_Event_Args $event_args |
199 | 199 | ) { |
200 | 200 | |
201 | - $conditions = $reaction->get_meta( 'conditions' ); |
|
201 | + $conditions = $reaction->get_meta('conditions'); |
|
202 | 202 | |
203 | - if ( $conditions && ! $this->conditions_are_met( $conditions, $event_args ) ) { |
|
203 | + if ($conditions && ! $this->conditions_are_met($conditions, $event_args)) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
@@ -222,35 +222,35 @@ discard block |
||
222 | 222 | WordPoints_Hook_Event_Args $event_args |
223 | 223 | ) { |
224 | 224 | |
225 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
225 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
226 | 226 | |
227 | - $event_args->descend( $arg_slug ); |
|
227 | + $event_args->descend($arg_slug); |
|
228 | 228 | |
229 | - if ( isset( $sub_args['_conditions'] ) ) { |
|
229 | + if (isset($sub_args['_conditions'])) { |
|
230 | 230 | |
231 | - foreach ( $sub_args['_conditions'] as $settings ) { |
|
231 | + foreach ($sub_args['_conditions'] as $settings) { |
|
232 | 232 | |
233 | 233 | $condition = $this->conditions->get( |
234 | - $this->get_data_type( $event_args->get_current() ) |
|
234 | + $this->get_data_type($event_args->get_current()) |
|
235 | 235 | , $settings['type'] |
236 | 236 | ); |
237 | 237 | |
238 | - $is_met = $condition->is_met( $settings['settings'], $event_args ); |
|
238 | + $is_met = $condition->is_met($settings['settings'], $event_args); |
|
239 | 239 | |
240 | - if ( ! $is_met ) { |
|
240 | + if ( ! $is_met) { |
|
241 | 241 | $event_args->ascend(); |
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | - unset( $sub_args['_conditions'] ); |
|
246 | + unset($sub_args['_conditions']); |
|
247 | 247 | } |
248 | 248 | |
249 | - $are_met = $this->conditions_are_met( $sub_args, $event_args ); |
|
249 | + $are_met = $this->conditions_are_met($sub_args, $event_args); |
|
250 | 250 | |
251 | 251 | $event_args->ascend(); |
252 | 252 | |
253 | - if ( ! $are_met ) { |
|
253 | + if ( ! $are_met) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | } |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return string|false The data type, or false. |
269 | 269 | */ |
270 | - protected function get_data_type( $arg ) { |
|
270 | + protected function get_data_type($arg) { |
|
271 | 271 | |
272 | - if ( $arg instanceof WordPoints_Entity_Attr ) { |
|
272 | + if ($arg instanceof WordPoints_Entity_Attr) { |
|
273 | 273 | $data_type = $arg->get_data_type(); |
274 | - } elseif ( $arg instanceof WordPoints_Entity_Array ) { |
|
274 | + } elseif ($arg instanceof WordPoints_Entity_Array) { |
|
275 | 275 | $data_type = 'entity_array'; |
276 | - } elseif ( $arg instanceof WordPoints_Entity ) { |
|
276 | + } elseif ($arg instanceof WordPoints_Entity) { |
|
277 | 277 | $data_type = 'entity'; |
278 | 278 | } else { |
279 | 279 | $data_type = false; |
@@ -10,104 +10,104 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // auto-generated { |
13 | -require_once( dirname( __FILE__ ) . 'app.php' ); |
|
14 | -require_once( dirname( __FILE__ ) . 'app/registry.php' ); |
|
15 | -require_once( dirname( __FILE__ ) . 'class/autoloader.php' ); |
|
16 | -require_once( dirname( __FILE__ ) . 'class/registry.php' ); |
|
17 | -require_once( dirname( __FILE__ ) . 'class/registry/children.php' ); |
|
18 | -require_once( dirname( __FILE__ ) . 'class/registry/childreni.php' ); |
|
19 | -require_once( dirname( __FILE__ ) . 'class/registry/persistent.php' ); |
|
20 | -require_once( dirname( __FILE__ ) . 'class/registryi.php' ); |
|
21 | -require_once( dirname( __FILE__ ) . 'data/type.php' ); |
|
22 | -require_once( dirname( __FILE__ ) . 'data/type/integer.php' ); |
|
23 | -require_once( dirname( __FILE__ ) . 'data/type/text.php' ); |
|
24 | -require_once( dirname( __FILE__ ) . 'data/typei.php' ); |
|
25 | -require_once( dirname( __FILE__ ) . 'entity.php' ); |
|
26 | -require_once( dirname( __FILE__ ) . 'entity/array.php' ); |
|
27 | -require_once( dirname( __FILE__ ) . 'entity/attr.php' ); |
|
28 | -require_once( dirname( __FILE__ ) . 'entity/childi.php' ); |
|
29 | -require_once( dirname( __FILE__ ) . 'entity/comment.php' ); |
|
30 | -require_once( dirname( __FILE__ ) . 'entity/comment/author.php' ); |
|
31 | -require_once( dirname( __FILE__ ) . 'entity/comment/post.php' ); |
|
32 | -require_once( dirname( __FILE__ ) . 'entity/enumerablei.php' ); |
|
33 | -require_once( dirname( __FILE__ ) . 'entity/hierarchy.php' ); |
|
34 | -require_once( dirname( __FILE__ ) . 'entity/hierarchyi.php' ); |
|
35 | -require_once( dirname( __FILE__ ) . 'entity/parenti.php' ); |
|
36 | -require_once( dirname( __FILE__ ) . 'entity/post.php' ); |
|
37 | -require_once( dirname( __FILE__ ) . 'entity/post/author.php' ); |
|
38 | -require_once( dirname( __FILE__ ) . 'entity/post/content.php' ); |
|
39 | -require_once( dirname( __FILE__ ) . 'entity/post/terms.php' ); |
|
40 | -require_once( dirname( __FILE__ ) . 'entity/post/type.php' ); |
|
41 | -require_once( dirname( __FILE__ ) . 'entity/post/type/name.php' ); |
|
42 | -require_once( dirname( __FILE__ ) . 'entity/post/type/relationship.php' ); |
|
43 | -require_once( dirname( __FILE__ ) . 'entity/relationship.php' ); |
|
44 | -require_once( dirname( __FILE__ ) . 'entity/restricted/visibilityi.php' ); |
|
45 | -require_once( dirname( __FILE__ ) . 'entity/site.php' ); |
|
46 | -require_once( dirname( __FILE__ ) . 'entity/term.php' ); |
|
47 | -require_once( dirname( __FILE__ ) . 'entity/term/id.php' ); |
|
48 | -require_once( dirname( __FILE__ ) . 'entity/user.php' ); |
|
49 | -require_once( dirname( __FILE__ ) . 'entity/user/role.php' ); |
|
50 | -require_once( dirname( __FILE__ ) . 'entity/user/role/name.php' ); |
|
51 | -require_once( dirname( __FILE__ ) . 'entity/user/roles.php' ); |
|
52 | -require_once( dirname( __FILE__ ) . 'entityish.php' ); |
|
53 | -require_once( dirname( __FILE__ ) . 'entityishi.php' ); |
|
54 | -require_once( dirname( __FILE__ ) . 'hierarchy.php' ); |
|
55 | -require_once( dirname( __FILE__ ) . 'hook/action.php' ); |
|
56 | -require_once( dirname( __FILE__ ) . 'hook/action/comment/new.php' ); |
|
57 | -require_once( dirname( __FILE__ ) . 'hook/action/post/publish.php' ); |
|
58 | -require_once( dirname( __FILE__ ) . 'hook/actioni.php' ); |
|
59 | -require_once( dirname( __FILE__ ) . 'hook/actions.php' ); |
|
60 | -require_once( dirname( __FILE__ ) . 'hook/arg.php' ); |
|
61 | -require_once( dirname( __FILE__ ) . 'hook/arg/current/post.php' ); |
|
62 | -require_once( dirname( __FILE__ ) . 'hook/arg/current/site.php' ); |
|
63 | -require_once( dirname( __FILE__ ) . 'hook/arg/current/user.php' ); |
|
64 | -require_once( dirname( __FILE__ ) . 'hook/condition.php' ); |
|
65 | -require_once( dirname( __FILE__ ) . 'hook/condition/entity/array/contains.php' ); |
|
66 | -require_once( dirname( __FILE__ ) . 'hook/condition/equals.php' ); |
|
67 | -require_once( dirname( __FILE__ ) . 'hook/condition/string/contains.php' ); |
|
68 | -require_once( dirname( __FILE__ ) . 'hook/conditioni.php' ); |
|
69 | -require_once( dirname( __FILE__ ) . 'hook/event.php' ); |
|
70 | -require_once( dirname( __FILE__ ) . 'hook/event/args.php' ); |
|
71 | -require_once( dirname( __FILE__ ) . 'hook/event/comment/leave.php' ); |
|
72 | -require_once( dirname( __FILE__ ) . 'hook/event/post/publish.php' ); |
|
73 | -require_once( dirname( __FILE__ ) . 'hook/event/user/register.php' ); |
|
74 | -require_once( dirname( __FILE__ ) . 'hook/event/user/visit.php' ); |
|
75 | -require_once( dirname( __FILE__ ) . 'hook/eventi.php' ); |
|
76 | -require_once( dirname( __FILE__ ) . 'hook/events.php' ); |
|
77 | -require_once( dirname( __FILE__ ) . 'hook/extension.php' ); |
|
78 | -require_once( dirname( __FILE__ ) . 'hook/extension/conditions.php' ); |
|
79 | -require_once( dirname( __FILE__ ) . 'hook/extension/periods.php' ); |
|
80 | -require_once( dirname( __FILE__ ) . 'hook/extension/reversei.php' ); |
|
81 | -require_once( dirname( __FILE__ ) . 'hook/extension/spami.php' ); |
|
82 | -require_once( dirname( __FILE__ ) . 'hook/firer.php' ); |
|
83 | -require_once( dirname( __FILE__ ) . 'hook/firer/reverse.php' ); |
|
84 | -require_once( dirname( __FILE__ ) . 'hook/firer/spam.php' ); |
|
85 | -require_once( dirname( __FILE__ ) . 'hook/fireri.php' ); |
|
86 | -require_once( dirname( __FILE__ ) . 'hook/reaction.php' ); |
|
87 | -require_once( dirname( __FILE__ ) . 'hook/reaction/options.php' ); |
|
88 | -require_once( dirname( __FILE__ ) . 'hook/reaction/storage.php' ); |
|
89 | -require_once( dirname( __FILE__ ) . 'hook/reaction/storage/options.php' ); |
|
90 | -require_once( dirname( __FILE__ ) . 'hook/reaction/storage/options/network.php' ); |
|
91 | -require_once( dirname( __FILE__ ) . 'hook/reaction/storagei.php' ); |
|
92 | -require_once( dirname( __FILE__ ) . 'hook/reaction/validator.php' ); |
|
93 | -require_once( dirname( __FILE__ ) . 'hook/reactioni.php' ); |
|
94 | -require_once( dirname( __FILE__ ) . 'hook/reactor.php' ); |
|
95 | -require_once( dirname( __FILE__ ) . 'hook/reactor/points.php' ); |
|
96 | -require_once( dirname( __FILE__ ) . 'hook/reactor/reversei.php' ); |
|
97 | -require_once( dirname( __FILE__ ) . 'hook/reactor/spami.php' ); |
|
98 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/conditions.php' ); |
|
99 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/query.php' ); |
|
100 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/query/modifieri.php' ); |
|
101 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/queryable.php' ); |
|
102 | -require_once( dirname( __FILE__ ) . 'hook/retroactive/queryi.php' ); |
|
103 | -require_once( dirname( __FILE__ ) . 'hook/router.php' ); |
|
104 | -require_once( dirname( __FILE__ ) . 'hook/settings.php' ); |
|
105 | -require_once( dirname( __FILE__ ) . 'hook/settingsi.php' ); |
|
106 | -require_once( dirname( __FILE__ ) . 'hook/validator/exception.php' ); |
|
107 | -require_once( dirname( __FILE__ ) . 'hooks.php' ); |
|
108 | -require_once( dirname( __FILE__ ) . 'query/builder/db/mysql.php' ); |
|
109 | -require_once( dirname( __FILE__ ) . 'spec.php' ); |
|
110 | -require_once( dirname( __FILE__ ) . 'specedi.php' ); |
|
13 | +require_once(dirname(__FILE__).'app.php'); |
|
14 | +require_once(dirname(__FILE__).'app/registry.php'); |
|
15 | +require_once(dirname(__FILE__).'class/autoloader.php'); |
|
16 | +require_once(dirname(__FILE__).'class/registry.php'); |
|
17 | +require_once(dirname(__FILE__).'class/registry/children.php'); |
|
18 | +require_once(dirname(__FILE__).'class/registry/childreni.php'); |
|
19 | +require_once(dirname(__FILE__).'class/registry/persistent.php'); |
|
20 | +require_once(dirname(__FILE__).'class/registryi.php'); |
|
21 | +require_once(dirname(__FILE__).'data/type.php'); |
|
22 | +require_once(dirname(__FILE__).'data/type/integer.php'); |
|
23 | +require_once(dirname(__FILE__).'data/type/text.php'); |
|
24 | +require_once(dirname(__FILE__).'data/typei.php'); |
|
25 | +require_once(dirname(__FILE__).'entity.php'); |
|
26 | +require_once(dirname(__FILE__).'entity/array.php'); |
|
27 | +require_once(dirname(__FILE__).'entity/attr.php'); |
|
28 | +require_once(dirname(__FILE__).'entity/childi.php'); |
|
29 | +require_once(dirname(__FILE__).'entity/comment.php'); |
|
30 | +require_once(dirname(__FILE__).'entity/comment/author.php'); |
|
31 | +require_once(dirname(__FILE__).'entity/comment/post.php'); |
|
32 | +require_once(dirname(__FILE__).'entity/enumerablei.php'); |
|
33 | +require_once(dirname(__FILE__).'entity/hierarchy.php'); |
|
34 | +require_once(dirname(__FILE__).'entity/hierarchyi.php'); |
|
35 | +require_once(dirname(__FILE__).'entity/parenti.php'); |
|
36 | +require_once(dirname(__FILE__).'entity/post.php'); |
|
37 | +require_once(dirname(__FILE__).'entity/post/author.php'); |
|
38 | +require_once(dirname(__FILE__).'entity/post/content.php'); |
|
39 | +require_once(dirname(__FILE__).'entity/post/terms.php'); |
|
40 | +require_once(dirname(__FILE__).'entity/post/type.php'); |
|
41 | +require_once(dirname(__FILE__).'entity/post/type/name.php'); |
|
42 | +require_once(dirname(__FILE__).'entity/post/type/relationship.php'); |
|
43 | +require_once(dirname(__FILE__).'entity/relationship.php'); |
|
44 | +require_once(dirname(__FILE__).'entity/restricted/visibilityi.php'); |
|
45 | +require_once(dirname(__FILE__).'entity/site.php'); |
|
46 | +require_once(dirname(__FILE__).'entity/term.php'); |
|
47 | +require_once(dirname(__FILE__).'entity/term/id.php'); |
|
48 | +require_once(dirname(__FILE__).'entity/user.php'); |
|
49 | +require_once(dirname(__FILE__).'entity/user/role.php'); |
|
50 | +require_once(dirname(__FILE__).'entity/user/role/name.php'); |
|
51 | +require_once(dirname(__FILE__).'entity/user/roles.php'); |
|
52 | +require_once(dirname(__FILE__).'entityish.php'); |
|
53 | +require_once(dirname(__FILE__).'entityishi.php'); |
|
54 | +require_once(dirname(__FILE__).'hierarchy.php'); |
|
55 | +require_once(dirname(__FILE__).'hook/action.php'); |
|
56 | +require_once(dirname(__FILE__).'hook/action/comment/new.php'); |
|
57 | +require_once(dirname(__FILE__).'hook/action/post/publish.php'); |
|
58 | +require_once(dirname(__FILE__).'hook/actioni.php'); |
|
59 | +require_once(dirname(__FILE__).'hook/actions.php'); |
|
60 | +require_once(dirname(__FILE__).'hook/arg.php'); |
|
61 | +require_once(dirname(__FILE__).'hook/arg/current/post.php'); |
|
62 | +require_once(dirname(__FILE__).'hook/arg/current/site.php'); |
|
63 | +require_once(dirname(__FILE__).'hook/arg/current/user.php'); |
|
64 | +require_once(dirname(__FILE__).'hook/condition.php'); |
|
65 | +require_once(dirname(__FILE__).'hook/condition/entity/array/contains.php'); |
|
66 | +require_once(dirname(__FILE__).'hook/condition/equals.php'); |
|
67 | +require_once(dirname(__FILE__).'hook/condition/string/contains.php'); |
|
68 | +require_once(dirname(__FILE__).'hook/conditioni.php'); |
|
69 | +require_once(dirname(__FILE__).'hook/event.php'); |
|
70 | +require_once(dirname(__FILE__).'hook/event/args.php'); |
|
71 | +require_once(dirname(__FILE__).'hook/event/comment/leave.php'); |
|
72 | +require_once(dirname(__FILE__).'hook/event/post/publish.php'); |
|
73 | +require_once(dirname(__FILE__).'hook/event/user/register.php'); |
|
74 | +require_once(dirname(__FILE__).'hook/event/user/visit.php'); |
|
75 | +require_once(dirname(__FILE__).'hook/eventi.php'); |
|
76 | +require_once(dirname(__FILE__).'hook/events.php'); |
|
77 | +require_once(dirname(__FILE__).'hook/extension.php'); |
|
78 | +require_once(dirname(__FILE__).'hook/extension/conditions.php'); |
|
79 | +require_once(dirname(__FILE__).'hook/extension/periods.php'); |
|
80 | +require_once(dirname(__FILE__).'hook/extension/reversei.php'); |
|
81 | +require_once(dirname(__FILE__).'hook/extension/spami.php'); |
|
82 | +require_once(dirname(__FILE__).'hook/firer.php'); |
|
83 | +require_once(dirname(__FILE__).'hook/firer/reverse.php'); |
|
84 | +require_once(dirname(__FILE__).'hook/firer/spam.php'); |
|
85 | +require_once(dirname(__FILE__).'hook/fireri.php'); |
|
86 | +require_once(dirname(__FILE__).'hook/reaction.php'); |
|
87 | +require_once(dirname(__FILE__).'hook/reaction/options.php'); |
|
88 | +require_once(dirname(__FILE__).'hook/reaction/storage.php'); |
|
89 | +require_once(dirname(__FILE__).'hook/reaction/storage/options.php'); |
|
90 | +require_once(dirname(__FILE__).'hook/reaction/storage/options/network.php'); |
|
91 | +require_once(dirname(__FILE__).'hook/reaction/storagei.php'); |
|
92 | +require_once(dirname(__FILE__).'hook/reaction/validator.php'); |
|
93 | +require_once(dirname(__FILE__).'hook/reactioni.php'); |
|
94 | +require_once(dirname(__FILE__).'hook/reactor.php'); |
|
95 | +require_once(dirname(__FILE__).'hook/reactor/points.php'); |
|
96 | +require_once(dirname(__FILE__).'hook/reactor/reversei.php'); |
|
97 | +require_once(dirname(__FILE__).'hook/reactor/spami.php'); |
|
98 | +require_once(dirname(__FILE__).'hook/retroactive/conditions.php'); |
|
99 | +require_once(dirname(__FILE__).'hook/retroactive/query.php'); |
|
100 | +require_once(dirname(__FILE__).'hook/retroactive/query/modifieri.php'); |
|
101 | +require_once(dirname(__FILE__).'hook/retroactive/queryable.php'); |
|
102 | +require_once(dirname(__FILE__).'hook/retroactive/queryi.php'); |
|
103 | +require_once(dirname(__FILE__).'hook/router.php'); |
|
104 | +require_once(dirname(__FILE__).'hook/settings.php'); |
|
105 | +require_once(dirname(__FILE__).'hook/settingsi.php'); |
|
106 | +require_once(dirname(__FILE__).'hook/validator/exception.php'); |
|
107 | +require_once(dirname(__FILE__).'hooks.php'); |
|
108 | +require_once(dirname(__FILE__).'query/builder/db/mysql.php'); |
|
109 | +require_once(dirname(__FILE__).'spec.php'); |
|
110 | +require_once(dirname(__FILE__).'specedi.php'); |
|
111 | 111 | // } |
112 | 112 | |
113 | 113 | // EOF |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry. |
35 | 35 | */ |
36 | -function wordpoints_hook_reactors_init( $reactors ) { |
|
36 | +function wordpoints_hook_reactors_init($reactors) { |
|
37 | 37 | |
38 | - $reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' ); |
|
38 | + $reactors->register('points', 'WordPoints_Hook_Reactor_Points'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
49 | 49 | */ |
50 | -function wordpoints_hook_extension_init( $extensions ) { |
|
50 | +function wordpoints_hook_extension_init($extensions) { |
|
51 | 51 | |
52 | - $extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' ); |
|
53 | - $extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' ); |
|
52 | + $extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions'); |
|
53 | + $extensions->register('periods', 'WordPoints_Hook_Extension_Periods'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param WordPoints_Class_Registry_Children $conditions The conditions registry. |
64 | 64 | */ |
65 | -function wordpoints_hook_conditions_init( $conditions ) { |
|
65 | +function wordpoints_hook_conditions_init($conditions) { |
|
66 | 66 | |
67 | 67 | $conditions->register( |
68 | 68 | 'text' |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param WordPoints_Hook_Actions $actions The action registry. |
100 | 100 | */ |
101 | -function wordpoints_hook_actions_init( $actions ) { |
|
101 | +function wordpoints_hook_actions_init($actions) { |
|
102 | 102 | |
103 | 103 | $actions->register( |
104 | 104 | 'comment_approve' |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | , array( |
107 | 107 | 'action' => 'transition_comment_status', |
108 | 108 | 'data' => array( |
109 | - 'arg_index' => array( 'comment' => 2 ), |
|
110 | - 'requirements' => array( 0 => 'approved' ), |
|
109 | + 'arg_index' => array('comment' => 2), |
|
110 | + 'requirements' => array(0 => 'approved'), |
|
111 | 111 | ), |
112 | 112 | ) |
113 | 113 | ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | , array( |
119 | 119 | 'action' => 'wp_insert_comment', |
120 | 120 | 'data' => array( |
121 | - 'arg_index' => array( 'comment' => 1 ), |
|
121 | + 'arg_index' => array('comment' => 1), |
|
122 | 122 | ), |
123 | 123 | ) |
124 | 124 | ); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | , array( |
130 | 130 | 'action' => 'transition_comment_status', |
131 | 131 | 'data' => array( |
132 | - 'arg_index' => array( 'comment' => 2 ), |
|
133 | - 'requirements' => array( 1 => 'approved' ), |
|
132 | + 'arg_index' => array('comment' => 2), |
|
133 | + 'requirements' => array(1 => 'approved'), |
|
134 | 134 | ), |
135 | 135 | ) |
136 | 136 | ); |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | , array( |
142 | 142 | 'action' => 'transition_post_status', |
143 | 143 | 'data' => array( |
144 | - 'arg_index' => array( 'post' => 2 ), |
|
145 | - 'requirements' => array( 0 => 'publish' ), |
|
144 | + 'arg_index' => array('post' => 2), |
|
145 | + 'requirements' => array(0 => 'publish'), |
|
146 | 146 | ), |
147 | 147 | ) |
148 | 148 | ); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | , array( |
154 | 154 | 'action' => 'post_delete', |
155 | 155 | 'data' => array( |
156 | - 'arg_index' => array( 'post' => 0 ), |
|
156 | + 'arg_index' => array('post' => 0), |
|
157 | 157 | ), |
158 | 158 | ) |
159 | 159 | ); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | , array( |
165 | 165 | 'action' => 'user_register', |
166 | 166 | 'data' => array( |
167 | - 'arg_index' => array( 'user' => 0 ), |
|
167 | + 'arg_index' => array('user' => 0), |
|
168 | 168 | ), |
169 | 169 | ) |
170 | 170 | ); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | , array( |
176 | 176 | 'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user', |
177 | 177 | 'data' => array( |
178 | - 'arg_index' => array( 'user' => 0 ), |
|
178 | + 'arg_index' => array('user' => 0), |
|
179 | 179 | ), |
180 | 180 | ) |
181 | 181 | ); |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @param WordPoints_Hook_Events $events The event registry. |
200 | 200 | */ |
201 | -function wordpoints_hook_events_init( $events ) { |
|
201 | +function wordpoints_hook_events_init($events) { |
|
202 | 202 | |
203 | 203 | $events->register( |
204 | 204 | 'comment_leave' |
205 | 205 | , 'WordPoints_Hook_Event_Comment_Leave' |
206 | 206 | , array( |
207 | 207 | 'actions' => array( |
208 | - 'fire' => array( 'comment_approve', 'comment_new' ), |
|
208 | + 'fire' => array('comment_approve', 'comment_new'), |
|
209 | 209 | 'reverse' => 'comment_deapprove', |
210 | 210 | 'spam' => 'comment_spam', |
211 | 211 | ), |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | ) |
257 | 257 | ); |
258 | 258 | |
259 | - if ( is_multisite() ) { |
|
259 | + if (is_multisite()) { |
|
260 | 260 | |
261 | 261 | $event_slugs = array( |
262 | 262 | 'user_visit', |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | 'comment_leave', |
266 | 266 | ); |
267 | 267 | |
268 | - foreach ( $event_slugs as $event_slug ) { |
|
268 | + foreach ($event_slugs as $event_slug) { |
|
269 | 269 | // TODO network hooks |
270 | 270 | $events->args->register( |
271 | 271 | $event_slug |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @param WordPoints_Class_Registry_Persistent $firers The firer registry. |
287 | 287 | */ |
288 | -function wordpoints_hook_firers_init( $firers ) { |
|
288 | +function wordpoints_hook_firers_init($firers) { |
|
289 | 289 | |
290 | - $firers->register( 'fire', 'WordPoints_Hook_Firer' ); |
|
291 | - $firers->register( 'reverse', 'WordPoints_Hook_Firer_Reverse' ); |
|
292 | - $firers->register( 'spam', 'WordPoints_Hook_Firer_Spam' ); |
|
290 | + $firers->register('fire', 'WordPoints_Hook_Firer'); |
|
291 | + $firers->register('reverse', 'WordPoints_Hook_Firer_Reverse'); |
|
292 | + $firers->register('spam', 'WordPoints_Hook_Firer_Spam'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @param WordPoints_App_Registry $entities The entities app. |
303 | 303 | */ |
304 | -function wordpoints_entities_app_init( $entities ) { |
|
304 | +function wordpoints_entities_app_init($entities) { |
|
305 | 305 | |
306 | - $entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' ); |
|
306 | + $entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children'); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @param WordPoints_App_Registry $entities The entities app. |
317 | 317 | */ |
318 | -function wordpoints_entities_init( $entities ) { |
|
318 | +function wordpoints_entities_init($entities) { |
|
319 | 319 | |
320 | 320 | // |
321 | 321 | // Entities. |
322 | 322 | // |
323 | 323 | |
324 | - $entities->register( 'post', 'WordPoints_Entity_Post' ); |
|
325 | - $entities->register( 'post_type', 'WordPoints_Entity_Post_Type' ); |
|
326 | - $entities->register( 'comment', 'WordPoints_Entity_Comment' ); |
|
327 | - $entities->register( 'user', 'WordPoints_Entity_User' ); |
|
328 | - $entities->register( 'user_role', 'WordPoints_Entity_User_Role' ); |
|
329 | - $entities->register( 'term', 'WordPoints_Entity_Term' ); |
|
324 | + $entities->register('post', 'WordPoints_Entity_Post'); |
|
325 | + $entities->register('post_type', 'WordPoints_Entity_Post_Type'); |
|
326 | + $entities->register('comment', 'WordPoints_Entity_Comment'); |
|
327 | + $entities->register('user', 'WordPoints_Entity_User'); |
|
328 | + $entities->register('user_role', 'WordPoints_Entity_User_Role'); |
|
329 | + $entities->register('term', 'WordPoints_Entity_Term'); |
|
330 | 330 | |
331 | 331 | // |
332 | 332 | // Attributes. |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | |
335 | 335 | $atts = $entities->children; |
336 | 336 | |
337 | - $atts->register( 'post', 'content', 'WordPoints_Entity_Post_Content' ); |
|
338 | - $atts->register( 'post_type', 'name', 'WordPoints_Entity_Post_Type_Name' ); |
|
339 | - $atts->register( 'term', 'id', 'WordPoints_Entity_Term_Id' ); |
|
340 | - $atts->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' ); |
|
337 | + $atts->register('post', 'content', 'WordPoints_Entity_Post_Content'); |
|
338 | + $atts->register('post_type', 'name', 'WordPoints_Entity_Post_Type_Name'); |
|
339 | + $atts->register('term', 'id', 'WordPoints_Entity_Term_Id'); |
|
340 | + $atts->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name'); |
|
341 | 341 | |
342 | 342 | // |
343 | 343 | // Relationships. |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | |
346 | 346 | $children = $entities->children; |
347 | 347 | |
348 | - $children->register( 'post', 'author', 'WordPoints_Entity_Post_Author' ); |
|
349 | - $children->register( 'post', 'type', 'WordPoints_Entity_Post_Type_Relationship' ); |
|
350 | - $children->register( 'post', 'terms', 'WordPoints_Entity_Post_Terms' ); |
|
351 | - $children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' ); |
|
352 | - $children->register( 'comment', 'post', 'WordPoints_Entity_Comment_Post' ); |
|
353 | - $children->register( 'comment', 'author', 'WordPoints_Entity_Comment_Author' ); |
|
348 | + $children->register('post', 'author', 'WordPoints_Entity_Post_Author'); |
|
349 | + $children->register('post', 'type', 'WordPoints_Entity_Post_Type_Relationship'); |
|
350 | + $children->register('post', 'terms', 'WordPoints_Entity_Post_Terms'); |
|
351 | + $children->register('user', 'roles', 'WordPoints_Entity_User_Roles'); |
|
352 | + $children->register('comment', 'post', 'WordPoints_Entity_Comment_Post'); |
|
353 | + $children->register('comment', 'author', 'WordPoints_Entity_Comment_Author'); |
|
354 | 354 | |
355 | - foreach ( get_post_types( array( 'public' => true ), false ) as $slug => $post_type ) { |
|
356 | - unset( $post_type ); // TODO |
|
355 | + foreach (get_post_types(array('public' => true), false) as $slug => $post_type) { |
|
356 | + unset($post_type); // TODO |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @param WordPoints_Class_RegistryI $data_types The data types registry. |
368 | 368 | */ |
369 | -function wordpoints_data_types_init( $data_types ) { |
|
369 | +function wordpoints_data_types_init($data_types) { |
|
370 | 370 | |
371 | - $data_types->register( 'integer', 'WordPoints_Data_Type_Integer' ); |
|
372 | - $data_types->register( 'text', 'WordPoints_Data_Type_Text' ); |
|
371 | + $data_types->register('integer', 'WordPoints_Data_Type_Integer'); |
|
372 | + $data_types->register('text', 'WordPoints_Data_Type_Text'); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return bool Whether the user can view the points log. |
386 | 386 | */ |
387 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) { |
|
387 | +function wordpoints_hooks_user_can_view_points_log($can_view, $log) { |
|
388 | 388 | |
389 | - if ( ! $can_view ) { |
|
389 | + if ( ! $can_view) { |
|
390 | 390 | return $can_view; |
391 | 391 | } |
392 | 392 | |
@@ -395,11 +395,11 @@ discard block |
||
395 | 395 | $event_slug = $log->log_type; |
396 | 396 | |
397 | 397 | /** @var WordPoints_Hook_Arg $arg */ |
398 | - foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) { |
|
398 | + foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) { |
|
399 | 399 | |
400 | - $value = wordpoints_get_points_log_meta( $log->id, $slug, true ); |
|
400 | + $value = wordpoints_get_points_log_meta($log->id, $slug, true); |
|
401 | 401 | |
402 | - if ( ! $value ) { |
|
402 | + if ( ! $value) { |
|
403 | 403 | continue; |
404 | 404 | } |
405 | 405 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | , $value |
410 | 410 | ); |
411 | 411 | |
412 | - if ( ! $can_view ) { |
|
412 | + if ( ! $can_view) { |
|
413 | 413 | break; |
414 | 414 | } |
415 | 415 | } |
@@ -428,20 +428,20 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return bool Whether the user can view this entity. |
430 | 430 | */ |
431 | -function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) { |
|
431 | +function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) { |
|
432 | 432 | |
433 | - $entity = wordpoints_entities()->get( $entity_slug ); |
|
433 | + $entity = wordpoints_entities()->get($entity_slug); |
|
434 | 434 | |
435 | 435 | // If this entity type is not found, we have no way of determining whether it is |
436 | 436 | // safe for the user to view it. |
437 | - if ( ! ( $entity instanceof WordPoints_Entity ) ) { |
|
437 | + if ( ! ($entity instanceof WordPoints_Entity)) { |
|
438 | 438 | return false; |
439 | 439 | } |
440 | 440 | |
441 | 441 | $can_view = true; |
442 | 442 | |
443 | - if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) { |
|
444 | - $can_view = $entity->user_can_view( $user_id, $entity_id ); |
|
443 | + if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) { |
|
444 | + $can_view = $entity->user_can_view($user_id, $entity_id); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | */ |
473 | 473 | function wordpoints_apps() { |
474 | 474 | |
475 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
476 | - WordPoints_App::$main = new WordPoints_App( 'apps' ); |
|
475 | + if ( ! isset(WordPoints_App::$main)) { |
|
476 | + WordPoints_App::$main = new WordPoints_App('apps'); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | return WordPoints_App::$main; |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | */ |
489 | 489 | function wordpoints_hooks() { |
490 | 490 | |
491 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
491 | + if ( ! isset(WordPoints_App::$main)) { |
|
492 | 492 | wordpoints_apps(); |
493 | 493 | } |
494 | 494 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | function wordpoints_entities() { |
506 | 506 | |
507 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
507 | + if ( ! isset(WordPoints_App::$main)) { |
|
508 | 508 | wordpoints_apps(); |
509 | 509 | } |
510 | 510 | |
@@ -520,13 +520,13 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @param WordPoints_App $app The main apps app. |
522 | 522 | */ |
523 | -function wordpoints_apps_init( $app ) { |
|
523 | +function wordpoints_apps_init($app) { |
|
524 | 524 | |
525 | 525 | $apps = $app->sub_apps; |
526 | 526 | |
527 | - $apps->register( 'hooks', 'WordPoints_Hooks' ); |
|
528 | - $apps->register( 'entities', 'WordPoints_App_Registry' ); |
|
529 | - $apps->register( 'data_types', 'WordPoints_Class_Registry' ); |
|
527 | + $apps->register('hooks', 'WordPoints_Hooks'); |
|
528 | + $apps->register('entities', 'WordPoints_App_Registry'); |
|
529 | + $apps->register('data_types', 'WordPoints_Class_Registry'); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -539,19 +539,19 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return object|false The constructed object, or false if to many args were passed. |
541 | 541 | */ |
542 | -function wordpoints_construct_class_with_args( $class_name, array $args ) { |
|
542 | +function wordpoints_construct_class_with_args($class_name, array $args) { |
|
543 | 543 | |
544 | - switch ( count( $args ) ) { |
|
544 | + switch (count($args)) { |
|
545 | 545 | case 0: |
546 | 546 | return new $class_name(); |
547 | 547 | case 1: |
548 | - return new $class_name( $args[0] ); |
|
548 | + return new $class_name($args[0]); |
|
549 | 549 | case 2: |
550 | - return new $class_name( $args[0], $args[1] ); |
|
550 | + return new $class_name($args[0], $args[1]); |
|
551 | 551 | case 3: |
552 | - return new $class_name( $args[0], $args[1], $args[2] ); |
|
552 | + return new $class_name($args[0], $args[1], $args[2]); |
|
553 | 553 | case 4: |
554 | - return new $class_name( $args[0], $args[1], $args[2], $args[3] ); |
|
554 | + return new $class_name($args[0], $args[1], $args[2], $args[3]); |
|
555 | 555 | default: |
556 | 556 | return false; |
557 | 557 | } |