@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public static function set_up() { |
92 | 92 | |
93 | - if ( isset( self::$instance ) ) { |
|
93 | + if (isset(self::$instance)) { |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | 97 | self::$instance = new WordPoints_Components(); |
98 | 98 | |
99 | - add_action( 'plugins_loaded', array( self::$instance, 'load' ) ); |
|
99 | + add_action('plugins_loaded', array(self::$instance, 'load')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | * @since 1.0.0 |
135 | 135 | * @since 1.7.0 The components' code isn't loaded until after this hook. |
136 | 136 | */ |
137 | - do_action( 'wordpoints_components_register' ); |
|
137 | + do_action('wordpoints_components_register'); |
|
138 | 138 | |
139 | - foreach ( $this->get() as $component ) { |
|
139 | + foreach ($this->get() as $component) { |
|
140 | 140 | |
141 | - if ( ! $this->is_active( $component['slug'] ) ) { |
|
141 | + if ( ! $this->is_active($component['slug'])) { |
|
142 | 142 | continue; |
143 | 143 | } |
144 | 144 | |
145 | - include_once( $component['file'] ); |
|
145 | + include_once($component['file']); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @since 1.0.0 |
152 | 152 | */ |
153 | - do_action( 'wordpoints_components_loaded' ); |
|
153 | + do_action('wordpoints_components_loaded'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function get() { |
167 | 167 | |
168 | - if ( ! isset( $this->registered ) ) { |
|
168 | + if ( ! isset($this->registered)) { |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return array|false The component, or false if it isn't registered. |
183 | 183 | */ |
184 | - public function get_component( $slug ) { |
|
184 | + public function get_component($slug) { |
|
185 | 185 | |
186 | - if ( ! isset( $this->registered[ $slug ] ) ) { |
|
186 | + if ( ! isset($this->registered[$slug])) { |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
190 | - return $this->registered[ $slug ]; |
|
190 | + return $this->registered[$slug]; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return bool True if the component is registered, otherwise false. |
217 | 217 | */ |
218 | - public function is_registered( $slug ) { |
|
218 | + public function is_registered($slug) { |
|
219 | 219 | |
220 | - return isset( $this->registered[ $slug ] ); |
|
220 | + return isset($this->registered[$slug]); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return bool True, or false if the component's slug has already been registered. |
249 | 249 | */ |
250 | - public function register( $args ) { |
|
250 | + public function register($args) { |
|
251 | 251 | |
252 | 252 | $defaults = array( |
253 | 253 | 'slug' => '', |
@@ -261,25 +261,25 @@ discard block |
||
261 | 261 | 'un_installer' => null, |
262 | 262 | ); |
263 | 263 | |
264 | - $component = array_merge( $defaults, $args ); |
|
264 | + $component = array_merge($defaults, $args); |
|
265 | 265 | |
266 | 266 | if ( |
267 | - empty( $component['name'] ) |
|
268 | - || empty( $component['file'] ) |
|
269 | - || empty( $component['slug'] ) |
|
270 | - || $this->is_registered( $component['slug'] ) |
|
267 | + empty($component['name']) |
|
268 | + || empty($component['file']) |
|
269 | + || empty($component['slug']) |
|
270 | + || $this->is_registered($component['slug']) |
|
271 | 271 | ) { |
272 | 272 | return false; |
273 | 273 | } |
274 | 274 | |
275 | - $this->registered[ $component['slug'] ] = array_intersect_key( $component, $defaults ); |
|
275 | + $this->registered[$component['slug']] = array_intersect_key($component, $defaults); |
|
276 | 276 | |
277 | 277 | WordPoints_Installables::register( |
278 | 278 | 'component' |
279 | 279 | , $component['slug'] |
280 | 280 | , array( |
281 | - 'version' => $this->registered[ $component['slug'] ]['version'], |
|
282 | - 'un_installer' => $this->registered[ $component['slug'] ]['un_installer'], |
|
281 | + 'version' => $this->registered[$component['slug']]['version'], |
|
282 | + 'un_installer' => $this->registered[$component['slug']]['un_installer'], |
|
283 | 283 | 'network_wide' => is_wordpoints_network_active(), |
284 | 284 | ) |
285 | 285 | ); |
@@ -296,18 +296,18 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return bool True, even if the component isn't registered. |
298 | 298 | */ |
299 | - public function deregister( $slug ) { |
|
299 | + public function deregister($slug) { |
|
300 | 300 | |
301 | - if ( isset( $this->registered[ $slug ] ) ) { |
|
301 | + if (isset($this->registered[$slug])) { |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * Component being deregistered. |
305 | 305 | * |
306 | 306 | * @since 1.0.0 |
307 | 307 | */ |
308 | - do_action( "wordpoints_component_deregister-{$slug}" ); |
|
308 | + do_action("wordpoints_component_deregister-{$slug}"); |
|
309 | 309 | |
310 | - unset( $this->registered[ $slug ] ); |
|
310 | + unset($this->registered[$slug]); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return true; |
@@ -330,24 +330,24 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool Whether the component was activated. |
332 | 332 | */ |
333 | - public function activate( $slug ) { |
|
333 | + public function activate($slug) { |
|
334 | 334 | |
335 | - if ( ! $this->is_registered( $slug ) ) { |
|
335 | + if ( ! $this->is_registered($slug)) { |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // If this component isn't already active, activate it. |
340 | - if ( ! $this->is_active( $slug ) ) { |
|
340 | + if ( ! $this->is_active($slug)) { |
|
341 | 341 | |
342 | - $this->active[ $slug ] = 1; |
|
342 | + $this->active[$slug] = 1; |
|
343 | 343 | |
344 | - if ( ! wordpoints_update_maybe_network_option( 'wordpoints_active_components', $this->active ) ) { |
|
344 | + if ( ! wordpoints_update_maybe_network_option('wordpoints_active_components', $this->active)) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | - include_once( $this->registered[ $slug ]['file'] ); |
|
348 | + include_once($this->registered[$slug]['file']); |
|
349 | 349 | |
350 | - WordPoints_Installables::get_installer( 'component', $slug )->install( |
|
350 | + WordPoints_Installables::get_installer('component', $slug)->install( |
|
351 | 351 | is_wordpoints_network_active() |
352 | 352 | ); |
353 | 353 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @since 1.0.0 |
358 | 358 | */ |
359 | - do_action( "wordpoints_component_activate-{$slug}" ); |
|
359 | + do_action("wordpoints_component_activate-{$slug}"); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | return true; |
@@ -376,17 +376,17 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @return bool Whether the component was deactivated. |
378 | 378 | */ |
379 | - public function deactivate( $slug ) { |
|
379 | + public function deactivate($slug) { |
|
380 | 380 | |
381 | - if ( ! $this->is_registered( $slug ) ) { |
|
381 | + if ( ! $this->is_registered($slug)) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
385 | - if ( $this->is_active( $slug ) ) { |
|
385 | + if ($this->is_active($slug)) { |
|
386 | 386 | |
387 | - unset( $this->active[ $slug ] ); |
|
387 | + unset($this->active[$slug]); |
|
388 | 388 | |
389 | - if ( ! wordpoints_update_maybe_network_option( 'wordpoints_active_components', $this->active ) ) { |
|
389 | + if ( ! wordpoints_update_maybe_network_option('wordpoints_active_components', $this->active)) { |
|
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @since 1.0.0 |
397 | 397 | */ |
398 | - do_action( "wordpoints_component_deactivate-{$slug}" ); |
|
398 | + do_action("wordpoints_component_deactivate-{$slug}"); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | return true; |
@@ -413,11 +413,11 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return bool Whether the component is active. |
415 | 415 | */ |
416 | - public function is_active( $slug ) { |
|
416 | + public function is_active($slug) { |
|
417 | 417 | |
418 | 418 | $this->get_active(); |
419 | 419 | |
420 | - $is_active = isset( $this->active[ $slug ] ); |
|
420 | + $is_active = isset($this->active[$slug]); |
|
421 | 421 | |
422 | 422 | /** |
423 | 423 | * Is a component active? |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @param bool $is_active Whether the component is currently active. |
428 | 428 | * @param string $slug The component's slug. |
429 | 429 | */ |
430 | - return apply_filters( 'wordpoints_component_active', $is_active, $slug ); |
|
430 | + return apply_filters('wordpoints_component_active', $is_active, $slug); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @param string $slug The component's slug. |
440 | 440 | */ |
441 | - public function uninstall( $slug ) { |
|
441 | + public function uninstall($slug) { |
|
442 | 442 | |
443 | 443 | _deprecated_function( |
444 | 444 | __METHOD__ |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | , 'WordPoints_Installables::uninstall()' |
447 | 447 | ); |
448 | 448 | |
449 | - WordPoints_Installables::uninstall( 'component', $slug ); |
|
449 | + WordPoints_Installables::uninstall('component', $slug); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return WordPoints_Un_Installer_Base|false The installer for the component. |
495 | 495 | */ |
496 | - public function get_installer( $slug ) { |
|
496 | + public function get_installer($slug) { |
|
497 | 497 | |
498 | 498 | _deprecated_function( |
499 | 499 | __METHOD__ |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | , 'WordPoints_Installables::get_installer()' |
502 | 502 | ); |
503 | 503 | |
504 | - return WordPoints_Installables::get_installer( 'component', $slug ); |
|
504 | + return WordPoints_Installables::get_installer('component', $slug); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 |
@@ -57,25 +57,25 @@ discard block |
||
57 | 57 | WordPoints_Hook_Event_Args $event_args |
58 | 58 | ) { |
59 | 59 | |
60 | - if ( ! isset( $settings[ $this->slug ] ) ) { |
|
60 | + if ( ! isset($settings[$this->slug])) { |
|
61 | 61 | return $settings; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $this->validator = $validator; |
65 | 65 | $this->event_args = $event_args; |
66 | 66 | |
67 | - $this->validator->push_field( $this->slug ); |
|
67 | + $this->validator->push_field($this->slug); |
|
68 | 68 | |
69 | 69 | $validated_settings = $this->validate_extension_settings( |
70 | - $settings[ $this->slug ] |
|
70 | + $settings[$this->slug] |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | $this->validator->pop_field(); |
74 | 74 | |
75 | - if ( null !== $validated_settings ) { |
|
76 | - $settings[ $this->slug ] = $validated_settings; |
|
75 | + if (null !== $validated_settings) { |
|
76 | + $settings[$this->slug] = $validated_settings; |
|
77 | 77 | } else { |
78 | - unset( $settings[ $this->slug ] ); |
|
78 | + unset($settings[$this->slug]); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | return $settings; |
@@ -95,27 +95,27 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return mixed The validated settings, or null if invalid. |
97 | 97 | */ |
98 | - protected function validate_extension_settings( $settings ) { |
|
98 | + protected function validate_extension_settings($settings) { |
|
99 | 99 | |
100 | - if ( ! is_array( $settings ) ) { |
|
100 | + if ( ! is_array($settings)) { |
|
101 | 101 | |
102 | - $this->validator->add_error( __( 'Invalid settings format.', 'wordpoints' ) ); |
|
102 | + $this->validator->add_error(__('Invalid settings format.', 'wordpoints')); |
|
103 | 103 | |
104 | 104 | return null; |
105 | 105 | } |
106 | 106 | |
107 | - foreach ( $settings as $action_type => $action_type_settings ) { |
|
107 | + foreach ($settings as $action_type => $action_type_settings) { |
|
108 | 108 | |
109 | - $this->validator->push_field( $action_type ); |
|
109 | + $this->validator->push_field($action_type); |
|
110 | 110 | |
111 | 111 | $validated_settings = $this->validate_action_type_settings( |
112 | 112 | $action_type_settings |
113 | 113 | ); |
114 | 114 | |
115 | - if ( null !== $validated_settings ) { |
|
116 | - $settings[ $action_type ] = $validated_settings; |
|
115 | + if (null !== $validated_settings) { |
|
116 | + $settings[$action_type] = $validated_settings; |
|
117 | 117 | } else { |
118 | - unset( $settings[ $action_type ] ); |
|
118 | + unset($settings[$action_type]); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $this->validator->pop_field(); |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * @since 2.1.0 |
129 | 129 | */ |
130 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
130 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
131 | 131 | |
132 | - if ( isset( $settings[ $this->slug ] ) ) { |
|
133 | - $reaction->update_meta( $this->slug, $settings[ $this->slug ] ); |
|
132 | + if (isset($settings[$this->slug])) { |
|
133 | + $reaction->update_meta($this->slug, $settings[$this->slug]); |
|
134 | 134 | } else { |
135 | - $reaction->delete_meta( $this->slug ); |
|
135 | + $reaction->delete_meta($this->slug); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return mixed The validated settings, or null if invalid. |
149 | 149 | */ |
150 | - protected function validate_action_type_settings( $settings ) { |
|
150 | + protected function validate_action_type_settings($settings) { |
|
151 | 151 | return $settings; |
152 | 152 | } |
153 | 153 | |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return mixed The settings for the extension, or false if none. |
166 | 166 | */ |
167 | - protected function get_settings_from_fire( WordPoints_Hook_Fire $fire ) { |
|
167 | + protected function get_settings_from_fire(WordPoints_Hook_Fire $fire) { |
|
168 | 168 | |
169 | - $settings = $fire->reaction->get_meta( $this->slug ); |
|
169 | + $settings = $fire->reaction->get_meta($this->slug); |
|
170 | 170 | |
171 | - if ( ! is_array( $settings ) ) { |
|
171 | + if ( ! is_array($settings)) { |
|
172 | 172 | return $settings; |
173 | 173 | } |
174 | 174 | |
175 | - if ( isset( $settings[ $fire->action_type ] ) ) { |
|
176 | - return $settings[ $fire->action_type ]; |
|
175 | + if (isset($settings[$fire->action_type])) { |
|
176 | + return $settings[$fire->action_type]; |
|
177 | 177 | } else { |
178 | 178 | return false; |
179 | 179 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @since 2.1.0 |
35 | 35 | */ |
36 | 36 | public function __construct() { |
37 | - $this->conditions = wordpoints_hooks()->get_sub_app( 'conditions' ); |
|
37 | + $this->conditions = wordpoints_hooks()->get_sub_app('conditions'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | |
45 | 45 | $conditions_data = array(); |
46 | 46 | |
47 | - foreach ( $this->conditions->get_all() as $data_type => $conditions ) { |
|
48 | - foreach ( $conditions as $slug => $condition ) { |
|
47 | + foreach ($this->conditions->get_all() as $data_type => $conditions) { |
|
48 | + foreach ($conditions as $slug => $condition) { |
|
49 | 49 | |
50 | - if ( ! ( $condition instanceof WordPoints_Hook_ConditionI ) ) { |
|
50 | + if ( ! ($condition instanceof WordPoints_Hook_ConditionI)) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
54 | - $conditions_data[ $data_type ][ $slug ] = array( |
|
54 | + $conditions_data[$data_type][$slug] = array( |
|
55 | 55 | 'slug' => $slug, |
56 | 56 | 'data_type' => $data_type, |
57 | 57 | 'title' => $condition->get_title(), |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - return array( 'conditions' => $conditions_data ); |
|
63 | + return array('conditions' => $conditions_data); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @since 2.1.0 |
68 | 68 | */ |
69 | - protected function validate_action_type_settings( $settings ) { |
|
70 | - return $this->validate_conditions( $settings ); |
|
69 | + protected function validate_action_type_settings($settings) { |
|
70 | + return $this->validate_conditions($settings); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -80,36 +80,36 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return array The validated settings. |
82 | 82 | */ |
83 | - public function validate_conditions( $conditions, WordPoints_Hook_Event_Args $event_args = null ) { |
|
83 | + public function validate_conditions($conditions, WordPoints_Hook_Event_Args $event_args = null) { |
|
84 | 84 | |
85 | - if ( $event_args ) { |
|
85 | + if ($event_args) { |
|
86 | 86 | $this->event_args = $event_args; |
87 | 87 | $this->validator = $event_args->get_validator(); |
88 | 88 | } |
89 | 89 | |
90 | - if ( ! is_array( $conditions ) ) { |
|
90 | + if ( ! is_array($conditions)) { |
|
91 | 91 | |
92 | 92 | $this->validator->add_error( |
93 | - __( 'Conditions do not match expected format.', 'wordpoints' ) |
|
93 | + __('Conditions do not match expected format.', 'wordpoints') |
|
94 | 94 | ); |
95 | 95 | |
96 | 96 | return array(); |
97 | 97 | } |
98 | 98 | |
99 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
99 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
100 | 100 | |
101 | - if ( '_conditions' === $arg_slug ) { |
|
101 | + if ('_conditions' === $arg_slug) { |
|
102 | 102 | |
103 | - $this->validator->push_field( $arg_slug ); |
|
103 | + $this->validator->push_field($arg_slug); |
|
104 | 104 | |
105 | - foreach ( $sub_args as $index => $settings ) { |
|
105 | + foreach ($sub_args as $index => $settings) { |
|
106 | 106 | |
107 | - $this->validator->push_field( $index ); |
|
107 | + $this->validator->push_field($index); |
|
108 | 108 | |
109 | - $condition = $this->validate_condition( $settings ); |
|
109 | + $condition = $this->validate_condition($settings); |
|
110 | 110 | |
111 | - if ( $condition ) { |
|
112 | - $sub_args[ $index ] = $condition; |
|
111 | + if ($condition) { |
|
112 | + $sub_args[$index] = $condition; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $this->validator->pop_field(); |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | |
120 | 120 | } else { |
121 | 121 | |
122 | - if ( ! $this->event_args->descend( $arg_slug ) ) { |
|
122 | + if ( ! $this->event_args->descend($arg_slug)) { |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
126 | - $sub_args = $this->validate_action_type_settings( $sub_args ); |
|
126 | + $sub_args = $this->validate_action_type_settings($sub_args); |
|
127 | 127 | |
128 | - $conditions[ $arg_slug ] = $sub_args; |
|
128 | + $conditions[$arg_slug] = $sub_args; |
|
129 | 129 | |
130 | 130 | $this->event_args->ascend(); |
131 | 131 | } |
132 | 132 | |
133 | - $conditions[ $arg_slug ] = $sub_args; |
|
133 | + $conditions[$arg_slug] = $sub_args; |
|
134 | 134 | |
135 | 135 | } // End foreach ( $conditions ). |
136 | 136 | |
@@ -147,33 +147,33 @@ discard block |
||
147 | 147 | * @return array|false The validated conditions settings, or false if unable to |
148 | 148 | * validate. |
149 | 149 | */ |
150 | - protected function validate_condition( $settings ) { |
|
150 | + protected function validate_condition($settings) { |
|
151 | 151 | |
152 | - if ( ! isset( $settings['type'] ) ) { |
|
153 | - $this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) ); |
|
152 | + if ( ! isset($settings['type'])) { |
|
153 | + $this->validator->add_error(__('Condition type is missing.', 'wordpoints')); |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 | |
157 | 157 | $arg = $this->event_args->get_current(); |
158 | 158 | |
159 | - $data_type = $this->get_data_type( $arg ); |
|
159 | + $data_type = $this->get_data_type($arg); |
|
160 | 160 | |
161 | - if ( ! $data_type ) { |
|
161 | + if ( ! $data_type) { |
|
162 | 162 | $this->validator->add_error( |
163 | - __( 'This type of condition does not work for the selected attribute.', 'wordpoints' ) |
|
163 | + __('This type of condition does not work for the selected attribute.', 'wordpoints') |
|
164 | 164 | ); |
165 | 165 | |
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - $condition = $this->conditions->get( $data_type, $settings['type'] ); |
|
169 | + $condition = $this->conditions->get($data_type, $settings['type']); |
|
170 | 170 | |
171 | - if ( ! $condition ) { |
|
171 | + if ( ! $condition) { |
|
172 | 172 | |
173 | 173 | $this->validator->add_error( |
174 | 174 | sprintf( |
175 | 175 | // translators: Condition type slug. |
176 | - __( 'Unknown condition type “%s”.', 'wordpoints' ) |
|
176 | + __('Unknown condition type “%s”.', 'wordpoints') |
|
177 | 177 | , $settings['type'] |
178 | 178 | ) |
179 | 179 | , 'type' |
@@ -182,17 +182,17 @@ discard block |
||
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
185 | - if ( ! isset( $settings['settings'] ) ) { |
|
186 | - $this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) ); |
|
185 | + if ( ! isset($settings['settings'])) { |
|
186 | + $this->validator->add_error(__('Condition settings are missing.', 'wordpoints')); |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
190 | - $this->validator->push_field( 'settings' ); |
|
190 | + $this->validator->push_field('settings'); |
|
191 | 191 | |
192 | 192 | // The condition may call this object's validate_settings() method to |
193 | 193 | // validate some sub-conditions. When that happens, these properties will be |
194 | 194 | // reset, so we need to back up their values and then restore them below. |
195 | - $backup = array( $this->validator, $this->event_args ); |
|
195 | + $backup = array($this->validator, $this->event_args); |
|
196 | 196 | |
197 | 197 | $settings['settings'] = $condition->validate_settings( |
198 | 198 | $arg |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | , $this->validator |
201 | 201 | ); |
202 | 202 | |
203 | - list( $this->validator, $this->event_args ) = $backup; |
|
203 | + list($this->validator, $this->event_args) = $backup; |
|
204 | 204 | |
205 | 205 | $this->validator->pop_field(); |
206 | 206 | |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @since 2.1.0 |
212 | 212 | */ |
213 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
213 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
214 | 214 | |
215 | - $conditions = $this->get_settings_from_fire( $fire ); |
|
215 | + $conditions = $this->get_settings_from_fire($fire); |
|
216 | 216 | |
217 | - if ( $conditions && ! $this->conditions_are_met( $conditions, $fire->event_args ) ) { |
|
217 | + if ($conditions && ! $this->conditions_are_met($conditions, $fire->event_args)) { |
|
218 | 218 | return false; |
219 | 219 | } |
220 | 220 | |
@@ -236,35 +236,35 @@ discard block |
||
236 | 236 | WordPoints_Hook_Event_Args $event_args |
237 | 237 | ) { |
238 | 238 | |
239 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
239 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
240 | 240 | |
241 | - $event_args->descend( $arg_slug ); |
|
241 | + $event_args->descend($arg_slug); |
|
242 | 242 | |
243 | - if ( isset( $sub_args['_conditions'] ) ) { |
|
243 | + if (isset($sub_args['_conditions'])) { |
|
244 | 244 | |
245 | - foreach ( $sub_args['_conditions'] as $settings ) { |
|
245 | + foreach ($sub_args['_conditions'] as $settings) { |
|
246 | 246 | |
247 | 247 | $condition = $this->conditions->get( |
248 | - $this->get_data_type( $event_args->get_current() ) |
|
248 | + $this->get_data_type($event_args->get_current()) |
|
249 | 249 | , $settings['type'] |
250 | 250 | ); |
251 | 251 | |
252 | - $is_met = $condition->is_met( $settings['settings'], $event_args ); |
|
252 | + $is_met = $condition->is_met($settings['settings'], $event_args); |
|
253 | 253 | |
254 | - if ( ! $is_met ) { |
|
254 | + if ( ! $is_met) { |
|
255 | 255 | $event_args->ascend(); |
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - unset( $sub_args['_conditions'] ); |
|
260 | + unset($sub_args['_conditions']); |
|
261 | 261 | } |
262 | 262 | |
263 | - $are_met = $this->conditions_are_met( $sub_args, $event_args ); |
|
263 | + $are_met = $this->conditions_are_met($sub_args, $event_args); |
|
264 | 264 | |
265 | 265 | $event_args->ascend(); |
266 | 266 | |
267 | - if ( ! $are_met ) { |
|
267 | + if ( ! $are_met) { |
|
268 | 268 | return false; |
269 | 269 | } |
270 | 270 | } |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string|false The data type, or false. |
283 | 283 | */ |
284 | - protected function get_data_type( $arg ) { |
|
284 | + protected function get_data_type($arg) { |
|
285 | 285 | |
286 | - if ( $arg instanceof WordPoints_Entity_Attr ) { |
|
286 | + if ($arg instanceof WordPoints_Entity_Attr) { |
|
287 | 287 | $data_type = $arg->get_data_type(); |
288 | - } elseif ( $arg instanceof WordPoints_Entity_Array ) { |
|
288 | + } elseif ($arg instanceof WordPoints_Entity_Array) { |
|
289 | 289 | $data_type = 'entity_array'; |
290 | - } elseif ( $arg instanceof WordPoints_Entity ) { |
|
290 | + } elseif ($arg instanceof WordPoints_Entity) { |
|
291 | 291 | $data_type = 'entity'; |
292 | 292 | } else { |
293 | 293 | $data_type = false; |
@@ -73,30 +73,30 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param WordPoints_Hook_ArgI[] $args The hook args. |
75 | 75 | */ |
76 | - public function __construct( array $args ) { |
|
76 | + public function __construct(array $args) { |
|
77 | 77 | |
78 | 78 | parent::__construct(); |
79 | 79 | |
80 | - foreach ( $args as $arg ) { |
|
80 | + foreach ($args as $arg) { |
|
81 | 81 | |
82 | 82 | $entity = $arg->get_entity(); |
83 | 83 | $slug = $arg->get_slug(); |
84 | 84 | |
85 | - if ( ! $entity instanceof WordPoints_Entity ) { |
|
85 | + if ( ! $entity instanceof WordPoints_Entity) { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | |
89 | - $this->entities[ $slug ] = $entity; |
|
89 | + $this->entities[$slug] = $entity; |
|
90 | 90 | |
91 | - if ( ! $arg->is_stateful() ) { |
|
91 | + if ( ! $arg->is_stateful()) { |
|
92 | 92 | |
93 | 93 | // If any of the args aren't stateful the event isn't repeatable. |
94 | 94 | $this->is_repeatable = false; |
95 | 95 | |
96 | - $this->signature_args[ $slug ] = $entity; |
|
96 | + $this->signature_args[$slug] = $entity; |
|
97 | 97 | |
98 | 98 | // Back-compat. Some events have multiple "primary" args. |
99 | - if ( ! $this->primary_arg_slug ) { |
|
99 | + if ( ! $this->primary_arg_slug) { |
|
100 | 100 | $this->primary_arg_slug = $slug; |
101 | 101 | } |
102 | 102 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function get_signature_args() { |
134 | 134 | |
135 | - if ( ! $this->signature_args ) { |
|
135 | + if ( ! $this->signature_args) { |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | , __CLASS__ . '::get_signature_args()' |
157 | 157 | ); |
158 | 158 | |
159 | - if ( ! $this->primary_arg_slug ) { |
|
159 | + if ( ! $this->primary_arg_slug) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | - return $this->entities[ $this->primary_arg_slug ]; |
|
163 | + return $this->entities[$this->primary_arg_slug]; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function get_stateful_args() { |
174 | 174 | |
175 | - return array_diff_key( $this->entities, $this->signature_args ); |
|
175 | + return array_diff_key($this->entities, $this->signature_args); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -193,53 +193,53 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param WordPoints_Hook_Reaction_Validator $validator The validator. |
195 | 195 | */ |
196 | - public function set_validator( WordPoints_Hook_Reaction_Validator $validator ) { |
|
196 | + public function set_validator(WordPoints_Hook_Reaction_Validator $validator) { |
|
197 | 197 | $this->validator = $validator; |
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
201 | 201 | * @since 2.1.0 |
202 | 202 | */ |
203 | - public function descend( $child_slug ) { |
|
203 | + public function descend($child_slug) { |
|
204 | 204 | |
205 | - $result = parent::descend( $child_slug ); |
|
205 | + $result = parent::descend($child_slug); |
|
206 | 206 | |
207 | 207 | // Just in case no validator has been set. |
208 | - if ( ! $this->validator ) { |
|
208 | + if ( ! $this->validator) { |
|
209 | 209 | return $result; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! $result ) { |
|
212 | + if ( ! $result) { |
|
213 | 213 | |
214 | - if ( ! isset( $this->current ) ) { |
|
214 | + if ( ! isset($this->current)) { |
|
215 | 215 | |
216 | 216 | $this->validator->add_error( |
217 | 217 | sprintf( |
218 | 218 | // translators: Arg slug. |
219 | - __( 'The “%s” arg is not registered for this event.', 'wordpoints' ) |
|
219 | + __('The “%s” arg is not registered for this event.', 'wordpoints') |
|
220 | 220 | , $child_slug |
221 | 221 | ) |
222 | 222 | ); |
223 | 223 | |
224 | - } elseif ( ! ( $this->current instanceof WordPoints_Entity_ParentI ) ) { |
|
224 | + } elseif ( ! ($this->current instanceof WordPoints_Entity_ParentI)) { |
|
225 | 225 | |
226 | 226 | $this->validator->add_error( |
227 | 227 | sprintf( |
228 | 228 | // translators: Arg name. |
229 | - __( 'Cannot get descendant of %s: not a parent.', 'wordpoints' ) |
|
229 | + __('Cannot get descendant of %s: not a parent.', 'wordpoints') |
|
230 | 230 | , $this->current->get_title() |
231 | 231 | ) |
232 | 232 | ); |
233 | 233 | |
234 | 234 | } else { |
235 | 235 | |
236 | - $child_arg = $this->current->get_child( $child_slug ); |
|
236 | + $child_arg = $this->current->get_child($child_slug); |
|
237 | 237 | |
238 | - if ( ! $child_arg ) { |
|
238 | + if ( ! $child_arg) { |
|
239 | 239 | $this->validator->add_error( |
240 | 240 | sprintf( |
241 | 241 | // translators: 1. Arg slug; 2. Other arg slug. |
242 | - __( '%1$s does not have a child “%2$s”.', 'wordpoints' ) |
|
242 | + __('%1$s does not have a child “%2$s”.', 'wordpoints') |
|
243 | 243 | , $this->current->get_slug() |
244 | 244 | , $child_slug |
245 | 245 | ) |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | |
250 | 250 | } // End if ( no current ) elseif ( current not parent ) else {}. |
251 | 251 | |
252 | - } elseif ( $this->push_on_descend ) { |
|
252 | + } elseif ($this->push_on_descend) { |
|
253 | 253 | |
254 | - $this->validator->push_field( $child_slug ); |
|
254 | + $this->validator->push_field($child_slug); |
|
255 | 255 | |
256 | 256 | } // End if ( ! $result ) elseif ( $this->push_on_descend ). |
257 | 257 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | $ascended = parent::ascend(); |
267 | 267 | |
268 | - if ( $ascended && $this->validator ) { |
|
268 | + if ($ascended && $this->validator) { |
|
269 | 269 | $this->validator->pop_field(); |
270 | 270 | } |
271 | 271 | |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | /** |
276 | 276 | * @since 2.1.0 |
277 | 277 | */ |
278 | - public function get_from_hierarchy( array $hierarchy ) { |
|
278 | + public function get_from_hierarchy(array $hierarchy) { |
|
279 | 279 | |
280 | 280 | $this->push_on_descend = false; |
281 | - $entityish = parent::get_from_hierarchy( $hierarchy ); |
|
281 | + $entityish = parent::get_from_hierarchy($hierarchy); |
|
282 | 282 | $this->push_on_descend = true; |
283 | 283 | |
284 | 284 | return $entityish; |
@@ -26,20 +26,20 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function get_title() { |
28 | 28 | |
29 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
29 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
30 | 30 | |
31 | - switch ( $parsed['dynamic'] ) { |
|
31 | + switch ($parsed['dynamic']) { |
|
32 | 32 | |
33 | 33 | case 'post': |
34 | - return __( 'Publish Post', 'wordpoints' ); |
|
34 | + return __('Publish Post', 'wordpoints'); |
|
35 | 35 | |
36 | 36 | case 'page': |
37 | - return __( 'Publish Page', 'wordpoints' ); |
|
37 | + return __('Publish Page', 'wordpoints'); |
|
38 | 38 | |
39 | 39 | default: |
40 | 40 | return sprintf( |
41 | 41 | // translators: Singular post type name. |
42 | - __( 'Publish %s', 'wordpoints' ) |
|
42 | + __('Publish %s', 'wordpoints') |
|
43 | 43 | , $this->get_entity_title() |
44 | 44 | ); |
45 | 45 | } |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function get_description() { |
52 | 52 | |
53 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
53 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
54 | 54 | |
55 | - switch ( $parsed['dynamic'] ) { |
|
55 | + switch ($parsed['dynamic']) { |
|
56 | 56 | |
57 | 57 | case 'post': |
58 | - return __( 'When a Post is published.', 'wordpoints' ); |
|
58 | + return __('When a Post is published.', 'wordpoints'); |
|
59 | 59 | |
60 | 60 | case 'page': |
61 | - return __( 'When a Page is published.', 'wordpoints' ); |
|
61 | + return __('When a Page is published.', 'wordpoints'); |
|
62 | 62 | |
63 | 63 | default: |
64 | 64 | return sprintf( |
65 | 65 | // translators: Singular post type name. |
66 | - __( 'When a %s is published.', 'wordpoints' ) |
|
66 | + __('When a %s is published.', 'wordpoints') |
|
67 | 67 | , $this->get_entity_title() |
68 | 68 | ); |
69 | 69 | } |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function get_reversal_text() { |
76 | 76 | |
77 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
77 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
78 | 78 | |
79 | - switch ( $parsed['dynamic'] ) { |
|
79 | + switch ($parsed['dynamic']) { |
|
80 | 80 | |
81 | 81 | case 'post': |
82 | - return __( 'Post removed.', 'wordpoints' ); |
|
82 | + return __('Post removed.', 'wordpoints'); |
|
83 | 83 | |
84 | 84 | case 'page': |
85 | - return __( 'Page removed.', 'wordpoints' ); |
|
85 | + return __('Page removed.', 'wordpoints'); |
|
86 | 86 | |
87 | 87 | default: |
88 | 88 | return sprintf( |
89 | 89 | // translators: Singular post type name. |
90 | - _x( '%s removed.', 'post type', 'wordpoints' ) |
|
90 | + _x('%s removed.', 'post type', 'wordpoints') |
|
91 | 91 | , $this->get_entity_title() |
92 | 92 | ); |
93 | 93 | } |
@@ -26,23 +26,23 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function get_title() { |
28 | 28 | |
29 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
29 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
30 | 30 | |
31 | - switch ( $parsed['dynamic'] ) { |
|
31 | + switch ($parsed['dynamic']) { |
|
32 | 32 | |
33 | 33 | case 'post': |
34 | - return __( 'Comment on a Post', 'wordpoints' ); |
|
34 | + return __('Comment on a Post', 'wordpoints'); |
|
35 | 35 | |
36 | 36 | case 'page': |
37 | - return __( 'Comment on a Page', 'wordpoints' ); |
|
37 | + return __('Comment on a Page', 'wordpoints'); |
|
38 | 38 | |
39 | 39 | case 'attachment': |
40 | - return __( 'Comment on a Media Upload', 'wordpoints' ); |
|
40 | + return __('Comment on a Media Upload', 'wordpoints'); |
|
41 | 41 | |
42 | 42 | default: |
43 | 43 | return sprintf( |
44 | 44 | // translators: Singular post type name. |
45 | - __( 'Comment on a %s', 'wordpoints' ) |
|
45 | + __('Comment on a %s', 'wordpoints') |
|
46 | 46 | , $this->get_entity_title() |
47 | 47 | ); |
48 | 48 | } |
@@ -53,23 +53,23 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function get_description() { |
55 | 55 | |
56 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
56 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
57 | 57 | |
58 | - switch ( $parsed['dynamic'] ) { |
|
58 | + switch ($parsed['dynamic']) { |
|
59 | 59 | |
60 | 60 | case 'post': |
61 | - return __( 'When a user leaves a comment on a Post.', 'wordpoints' ); |
|
61 | + return __('When a user leaves a comment on a Post.', 'wordpoints'); |
|
62 | 62 | |
63 | 63 | case 'page': |
64 | - return __( 'When a user leaves a comment on a Page.', 'wordpoints' ); |
|
64 | + return __('When a user leaves a comment on a Page.', 'wordpoints'); |
|
65 | 65 | |
66 | 66 | case 'attachment': |
67 | - return __( 'When a user leaves a comment on a file uploaded to the Media Library.', 'wordpoints' ); |
|
67 | + return __('When a user leaves a comment on a file uploaded to the Media Library.', 'wordpoints'); |
|
68 | 68 | |
69 | 69 | default: |
70 | 70 | return sprintf( |
71 | 71 | // translators: Singular post type name. |
72 | - __( 'When a user leaves a comment on a %s.', 'wordpoints' ) |
|
72 | + __('When a user leaves a comment on a %s.', 'wordpoints') |
|
73 | 73 | , $this->get_entity_title() |
74 | 74 | ); |
75 | 75 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @since 2.1.0 |
80 | 80 | */ |
81 | 81 | public function get_reversal_text() { |
82 | - return __( 'Comment removed.', 'wordpoints' ); |
|
82 | + return __('Comment removed.', 'wordpoints'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 |
@@ -23,34 +23,34 @@ discard block |
||
23 | 23 | WordPoints_Hook_Reaction_Validator $validator |
24 | 24 | ) { |
25 | 25 | |
26 | - if ( ! isset( $settings['value'] ) || '' === $settings['value'] ) { |
|
26 | + if ( ! isset($settings['value']) || '' === $settings['value']) { |
|
27 | 27 | |
28 | 28 | $settings_fields = $this->get_settings_fields(); |
29 | 29 | |
30 | 30 | $validator->add_error( |
31 | 31 | sprintf( |
32 | 32 | // translators: Form field name. |
33 | - __( '%s is required.', 'wordpoints' ) |
|
33 | + __('%s is required.', 'wordpoints') |
|
34 | 34 | , $settings_fields['value']['label'] |
35 | 35 | ) |
36 | 36 | , 'value' |
37 | 37 | ); |
38 | 38 | |
39 | - } elseif ( $arg instanceof WordPoints_Entity_Attr ) { |
|
39 | + } elseif ($arg instanceof WordPoints_Entity_Attr) { |
|
40 | 40 | |
41 | - $data_types = wordpoints_apps()->get_sub_app( 'data_types' ); |
|
41 | + $data_types = wordpoints_apps()->get_sub_app('data_types'); |
|
42 | 42 | |
43 | - $data_type = $data_types->get( $arg->get_data_type() ); |
|
43 | + $data_type = $data_types->get($arg->get_data_type()); |
|
44 | 44 | |
45 | 45 | // If this data type isn't recognized, that's probably OK. Validation is |
46 | 46 | // just to help the user know that they've made a mistake anyway. |
47 | - if ( ! ( $data_type instanceof WordPoints_Data_TypeI ) ) { |
|
47 | + if ( ! ($data_type instanceof WordPoints_Data_TypeI)) { |
|
48 | 48 | return $settings; |
49 | 49 | } |
50 | 50 | |
51 | - $validated_value = $data_type->validate_value( $settings['value'] ); |
|
51 | + $validated_value = $data_type->validate_value($settings['value']); |
|
52 | 52 | |
53 | - if ( is_wp_error( $validated_value ) ) { |
|
53 | + if (is_wp_error($validated_value)) { |
|
54 | 54 | |
55 | 55 | $settings_fields = $this->get_settings_fields(); |
56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | |
68 | 68 | $settings['value'] = $validated_value; |
69 | 69 | |
70 | - } elseif ( $arg instanceof WordPoints_Entity ) { |
|
70 | + } elseif ($arg instanceof WordPoints_Entity) { |
|
71 | 71 | |
72 | - if ( ! $arg->exists( $settings['value'] ) ) { |
|
72 | + if ( ! $arg->exists($settings['value'])) { |
|
73 | 73 | $validator->add_error( |
74 | 74 | sprintf( |
75 | 75 | // translators: 1. Singular item type name; 2. Item ID/slug. |
76 | - __( '%1$s “%2$s” not found.', 'wordpoints' ) |
|
76 | + __('%1$s “%2$s” not found.', 'wordpoints') |
|
77 | 77 | , $arg->get_title() |
78 | 78 | , $settings['value'] |
79 | 79 | ) |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * @param WP_Error|string $message The error message to display. |
53 | 53 | * @param array $args Arguments for widget display. |
54 | 54 | */ |
55 | - public function wordpoints_widget_error( $message, $args ) { |
|
55 | + public function wordpoints_widget_error($message, $args) { |
|
56 | 56 | |
57 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
57 | + if ( ! current_user_can('edit_theme_options')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - if ( is_wp_error( $message ) ) { |
|
61 | + if (is_wp_error($message)) { |
|
62 | 62 | $message = $message->get_error_message(); |
63 | 63 | } |
64 | 64 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | echo wp_kses( |
74 | 74 | sprintf( |
75 | 75 | // translators: 1. Widget name; 2. Error message. |
76 | - esc_html__( 'The “%1$s” widget could not be displayed because of an error: %2$s', 'wordpoints' ) |
|
77 | - , esc_html( $this->name ) |
|
76 | + esc_html__('The “%1$s” widget could not be displayed because of an error: %2$s', 'wordpoints') |
|
77 | + , esc_html($this->name) |
|
78 | 78 | , $message |
79 | 79 | ) |
80 | 80 | , 'wordpoints_widget_error' |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return array|WP_Error The verified settings. |
106 | 106 | */ |
107 | - protected function verify_settings( $instance ) { |
|
107 | + protected function verify_settings($instance) { |
|
108 | 108 | |
109 | - if ( ! isset( $instance['title'] ) ) { |
|
109 | + if ( ! isset($instance['title'])) { |
|
110 | 110 | $instance['title'] = ''; |
111 | 111 | } |
112 | 112 | |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | * @param array $args Arguments for widget display. |
122 | 122 | * @param array $instance The settings for this widget instance. |
123 | 123 | */ |
124 | - public function widget( $args, $instance ) { |
|
124 | + public function widget($args, $instance) { |
|
125 | 125 | |
126 | - $instance = $this->verify_settings( $instance ); |
|
126 | + $instance = $this->verify_settings($instance); |
|
127 | 127 | |
128 | - if ( is_wp_error( $instance ) ) { |
|
129 | - $this->wordpoints_widget_error( $instance, $args ); |
|
128 | + if (is_wp_error($instance)) { |
|
129 | + $this->wordpoints_widget_error($instance, $args); |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @param string $title The widget title. |
141 | 141 | */ |
142 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
142 | + $title = apply_filters('widget_title', $instance['title']); |
|
143 | 143 | |
144 | - if ( ! empty( $title ) ) { |
|
144 | + if ( ! empty($title)) { |
|
145 | 145 | |
146 | 146 | echo $args['before_title'] . $title . $args['after_title']; // XSS OK, WPCS. |
147 | 147 | } |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param array $instance The settings for this widget instance. |
157 | 157 | */ |
158 | - do_action( "wordpoints_{$widget_slug}_widget_before", $instance ); |
|
158 | + do_action("wordpoints_{$widget_slug}_widget_before", $instance); |
|
159 | 159 | |
160 | - $this->widget_body( $instance ); |
|
160 | + $this->widget_body($instance); |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * After a WordPoints widget. |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param array $instance The settings for this widget instance. |
168 | 168 | */ |
169 | - do_action( "wordpoints_{$widget_slug}_widget_after", $instance ); |
|
169 | + do_action("wordpoints_{$widget_slug}_widget_after", $instance); |
|
170 | 170 | |
171 | 171 | echo $args['after_widget']; // XSS OK here too, WPCS. |
172 | 172 | } |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @param array $instance The settings of the widget instance to display. |
188 | 188 | */ |
189 | - protected function widget_body( $instance ) {} |
|
189 | + protected function widget_body($instance) {} |
|
190 | 190 | |
191 | 191 | /** |
192 | 192 | * @since 2.0.0 |
193 | 193 | */ |
194 | - public function update( $new_instance, $old_instance ) { |
|
194 | + public function update($new_instance, $old_instance) { |
|
195 | 195 | |
196 | - $this->instance = array_merge( $this->defaults, $old_instance, $new_instance ); |
|
196 | + $this->instance = array_merge($this->defaults, $old_instance, $new_instance); |
|
197 | 197 | |
198 | 198 | $this->update_title(); |
199 | 199 | |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | * @since 2.0.0 |
207 | 207 | */ |
208 | 208 | public function update_title() { |
209 | - $this->instance['title'] = strip_tags( $this->instance['title'] ); |
|
209 | + $this->instance['title'] = strip_tags($this->instance['title']); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | 213 | * @since 2.0.0 |
214 | 214 | */ |
215 | - public function form( $instance ) { |
|
215 | + public function form($instance) { |
|
216 | 216 | |
217 | - $this->instance = array_merge( $this->defaults, $instance ); |
|
217 | + $this->instance = array_merge($this->defaults, $instance); |
|
218 | 218 | |
219 | 219 | $this->form_title_field(); |
220 | 220 | |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | ?> |
232 | 232 | |
233 | 233 | <p> |
234 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php echo esc_html_x( 'Title', 'form label', 'wordpoints' ); ?></label> |
|
235 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $this->instance['title'] ); ?>" /> |
|
234 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php echo esc_html_x('Title', 'form label', 'wordpoints'); ?></label> |
|
235 | + <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" value="<?php echo esc_attr($this->instance['title']); ?>" /> |
|
236 | 236 | </p> |
237 | 237 | |
238 | 238 | <?php |
@@ -20,13 +20,13 @@ |
||
20 | 20 | /** |
21 | 21 | * @since 2.1.0 |
22 | 22 | */ |
23 | - public function validate_value( $value ) { |
|
23 | + public function validate_value($value) { |
|
24 | 24 | |
25 | - if ( ! is_string( $value ) ) { |
|
25 | + if ( ! is_string($value)) { |
|
26 | 26 | return new WP_Error( |
27 | 27 | 'not_string' |
28 | 28 | // translators: Form field name. |
29 | - , __( '%s must be a text value.', 'wordpoints' ) |
|
29 | + , __('%s must be a text value.', 'wordpoints') |
|
30 | 30 | ); |
31 | 31 | } |
32 | 32 |