@@ -190,7 +190,7 @@ |
||
190 | 190 | * |
191 | 191 | * @param string $event_slug The slug of the event this reaction is for. |
192 | 192 | * |
193 | - * @return int|false The reaction ID, or false if not created. |
|
193 | + * @return integer The reaction ID, or false if not created. |
|
194 | 194 | */ |
195 | 195 | abstract protected function _create_reaction( $event_slug ); |
196 | 196 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param string $slug The slug of this store. |
64 | 64 | * @param string $mode_slug The slug of the mode this store relates to. |
65 | 65 | */ |
66 | - public function __construct( $slug, $mode_slug ) { |
|
66 | + public function __construct($slug, $mode_slug) { |
|
67 | 67 | $this->slug = $slug; |
68 | 68 | $this->mode_slug = $mode_slug; |
69 | 69 | } |
@@ -86,33 +86,33 @@ discard block |
||
86 | 86 | * @since 2.1.0 |
87 | 87 | */ |
88 | 88 | public function get_context_id() { |
89 | - return wordpoints_entities_get_current_context_id( $this->context ); |
|
89 | + return wordpoints_entities_get_current_context_id($this->context); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @since 2.1.0 |
94 | 94 | */ |
95 | - public function get_reaction( $id ) { |
|
95 | + public function get_reaction($id) { |
|
96 | 96 | |
97 | - if ( ! $this->reaction_exists( $id ) ) { |
|
97 | + if ( ! $this->reaction_exists($id)) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
101 | - return new $this->reaction_class( $id, $this ); |
|
101 | + return new $this->reaction_class($id, $this); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @since 2.1.0 |
106 | 106 | */ |
107 | - public function create_reaction( array $settings ) { |
|
108 | - return $this->create_or_update_reaction( $settings ); |
|
107 | + public function create_reaction(array $settings) { |
|
108 | + return $this->create_or_update_reaction($settings); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @since 2.1.0 |
113 | 113 | */ |
114 | - public function update_reaction( $id, array $settings ) { |
|
115 | - return $this->create_or_update_reaction( $settings, $id ); |
|
114 | + public function update_reaction($id, array $settings) { |
|
115 | + return $this->create_or_update_reaction($settings, $id); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -127,45 +127,45 @@ discard block |
||
127 | 127 | * The reaction object if created/updated successfully. False or a |
128 | 128 | * validator instance if not. |
129 | 129 | */ |
130 | - protected function create_or_update_reaction( array $settings, $id = null ) { |
|
130 | + protected function create_or_update_reaction(array $settings, $id = null) { |
|
131 | 131 | |
132 | - $is_new = ! isset( $id ); |
|
132 | + $is_new = ! isset($id); |
|
133 | 133 | |
134 | - if ( ! $is_new && ! $this->reaction_exists( $id ) ) { |
|
134 | + if ( ! $is_new && ! $this->reaction_exists($id)) { |
|
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | |
138 | - $validator = new WordPoints_Hook_Reaction_Validator( $settings ); |
|
138 | + $validator = new WordPoints_Hook_Reaction_Validator($settings); |
|
139 | 139 | $settings = $validator->validate(); |
140 | 140 | |
141 | - if ( $validator->had_errors() ) { |
|
141 | + if ($validator->had_errors()) { |
|
142 | 142 | return $validator; |
143 | 143 | } |
144 | 144 | |
145 | - if ( $is_new ) { |
|
145 | + if ($is_new) { |
|
146 | 146 | |
147 | - $id = $this->_create_reaction( $settings['event'] ); |
|
147 | + $id = $this->_create_reaction($settings['event']); |
|
148 | 148 | |
149 | - if ( ! $id ) { |
|
149 | + if ( ! $id) { |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - $reaction = $this->get_reaction( $id ); |
|
154 | + $reaction = $this->get_reaction($id); |
|
155 | 155 | |
156 | - $reaction->update_event_slug( $settings['event'] ); |
|
156 | + $reaction->update_event_slug($settings['event']); |
|
157 | 157 | |
158 | - unset( $settings['event'] ); |
|
158 | + unset($settings['event']); |
|
159 | 159 | |
160 | - $reaction->update_meta( 'reactor', $settings['reactor'] ); |
|
160 | + $reaction->update_meta('reactor', $settings['reactor']); |
|
161 | 161 | |
162 | 162 | /** @var WordPoints_Hook_ReactorI $reactor */ |
163 | - $reactor = wordpoints_hooks()->get_sub_app( 'reactors' )->get( $settings['reactor'] ); |
|
164 | - $reactor->update_settings( $reaction, $settings ); |
|
163 | + $reactor = wordpoints_hooks()->get_sub_app('reactors')->get($settings['reactor']); |
|
164 | + $reactor->update_settings($reaction, $settings); |
|
165 | 165 | |
166 | 166 | /** @var WordPoints_Hook_ExtensionI $extension */ |
167 | - foreach ( wordpoints_hooks()->get_sub_app( 'extensions' )->get_all() as $extension ) { |
|
168 | - $extension->update_settings( $reaction, $settings ); |
|
167 | + foreach (wordpoints_hooks()->get_sub_app('extensions')->get_all() as $extension) { |
|
168 | + $extension->update_settings($reaction, $settings); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param array $settings The new settings for the reaction. |
176 | 176 | * @param bool $is_new Whether the reaction was just now created. |
177 | 177 | */ |
178 | - do_action( 'wordpoints_hook_reaction_save', $reaction, $settings, $is_new ); |
|
178 | + do_action('wordpoints_hook_reaction_save', $reaction, $settings, $is_new); |
|
179 | 179 | |
180 | 180 | return $reaction; |
181 | 181 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int|false The reaction ID, or false if not created. |
194 | 194 | */ |
195 | - abstract protected function _create_reaction( $event_slug ); |
|
195 | + abstract protected function _create_reaction($event_slug); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | // EOF |
@@ -1073,6 +1073,7 @@ |
||
1073 | 1073 | * |
1074 | 1074 | * @since 2.1.4 |
1075 | 1075 | * |
1076 | + * @param string[] $post_types |
|
1076 | 1077 | * @return array The slugs of the events. |
1077 | 1078 | */ |
1078 | 1079 | protected function _2_1_4_get_reversal_log_types( $post_types ) { |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | * @since 1.8.0 |
28 | 28 | */ |
29 | 29 | protected $updates = array( |
30 | - '1.2.0' => array( 'single' => true, /* - */ 'network' => true ), |
|
31 | - '1.4.0' => array( 'single' => true, 'site' => true, 'network' => true ), |
|
30 | + '1.2.0' => array('single' => true, /* - */ 'network' => true), |
|
31 | + '1.4.0' => array('single' => true, 'site' => true, 'network' => true), |
|
32 | 32 | '1.5.0' => array( /* - */ 'site' => true /* - */ ), |
33 | - '1.5.1' => array( 'single' => true, /* - */ 'network' => true ), |
|
33 | + '1.5.1' => array('single' => true, /* - */ 'network' => true), |
|
34 | 34 | '1.8.0' => array( /* - */ 'site' => true /* - */ ), |
35 | - '1.9.0' => array( 'single' => true, 'site' => true, 'network' => true ), |
|
36 | - '1.10.0' => array( 'single' => true, /* - */ 'network' => true ), |
|
37 | - '2.0.0' => array( 'single' => true, /* - */ 'network' => true ), |
|
38 | - '2.1.0' => array( 'single' => true, /* - */ 'network' => true ), |
|
39 | - '2.1.4' => array( 'single' => true, 'site' => true, /* - */ ), |
|
35 | + '1.9.0' => array('single' => true, 'site' => true, 'network' => true), |
|
36 | + '1.10.0' => array('single' => true, /* - */ 'network' => true), |
|
37 | + '2.0.0' => array('single' => true, /* - */ 'network' => true), |
|
38 | + '2.1.0' => array('single' => true, /* - */ 'network' => true), |
|
39 | + '2.1.4' => array('single' => true, 'site' => true, /* - */), |
|
40 | 40 | ); |
41 | 41 | |
42 | 42 | /** |
@@ -143,26 +143,26 @@ discard block |
||
143 | 143 | |
144 | 144 | parent::before_update(); |
145 | 145 | |
146 | - if ( 1 === version_compare( '1.4.0', $this->updating_from ) ) { |
|
147 | - add_filter( 'wordpoints_points_hook_update_callback', array( $this, '_1_4_0_clean_hook_settings' ), 10, 4 ); |
|
146 | + if (1 === version_compare('1.4.0', $this->updating_from)) { |
|
147 | + add_filter('wordpoints_points_hook_update_callback', array($this, '_1_4_0_clean_hook_settings'), 10, 4); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( 1 === version_compare( '1.5.0', $this->updating_from ) ) { |
|
150 | + if (1 === version_compare('1.5.0', $this->updating_from)) { |
|
151 | 151 | |
152 | - if ( ! $this->network_wide ) { |
|
153 | - unset( $this->updates['1_5_0'] ); |
|
152 | + if ( ! $this->network_wide) { |
|
153 | + unset($this->updates['1_5_0']); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - if ( $this->network_wide ) { |
|
158 | - unset( $this->updates['1_8_0'] ); |
|
157 | + if ($this->network_wide) { |
|
158 | + unset($this->updates['1_8_0']); |
|
159 | 159 | } |
160 | 160 | |
161 | - if ( 1 === version_compare( '1.9.0', $this->updating_from ) ) { |
|
161 | + if (1 === version_compare('1.9.0', $this->updating_from)) { |
|
162 | 162 | |
163 | 163 | // If we're updating to 1.4.0, we initialize the hooks early, because |
164 | 164 | // we use them during the update. |
165 | - remove_action( 'wordpoints_modules_loaded', array( 'WordPoints_Points_Hooks', 'initialize_hooks' ) ); |
|
165 | + remove_action('wordpoints_modules_loaded', array('WordPoints_Points_Hooks', 'initialize_hooks')); |
|
166 | 166 | |
167 | 167 | WordPoints_Points_Hooks::register( |
168 | 168 | 'WordPoints_Comment_Removed_Points_Hook' |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | // Default to network mode off during the tests, but save the current |
178 | 178 | // mode so we can restore it afterward. |
179 | 179 | $this->points_hooks_network_mode = WordPoints_Points_Hooks::get_network_mode(); |
180 | - WordPoints_Points_Hooks::set_network_mode( false ); |
|
180 | + WordPoints_Points_Hooks::set_network_mode(false); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function after_update() { |
188 | 188 | |
189 | - if ( isset( $this->points_hooks_network_mode ) ) { |
|
189 | + if (isset($this->points_hooks_network_mode)) { |
|
190 | 190 | |
191 | - WordPoints_Points_Hooks::set_network_mode( $this->points_hooks_network_mode ); |
|
191 | + WordPoints_Points_Hooks::set_network_mode($this->points_hooks_network_mode); |
|
192 | 192 | |
193 | - remove_filter( 'wordpoints_points_hook_update_callback', array( $this, '_1_4_0_clean_hook_settings' ), 10 ); |
|
193 | + remove_filter('wordpoints_points_hook_update_callback', array($this, '_1_4_0_clean_hook_settings'), 10); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * Regenerate the custom caps every time on multisite, because they depend on |
204 | 204 | * network activation status. |
205 | 205 | */ |
206 | - if ( 'site' === $this->context ) { |
|
207 | - wordpoints_remove_custom_caps( $this->custom_caps_keys ); |
|
206 | + if ('site' === $this->context) { |
|
207 | + wordpoints_remove_custom_caps($this->custom_caps_keys); |
|
208 | 208 | } |
209 | 209 | |
210 | - wordpoints_add_custom_caps( $this->custom_caps ); |
|
210 | + wordpoints_add_custom_caps($this->custom_caps); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | parent::install_single(); |
239 | 239 | |
240 | - add_option( 'wordpoints_default_points_type', '' ); |
|
240 | + add_option('wordpoints_default_points_type', ''); |
|
241 | 241 | |
242 | 242 | $this->disable_legacy_hooks(); |
243 | 243 | } |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | " |
318 | 318 | ); // WPCS: cache pass. |
319 | 319 | |
320 | - if ( $log_ids && is_array( $log_ids ) ) { |
|
320 | + if ($log_ids && is_array($log_ids)) { |
|
321 | 321 | |
322 | 322 | $wpdb->query( // WPCS: unprepared SQL OK |
323 | 323 | " |
324 | 324 | DELETE |
325 | 325 | FROM {$wpdb->wordpoints_points_logs} |
326 | - WHERE `id` IN (" . implode( ',', array_map( 'absint', $log_ids ) ) . ') |
|
326 | + WHERE `id` IN (" . implode(',', array_map('absint', $log_ids)) . ') |
|
327 | 327 | ' |
328 | 328 | ); // WPCS: cache pass (points logs weren't cached until 1.5.0). |
329 | 329 | |
330 | - foreach ( $log_ids as $log_id ) { |
|
331 | - wordpoints_points_log_delete_all_metadata( $log_id ); |
|
330 | + foreach ($log_ids as $log_id) { |
|
331 | + wordpoints_points_log_delete_all_metadata($log_id); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | } |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | " |
354 | 354 | ); // WPCS: cache pass. |
355 | 355 | |
356 | - $hook = WordPoints_Points_Hooks::get_handler_by_id_base( 'wordpoints_post_points_hook' ); |
|
356 | + $hook = WordPoints_Points_Hooks::get_handler_by_id_base('wordpoints_post_points_hook'); |
|
357 | 357 | |
358 | - if ( $post_ids && is_array( $post_ids ) && $hook ) { |
|
359 | - foreach ( $post_ids as $post_id ) { |
|
360 | - $hook->clean_logs_on_post_deletion( $post_id ); |
|
358 | + if ($post_ids && is_array($post_ids) && $hook) { |
|
359 | + foreach ($post_ids as $post_id) { |
|
360 | + $hook->clean_logs_on_post_deletion($post_id); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | } |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | " |
383 | 383 | ); // WPCS: cache pass. |
384 | 384 | |
385 | - $hook = WordPoints_Points_Hooks::get_handler_by_id_base( 'wordpoints_comment_points_hook' ); |
|
385 | + $hook = WordPoints_Points_Hooks::get_handler_by_id_base('wordpoints_comment_points_hook'); |
|
386 | 386 | |
387 | - if ( $comment_ids && is_array( $comment_ids ) && $hook ) { |
|
388 | - foreach ( $comment_ids as $comment_id ) { |
|
389 | - $hook->clean_logs_on_comment_deletion( $comment_id ); |
|
387 | + if ($comment_ids && is_array($comment_ids) && $hook) { |
|
388 | + foreach ($comment_ids as $comment_id) { |
|
389 | + $hook->clean_logs_on_comment_deletion($comment_id); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | } |
@@ -398,14 +398,14 @@ discard block |
||
398 | 398 | */ |
399 | 399 | protected function update_network_to_1_4_0() { |
400 | 400 | |
401 | - if ( $this->network_wide ) { |
|
401 | + if ($this->network_wide) { |
|
402 | 402 | |
403 | 403 | // Split the network-wide points hooks. |
404 | 404 | $network_mode = WordPoints_Points_Hooks::get_network_mode(); |
405 | - WordPoints_Points_Hooks::set_network_mode( true ); |
|
405 | + WordPoints_Points_Hooks::set_network_mode(true); |
|
406 | 406 | $this->_1_4_0_split_post_hooks(); |
407 | 407 | $this->_1_4_0_split_comment_hooks(); |
408 | - WordPoints_Points_Hooks::set_network_mode( $network_mode ); |
|
408 | + WordPoints_Points_Hooks::set_network_mode($network_mode); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
@@ -471,9 +471,9 @@ discard block |
||
471 | 471 | * @param string $key The settings key for the hook that holds the points. |
472 | 472 | * @param string $split_key The settings key for points that is being split. |
473 | 473 | */ |
474 | - protected function _1_4_0_split_points_hooks( $hook, $new_hook, $key, $split_key ) { |
|
474 | + protected function _1_4_0_split_points_hooks($hook, $new_hook, $key, $split_key) { |
|
475 | 475 | |
476 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
476 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
477 | 477 | $hook_type = 'network'; |
478 | 478 | $network_ = 'network_'; |
479 | 479 | } else { |
@@ -481,58 +481,58 @@ discard block |
||
481 | 481 | $network_ = ''; |
482 | 482 | } |
483 | 483 | |
484 | - $new_hook = WordPoints_Points_Hooks::get_handler_by_id_base( $new_hook ); |
|
485 | - $hook = WordPoints_Points_Hooks::get_handler_by_id_base( $hook ); |
|
484 | + $new_hook = WordPoints_Points_Hooks::get_handler_by_id_base($new_hook); |
|
485 | + $hook = WordPoints_Points_Hooks::get_handler_by_id_base($hook); |
|
486 | 486 | |
487 | 487 | $points_types_hooks = WordPoints_Points_Hooks::get_points_types_hooks(); |
488 | - $instances = $hook->get_instances( $hook_type ); |
|
488 | + $instances = $hook->get_instances($hook_type); |
|
489 | 489 | |
490 | 490 | // Loop through all of the post hook instances. |
491 | - foreach ( $instances as $number => $settings ) { |
|
491 | + foreach ($instances as $number => $settings) { |
|
492 | 492 | |
493 | 493 | // Don't split the hook if it is just a placeholder, or it's already split. |
494 | - if ( 0 === (int) $number || ! isset( $settings[ $key ], $settings[ $split_key ] ) ) { |
|
494 | + if (0 === (int) $number || ! isset($settings[$key], $settings[$split_key])) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
498 | - if ( ! isset( $settings['post_type'] ) ) { |
|
498 | + if ( ! isset($settings['post_type'])) { |
|
499 | 499 | $settings['post_type'] = 'ALL'; |
500 | 500 | } |
501 | 501 | |
502 | 502 | // If the trash points are set, create a post delete points hook instead. |
503 | - if ( isset( $settings[ $split_key ] ) && wordpoints_posint( $settings[ $split_key ] ) ) { |
|
503 | + if (isset($settings[$split_key]) && wordpoints_posint($settings[$split_key])) { |
|
504 | 504 | |
505 | 505 | $new_hook->update_callback( |
506 | 506 | array( |
507 | - 'points' => $settings[ $split_key ], |
|
507 | + 'points' => $settings[$split_key], |
|
508 | 508 | 'post_type' => $settings['post_type'], |
509 | 509 | ) |
510 | 510 | , $new_hook->next_hook_id_number() |
511 | 511 | ); |
512 | 512 | |
513 | 513 | // Make sure the correct points type is retrieved for network hooks. |
514 | - $points_type = $hook->points_type( $network_ . $number ); |
|
514 | + $points_type = $hook->points_type($network_ . $number); |
|
515 | 515 | |
516 | 516 | // Add this instance to the points-types-hooks list. |
517 | - $points_types_hooks[ $points_type ][] = $new_hook->get_id( $number ); |
|
517 | + $points_types_hooks[$points_type][] = $new_hook->get_id($number); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | // If the publish points are set, update the settings of the hook. |
521 | - if ( isset( $settings[ $key ] ) && wordpoints_posint( $settings[ $key ] ) ) { |
|
521 | + if (isset($settings[$key]) && wordpoints_posint($settings[$key])) { |
|
522 | 522 | |
523 | - $settings['points'] = $settings[ $key ]; |
|
523 | + $settings['points'] = $settings[$key]; |
|
524 | 524 | |
525 | - $hook->update_callback( $settings, $number ); |
|
525 | + $hook->update_callback($settings, $number); |
|
526 | 526 | |
527 | 527 | } else { |
528 | 528 | |
529 | 529 | // If not, delete this instance. |
530 | - $hook->delete_callback( $hook->get_id( $number ) ); |
|
530 | + $hook->delete_callback($hook->get_id($number)); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | } // End foreach ( $instances ). |
534 | 534 | |
535 | - WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks ); |
|
535 | + WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -551,12 +551,12 @@ discard block |
||
551 | 551 | * |
552 | 552 | * @return array The filtered instance settings. |
553 | 553 | */ |
554 | - public function _1_4_0_clean_hook_settings( $instance, $new_instance, $old_instance, $hook ) { |
|
554 | + public function _1_4_0_clean_hook_settings($instance, $new_instance, $old_instance, $hook) { |
|
555 | 555 | |
556 | - if ( $hook instanceof WordPoints_Post_Points_Hook ) { |
|
557 | - unset( $instance['trash'], $instance['publish'] ); |
|
558 | - } elseif ( $hook instanceof WordPoints_Comment_Points_Hook ) { |
|
559 | - unset( $instance['approve'], $instance['disapprove'] ); |
|
556 | + if ($hook instanceof WordPoints_Post_Points_Hook) { |
|
557 | + unset($instance['trash'], $instance['publish']); |
|
558 | + } elseif ($hook instanceof WordPoints_Comment_Points_Hook) { |
|
559 | + unset($instance['approve'], $instance['disapprove']); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | return $instance; |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | " |
586 | 586 | ); // WPCS: cache pass. |
587 | 587 | |
588 | - $hook = WordPoints_Points_Hooks::get_handler_by_id_base( 'wordpoints_comment_points_hook' ); |
|
588 | + $hook = WordPoints_Points_Hooks::get_handler_by_id_base('wordpoints_comment_points_hook'); |
|
589 | 589 | |
590 | - if ( $post_ids && is_array( $post_ids ) && $hook ) { |
|
591 | - foreach ( $post_ids as $post_id ) { |
|
592 | - $hook->clean_logs_on_post_deletion( $post_id ); |
|
590 | + if ($post_ids && is_array($post_ids) && $hook) { |
|
591 | + foreach ($post_ids as $post_id) { |
|
592 | + $hook->clean_logs_on_post_deletion($post_id); |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | */ |
605 | 605 | protected function update_site_to_1_5_0() { |
606 | 606 | |
607 | - wordpoints_add_custom_caps( $this->custom_caps ); |
|
607 | + wordpoints_add_custom_caps($this->custom_caps); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -616,18 +616,18 @@ discard block |
||
616 | 616 | |
617 | 617 | global $wpdb; |
618 | 618 | |
619 | - if ( empty( $wpdb->charset ) ) { |
|
619 | + if (empty($wpdb->charset)) { |
|
620 | 620 | return; |
621 | 621 | } |
622 | 622 | |
623 | 623 | $charset_collate = " CHARACTER SET {$wpdb->charset}"; |
624 | 624 | |
625 | - if ( ! empty( $wpdb->collate ) ) { |
|
625 | + if ( ! empty($wpdb->collate)) { |
|
626 | 626 | $charset_collate .= " COLLATE {$wpdb->collate}"; |
627 | 627 | } |
628 | 628 | |
629 | - $wpdb->query( "ALTER TABLE {$wpdb->wordpoints_points_logs} CONVERT TO {$charset_collate}" ); // WPCS: unprepared SQL, cache pass. |
|
630 | - $wpdb->query( "ALTER TABLE {$wpdb->wordpoints_points_log_meta} CONVERT TO {$charset_collate}" ); // WPCS: unprepared SQL, cache pass. |
|
629 | + $wpdb->query("ALTER TABLE {$wpdb->wordpoints_points_logs} CONVERT TO {$charset_collate}"); // WPCS: unprepared SQL, cache pass. |
|
630 | + $wpdb->query("ALTER TABLE {$wpdb->wordpoints_points_log_meta} CONVERT TO {$charset_collate}"); // WPCS: unprepared SQL, cache pass. |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | /** |
@@ -655,14 +655,14 @@ discard block |
||
655 | 655 | */ |
656 | 656 | protected function update_network_to_1_9_0() { |
657 | 657 | |
658 | - if ( $this->network_wide ) { |
|
658 | + if ($this->network_wide) { |
|
659 | 659 | |
660 | 660 | // Combine the network-wide points hooks. |
661 | 661 | $network_mode = WordPoints_Points_Hooks::get_network_mode(); |
662 | - WordPoints_Points_Hooks::set_network_mode( true ); |
|
663 | - $this->_1_9_0_combine_hooks( 'comment', 'comment_removed' ); |
|
664 | - $this->_1_9_0_combine_hooks( 'post', 'post_delete' ); |
|
665 | - WordPoints_Points_Hooks::set_network_mode( $network_mode ); |
|
662 | + WordPoints_Points_Hooks::set_network_mode(true); |
|
663 | + $this->_1_9_0_combine_hooks('comment', 'comment_removed'); |
|
664 | + $this->_1_9_0_combine_hooks('post', 'post_delete'); |
|
665 | + WordPoints_Points_Hooks::set_network_mode($network_mode); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
@@ -672,8 +672,8 @@ discard block |
||
672 | 672 | * @since 1.9.0 |
673 | 673 | */ |
674 | 674 | protected function update_site_to_1_9_0() { |
675 | - $this->_1_9_0_combine_hooks( 'comment', 'comment_removed' ); |
|
676 | - $this->_1_9_0_combine_hooks( 'post', 'post_delete' ); |
|
675 | + $this->_1_9_0_combine_hooks('comment', 'comment_removed'); |
|
676 | + $this->_1_9_0_combine_hooks('post', 'post_delete'); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * @since 1.9.0 |
683 | 683 | */ |
684 | 684 | protected function update_single_to_1_9_0() { |
685 | - $this->_1_9_0_combine_hooks( 'comment', 'comment_removed' ); |
|
686 | - $this->_1_9_0_combine_hooks( 'post', 'post_delete' ); |
|
685 | + $this->_1_9_0_combine_hooks('comment', 'comment_removed'); |
|
686 | + $this->_1_9_0_combine_hooks('post', 'post_delete'); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | * @param string $type The primary hook type that awards the points. |
695 | 695 | * @param string $reverse_type The counterpart hook type that reverses points. |
696 | 696 | */ |
697 | - protected function _1_9_0_combine_hooks( $type, $reverse_type ) { |
|
697 | + protected function _1_9_0_combine_hooks($type, $reverse_type) { |
|
698 | 698 | |
699 | 699 | $hook = WordPoints_Points_Hooks::get_handler_by_id_base( |
700 | 700 | "wordpoints_{$type}_points_hook" |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | "wordpoints_{$reverse_type}_points_hook" |
704 | 704 | ); |
705 | 705 | |
706 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
706 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
707 | 707 | $hook_type = 'network'; |
708 | 708 | $network_ = 'network_'; |
709 | 709 | } else { |
@@ -711,11 +711,11 @@ discard block |
||
711 | 711 | $network_ = ''; |
712 | 712 | } |
713 | 713 | |
714 | - $hook_instances = $hook->get_instances( $hook_type ); |
|
715 | - $hook_reverse_instances = $reverse_hook->get_instances( $hook_type ); |
|
714 | + $hook_instances = $hook->get_instances($hook_type); |
|
715 | + $hook_reverse_instances = $reverse_hook->get_instances($hook_type); |
|
716 | 716 | |
717 | - $default_points = ( 'post' === $hook_type ) ? 20 : 10; |
|
718 | - $defaults = array( 'points' => $default_points, 'post_type' => 'ALL' ); |
|
717 | + $default_points = ('post' === $hook_type) ? 20 : 10; |
|
718 | + $defaults = array('points' => $default_points, 'post_type' => 'ALL'); |
|
719 | 719 | |
720 | 720 | // Get the hooks into an array that is indexed by post type and the |
721 | 721 | // number of points. This allows us to easily check for any counterparts when |
@@ -723,53 +723,53 @@ discard block |
||
723 | 723 | // is doing something crazy like multiple hooks for the same post type. |
724 | 724 | $hook_instances_indexed = array(); |
725 | 725 | |
726 | - foreach ( $hook_instances as $number => $instance ) { |
|
726 | + foreach ($hook_instances as $number => $instance) { |
|
727 | 727 | |
728 | - $instance = array_merge( $defaults, $instance ); |
|
728 | + $instance = array_merge($defaults, $instance); |
|
729 | 729 | |
730 | 730 | $hook_instances_indexed |
731 | - [ $hook->points_type( $network_ . $number ) ] |
|
732 | - [ $instance['post_type'] ] |
|
733 | - [ $instance['points'] ] |
|
731 | + [$hook->points_type($network_ . $number)] |
|
732 | + [$instance['post_type']] |
|
733 | + [$instance['points']] |
|
734 | 734 | [] = $number; |
735 | 735 | } |
736 | 736 | |
737 | - foreach ( $hook_reverse_instances as $number => $instance ) { |
|
737 | + foreach ($hook_reverse_instances as $number => $instance) { |
|
738 | 738 | |
739 | - $instance = array_merge( $defaults, $instance ); |
|
739 | + $instance = array_merge($defaults, $instance); |
|
740 | 740 | |
741 | - $points_type = $reverse_hook->points_type( $network_ . $number ); |
|
741 | + $points_type = $reverse_hook->points_type($network_ . $number); |
|
742 | 742 | |
743 | 743 | // We use empty() instead of isset() because array_pop() below may leave |
744 | 744 | // us with an empty array as the value. |
745 | - if ( empty( $hook_instances_indexed[ $points_type ][ $instance['post_type'] ][ $instance['points'] ] ) ) { |
|
745 | + if (empty($hook_instances_indexed[$points_type][$instance['post_type']][$instance['points']])) { |
|
746 | 746 | continue; |
747 | 747 | } |
748 | 748 | |
749 | 749 | $comment_instance_number = array_pop( |
750 | - $hook_instances_indexed[ $points_type ][ $instance['post_type'] ][ $instance['points'] ] |
|
750 | + $hook_instances_indexed[$points_type][$instance['post_type']][$instance['points']] |
|
751 | 751 | ); |
752 | 752 | |
753 | 753 | // We need to unset this instance from the list of hook instances. It |
754 | 754 | // is expected for it to be automatically reversed, and that is the |
755 | 755 | // default setting. If we don't unset it here it will get auto-reversal |
756 | 756 | // turned off below, which isn't what we want. |
757 | - unset( $hook_instances[ $comment_instance_number ] ); |
|
757 | + unset($hook_instances[$comment_instance_number]); |
|
758 | 758 | |
759 | 759 | // Now we can just delete this reverse hook instance. |
760 | 760 | $reverse_hook->delete_callback( |
761 | - $reverse_hook->get_id( $number ) |
|
761 | + $reverse_hook->get_id($number) |
|
762 | 762 | ); |
763 | 763 | } |
764 | 764 | |
765 | 765 | // Any hooks left in the array are not paired with a reverse type hook, and |
766 | 766 | // aren't expected to auto-reverse, so we need to turn their auto-reversal |
767 | 767 | // setting off. |
768 | - if ( ! empty( $hook_instances ) ) { |
|
768 | + if ( ! empty($hook_instances)) { |
|
769 | 769 | |
770 | - foreach ( $hook_instances as $number => $instance ) { |
|
770 | + foreach ($hook_instances as $number => $instance) { |
|
771 | 771 | $instance['auto_reverse'] = 0; |
772 | - $hook->update_callback( $instance, $number ); |
|
772 | + $hook->update_callback($instance, $number); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | // We add a flag to the database so we'll know to enable legacy features. |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | // Now we check if there are any unpaired reverse type hooks. If there are |
783 | 783 | // we'll set this flag in the database that will keep some legacy features |
784 | 784 | // enabled. |
785 | - if ( $reverse_hook->get_instances( $hook_type ) ) { |
|
785 | + if ($reverse_hook->get_instances($hook_type)) { |
|
786 | 786 | update_site_option( |
787 | 787 | "wordpoints_{$reverse_type}_hook_legacy" |
788 | 788 | , true |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @since 1.10.0 |
797 | 797 | */ |
798 | 798 | protected function update_network_to_1_10_0() { |
799 | - $this->_1_10_0_delete_post_title_points_log_meta( true ); |
|
799 | + $this->_1_10_0_delete_post_title_points_log_meta(true); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -816,28 +816,28 @@ discard block |
||
816 | 816 | * @param bool $network_wide Whether to delete all of the metadata for the whole |
817 | 817 | * network, or just the current site (default). |
818 | 818 | */ |
819 | - protected function _1_10_0_delete_post_title_points_log_meta( $network_wide = false ) { |
|
819 | + protected function _1_10_0_delete_post_title_points_log_meta($network_wide = false) { |
|
820 | 820 | |
821 | 821 | $query_args = array( |
822 | 822 | 'log_type' => 'post_delete', |
823 | 823 | 'meta_query' => array( |
824 | - array( 'key' => 'post_title', 'compare' => 'EXISTS' ), |
|
824 | + array('key' => 'post_title', 'compare' => 'EXISTS'), |
|
825 | 825 | ), |
826 | 826 | ); |
827 | 827 | |
828 | - if ( $network_wide ) { |
|
828 | + if ($network_wide) { |
|
829 | 829 | $query_args['blog_id'] = false; |
830 | 830 | } |
831 | 831 | |
832 | - $query = new WordPoints_Points_Logs_Query( $query_args ); |
|
832 | + $query = new WordPoints_Points_Logs_Query($query_args); |
|
833 | 833 | |
834 | 834 | $logs = $query->get(); |
835 | 835 | |
836 | - foreach ( $logs as $log ) { |
|
837 | - wordpoints_delete_points_log_meta( $log->id, 'post_title' ); |
|
836 | + foreach ($logs as $log) { |
|
837 | + wordpoints_delete_points_log_meta($log->id, 'post_title'); |
|
838 | 838 | } |
839 | 839 | |
840 | - wordpoints_regenerate_points_logs( $logs ); |
|
840 | + wordpoints_regenerate_points_logs($logs); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | " |
876 | 876 | ); // WPCS: cache pass. |
877 | 877 | |
878 | - $this->maybe_update_tables_to_utf8mb4( 'global' ); |
|
878 | + $this->maybe_update_tables_to_utf8mb4('global'); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | * @since 2.1.0 |
894 | 894 | */ |
895 | 895 | protected function update_network_to_2_1_0() { |
896 | - add_site_option( 'wordpoints_disabled_points_hooks_edit_points_types', true ); |
|
896 | + add_site_option('wordpoints_disabled_points_hooks_edit_points_types', true); |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | /** |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @since 2.1.0 |
903 | 903 | */ |
904 | 904 | protected function update_single_to_2_1_0() { |
905 | - add_option( 'wordpoints_disabled_points_hooks_edit_points_types', true ); |
|
905 | + add_option('wordpoints_disabled_points_hooks_edit_points_types', true); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -922,44 +922,44 @@ discard block |
||
922 | 922 | protected function update_single_to_2_1_4() { |
923 | 923 | |
924 | 924 | $post_types = $this->_2_1_4_get_post_types(); |
925 | - $reversal_log_types = $this->_2_1_4_get_reversal_log_types( $post_types ); |
|
925 | + $reversal_log_types = $this->_2_1_4_get_reversal_log_types($post_types); |
|
926 | 926 | $hits = $this->_2_1_4_get_hits_with_multiple_logs(); |
927 | 927 | |
928 | 928 | $logs_to_delete = array(); |
929 | 929 | |
930 | - foreach ( $hits as $hit ) { |
|
930 | + foreach ($hits as $hit) { |
|
931 | 931 | |
932 | - $log_ids = explode( ',', $hit->log_ids ); |
|
932 | + $log_ids = explode(',', $hit->log_ids); |
|
933 | 933 | |
934 | 934 | // If there weren't exactly two of them, we don't know what to do. |
935 | - if ( count( $log_ids ) !== 2 ) { |
|
935 | + if (count($log_ids) !== 2) { |
|
936 | 936 | continue; |
937 | 937 | } |
938 | 938 | |
939 | 939 | $query = new WordPoints_Points_Logs_Query( |
940 | 940 | array( |
941 | 941 | 'id__in' => $log_ids, |
942 | - 'log_type__in' => array_keys( $reversal_log_types ), |
|
942 | + 'log_type__in' => array_keys($reversal_log_types), |
|
943 | 943 | ) |
944 | 944 | ); |
945 | 945 | |
946 | 946 | // And if they aren't both the correct types, we don't know what to do. |
947 | - if ( $query->count() !== 2 ) { |
|
947 | + if ($query->count() !== 2) { |
|
948 | 948 | continue; |
949 | 949 | } |
950 | 950 | |
951 | - $original_log_ids = $this->_2_1_4_get_original_log_ids( $log_ids ); |
|
951 | + $original_log_ids = $this->_2_1_4_get_original_log_ids($log_ids); |
|
952 | 952 | |
953 | - $post_publish_log_id = min( array_keys( $original_log_ids ) ); |
|
954 | - $post_update_log_id = max( array_keys( $original_log_ids ) ); |
|
955 | - $post_publish_reverse_log_id = $original_log_ids[ $post_publish_log_id ]; |
|
956 | - $post_update_reverse_log_id = $original_log_ids[ $post_update_log_id ]; |
|
953 | + $post_publish_log_id = min(array_keys($original_log_ids)); |
|
954 | + $post_update_log_id = max(array_keys($original_log_ids)); |
|
955 | + $post_publish_reverse_log_id = $original_log_ids[$post_publish_log_id]; |
|
956 | + $post_update_reverse_log_id = $original_log_ids[$post_update_log_id]; |
|
957 | 957 | |
958 | 958 | $query = new WordPoints_Points_Logs_Query( |
959 | - array( 'id__in' => array( $post_publish_reverse_log_id ) ) |
|
959 | + array('id__in' => array($post_publish_reverse_log_id)) |
|
960 | 960 | ); |
961 | 961 | |
962 | - $post_publish_reverse_log = $query->get( 'row' ); |
|
962 | + $post_publish_reverse_log = $query->get('row'); |
|
963 | 963 | |
964 | 964 | $post_type = str_replace( |
965 | 965 | 'reverse-post_publish\\' |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | , true |
980 | 980 | ); |
981 | 981 | |
982 | - if ( $post_id !== $post_id_2 ) { |
|
982 | + if ($post_id !== $post_id_2) { |
|
983 | 983 | continue; |
984 | 984 | } |
985 | 985 | |
@@ -988,9 +988,9 @@ discard block |
||
988 | 988 | $logs_to_delete[] = $post_update_log_id; |
989 | 989 | |
990 | 990 | // Give the user their points back, as they were removed in error. |
991 | - $this->_2_1_4_revert_log( $post_publish_reverse_log ); |
|
991 | + $this->_2_1_4_revert_log($post_publish_reverse_log); |
|
992 | 992 | |
993 | - $this->_2_1_4_mark_unreversed( $post_publish_log_id ); |
|
993 | + $this->_2_1_4_mark_unreversed($post_publish_log_id); |
|
994 | 994 | |
995 | 995 | // Now clean up any later updates. |
996 | 996 | $logs_to_delete = $this->_2_1_4_clean_other_logs( |
@@ -1002,43 +1002,43 @@ discard block |
||
1002 | 1002 | } // End foreach ( $hits ). |
1003 | 1003 | |
1004 | 1004 | // Now the legacy logs. |
1005 | - $legacy_logs = $this->_2_1_4_get_legacy_reactor_logs( $post_types ); |
|
1005 | + $legacy_logs = $this->_2_1_4_get_legacy_reactor_logs($post_types); |
|
1006 | 1006 | $post_ids = $this->_2_1_4_get_legacy_points_hook_post_ids(); |
1007 | 1007 | |
1008 | - foreach ( $post_ids as $post_id ) { |
|
1008 | + foreach ($post_ids as $post_id) { |
|
1009 | 1009 | |
1010 | - if ( ! isset( $legacy_logs[ $post_id ] ) ) { |
|
1010 | + if ( ! isset($legacy_logs[$post_id])) { |
|
1011 | 1011 | continue; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - array_map( array( $this, '_2_1_4_revert_log' ), $legacy_logs[ $post_id ] ); |
|
1014 | + array_map(array($this, '_2_1_4_revert_log'), $legacy_logs[$post_id]); |
|
1015 | 1015 | |
1016 | 1016 | $logs_to_delete = array_merge( |
1017 | 1017 | $logs_to_delete |
1018 | - , wp_list_pluck( $legacy_logs[ $post_id ], 'id' ) |
|
1018 | + , wp_list_pluck($legacy_logs[$post_id], 'id') |
|
1019 | 1019 | ); |
1020 | 1020 | |
1021 | - unset( $legacy_logs[ $post_id ] ); |
|
1021 | + unset($legacy_logs[$post_id]); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | - foreach ( $legacy_logs as $logs ) { |
|
1025 | - if ( count( $logs ) > 1 ) { |
|
1024 | + foreach ($legacy_logs as $logs) { |
|
1025 | + if (count($logs) > 1) { |
|
1026 | 1026 | |
1027 | 1027 | // The first one is the original, so keep it. |
1028 | - unset( $logs[0] ); |
|
1028 | + unset($logs[0]); |
|
1029 | 1029 | |
1030 | - array_map( array( $this, '_2_1_4_revert_log' ), $logs ); |
|
1030 | + array_map(array($this, '_2_1_4_revert_log'), $logs); |
|
1031 | 1031 | |
1032 | 1032 | $logs_to_delete = array_merge( |
1033 | 1033 | $logs_to_delete |
1034 | - , wp_list_pluck( $logs, 'id' ) |
|
1034 | + , wp_list_pluck($logs, 'id') |
|
1035 | 1035 | ); |
1036 | 1036 | } |
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | // Now delete the logs. |
1040 | - if ( $logs_to_delete ) { |
|
1041 | - $this->_2_1_4_delete_logs( $logs_to_delete ); |
|
1040 | + if ($logs_to_delete) { |
|
1041 | + $this->_2_1_4_delete_logs($logs_to_delete); |
|
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | */ |
1052 | 1052 | protected function _2_1_4_get_post_types() { |
1053 | 1053 | |
1054 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
1054 | + $post_types = get_post_types(array('public' => true)); |
|
1055 | 1055 | |
1056 | 1056 | /** |
1057 | 1057 | * Filter which post types to register hook events for. |
@@ -1075,12 +1075,12 @@ discard block |
||
1075 | 1075 | * |
1076 | 1076 | * @return array The slugs of the events. |
1077 | 1077 | */ |
1078 | - protected function _2_1_4_get_reversal_log_types( $post_types ) { |
|
1078 | + protected function _2_1_4_get_reversal_log_types($post_types) { |
|
1079 | 1079 | |
1080 | 1080 | $event_slugs = array(); |
1081 | 1081 | |
1082 | - foreach ( $post_types as $slug ) { |
|
1083 | - $event_slugs[ "reverse-post_publish\\{$slug}" ] = true; |
|
1082 | + foreach ($post_types as $slug) { |
|
1083 | + $event_slugs["reverse-post_publish\\{$slug}"] = true; |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | return $event_slugs; |
@@ -1124,11 +1124,11 @@ discard block |
||
1124 | 1124 | * |
1125 | 1125 | * @return array The IDs of the original logs. |
1126 | 1126 | */ |
1127 | - protected function _2_1_4_get_original_log_ids( $log_ids ) { |
|
1127 | + protected function _2_1_4_get_original_log_ids($log_ids) { |
|
1128 | 1128 | |
1129 | 1129 | $original_log_ids = array(); |
1130 | 1130 | |
1131 | - foreach ( $log_ids as $log_id ) { |
|
1131 | + foreach ($log_ids as $log_id) { |
|
1132 | 1132 | |
1133 | 1133 | $original_log_id = wordpoints_get_points_log_meta( |
1134 | 1134 | $log_id |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | , true |
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - $original_log_ids[ $original_log_id ] = $log_id; |
|
1139 | + $original_log_ids[$original_log_id] = $log_id; |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | return $original_log_ids; |
@@ -1151,13 +1151,13 @@ discard block |
||
1151 | 1151 | * |
1152 | 1152 | * @param int[] $log_ids The IDs of the logs to delete. |
1153 | 1153 | */ |
1154 | - protected function _2_1_4_delete_logs( $log_ids ) { |
|
1154 | + protected function _2_1_4_delete_logs($log_ids) { |
|
1155 | 1155 | |
1156 | 1156 | $hits_to_delete = array(); |
1157 | 1157 | |
1158 | 1158 | global $wpdb; |
1159 | 1159 | |
1160 | - foreach ( $log_ids as $log_id ) { |
|
1160 | + foreach ($log_ids as $log_id) { |
|
1161 | 1161 | |
1162 | 1162 | $hit_id = wordpoints_get_points_log_meta( |
1163 | 1163 | $log_id |
@@ -1165,26 +1165,26 @@ discard block |
||
1165 | 1165 | , true |
1166 | 1166 | ); |
1167 | 1167 | |
1168 | - if ( $hit_id ) { |
|
1168 | + if ($hit_id) { |
|
1169 | 1169 | $hits_to_delete[] = $hit_id; |
1170 | 1170 | } |
1171 | 1171 | |
1172 | - wordpoints_points_log_delete_all_metadata( $log_id ); |
|
1172 | + wordpoints_points_log_delete_all_metadata($log_id); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | $wpdb->query( // WPCS: unprepared SQL OK. |
1176 | 1176 | " |
1177 | 1177 | DELETE |
1178 | 1178 | FROM `{$wpdb->wordpoints_points_logs}` |
1179 | - WHERE `id` IN (" . wordpoints_prepare__in( $log_ids, '%d' ) . ') |
|
1179 | + WHERE `id` IN (" . wordpoints_prepare__in($log_ids, '%d') . ') |
|
1180 | 1180 | ' |
1181 | 1181 | ); |
1182 | 1182 | |
1183 | 1183 | wordpoints_flush_points_logs_caches(); |
1184 | 1184 | |
1185 | 1185 | // Now delete the hits. |
1186 | - if ( $hits_to_delete ) { |
|
1187 | - $this->_2_1_4_delete_hits( $hits_to_delete ); |
|
1186 | + if ($hits_to_delete) { |
|
1187 | + $this->_2_1_4_delete_hits($hits_to_delete); |
|
1188 | 1188 | } |
1189 | 1189 | } |
1190 | 1190 | |
@@ -1195,11 +1195,11 @@ discard block |
||
1195 | 1195 | * |
1196 | 1196 | * @param int[] $hit_ids The IDs of the hits to delete. |
1197 | 1197 | */ |
1198 | - protected function _2_1_4_delete_hits( $hit_ids ) { |
|
1198 | + protected function _2_1_4_delete_hits($hit_ids) { |
|
1199 | 1199 | |
1200 | 1200 | global $wpdb; |
1201 | 1201 | |
1202 | - foreach ( $hit_ids as $hit_id ) { |
|
1202 | + foreach ($hit_ids as $hit_id) { |
|
1203 | 1203 | |
1204 | 1204 | $hit_ids[] = get_metadata( |
1205 | 1205 | 'wordpoints_hook_hit' |
@@ -1208,14 +1208,14 @@ discard block |
||
1208 | 1208 | , true |
1209 | 1209 | ); |
1210 | 1210 | |
1211 | - delete_metadata( 'wordpoints_hook_hit', $hit_id, '', '', true ); |
|
1211 | + delete_metadata('wordpoints_hook_hit', $hit_id, '', '', true); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | $wpdb->query( // WPCS: unprepared SQL OK. |
1215 | 1215 | " |
1216 | 1216 | DELETE |
1217 | 1217 | FROM `{$wpdb->wordpoints_hook_hits}` |
1218 | - WHERE `id` IN (" . wordpoints_prepare__in( $hit_ids, '%d' ) . ') |
|
1218 | + WHERE `id` IN (" . wordpoints_prepare__in($hit_ids, '%d') . ') |
|
1219 | 1219 | ' |
1220 | 1220 | ); // WPCS: cache OK. |
1221 | 1221 | } |
@@ -1231,14 +1231,14 @@ discard block |
||
1231 | 1231 | * |
1232 | 1232 | * @return int[] The list of logs to be deleted. |
1233 | 1233 | */ |
1234 | - protected function _2_1_4_clean_other_logs( $post_id, $post_type, $logs_to_delete ) { |
|
1234 | + protected function _2_1_4_clean_other_logs($post_id, $post_type, $logs_to_delete) { |
|
1235 | 1235 | |
1236 | 1236 | $query = new WordPoints_Points_Logs_Query( |
1237 | 1237 | array( |
1238 | 1238 | 'order' => 'ASC', |
1239 | 1239 | 'orderby' => 'id', |
1240 | 1240 | 'id__not_in' => $logs_to_delete, |
1241 | - 'log_type__in' => array( 'post_publish\\' . $post_type ), |
|
1241 | + 'log_type__in' => array('post_publish\\' . $post_type), |
|
1242 | 1242 | 'meta_query' => array( |
1243 | 1243 | array( |
1244 | 1244 | 'key' => 'post\\' . $post_type, |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | 'meta_query' => array( |
1258 | 1258 | array( |
1259 | 1259 | 'key' => 'original_log_id', |
1260 | - 'value' => wp_list_pluck( $other_logs, 'id' ), |
|
1260 | + 'value' => wp_list_pluck($other_logs, 'id'), |
|
1261 | 1261 | 'compare' => 'IN', |
1262 | 1262 | ), |
1263 | 1263 | ), |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | |
1267 | 1267 | $reversal_logs = array(); |
1268 | 1268 | |
1269 | - foreach ( $query->get() as $log ) { |
|
1269 | + foreach ($query->get() as $log) { |
|
1270 | 1270 | |
1271 | 1271 | $original_log_id = wordpoints_get_points_log_meta( |
1272 | 1272 | $log->id |
@@ -1274,20 +1274,20 @@ discard block |
||
1274 | 1274 | , true |
1275 | 1275 | ); |
1276 | 1276 | |
1277 | - $reversal_logs[ $original_log_id ] = $log; |
|
1277 | + $reversal_logs[$original_log_id] = $log; |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | - foreach ( $other_logs as $index => $log ) { |
|
1280 | + foreach ($other_logs as $index => $log) { |
|
1281 | 1281 | |
1282 | 1282 | // If this is a log that was reversed within less than a second or so |
1283 | 1283 | // of its occurrence, it is almost certainly the result of another |
1284 | 1284 | // update, and it is just cluttering things up. |
1285 | 1285 | if ( |
1286 | - isset( $reversal_logs[ $log->id ] ) |
|
1287 | - && strtotime( $reversal_logs[ $log->id ]->date ) - strtotime( $log->date ) < 2 |
|
1286 | + isset($reversal_logs[$log->id]) |
|
1287 | + && strtotime($reversal_logs[$log->id]->date) - strtotime($log->date) < 2 |
|
1288 | 1288 | ) { |
1289 | 1289 | $logs_to_delete[] = $log->id; |
1290 | - $logs_to_delete[] = $reversal_logs[ $log->id ]->id; |
|
1290 | + $logs_to_delete[] = $reversal_logs[$log->id]->id; |
|
1291 | 1291 | } |
1292 | 1292 | } |
1293 | 1293 | |
@@ -1301,9 +1301,9 @@ discard block |
||
1301 | 1301 | * |
1302 | 1302 | * @param object $log The points log object. |
1303 | 1303 | */ |
1304 | - protected function _2_1_4_revert_log( $log ) { |
|
1304 | + protected function _2_1_4_revert_log($log) { |
|
1305 | 1305 | |
1306 | - add_filter( 'wordpoints_points_log', '__return_false' ); |
|
1306 | + add_filter('wordpoints_points_log', '__return_false'); |
|
1307 | 1307 | |
1308 | 1308 | wordpoints_alter_points( |
1309 | 1309 | $log->user_id |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | , $log->log_type |
1313 | 1313 | ); |
1314 | 1314 | |
1315 | - remove_filter( 'wordpoints_points_log', '__return_false' ); |
|
1315 | + remove_filter('wordpoints_points_log', '__return_false'); |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | /** |
@@ -1322,13 +1322,13 @@ discard block |
||
1322 | 1322 | * |
1323 | 1323 | * @param int $log_id The ID of the log to mark as unreversed. |
1324 | 1324 | */ |
1325 | - protected function _2_1_4_mark_unreversed( $log_id ) { |
|
1325 | + protected function _2_1_4_mark_unreversed($log_id) { |
|
1326 | 1326 | |
1327 | - wordpoints_delete_points_log_meta( $log_id, 'auto_reversed' ); |
|
1327 | + wordpoints_delete_points_log_meta($log_id, 'auto_reversed'); |
|
1328 | 1328 | |
1329 | - $hit_id = wordpoints_get_points_log_meta( $log_id, 'hook_hit_id', true ); |
|
1329 | + $hit_id = wordpoints_get_points_log_meta($log_id, 'hook_hit_id', true); |
|
1330 | 1330 | |
1331 | - delete_metadata( 'wordpoints_hook_hit', $hit_id, 'reverse_fired' ); |
|
1331 | + delete_metadata('wordpoints_hook_hit', $hit_id, 'reverse_fired'); |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | /** |
@@ -1340,21 +1340,21 @@ discard block |
||
1340 | 1340 | * |
1341 | 1341 | * @return array[] The logs, grouped by post ID. |
1342 | 1342 | */ |
1343 | - protected function _2_1_4_get_legacy_reactor_logs( $post_types ) { |
|
1343 | + protected function _2_1_4_get_legacy_reactor_logs($post_types) { |
|
1344 | 1344 | |
1345 | 1345 | $legacy_log_types = array(); |
1346 | 1346 | |
1347 | - foreach ( $post_types as $post_type ) { |
|
1347 | + foreach ($post_types as $post_type) { |
|
1348 | 1348 | $legacy_log_types[] = "points_legacy_post_publish\\{$post_type}"; |
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | $query = new WordPoints_Points_Logs_Query( |
1352 | - array( 'log_type__in' => $legacy_log_types, 'order' => 'ASC' ) |
|
1352 | + array('log_type__in' => $legacy_log_types, 'order' => 'ASC') |
|
1353 | 1353 | ); |
1354 | 1354 | |
1355 | 1355 | $legacy_logs = array(); |
1356 | 1356 | |
1357 | - foreach ( $query->get() as $legacy_log ) { |
|
1357 | + foreach ($query->get() as $legacy_log) { |
|
1358 | 1358 | |
1359 | 1359 | $post_type = str_replace( |
1360 | 1360 | 'points_legacy_post_publish\\' |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | , true |
1369 | 1369 | ); |
1370 | 1370 | |
1371 | - $legacy_logs[ $post_id ][] = $legacy_log; |
|
1371 | + $legacy_logs[$post_id][] = $legacy_log; |
|
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | return $legacy_logs; |
@@ -103,7 +103,7 @@ |
||
103 | 103 | * |
104 | 104 | * @param int|string $number The hook number or ID to get the points for. |
105 | 105 | * |
106 | - * @return int|false The number of points for this instance, or false. |
|
106 | + * @return integer The number of points for this instance, or false. |
|
107 | 107 | */ |
108 | 108 | public function get_points( $number = null ) { |
109 | 109 |
@@ -105,18 +105,18 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return int|false The number of points for this instance, or false. |
107 | 107 | */ |
108 | - public function get_points( $number = null ) { |
|
108 | + public function get_points($number = null) { |
|
109 | 109 | |
110 | - if ( isset( $number ) ) { |
|
111 | - $number = $this->get_number_by_id( $number ); |
|
110 | + if (isset($number)) { |
|
111 | + $number = $this->get_number_by_id($number); |
|
112 | 112 | } else { |
113 | 113 | $number = $this->number; |
114 | 114 | } |
115 | 115 | |
116 | 116 | $instances = $this->get_instances(); |
117 | 117 | |
118 | - if ( isset( $instances[ $number ]['points'] ) ) { |
|
119 | - return $instances[ $number ]['points']; |
|
118 | + if (isset($instances[$number]['points'])) { |
|
119 | + return $instances[$number]['points']; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return false; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return array|false Settings to save, or false to cancel saving. |
149 | 149 | */ |
150 | - protected function update( $new_instance, $old_instance ) { |
|
150 | + protected function update($new_instance, $old_instance) { |
|
151 | 151 | |
152 | - $new_instance = array_merge( array( 'points' => 0 ), $old_instance, $new_instance ); |
|
152 | + $new_instance = array_merge(array('points' => 0), $old_instance, $new_instance); |
|
153 | 153 | |
154 | - if ( false === wordpoints_posint( $new_instance['points'] ) ) { |
|
155 | - if ( isset( $this->defaults['points'] ) ) { |
|
154 | + if (false === wordpoints_posint($new_instance['points'])) { |
|
155 | + if (isset($this->defaults['points'])) { |
|
156 | 156 | $new_instance['points'] = $this->defaults['points']; |
157 | 157 | } else { |
158 | 158 | return false; |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return bool Whether the hook has a form. |
180 | 180 | */ |
181 | - protected function form( $instance ) { |
|
181 | + protected function form($instance) { |
|
182 | 182 | |
183 | - if ( ! isset( $instance['points'] ) ) { |
|
183 | + if ( ! isset($instance['points'])) { |
|
184 | 184 | |
185 | - if ( isset( $this->defaults['points'] ) ) { |
|
185 | + if (isset($this->defaults['points'])) { |
|
186 | 186 | $instance['points'] = $this->defaults['points']; |
187 | 187 | } else { |
188 | 188 | $instance['points'] = 0; |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <p> |
195 | - <label for="<?php $this->the_field_id( 'points' ); ?>"><?php echo esc_html( $this->options['points_label'] ); ?></label> |
|
196 | - <input class="widefat" name="<?php $this->the_field_name( 'points' ); ?>" id="<?php $this->the_field_id( 'points' ); ?>" type="number" min="0" value="<?php echo wordpoints_posint( $instance['points'] ); ?>" /> |
|
195 | + <label for="<?php $this->the_field_id('points'); ?>"><?php echo esc_html($this->options['points_label']); ?></label> |
|
196 | + <input class="widefat" name="<?php $this->the_field_name('points'); ?>" id="<?php $this->the_field_id('points'); ?>" type="number" min="0" value="<?php echo wordpoints_posint($instance['points']); ?>" /> |
|
197 | 197 | </p> |
198 | 198 | |
199 | 199 | <?php |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return string The hook instance's description. |
212 | 212 | */ |
213 | - protected function generate_description( $instance = array() ) { |
|
213 | + protected function generate_description($instance = array()) { |
|
214 | 214 | |
215 | 215 | return $this->options['description']; |
216 | 216 | } |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @return string The unique ID for the instance. |
245 | 245 | */ |
246 | - final public function get_id( $number = null ) { |
|
246 | + final public function get_id($number = null) { |
|
247 | 247 | |
248 | - if ( ! isset( $number ) ) { |
|
248 | + if ( ! isset($number)) { |
|
249 | 249 | $number = $this->number; |
250 | 250 | } |
251 | 251 | |
@@ -275,16 +275,16 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param int|string $instance_id The number or ID of an instance. |
277 | 277 | */ |
278 | - final public function set_number( $instance_id ) { |
|
278 | + final public function set_number($instance_id) { |
|
279 | 279 | |
280 | - $this->number = $this->get_number_by_id( $instance_id ); |
|
280 | + $this->number = $this->get_number_by_id($instance_id); |
|
281 | 281 | |
282 | - if ( '__i__' === $this->number ) { |
|
282 | + if ('__i__' === $this->number) { |
|
283 | 283 | return; |
284 | - } elseif ( '0' === $this->number ) { |
|
284 | + } elseif ('0' === $this->number) { |
|
285 | 285 | $this->number = 0; |
286 | 286 | } else { |
287 | - wordpoints_posint( $this->number ); |
|
287 | + wordpoints_posint($this->number); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | * @return string The number for the hook instance. Prefixed with 'network_' for |
299 | 299 | * network hooks. |
300 | 300 | */ |
301 | - final public function get_number_by_id( $id ) { |
|
301 | + final public function get_number_by_id($id) { |
|
302 | 302 | |
303 | - return str_replace( $this->id_base . '-', '', $id ); |
|
303 | + return str_replace($this->id_base . '-', '', $id); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @return mixed The option, or null if it doesn't exist. |
340 | 340 | */ |
341 | - final public function get_option( $option ) { |
|
341 | + final public function get_option($option) { |
|
342 | 342 | |
343 | - if ( isset( $this->options[ $option ] ) ) { |
|
343 | + if (isset($this->options[$option])) { |
|
344 | 344 | |
345 | - return $this->options[ $option ]; |
|
345 | + return $this->options[$option]; |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @param array $options The options for the hook. |
356 | 356 | */ |
357 | - final public function set_options( array $options ) { |
|
357 | + final public function set_options(array $options) { |
|
358 | 358 | $this->options = $options; |
359 | 359 | } |
360 | 360 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @param string $option The index for the option. |
368 | 368 | * @param mixed $value The value to assign to this option. |
369 | 369 | */ |
370 | - final public function set_option( $option, $value ) { |
|
370 | + final public function set_option($option, $value) { |
|
371 | 371 | |
372 | - $this->options[ $option ] = $value; |
|
372 | + $this->options[$option] = $value; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -385,13 +385,13 @@ discard block |
||
385 | 385 | */ |
386 | 386 | final public function next_hook_id_number() { |
387 | 387 | |
388 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
388 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
389 | 389 | $type = 'network'; |
390 | 390 | } else { |
391 | 391 | $type = 'standard'; |
392 | 392 | } |
393 | 393 | |
394 | - return 1 + max( array_keys( $this->get_instances( $type ) ) + array( 0 ) ); |
|
394 | + return 1 + max(array_keys($this->get_instances($type)) + array(0)); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -413,34 +413,34 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return array The saved instances of this hook. |
415 | 415 | */ |
416 | - final public function get_instances( $type = 'all' ) { |
|
416 | + final public function get_instances($type = 'all') { |
|
417 | 417 | |
418 | - switch ( $type ) { |
|
418 | + switch ($type) { |
|
419 | 419 | |
420 | 420 | case 'standard': |
421 | - $instances = wordpoints_get_array_option( $this->option_name ); |
|
421 | + $instances = wordpoints_get_array_option($this->option_name); |
|
422 | 422 | break; |
423 | 423 | |
424 | 424 | case 'network': |
425 | - if ( is_multisite() ) { |
|
426 | - $instances = wordpoints_get_array_option( $this->option_name, 'site' ); |
|
425 | + if (is_multisite()) { |
|
426 | + $instances = wordpoints_get_array_option($this->option_name, 'site'); |
|
427 | 427 | } else { |
428 | 428 | $instances = array(); |
429 | 429 | } |
430 | 430 | break; |
431 | 431 | |
432 | 432 | case 'all': |
433 | - $instances = wordpoints_get_array_option( $this->option_name ); |
|
433 | + $instances = wordpoints_get_array_option($this->option_name); |
|
434 | 434 | |
435 | - if ( is_multisite() ) { |
|
436 | - foreach ( wordpoints_get_array_option( $this->option_name, 'site' ) as $number => $instance ) { |
|
437 | - $instances[ 'network_' . $number ] = $instance; |
|
435 | + if (is_multisite()) { |
|
436 | + foreach (wordpoints_get_array_option($this->option_name, 'site') as $number => $instance) { |
|
437 | + $instances['network_' . $number] = $instance; |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | break; |
441 | 441 | } |
442 | 442 | |
443 | - unset( $instances['__i__'] ); |
|
443 | + unset($instances['__i__']); |
|
444 | 444 | |
445 | 445 | return $instances; |
446 | 446 | } |
@@ -455,22 +455,22 @@ discard block |
||
455 | 455 | * @param array $new_instance The new instance of this hooks settings. |
456 | 456 | * @param int $number The ID number for this hook. |
457 | 457 | */ |
458 | - final public function update_callback( $new_instance, $number ) { |
|
458 | + final public function update_callback($new_instance, $number) { |
|
459 | 459 | |
460 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
460 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
461 | 461 | $type = 'network'; |
462 | 462 | } else { |
463 | 463 | $type = 'standard'; |
464 | 464 | } |
465 | 465 | |
466 | 466 | // Get all saved instances of this points hook. |
467 | - $all_instances = $this->get_instances( $type ); |
|
467 | + $all_instances = $this->get_instances($type); |
|
468 | 468 | |
469 | - $this->set_number( $number ); |
|
469 | + $this->set_number($number); |
|
470 | 470 | |
471 | - $old_instance = isset( $all_instances[ $this->number ] ) ? $all_instances[ $this->number ] : array(); |
|
471 | + $old_instance = isset($all_instances[$this->number]) ? $all_instances[$this->number] : array(); |
|
472 | 472 | |
473 | - $instance = $this->update( $new_instance, $old_instance ); |
|
473 | + $instance = $this->update($new_instance, $old_instance); |
|
474 | 474 | |
475 | 475 | /** |
476 | 476 | * Filter a points hook's settings before saving. |
@@ -486,13 +486,13 @@ discard block |
||
486 | 486 | * @param array $old_instance The old instance of the hook. |
487 | 487 | * @param WordPoints_Points_Hook $hook The hook object. |
488 | 488 | */ |
489 | - $instance = apply_filters( 'wordpoints_points_hook_update_callback', $instance, $new_instance, $old_instance, $this ); |
|
489 | + $instance = apply_filters('wordpoints_points_hook_update_callback', $instance, $new_instance, $old_instance, $this); |
|
490 | 490 | |
491 | - if ( false !== $instance ) { |
|
492 | - $all_instances[ $this->number ] = $instance; |
|
491 | + if (false !== $instance) { |
|
492 | + $all_instances[$this->number] = $instance; |
|
493 | 493 | } |
494 | 494 | |
495 | - $this->_save_instances( $all_instances ); |
|
495 | + $this->_save_instances($all_instances); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -502,24 +502,24 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @param string $hook_id The ID of the instance to delete. |
504 | 504 | */ |
505 | - final public function delete_callback( $hook_id ) { |
|
505 | + final public function delete_callback($hook_id) { |
|
506 | 506 | |
507 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
507 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
508 | 508 | $type = 'network'; |
509 | 509 | } else { |
510 | 510 | $type = 'standard'; |
511 | 511 | } |
512 | 512 | |
513 | 513 | // Get all saved instances of this points hook. |
514 | - $all_instances = $this->get_instances( $type ); |
|
514 | + $all_instances = $this->get_instances($type); |
|
515 | 515 | |
516 | - $number = $this->get_number_by_id( $hook_id ); |
|
516 | + $number = $this->get_number_by_id($hook_id); |
|
517 | 517 | |
518 | - if ( isset( $all_instances[ $number ] ) && $hook_id = $this->get_id( $number ) ) { |
|
518 | + if (isset($all_instances[$number]) && $hook_id = $this->get_id($number)) { |
|
519 | 519 | |
520 | - unset( $all_instances[ $number ] ); |
|
520 | + unset($all_instances[$number]); |
|
521 | 521 | |
522 | - $this->_save_instances( $all_instances ); |
|
522 | + $this->_save_instances($all_instances); |
|
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
@@ -532,27 +532,27 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return bool|void Whether the form was displayed. |
534 | 534 | */ |
535 | - final public function form_callback( $number ) { |
|
535 | + final public function form_callback($number) { |
|
536 | 536 | |
537 | - $this->set_number( $number ); |
|
537 | + $this->set_number($number); |
|
538 | 538 | |
539 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
539 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
540 | 540 | $type = 'network'; |
541 | 541 | } else { |
542 | 542 | $type = 'standard'; |
543 | 543 | } |
544 | 544 | |
545 | - $all_instances = $this->get_instances( $type ); |
|
545 | + $all_instances = $this->get_instances($type); |
|
546 | 546 | |
547 | - if ( 0 === $this->number || '0' === $this->number ) { |
|
547 | + if (0 === $this->number || '0' === $this->number) { |
|
548 | 548 | |
549 | 549 | // We echo out a form where 'number' can be set later. |
550 | - $this->set_number( '__i__' ); |
|
550 | + $this->set_number('__i__'); |
|
551 | 551 | $instance = array(); |
552 | 552 | |
553 | 553 | } else { |
554 | 554 | |
555 | - $instance = $all_instances[ $this->number ]; |
|
555 | + $instance = $all_instances[$this->number]; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | * @param array $instance The settings for this instance. |
566 | 566 | * @param WordPoints_Points_Hook $hook The hook object. |
567 | 567 | */ |
568 | - $instance = apply_filters( 'wordpoints_points_hook_form_callback', $instance, $this ); |
|
568 | + $instance = apply_filters('wordpoints_points_hook_form_callback', $instance, $this); |
|
569 | 569 | |
570 | - if ( false !== $instance ) { |
|
570 | + if (false !== $instance) { |
|
571 | 571 | |
572 | - $has_form = $this->form( $instance ); |
|
572 | + $has_form = $this->form($instance); |
|
573 | 573 | |
574 | 574 | /** |
575 | 575 | * Inside the points hook form. |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @param array $instance Settings for this instance. |
582 | 582 | * @param WordPoints_Points_Hook $hook The hook object. |
583 | 583 | */ |
584 | - do_action( 'wordpoints_in_points_hook_form', $has_form, $instance, $this ); |
|
584 | + do_action('wordpoints_in_points_hook_form', $has_form, $instance, $this); |
|
585 | 585 | |
586 | 586 | return $has_form; |
587 | 587 | } |
@@ -602,9 +602,9 @@ discard block |
||
602 | 602 | * |
603 | 603 | * @return string Name attribute for $field_name. |
604 | 604 | */ |
605 | - final public function get_field_name( $field_name ) { |
|
605 | + final public function get_field_name($field_name) { |
|
606 | 606 | |
607 | - return esc_attr( 'hook-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']' ); |
|
607 | + return esc_attr('hook-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | * |
617 | 617 | * @param string $field_name The field name. |
618 | 618 | */ |
619 | - final public function the_field_name( $field_name ) { |
|
619 | + final public function the_field_name($field_name) { |
|
620 | 620 | |
621 | - echo esc_attr( $this->get_field_name( $field_name ) ); |
|
621 | + echo esc_attr($this->get_field_name($field_name)); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -636,9 +636,9 @@ discard block |
||
636 | 636 | * |
637 | 637 | * @return string ID attribute for $field_name. |
638 | 638 | */ |
639 | - final public function get_field_id( $field_name ) { |
|
639 | + final public function get_field_id($field_name) { |
|
640 | 640 | |
641 | - return esc_attr( 'hook-' . $this->id_base . '-' . $this->number . '-' . $field_name ); |
|
641 | + return esc_attr('hook-' . $this->id_base . '-' . $this->number . '-' . $field_name); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | * |
651 | 651 | * @param string $field_name The field name. |
652 | 652 | */ |
653 | - final public function the_field_id( $field_name ) { |
|
653 | + final public function the_field_id($field_name) { |
|
654 | 654 | |
655 | - echo esc_attr( $this->get_field_id( $field_name ) ); |
|
655 | + echo esc_attr($this->get_field_id($field_name)); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -665,15 +665,15 @@ discard block |
||
665 | 665 | * |
666 | 666 | * @return string The hook's description. |
667 | 667 | */ |
668 | - final public function get_description( $type = 'any' ) { |
|
668 | + final public function get_description($type = 'any') { |
|
669 | 669 | |
670 | 670 | $instances = $this->get_instances(); |
671 | 671 | |
672 | - if ( 'generated' !== $type && ! empty( $instances[ $this->number ]['_description'] ) ) { |
|
673 | - return $instances[ $this->number ]['_description']; |
|
672 | + if ('generated' !== $type && ! empty($instances[$this->number]['_description'])) { |
|
673 | + return $instances[$this->number]['_description']; |
|
674 | 674 | } |
675 | 675 | |
676 | - $instance = ( isset( $instances[ $this->number ] ) ) ? $instances[ $this->number ] : array(); |
|
676 | + $instance = (isset($instances[$this->number])) ? $instances[$this->number] : array(); |
|
677 | 677 | |
678 | 678 | /** |
679 | 679 | * Filter the description for a points hook. |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | * @param WordPoints_Points_Hook $hook The points hook object. |
685 | 685 | * @param array $instance The settings for this instance. |
686 | 686 | */ |
687 | - return apply_filters( 'wordpoints_points_hook_description', $this->generate_description( $instance ), $this, $instance ); |
|
687 | + return apply_filters('wordpoints_points_hook_description', $this->generate_description($instance), $this, $instance); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
@@ -697,31 +697,31 @@ discard block |
||
697 | 697 | * |
698 | 698 | * @return string|false The type of points, or false if none found. |
699 | 699 | */ |
700 | - final public function points_type( $number = null ) { |
|
700 | + final public function points_type($number = null) { |
|
701 | 701 | |
702 | 702 | $network_mode = false; |
703 | 703 | |
704 | - if ( ! isset( $number ) ) { |
|
704 | + if ( ! isset($number)) { |
|
705 | 705 | |
706 | 706 | $number = $this->number; |
707 | 707 | |
708 | - } elseif ( is_string( $number ) && 'network_' === substr( $number, 0, 8 ) ) { |
|
708 | + } elseif (is_string($number) && 'network_' === substr($number, 0, 8)) { |
|
709 | 709 | |
710 | 710 | $network_mode = true; |
711 | - $number = (int) substr( $number, 8 ); |
|
711 | + $number = (int) substr($number, 8); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | $current_mode = WordPoints_Points_Hooks::get_network_mode(); |
715 | 715 | |
716 | - if ( $current_mode !== $network_mode ) { |
|
717 | - WordPoints_Points_Hooks::set_network_mode( $network_mode ); |
|
716 | + if ($current_mode !== $network_mode) { |
|
717 | + WordPoints_Points_Hooks::set_network_mode($network_mode); |
|
718 | 718 | } |
719 | 719 | |
720 | - $points_type = WordPoints_Points_Hooks::get_points_type( $this->get_id( $number ) ); |
|
720 | + $points_type = WordPoints_Points_Hooks::get_points_type($this->get_id($number)); |
|
721 | 721 | |
722 | 722 | // Reset network mode if it was changed. |
723 | - if ( $current_mode !== $network_mode ) { |
|
724 | - WordPoints_Points_Hooks::set_network_mode( $current_mode ); |
|
723 | + if ($current_mode !== $network_mode) { |
|
724 | + WordPoints_Points_Hooks::set_network_mode($current_mode); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | return $points_type; |
@@ -750,15 +750,15 @@ discard block |
||
750 | 750 | * overriding that function, you can ignore this option. |
751 | 751 | * } |
752 | 752 | */ |
753 | - final protected function init( $name, array $options = array() ) { |
|
753 | + final protected function init($name, array $options = array()) { |
|
754 | 754 | |
755 | - $this->id_base = strtolower( get_class( $this ) ); |
|
755 | + $this->id_base = strtolower(get_class($this)); |
|
756 | 756 | $this->name = $name; |
757 | 757 | $this->option_name = 'wordpoints_hook-' . $this->id_base; |
758 | 758 | |
759 | 759 | // Option names can only be 191 characters long. |
760 | - if ( isset( $this->option_name{191} ) ) { |
|
761 | - _doing_it_wrong( __METHOD__, sprintf( 'Points hook class names cannot be longer than 175 characters, %s is %s character(s) too long.', esc_html( $this->id_base ), (int) strlen( $this->id_base ) - 175 ), '1.5.0' ); |
|
760 | + if (isset($this->option_name{191} )) { |
|
761 | + _doing_it_wrong(__METHOD__, sprintf('Points hook class names cannot be longer than 175 characters, %s is %s character(s) too long.', esc_html($this->id_base), (int) strlen($this->id_base) - 175), '1.5.0'); |
|
762 | 762 | return; |
763 | 763 | } |
764 | 764 | |
@@ -766,12 +766,12 @@ discard block |
||
766 | 766 | array( |
767 | 767 | 'width' => 250, |
768 | 768 | 'description' => '', |
769 | - 'points_label' => __( 'Points:', 'wordpoints' ), |
|
769 | + 'points_label' => __('Points:', 'wordpoints'), |
|
770 | 770 | ) |
771 | 771 | , $options |
772 | 772 | ); |
773 | 773 | |
774 | - $this->options['_classname'] = $this->option_name; |
|
774 | + $this->options['_classname'] = $this->option_name; |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | // |
@@ -785,15 +785,15 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @param array $instances All settings, indexed by instance number. |
787 | 787 | */ |
788 | - final private function _save_instances( $instances ) { |
|
788 | + final private function _save_instances($instances) { |
|
789 | 789 | |
790 | 790 | // This needs to start at 1. |
791 | - unset( $instances[0] ); |
|
791 | + unset($instances[0]); |
|
792 | 792 | |
793 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
794 | - update_site_option( $this->option_name, $instances ); |
|
793 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
794 | + update_site_option($this->option_name, $instances); |
|
795 | 795 | } else { |
796 | - update_option( $this->option_name, $instances ); |
|
796 | + update_option($this->option_name, $instances); |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 |
@@ -263,7 +263,7 @@ |
||
263 | 263 | * |
264 | 264 | * @param string $arg The query arg whose value to retrieve. |
265 | 265 | * |
266 | - * @return mixed|void The query arg's value, or nothing if it isn't set. |
|
266 | + * @return string The query arg's value, or nothing if it isn't set. |
|
267 | 267 | */ |
268 | 268 | public function get_arg( $arg ) { |
269 | 269 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @type array $_fields |
40 | 40 | */ |
41 | - private $_fields = array( 'id', 'user_id', 'log_type', 'text', 'points', 'points_type', 'blog_id', 'site_id', 'date' ); |
|
41 | + private $_fields = array('id', 'user_id', 'log_type', 'text', 'points', 'points_type', 'blog_id', 'site_id', 'date'); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Whether the query is ready for execution. |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @type array $meta_query See WP_Meta_Query. |
221 | 221 | * } |
222 | 222 | */ |
223 | - public function __construct( $args = array() ) { |
|
223 | + public function __construct($args = array()) { |
|
224 | 224 | |
225 | 225 | global $wpdb; |
226 | 226 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | 'date_query' => null, |
253 | 253 | ); |
254 | 254 | |
255 | - $this->_args = wp_parse_args( $args, $defaults ); |
|
255 | + $this->_args = wp_parse_args($args, $defaults); |
|
256 | 256 | |
257 | 257 | } // public function __construct() |
258 | 258 | |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return mixed|void The query arg's value, or nothing if it isn't set. |
267 | 267 | */ |
268 | - public function get_arg( $arg ) { |
|
268 | + public function get_arg($arg) { |
|
269 | 269 | |
270 | - if ( isset( $this->_args[ $arg ] ) ) { |
|
271 | - return $this->_args[ $arg ]; |
|
270 | + if (isset($this->_args[$arg])) { |
|
271 | + return $this->_args[$arg]; |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @param array $args A list of arguments to set and their values. |
281 | 281 | */ |
282 | - public function set_args( array $args ) { |
|
282 | + public function set_args(array $args) { |
|
283 | 283 | |
284 | - $this->_args = array_merge( $this->_args, $args ); |
|
284 | + $this->_args = array_merge($this->_args, $args); |
|
285 | 285 | |
286 | 286 | $this->_query_ready = false; |
287 | 287 | $this->_cache_query_hash = null; |
@@ -303,20 +303,20 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function count() { |
305 | 305 | |
306 | - if ( $this->_is_cached_query ) { |
|
307 | - $cache = $this->_cache_get( 'count' ); |
|
306 | + if ($this->_is_cached_query) { |
|
307 | + $cache = $this->_cache_get('count'); |
|
308 | 308 | |
309 | - if ( false !== $cache ) { |
|
309 | + if (false !== $cache) { |
|
310 | 310 | return $cache; |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | $this->_select_type = 'SELECT COUNT'; |
315 | 315 | |
316 | - $count = (int) $this->_get( 'var' ); |
|
316 | + $count = (int) $this->_get('var'); |
|
317 | 317 | |
318 | - if ( $this->_is_cached_query ) { |
|
319 | - $this->_cache_set( $count, 'count' ); |
|
318 | + if ($this->_is_cached_query) { |
|
319 | + $this->_cache_set($count, 'count'); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return $count; |
@@ -334,34 +334,34 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return mixed The results of the query, or false on failure. |
336 | 336 | */ |
337 | - public function get( $method = 'results' ) { |
|
337 | + public function get($method = 'results') { |
|
338 | 338 | |
339 | - $methods = array( 'results', 'row', 'col', 'var' ); |
|
339 | + $methods = array('results', 'row', 'col', 'var'); |
|
340 | 340 | |
341 | - if ( ! in_array( $method, $methods ) ) { |
|
341 | + if ( ! in_array($method, $methods)) { |
|
342 | 342 | |
343 | - _doing_it_wrong( __METHOD__, esc_html( sprintf( 'WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode( ', ', $methods ) ) ), '1.0.0' ); |
|
343 | + _doing_it_wrong(__METHOD__, esc_html(sprintf('WordPoints Debug Error: invalid get method %s, possible values are %s', $method, implode(', ', $methods))), '1.0.0'); |
|
344 | 344 | |
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | - if ( $this->_is_cached_query ) { |
|
349 | - $cache = $this->_cache_get( "get_{$method}" ); |
|
348 | + if ($this->_is_cached_query) { |
|
349 | + $cache = $this->_cache_get("get_{$method}"); |
|
350 | 350 | |
351 | - if ( false !== $cache ) { |
|
351 | + if (false !== $cache) { |
|
352 | 352 | return $cache; |
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | $this->_select_type = 'SELECT'; |
357 | 357 | |
358 | - $result = $this->_get( $method ); |
|
358 | + $result = $this->_get($method); |
|
359 | 359 | |
360 | - if ( $this->_is_cached_query ) { |
|
361 | - $this->_cache_set( $result, "get_{$method}" ); |
|
360 | + if ($this->_is_cached_query) { |
|
361 | + $this->_cache_set($result, "get_{$method}"); |
|
362 | 362 | |
363 | - if ( 'results' === $method || 'col' === $method ) { |
|
364 | - $this->_cache_set( count( $result ), 'count' ); |
|
363 | + if ('results' === $method || 'col' === $method) { |
|
364 | + $this->_cache_set(count($result), 'count'); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
@@ -388,20 +388,20 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @return object[]|false The logs for this page, or false if $page or $per_page is invalid. |
390 | 390 | */ |
391 | - public function get_page( $page, $per_page = 25 ) { |
|
391 | + public function get_page($page, $per_page = 25) { |
|
392 | 392 | |
393 | - if ( ! wordpoints_posint( $page ) || ! wordpoints_posint( $per_page ) ) { |
|
393 | + if ( ! wordpoints_posint($page) || ! wordpoints_posint($per_page)) { |
|
394 | 394 | return false; |
395 | 395 | } |
396 | 396 | |
397 | - $start = ( $page - 1 ) * $per_page; |
|
397 | + $start = ($page - 1) * $per_page; |
|
398 | 398 | |
399 | 399 | // First try the main cache. |
400 | - if ( $this->_is_cached_query ) { |
|
400 | + if ($this->_is_cached_query) { |
|
401 | 401 | |
402 | - $cache = $this->_cache_get( 'get_results' ); |
|
402 | + $cache = $this->_cache_get('get_results'); |
|
403 | 403 | |
404 | - if ( false !== $cache ) { |
|
404 | + if (false !== $cache) { |
|
405 | 405 | return array_slice( |
406 | 406 | $cache |
407 | 407 | , $start - $this->_args['start'] |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | |
416 | 416 | $this->_args['start'] += $start; |
417 | 417 | |
418 | - if ( $this->_args['limit'] ) { |
|
418 | + if ($this->_args['limit']) { |
|
419 | 419 | $this->_args['limit'] -= $start; |
420 | 420 | } |
421 | 421 | |
422 | - if ( ! $this->_args['limit'] || $this->_args['limit'] > $per_page ) { |
|
422 | + if ( ! $this->_args['limit'] || $this->_args['limit'] > $per_page) { |
|
423 | 423 | $this->_args['limit'] = $per_page; |
424 | 424 | } |
425 | 425 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | $this->_select_type = 'SELECT'; |
430 | 430 | |
431 | - unset( $this->_cache_query_hash ); |
|
431 | + unset($this->_cache_query_hash); |
|
432 | 432 | |
433 | 433 | $results = $this->get(); |
434 | 434 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $this->_limit = ''; |
440 | 440 | $this->_prepare_limit(); |
441 | 441 | |
442 | - unset( $this->_cache_query_hash ); |
|
442 | + unset($this->_cache_query_hash); |
|
443 | 443 | |
444 | 444 | return $results; |
445 | 445 | } |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return string The SQL for the query. |
462 | 462 | */ |
463 | - public function get_sql( $select_type = null ) { |
|
463 | + public function get_sql($select_type = null) { |
|
464 | 464 | |
465 | - if ( isset( $select_type ) ) { |
|
465 | + if (isset($select_type)) { |
|
466 | 466 | $this->_select_type = $select_type; |
467 | 467 | } |
468 | 468 | |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | * @param string $deprecated Deprecated; no longer used. |
513 | 513 | * @param bool $network Whether this is a network-wide query. |
514 | 514 | */ |
515 | - public function prime_cache( $key = 'default:%points_type%', $deprecated = null, $network = false ) { |
|
515 | + public function prime_cache($key = 'default:%points_type%', $deprecated = null, $network = false) { |
|
516 | 516 | |
517 | - if ( ! is_null( $deprecated ) ) { |
|
517 | + if ( ! is_null($deprecated)) { |
|
518 | 518 | _deprecated_argument( |
519 | 519 | __METHOD__ |
520 | 520 | , '1.9.0' |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | , $key |
537 | 537 | ); |
538 | 538 | |
539 | - if ( $network ) { |
|
539 | + if ($network) { |
|
540 | 540 | $this->_cache_group = 'wordpoints_network_points_logs_query'; |
541 | 541 | } else { |
542 | 542 | $this->_cache_group = 'wordpoints_points_logs_query'; |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | * |
557 | 557 | * @return string[] The valid columns. |
558 | 558 | */ |
559 | - public function date_query_valid_columns_filter( $valid_columns ) { |
|
559 | + public function date_query_valid_columns_filter($valid_columns) { |
|
560 | 560 | |
561 | 561 | $valid_columns[] = 'date'; |
562 | 562 | |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | * |
573 | 573 | * @return string The correct meta table ID column, if the key is wordpoints_points_log_. |
574 | 574 | */ |
575 | - public function meta_query_meta_table_id_filter( $key ) { |
|
575 | + public function meta_query_meta_table_id_filter($key) { |
|
576 | 576 | |
577 | - if ( 'wordpoints_points_log__id' === $key ) { |
|
577 | + if ('wordpoints_points_log__id' === $key) { |
|
578 | 578 | $key = 'log_id'; |
579 | 579 | } |
580 | 580 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | |
599 | 599 | $this->_prepare_query(); |
600 | 600 | |
601 | - $select = ( 'SELECT COUNT' === $this->_select_type ) ? $this->_select_count : $this->_select; |
|
601 | + $select = ('SELECT COUNT' === $this->_select_type) ? $this->_select_count : $this->_select; |
|
602 | 602 | |
603 | 603 | return $select |
604 | 604 | . "\nFROM `{$wpdb->wordpoints_points_logs}`\n" |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | * |
620 | 620 | * @return mixed The query results. |
621 | 621 | */ |
622 | - private function _get( $method ) { |
|
622 | + private function _get($method) { |
|
623 | 623 | |
624 | 624 | global $wpdb; |
625 | 625 | |
626 | 626 | $get = "get_{$method}"; |
627 | 627 | |
628 | - return $wpdb->$get( $this->_get_sql() ); |
|
628 | + return $wpdb->$get($this->_get_sql()); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -638,29 +638,29 @@ discard block |
||
638 | 638 | * |
639 | 639 | * @return mixed Cached value, or false if none. |
640 | 640 | */ |
641 | - private function _cache_get( $type = null ) { |
|
641 | + private function _cache_get($type = null) { |
|
642 | 642 | |
643 | - $cache = wp_cache_get( $this->_cache_key, $this->_cache_group ); |
|
643 | + $cache = wp_cache_get($this->_cache_key, $this->_cache_group); |
|
644 | 644 | |
645 | - if ( ! is_array( $cache ) ) { |
|
645 | + if ( ! is_array($cache)) { |
|
646 | 646 | return false; |
647 | 647 | } |
648 | 648 | |
649 | 649 | $this->_calc_cache_query_hash(); |
650 | 650 | |
651 | - if ( ! isset( $cache[ $this->_cache_query_hash ] ) ) { |
|
651 | + if ( ! isset($cache[$this->_cache_query_hash])) { |
|
652 | 652 | return false; |
653 | 653 | } |
654 | 654 | |
655 | - if ( isset( $type ) ) { |
|
656 | - if ( isset( $cache[ $this->_cache_query_hash ][ $type ] ) ) { |
|
657 | - return $cache[ $this->_cache_query_hash ][ $type ]; |
|
655 | + if (isset($type)) { |
|
656 | + if (isset($cache[$this->_cache_query_hash][$type])) { |
|
657 | + return $cache[$this->_cache_query_hash][$type]; |
|
658 | 658 | } else { |
659 | 659 | return false; |
660 | 660 | } |
661 | 661 | } |
662 | 662 | |
663 | - return $cache[ $this->_cache_query_hash ]; |
|
663 | + return $cache[$this->_cache_query_hash]; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -672,26 +672,26 @@ discard block |
||
672 | 672 | * @param string $type Optionally specify a results type to cache. Default is |
673 | 673 | * null, or all types. |
674 | 674 | */ |
675 | - private function _cache_set( $value, $type = null ) { |
|
675 | + private function _cache_set($value, $type = null) { |
|
676 | 676 | |
677 | - $cache = wp_cache_get( $this->_cache_key, $this->_cache_group ); |
|
677 | + $cache = wp_cache_get($this->_cache_key, $this->_cache_group); |
|
678 | 678 | |
679 | 679 | $this->_calc_cache_query_hash(); |
680 | 680 | |
681 | 681 | if ( |
682 | - ! isset( $cache[ $this->_cache_query_hash ] ) |
|
683 | - || ! is_array( $cache[ $this->_cache_query_hash ] ) |
|
682 | + ! isset($cache[$this->_cache_query_hash]) |
|
683 | + || ! is_array($cache[$this->_cache_query_hash]) |
|
684 | 684 | ) { |
685 | - $cache[ $this->_cache_query_hash ] = array(); |
|
685 | + $cache[$this->_cache_query_hash] = array(); |
|
686 | 686 | } |
687 | 687 | |
688 | - if ( isset( $type ) ) { |
|
689 | - $cache[ $this->_cache_query_hash ][ $type ] = $value; |
|
688 | + if (isset($type)) { |
|
689 | + $cache[$this->_cache_query_hash][$type] = $value; |
|
690 | 690 | } else { |
691 | - $cache[ $this->_cache_query_hash ] = $value; |
|
691 | + $cache[$this->_cache_query_hash] = $value; |
|
692 | 692 | } |
693 | 693 | |
694 | - wp_cache_set( $this->_cache_key, $cache, $this->_cache_group ); |
|
694 | + wp_cache_set($this->_cache_key, $cache, $this->_cache_group); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | */ |
702 | 702 | private function _calc_cache_query_hash() { |
703 | 703 | |
704 | - if ( ! isset( $this->_cache_query_hash ) ) { |
|
705 | - $this->_cache_query_hash = wordpoints_hash( $this->get_sql() ); |
|
704 | + if ( ! isset($this->_cache_query_hash)) { |
|
705 | + $this->_cache_query_hash = wordpoints_hash($this->get_sql()); |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | */ |
714 | 714 | private function _prepare_query() { |
715 | 715 | |
716 | - if ( ! $this->_query_ready ) { |
|
716 | + if ( ! $this->_query_ready) { |
|
717 | 717 | |
718 | 718 | $this->_prepare_select(); |
719 | 719 | $this->_prepare_where(); |
@@ -734,22 +734,22 @@ discard block |
||
734 | 734 | // Pull all fields by default. |
735 | 735 | $fields = $this->_fields; |
736 | 736 | |
737 | - if ( 'all' !== $this->_args['fields'] ) { |
|
737 | + if ('all' !== $this->_args['fields']) { |
|
738 | 738 | |
739 | 739 | $_fields = (array) $this->_args['fields']; |
740 | - $diff = array_diff( $_fields, $this->_fields ); |
|
741 | - $_fields = array_intersect( $this->_fields, $_fields ); |
|
740 | + $diff = array_diff($_fields, $this->_fields); |
|
741 | + $_fields = array_intersect($this->_fields, $_fields); |
|
742 | 742 | |
743 | - if ( ! empty( $diff ) ) { |
|
744 | - _doing_it_wrong( __METHOD__, esc_html( 'WordPoints Debug Error: invalid field(s) "' . implode( '", "', $diff ) . '" given' ), '1.0.0' ); |
|
743 | + if ( ! empty($diff)) { |
|
744 | + _doing_it_wrong(__METHOD__, esc_html('WordPoints Debug Error: invalid field(s) "' . implode('", "', $diff) . '" given'), '1.0.0'); |
|
745 | 745 | } |
746 | 746 | |
747 | - if ( ! empty( $_fields ) ) { |
|
747 | + if ( ! empty($_fields)) { |
|
748 | 748 | $fields = $_fields; |
749 | 749 | } |
750 | 750 | } |
751 | 751 | |
752 | - $fields = '`' . implode( '`, `', $fields ) . '`'; |
|
752 | + $fields = '`' . implode('`, `', $fields) . '`'; |
|
753 | 753 | |
754 | 754 | $this->_select = "SELECT {$fields}"; |
755 | 755 | } |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | |
764 | 764 | $this->_wheres = array(); |
765 | 765 | |
766 | - $this->_prepare_posint__in( $this->_args['id__in'], 'id' ); |
|
767 | - $this->_prepare_posint__in( $this->_args['id__not_in'], 'id', 'NOT IN' ); |
|
766 | + $this->_prepare_posint__in($this->_args['id__in'], 'id'); |
|
767 | + $this->_prepare_posint__in($this->_args['id__not_in'], 'id', 'NOT IN'); |
|
768 | 768 | $this->_prepare_user_where(); |
769 | 769 | $this->_prepare_points_type_where(); |
770 | 770 | $this->_prepare_log_type_where(); |
@@ -774,9 +774,9 @@ discard block |
||
774 | 774 | $this->_prepare_date_where(); |
775 | 775 | $this->_prepare_meta_where(); |
776 | 776 | |
777 | - if ( ! empty( $this->_wheres ) ) { |
|
777 | + if ( ! empty($this->_wheres)) { |
|
778 | 778 | |
779 | - $this->_where = 'WHERE ' . implode( ' AND ', $this->_wheres ) . "\n"; |
|
779 | + $this->_where = 'WHERE ' . implode(' AND ', $this->_wheres) . "\n"; |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | } // function _prepare_where() |
@@ -790,31 +790,31 @@ discard block |
||
790 | 790 | */ |
791 | 791 | private function _prepare_limit() { |
792 | 792 | |
793 | - if ( ! isset( $this->_args['limit'] ) ) { |
|
793 | + if ( ! isset($this->_args['limit'])) { |
|
794 | 794 | return; |
795 | 795 | } |
796 | 796 | |
797 | - foreach ( array( 'limit', 'start' ) as $var ) { |
|
797 | + foreach (array('limit', 'start') as $var) { |
|
798 | 798 | |
799 | - $_var = $this->_args[ $var ]; |
|
799 | + $_var = $this->_args[$var]; |
|
800 | 800 | |
801 | - if ( false === wordpoints_int( $this->_args[ $var ] ) ) { |
|
801 | + if (false === wordpoints_int($this->_args[$var])) { |
|
802 | 802 | |
803 | 803 | _doing_it_wrong( |
804 | 804 | __METHOD__ |
805 | 805 | , sprintf( |
806 | 806 | "WordPoints Debug Error: '%s' must be a positive integer, %s given" |
807 | - , esc_html( $var ) |
|
808 | - , esc_html( strval( $_var ) ? $_var : gettype( $_var ) ) |
|
807 | + , esc_html($var) |
|
808 | + , esc_html(strval($_var) ? $_var : gettype($_var)) |
|
809 | 809 | ) |
810 | 810 | , '1.0.0' |
811 | 811 | ); |
812 | 812 | |
813 | - $this->_args[ $var ] = 0; |
|
813 | + $this->_args[$var] = 0; |
|
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | - if ( $this->_args['limit'] > 0 && $this->_args['start'] >= 0 ) { |
|
817 | + if ($this->_args['limit'] > 0 && $this->_args['start'] >= 0) { |
|
818 | 818 | $this->_limit = "LIMIT {$this->_args['start']}, {$this->_args['limit']}"; |
819 | 819 | } |
820 | 820 | } |
@@ -833,21 +833,21 @@ discard block |
||
833 | 833 | $order = $this->_args['order']; |
834 | 834 | $order_by = $this->_args['orderby']; |
835 | 835 | |
836 | - if ( 'none' === $order_by ) { |
|
836 | + if ('none' === $order_by) { |
|
837 | 837 | return; |
838 | 838 | } |
839 | 839 | |
840 | - if ( ! in_array( $order, array( 'DESC', 'ASC' ) ) ) { |
|
840 | + if ( ! in_array($order, array('DESC', 'ASC'))) { |
|
841 | 841 | |
842 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC" ), '1.0.0' ); |
|
842 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'order' \"{$order}\", possible values are DESC and ASC"), '1.0.0'); |
|
843 | 843 | $order = 'DESC'; |
844 | 844 | } |
845 | 845 | |
846 | - if ( 'meta_value' === $order_by ) { |
|
846 | + if ('meta_value' === $order_by) { |
|
847 | 847 | |
848 | - if ( isset( $this->_args['meta_type'] ) ) { |
|
848 | + if (isset($this->_args['meta_type'])) { |
|
849 | 849 | |
850 | - $meta_type = $this->meta_query->get_cast_for_type( $this->_args['meta_type'] ); |
|
850 | + $meta_type = $this->meta_query->get_cast_for_type($this->_args['meta_type']); |
|
851 | 851 | $order_by = "CAST({$wpdb->wordpoints_points_log_meta}.meta_value AS {$meta_type})"; |
852 | 852 | |
853 | 853 | } else { |
@@ -855,9 +855,9 @@ discard block |
||
855 | 855 | $order_by = "{$wpdb->wordpoints_points_log_meta}.meta_value"; |
856 | 856 | } |
857 | 857 | |
858 | - } elseif ( ! in_array( $order_by, $this->_fields ) ) { |
|
858 | + } elseif ( ! in_array($order_by, $this->_fields)) { |
|
859 | 859 | |
860 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'orderby' \"{$order_by}\", possible values are " . implode( ', ', $this->_fields ) ), '1.0.0' ); |
|
860 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'orderby' \"{$order_by}\", possible values are " . implode(', ', $this->_fields)), '1.0.0'); |
|
861 | 861 | return; |
862 | 862 | } |
863 | 863 | |
@@ -876,13 +876,13 @@ discard block |
||
876 | 876 | * @param string $type The type of IN condition: 'IN' or 'NOT IN'. |
877 | 877 | * @param string $format The format for the values in $_in ('%s', '%d', '%f'). |
878 | 878 | */ |
879 | - private function _prepare__in( $_in, $column, $type = 'IN', $format = '%s' ) { |
|
879 | + private function _prepare__in($_in, $column, $type = 'IN', $format = '%s') { |
|
880 | 880 | |
881 | - if ( ! empty( $_in ) ) { |
|
881 | + if ( ! empty($_in)) { |
|
882 | 882 | |
883 | - $in = wordpoints_prepare__in( $_in, $format ); |
|
883 | + $in = wordpoints_prepare__in($_in, $format); |
|
884 | 884 | |
885 | - if ( $in ) { |
|
885 | + if ($in) { |
|
886 | 886 | $this->_wheres[] = "{$column} {$type} ({$in})"; |
887 | 887 | } |
888 | 888 | } |
@@ -899,10 +899,10 @@ discard block |
||
899 | 899 | * @param string $column The column to search. |
900 | 900 | * @param string $type The type of IN condition: 'IN' or 'NOT IN'. |
901 | 901 | */ |
902 | - private function _prepare_posint__in( $in, $column, $type = 'IN' ) { |
|
902 | + private function _prepare_posint__in($in, $column, $type = 'IN') { |
|
903 | 903 | |
904 | - $in = array_filter( array_map( 'wordpoints_posint', $in ) ); |
|
905 | - $this->_prepare__in( $in, $column, $type, '%d' ); |
|
904 | + $in = array_filter(array_map('wordpoints_posint', $in)); |
|
905 | + $this->_prepare__in($in, $column, $type, '%d'); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -914,14 +914,14 @@ discard block |
||
914 | 914 | |
915 | 915 | global $wpdb; |
916 | 916 | |
917 | - if ( wordpoints_posint( $this->_args['user_id'] ) ) { |
|
917 | + if (wordpoints_posint($this->_args['user_id'])) { |
|
918 | 918 | |
919 | - $this->_wheres[] = $wpdb->prepare( '`user_id` = %d', $this->_args['user_id'] ); |
|
919 | + $this->_wheres[] = $wpdb->prepare('`user_id` = %d', $this->_args['user_id']); |
|
920 | 920 | |
921 | 921 | } else { |
922 | 922 | |
923 | - $this->_prepare_posint__in( $this->_args['user__in'], 'user_id' ); |
|
924 | - $this->_prepare_posint__in( $this->_args['user__not_in'], 'user_id', 'NOT IN' ); |
|
923 | + $this->_prepare_posint__in($this->_args['user__in'], 'user_id'); |
|
924 | + $this->_prepare_posint__in($this->_args['user__not_in'], 'user_id', 'NOT IN'); |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
@@ -934,22 +934,22 @@ discard block |
||
934 | 934 | |
935 | 935 | global $wpdb; |
936 | 936 | |
937 | - if ( wordpoints_is_points_type( $this->_args['points_type'] ) ) { |
|
937 | + if (wordpoints_is_points_type($this->_args['points_type'])) { |
|
938 | 938 | |
939 | - $this->_wheres[] = $wpdb->prepare( '`points_type` = %s', $this->_args['points_type'] ); |
|
939 | + $this->_wheres[] = $wpdb->prepare('`points_type` = %s', $this->_args['points_type']); |
|
940 | 940 | |
941 | 941 | } else { |
942 | 942 | |
943 | - $points_types = array_keys( wordpoints_get_points_types() ); |
|
943 | + $points_types = array_keys(wordpoints_get_points_types()); |
|
944 | 944 | |
945 | - if ( is_array( $this->_args['points_type__in'] ) ) { |
|
945 | + if (is_array($this->_args['points_type__in'])) { |
|
946 | 946 | |
947 | - $this->_prepare__in( array_intersect( $this->_args['points_type__in'], $points_types ), 'points_type' ); |
|
947 | + $this->_prepare__in(array_intersect($this->_args['points_type__in'], $points_types), 'points_type'); |
|
948 | 948 | } |
949 | 949 | |
950 | - if ( is_array( $this->_args['points_type__not_in'] ) ) { |
|
950 | + if (is_array($this->_args['points_type__not_in'])) { |
|
951 | 951 | |
952 | - $this->_prepare__in( array_intersect( $this->_args['points_type__not_in'], $points_types ), 'points_type', 'NOT IN' ); |
|
952 | + $this->_prepare__in(array_intersect($this->_args['points_type__not_in'], $points_types), 'points_type', 'NOT IN'); |
|
953 | 953 | } |
954 | 954 | } |
955 | 955 | } |
@@ -963,14 +963,14 @@ discard block |
||
963 | 963 | |
964 | 964 | global $wpdb; |
965 | 965 | |
966 | - if ( ! empty( $this->_args['log_type'] ) ) { |
|
966 | + if ( ! empty($this->_args['log_type'])) { |
|
967 | 967 | |
968 | - $this->_wheres[] = $wpdb->prepare( '`log_type` = %s', $this->_args['log_type'] ); |
|
968 | + $this->_wheres[] = $wpdb->prepare('`log_type` = %s', $this->_args['log_type']); |
|
969 | 969 | |
970 | 970 | } else { |
971 | 971 | |
972 | - $this->_prepare__in( $this->_args['log_type__in'], 'log_type' ); |
|
973 | - $this->_prepare__in( $this->_args['log_type__not_in'], 'log_type', 'NOT IN' ); |
|
972 | + $this->_prepare__in($this->_args['log_type__in'], 'log_type'); |
|
973 | + $this->_prepare__in($this->_args['log_type__not_in'], 'log_type', 'NOT IN'); |
|
974 | 974 | } |
975 | 975 | } |
976 | 976 | |
@@ -983,26 +983,26 @@ discard block |
||
983 | 983 | |
984 | 984 | global $wpdb; |
985 | 985 | |
986 | - if ( ! isset( $this->_args['points'] ) ) { |
|
986 | + if ( ! isset($this->_args['points'])) { |
|
987 | 987 | return; |
988 | 988 | } |
989 | 989 | |
990 | 990 | $_points = $this->_args['points']; |
991 | 991 | |
992 | - if ( ! wordpoints_int( $this->_args['points'] ) ) { |
|
993 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: 'points' must be an integer, " . gettype( $_points ) . ' given' ), '1.0.0' ); |
|
992 | + if ( ! wordpoints_int($this->_args['points'])) { |
|
993 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: 'points' must be an integer, " . gettype($_points) . ' given'), '1.0.0'); |
|
994 | 994 | return; |
995 | 995 | } |
996 | 996 | |
997 | - $comparisons = array( '=', '<', '>', '<>', '!=', '<=', '>=' ); |
|
997 | + $comparisons = array('=', '<', '>', '<>', '!=', '<=', '>='); |
|
998 | 998 | |
999 | - if ( ! in_array( $this->_args['points__compare'], $comparisons ) ) { |
|
999 | + if ( ! in_array($this->_args['points__compare'], $comparisons)) { |
|
1000 | 1000 | |
1001 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'points__compare' {$this->_args['points__compare']}, possible values are " . implode( ', ', $comparisons ) ), '1.0.0' ); |
|
1001 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'points__compare' {$this->_args['points__compare']}, possible values are " . implode(', ', $comparisons)), '1.0.0'); |
|
1002 | 1002 | $this->_args['points__compare'] = '='; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - $this->_wheres[] = $wpdb->prepare( "`points` {$this->_args['points__compare']} %d", $this->_args['points'] ); // WPCS: unprepared SQL OK |
|
1005 | + $this->_wheres[] = $wpdb->prepare("`points` {$this->_args['points__compare']} %d", $this->_args['points']); // WPCS: unprepared SQL OK |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
@@ -1014,19 +1014,19 @@ discard block |
||
1014 | 1014 | |
1015 | 1015 | global $wpdb; |
1016 | 1016 | |
1017 | - if ( empty( $this->_args['text'] ) ) { |
|
1017 | + if (empty($this->_args['text'])) { |
|
1018 | 1018 | return; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - $comparisons = array( '=', '<>', '!=', 'LIKE', 'NOT LIKE' ); |
|
1021 | + $comparisons = array('=', '<>', '!=', 'LIKE', 'NOT LIKE'); |
|
1022 | 1022 | |
1023 | - if ( ! in_array( $this->_args['text__compare'], $comparisons ) ) { |
|
1023 | + if ( ! in_array($this->_args['text__compare'], $comparisons)) { |
|
1024 | 1024 | |
1025 | - _doing_it_wrong( __METHOD__, esc_html( "WordPoints Debug Error: invalid 'text__compare' {$this->_args['text__compare']}, possible values are " . implode( ', ', $comparisons ) ), '1.6.0' ); |
|
1025 | + _doing_it_wrong(__METHOD__, esc_html("WordPoints Debug Error: invalid 'text__compare' {$this->_args['text__compare']}, possible values are " . implode(', ', $comparisons)), '1.6.0'); |
|
1026 | 1026 | $this->_args['text__compare'] = '='; |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - $this->_wheres[] = $wpdb->prepare( "`text` {$this->_args['text__compare']} %s", $this->_args['text'] ); // WPCS: unprepared SQL OK |
|
1029 | + $this->_wheres[] = $wpdb->prepare("`text` {$this->_args['text__compare']} %s", $this->_args['text']); // WPCS: unprepared SQL OK |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | /** |
@@ -1038,22 +1038,22 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | global $wpdb; |
1040 | 1040 | |
1041 | - if ( ! is_multisite() ) { |
|
1041 | + if ( ! is_multisite()) { |
|
1042 | 1042 | return; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - if ( wordpoints_posint( $this->_args['site_id'] ) ) { |
|
1046 | - $this->_wheres[] = $wpdb->prepare( '`site_id` = %d', $this->_args['site_id'] ); |
|
1045 | + if (wordpoints_posint($this->_args['site_id'])) { |
|
1046 | + $this->_wheres[] = $wpdb->prepare('`site_id` = %d', $this->_args['site_id']); |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | - if ( ! empty( $this->_args['blog__in'] ) || ! empty( $this->_args['blog__not_in'] ) ) { |
|
1049 | + if ( ! empty($this->_args['blog__in']) || ! empty($this->_args['blog__not_in'])) { |
|
1050 | 1050 | |
1051 | - $this->_prepare_posint__in( $this->_args['blog__in'], 'blog_id' ); |
|
1052 | - $this->_prepare_posint__in( $this->_args['blog__not_in'], 'blog_id', 'NOT IN' ); |
|
1051 | + $this->_prepare_posint__in($this->_args['blog__in'], 'blog_id'); |
|
1052 | + $this->_prepare_posint__in($this->_args['blog__not_in'], 'blog_id', 'NOT IN'); |
|
1053 | 1053 | |
1054 | - } elseif ( wordpoints_posint( $this->_args['blog_id'] ) ) { |
|
1054 | + } elseif (wordpoints_posint($this->_args['blog_id'])) { |
|
1055 | 1055 | |
1056 | - $this->_wheres[] = $wpdb->prepare( '`blog_id` = %d', $this->_args['blog_id'] ); |
|
1056 | + $this->_wheres[] = $wpdb->prepare('`blog_id` = %d', $this->_args['blog_id']); |
|
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | |
@@ -1064,21 +1064,21 @@ discard block |
||
1064 | 1064 | */ |
1065 | 1065 | private function _prepare_date_where() { |
1066 | 1066 | |
1067 | - if ( empty( $this->_args['date_query'] ) || ! is_array( $this->_args['date_query'] ) ) { |
|
1067 | + if (empty($this->_args['date_query']) || ! is_array($this->_args['date_query'])) { |
|
1068 | 1068 | return; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - add_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
1071 | + add_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
1072 | 1072 | |
1073 | - $date_query = new WP_Date_Query( $this->_args['date_query'], 'date' ); |
|
1073 | + $date_query = new WP_Date_Query($this->_args['date_query'], 'date'); |
|
1074 | 1074 | $date_query = $date_query->get_sql(); |
1075 | 1075 | |
1076 | - if ( ! empty( $date_query ) ) { |
|
1076 | + if ( ! empty($date_query)) { |
|
1077 | 1077 | |
1078 | - $this->_wheres[] = ltrim( $date_query, ' AND' ); |
|
1078 | + $this->_wheres[] = ltrim($date_query, ' AND'); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | - remove_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
|
1081 | + remove_filter('date_query_valid_columns', array($this, 'date_query_valid_columns_filter')); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | /** |
@@ -1101,19 +1101,19 @@ discard block |
||
1101 | 1101 | ) |
1102 | 1102 | ); |
1103 | 1103 | |
1104 | - if ( empty( $meta_args ) ) { |
|
1104 | + if (empty($meta_args)) { |
|
1105 | 1105 | return; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | $this->meta_query = new WP_Meta_Query(); |
1109 | - $this->meta_query->parse_query_vars( $meta_args ); |
|
1109 | + $this->meta_query->parse_query_vars($meta_args); |
|
1110 | 1110 | |
1111 | - add_filter( 'sanitize_key', array( $this, 'meta_query_meta_table_id_filter' ) ); |
|
1112 | - $meta_query = $this->meta_query->get_sql( 'wordpoints_points_log_', $wpdb->wordpoints_points_logs, 'id', $this ); |
|
1113 | - remove_filter( 'sanitize_key', array( $this, 'meta_query_meta_table_id_filter' ) ); |
|
1111 | + add_filter('sanitize_key', array($this, 'meta_query_meta_table_id_filter')); |
|
1112 | + $meta_query = $this->meta_query->get_sql('wordpoints_points_log_', $wpdb->wordpoints_points_logs, 'id', $this); |
|
1113 | + remove_filter('sanitize_key', array($this, 'meta_query_meta_table_id_filter')); |
|
1114 | 1114 | |
1115 | - if ( ! empty( $meta_query['where'] ) ) { |
|
1116 | - $this->_wheres[] = ltrim( $meta_query['where'], ' AND' ); |
|
1115 | + if ( ! empty($meta_query['where'])) { |
|
1116 | + $this->_wheres[] = ltrim($meta_query['where'], ' AND'); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | $this->_meta_join = $meta_query['join'] . "\n"; |
@@ -421,7 +421,7 @@ |
||
421 | 421 | * @since 2.0.0 |
422 | 422 | * |
423 | 423 | * @param string $key The log meta key to match on. |
424 | - * @param mixed $value The log meta value to match on. |
|
424 | + * @param integer $value The log meta value to match on. |
|
425 | 425 | * @param string $new_key The key for the new meta value to add. |
426 | 426 | * @param mixed $new_value The new meta value to add. If falsey, new meta isn't added. |
427 | 427 | */ |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @since 1.9.0 |
43 | 43 | */ |
44 | - public function __construct( $title, $args ) { |
|
44 | + public function __construct($title, $args) { |
|
45 | 45 | |
46 | - $this->init( $title, $args ); |
|
46 | + $this->init($title, $args); |
|
47 | 47 | |
48 | - add_filter( "wordpoints_points_log-{$this->log_type}", array( $this, 'logs' ), 10, 6 ); |
|
49 | - add_filter( "wordpoints_points_log-reverse_{$this->log_type}", array( $this, 'logs' ), 10, 6 ); |
|
48 | + add_filter("wordpoints_points_log-{$this->log_type}", array($this, 'logs'), 10, 6); |
|
49 | + add_filter("wordpoints_points_log-reverse_{$this->log_type}", array($this, 'logs'), 10, 6); |
|
50 | 50 | |
51 | - add_action( 'delete_post', array( $this, 'clean_logs_on_post_deletion' ), 15 ); |
|
51 | + add_action('delete_post', array($this, 'clean_logs_on_post_deletion'), 15); |
|
52 | 52 | |
53 | - if ( ! $this->uses_points_logs_viewing_restriction_api ) { |
|
54 | - add_filter( "wordpoints_user_can_view_points_log-{$this->log_type}", array( $this, 'user_can_view' ), 10, 3 ); |
|
53 | + if ( ! $this->uses_points_logs_viewing_restriction_api) { |
|
54 | + add_filter("wordpoints_user_can_view_points_log-{$this->log_type}", array($this, 'user_can_view'), 10, 3); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return bool Whether this post type matches and points should be awarded. |
67 | 67 | */ |
68 | - public function is_matching_post_type( $post_type, $instance_post_type ) { |
|
68 | + public function is_matching_post_type($post_type, $instance_post_type) { |
|
69 | 69 | |
70 | 70 | return ( |
71 | 71 | $instance_post_type === $post_type |
72 | 72 | || ( |
73 | 73 | 'ALL' === $instance_post_type |
74 | - && post_type_exists( $post_type ) |
|
75 | - && get_post_type_object( $post_type )->public |
|
74 | + && post_type_exists($post_type) |
|
75 | + && get_post_type_object($post_type)->public |
|
76 | 76 | ) |
77 | 77 | ); |
78 | 78 | } |
@@ -86,27 +86,27 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return bool True if auto-reversals should be done; false otherwise. |
88 | 88 | */ |
89 | - protected function should_do_auto_reversals_for_post_type( $post_type ) { |
|
89 | + protected function should_do_auto_reversals_for_post_type($post_type) { |
|
90 | 90 | |
91 | 91 | // Check if this hook type allows auto-reversals to be disabled. |
92 | - if ( ! $this->get_option( 'disable_auto_reverse_label' ) ) { |
|
92 | + if ( ! $this->get_option('disable_auto_reverse_label')) { |
|
93 | 93 | return true; |
94 | 94 | } |
95 | 95 | |
96 | 96 | $instances = $this->get_instances(); |
97 | 97 | |
98 | - foreach ( $instances as $instance ) { |
|
98 | + foreach ($instances as $instance) { |
|
99 | 99 | |
100 | - $instance = array_merge( $this->defaults, $instance ); |
|
100 | + $instance = array_merge($this->defaults, $instance); |
|
101 | 101 | |
102 | - if ( $post_type === $instance['post_type'] ) { |
|
103 | - return ! empty( $instance['auto_reverse'] ); |
|
104 | - } elseif ( 'ALL' === $instance['post_type'] ) { |
|
102 | + if ($post_type === $instance['post_type']) { |
|
103 | + return ! empty($instance['auto_reverse']); |
|
104 | + } elseif ('ALL' === $instance['post_type']) { |
|
105 | 105 | $all_posts_instance = $instance; |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - return ! empty( $all_posts_instance['auto_reverse'] ); |
|
109 | + return ! empty($all_posts_instance['auto_reverse']); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return array The logs to reverse. |
120 | 120 | */ |
121 | - protected function get_logs_to_auto_reverse( array $meta_query ) { |
|
121 | + protected function get_logs_to_auto_reverse(array $meta_query) { |
|
122 | 122 | |
123 | 123 | $query = new WordPoints_Points_Logs_Query( |
124 | 124 | array( |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | $logs = $query->get(); |
137 | 137 | |
138 | - if ( ! $logs ) { |
|
138 | + if ( ! $logs) { |
|
139 | 139 | return array(); |
140 | 140 | } |
141 | 141 | |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @param object $log The log to reverse. |
151 | 151 | */ |
152 | - protected function auto_reverse_log( $log ) { |
|
152 | + protected function auto_reverse_log($log) { |
|
153 | 153 | |
154 | 154 | wordpoints_alter_points( |
155 | 155 | $log->user_id |
156 | 156 | , -$log->points |
157 | 157 | , $log->points_type |
158 | 158 | , "reverse_{$this->log_type}" |
159 | - , array( 'original_log_id' => $log->id ) |
|
159 | + , array('original_log_id' => $log->id) |
|
160 | 160 | ); |
161 | 161 | |
162 | - wordpoints_add_points_log_meta( $log->id, 'auto_reversed', true ); |
|
162 | + wordpoints_add_points_log_meta($log->id, 'auto_reversed', true); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -176,47 +176,47 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string |
178 | 178 | */ |
179 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
179 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
180 | 180 | |
181 | 181 | $reverse = ''; |
182 | 182 | |
183 | - if ( "reverse_{$this->log_type}" === $log_type ) { |
|
183 | + if ("reverse_{$this->log_type}" === $log_type) { |
|
184 | 184 | $reverse = '_reverse'; |
185 | 185 | } |
186 | 186 | |
187 | 187 | $post = false; |
188 | 188 | |
189 | - if ( '' === $reverse && isset( $meta['post_id'] ) ) { |
|
190 | - $post = get_post( $meta['post_id'] ); |
|
189 | + if ('' === $reverse && isset($meta['post_id'])) { |
|
190 | + $post = get_post($meta['post_id']); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( $post ) { |
|
193 | + if ($post) { |
|
194 | 194 | |
195 | 195 | // This post exists, so we should include the permalink in the log text. |
196 | - $text = $this->log_with_post_title_link( $post->ID, $reverse ); |
|
196 | + $text = $this->log_with_post_title_link($post->ID, $reverse); |
|
197 | 197 | |
198 | 198 | } else { |
199 | 199 | |
200 | 200 | // This post doesn't exist; we probably can't use the title. |
201 | - $text = $this->get_option( 'log_text_no_post_title' . $reverse ); |
|
201 | + $text = $this->get_option('log_text_no_post_title' . $reverse); |
|
202 | 202 | |
203 | 203 | if ( |
204 | - $this->get_option( 'log_text_post_type' . $reverse ) |
|
205 | - && isset( $meta['post_type'] ) |
|
206 | - && post_type_exists( $meta['post_type'] ) |
|
204 | + $this->get_option('log_text_post_type' . $reverse) |
|
205 | + && isset($meta['post_type']) |
|
206 | + && post_type_exists($meta['post_type']) |
|
207 | 207 | ) { |
208 | 208 | |
209 | 209 | // We do know the type of post though, so include that in the log. |
210 | 210 | $text = sprintf( |
211 | - $this->get_option( 'log_text_post_type' . $reverse ) |
|
212 | - , get_post_type_object( $meta['post_type'] )->labels->singular_name |
|
211 | + $this->get_option('log_text_post_type' . $reverse) |
|
212 | + , get_post_type_object($meta['post_type'])->labels->singular_name |
|
213 | 213 | ); |
214 | 214 | |
215 | - } elseif ( isset( $meta['post_title'] ) ) { |
|
215 | + } elseif (isset($meta['post_title'])) { |
|
216 | 216 | |
217 | 217 | // If the title is saved as metadata, then we can use it. |
218 | 218 | $text = sprintf( |
219 | - $this->get_option( 'log_text_post_title' . $reverse ) |
|
219 | + $this->get_option('log_text_post_title' . $reverse) |
|
220 | 220 | , $meta['post_title'] |
221 | 221 | ); |
222 | 222 | } |
@@ -236,33 +236,33 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return string The text for the log entry. |
238 | 238 | */ |
239 | - protected function log_with_post_title_link( $post_id, $reverse = '', $url = null ) { |
|
239 | + protected function log_with_post_title_link($post_id, $reverse = '', $url = null) { |
|
240 | 240 | |
241 | - if ( ! isset( $url ) ) { |
|
242 | - $url = get_permalink( $post_id ); |
|
241 | + if ( ! isset($url)) { |
|
242 | + $url = get_permalink($post_id); |
|
243 | 243 | } |
244 | 244 | |
245 | - $post_title = get_the_title( $post_id ); |
|
245 | + $post_title = get_the_title($post_id); |
|
246 | 246 | |
247 | 247 | $args = array(); |
248 | 248 | |
249 | - $args[] = '<a href="' . esc_url( $url ) . '">' |
|
250 | - . ( $post_title ? $post_title : _x( '(no title)', 'post title', 'wordpoints' ) ) |
|
249 | + $args[] = '<a href="' . esc_url($url) . '">' |
|
250 | + . ($post_title ? $post_title : _x('(no title)', 'post title', 'wordpoints')) |
|
251 | 251 | . '</a>'; |
252 | 252 | |
253 | - $text = $this->get_option( 'log_text_post_title_and_type' . $reverse ); |
|
253 | + $text = $this->get_option('log_text_post_title_and_type' . $reverse); |
|
254 | 254 | |
255 | 255 | if ( |
256 | 256 | $text |
257 | - && ( $post_type = get_post_field( 'post_type', $post_id ) ) |
|
258 | - && post_type_exists( $post_type ) |
|
257 | + && ($post_type = get_post_field('post_type', $post_id)) |
|
258 | + && post_type_exists($post_type) |
|
259 | 259 | ) { |
260 | - $args[] = get_post_type_object( $post_type )->labels->singular_name; |
|
260 | + $args[] = get_post_type_object($post_type)->labels->singular_name; |
|
261 | 261 | } else { |
262 | - $text = $this->get_option( 'log_text_post_title' . $reverse ); |
|
262 | + $text = $this->get_option('log_text_post_title' . $reverse); |
|
263 | 263 | } |
264 | 264 | |
265 | - return vsprintf( $text, $args ); |
|
265 | + return vsprintf($text, $args); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -274,17 +274,17 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return string A description for the hook instance. |
276 | 276 | */ |
277 | - protected function generate_description( $instance = array() ) { |
|
277 | + protected function generate_description($instance = array()) { |
|
278 | 278 | |
279 | - if ( ! empty( $instance['post_type'] ) && 'ALL' !== $instance['post_type'] ) { |
|
280 | - $post_type = get_post_type_object( $instance['post_type'] ); |
|
279 | + if ( ! empty($instance['post_type']) && 'ALL' !== $instance['post_type']) { |
|
280 | + $post_type = get_post_type_object($instance['post_type']); |
|
281 | 281 | |
282 | - if ( $post_type ) { |
|
283 | - return sprintf( $this->get_option( 'post_type_description' ), $post_type->labels->singular_name ); |
|
282 | + if ($post_type) { |
|
283 | + return sprintf($this->get_option('post_type_description'), $post_type->labels->singular_name); |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - return parent::generate_description( $instance ); |
|
287 | + return parent::generate_description($instance); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -296,43 +296,43 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return bool True. |
298 | 298 | */ |
299 | - protected function form( $instance ) { |
|
299 | + protected function form($instance) { |
|
300 | 300 | |
301 | - $instance = array_merge( $this->defaults, $instance ); |
|
301 | + $instance = array_merge($this->defaults, $instance); |
|
302 | 302 | |
303 | 303 | ?> |
304 | 304 | |
305 | 305 | <p> |
306 | - <label for="<?php $this->the_field_id( 'post_type' ); ?>"><?php esc_html_e( 'Select post type:', 'wordpoints' ); ?></label> |
|
306 | + <label for="<?php $this->the_field_id('post_type'); ?>"><?php esc_html_e('Select post type:', 'wordpoints'); ?></label> |
|
307 | 307 | <?php |
308 | 308 | |
309 | 309 | wordpoints_list_post_types( |
310 | 310 | array( |
311 | 311 | 'selected' => $instance['post_type'], |
312 | - 'id' => $this->get_field_id( 'post_type' ), |
|
313 | - 'name' => $this->get_field_name( 'post_type' ), |
|
312 | + 'id' => $this->get_field_id('post_type'), |
|
313 | + 'name' => $this->get_field_name('post_type'), |
|
314 | 314 | 'class' => 'widefat wordpoints-append-to-hook-title', |
315 | - 'filter' => $this->get_option( 'post_type_filter' ), |
|
315 | + 'filter' => $this->get_option('post_type_filter'), |
|
316 | 316 | ) |
317 | - , array( 'public' => true ) |
|
317 | + , array('public' => true) |
|
318 | 318 | ); |
319 | 319 | |
320 | 320 | ?> |
321 | 321 | </p> |
322 | 322 | |
323 | - <?php parent::form( $instance ); ?> |
|
323 | + <?php parent::form($instance); ?> |
|
324 | 324 | |
325 | 325 | <?php |
326 | 326 | |
327 | - $disable_label = $this->get_option( 'disable_auto_reverse_label' ); |
|
327 | + $disable_label = $this->get_option('disable_auto_reverse_label'); |
|
328 | 328 | |
329 | - if ( $disable_label ) { |
|
329 | + if ($disable_label) { |
|
330 | 330 | |
331 | 331 | ?> |
332 | 332 | |
333 | 333 | <p> |
334 | - <input class="widefat" name="<?php $this->the_field_name( 'auto_reverse' ); ?>" id="<?php $this->the_field_id( 'auto_reverse' ); ?>" type="checkbox" value="1" <?php checked( '1', $instance['auto_reverse'] ); ?> /> |
|
335 | - <label for="<?php $this->the_field_id( 'auto_reverse' ); ?>"><?php echo esc_html( $disable_label ); ?></label> |
|
334 | + <input class="widefat" name="<?php $this->the_field_name('auto_reverse'); ?>" id="<?php $this->the_field_id('auto_reverse'); ?>" type="checkbox" value="1" <?php checked('1', $instance['auto_reverse']); ?> /> |
|
335 | + <label for="<?php $this->the_field_id('auto_reverse'); ?>"><?php echo esc_html($disable_label); ?></label> |
|
336 | 336 | </p> |
337 | 337 | |
338 | 338 | <?php |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return bool True if the post type supports comments, false otherwise. |
352 | 352 | */ |
353 | - public function post_type_supports_comments( $post_type ) { |
|
353 | + public function post_type_supports_comments($post_type) { |
|
354 | 354 | |
355 | - return post_type_supports( $post_type->name, 'comments' ); |
|
355 | + return post_type_supports($post_type->name, 'comments'); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return bool Whether the user can view this log. |
372 | 372 | */ |
373 | - public function user_can_view( $can_view, $log, $user_id ) { |
|
373 | + public function user_can_view($can_view, $log, $user_id) { |
|
374 | 374 | |
375 | 375 | _deprecated_function( |
376 | 376 | __METHOD__ |
@@ -378,13 +378,13 @@ discard block |
||
378 | 378 | , 'the points logs viewing restrictions API' |
379 | 379 | ); |
380 | 380 | |
381 | - if ( $can_view ) { |
|
381 | + if ($can_view) { |
|
382 | 382 | |
383 | 383 | $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Read_Post( |
384 | 384 | $log |
385 | 385 | ); |
386 | 386 | |
387 | - $can_view = $restriction->user_can( $user_id ); |
|
387 | + $can_view = $restriction->user_can($user_id); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | return $can_view; |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param int $post_id The ID of the post being deleted. |
407 | 407 | */ |
408 | - public function clean_logs_on_post_deletion( $post_id ) { |
|
408 | + public function clean_logs_on_post_deletion($post_id) { |
|
409 | 409 | |
410 | 410 | $this->clean_logs( |
411 | 411 | 'post_id' |
412 | 412 | , $post_id |
413 | 413 | , 'post_type' |
414 | - , get_post_field( 'post_type', $post_id ) |
|
414 | + , get_post_field('post_type', $post_id) |
|
415 | 415 | ); |
416 | 416 | } |
417 | 417 | |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @param string $new_key The key for the new meta value to add. |
426 | 426 | * @param mixed $new_value The new meta value to add. If falsey, new meta isn't added. |
427 | 427 | */ |
428 | - protected function clean_logs( $key, $value, $new_key, $new_value ) { |
|
428 | + protected function clean_logs($key, $value, $new_key, $new_value) { |
|
429 | 429 | |
430 | 430 | $logs_query = new WordPoints_Points_Logs_Query( |
431 | 431 | array( |
@@ -441,20 +441,20 @@ discard block |
||
441 | 441 | |
442 | 442 | $logs = $logs_query->get(); |
443 | 443 | |
444 | - if ( ! $logs ) { |
|
444 | + if ( ! $logs) { |
|
445 | 445 | return; |
446 | 446 | } |
447 | 447 | |
448 | - foreach ( $logs as $log ) { |
|
448 | + foreach ($logs as $log) { |
|
449 | 449 | |
450 | - wordpoints_delete_points_log_meta( $log->id, $key ); |
|
450 | + wordpoints_delete_points_log_meta($log->id, $key); |
|
451 | 451 | |
452 | - if ( $new_value ) { |
|
453 | - wordpoints_add_points_log_meta( $log->id, $new_key, $new_value ); |
|
452 | + if ($new_value) { |
|
453 | + wordpoints_add_points_log_meta($log->id, $new_key, $new_value); |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | - wordpoints_regenerate_points_logs( $logs ); |
|
457 | + wordpoints_regenerate_points_logs($logs); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * 'default', which will return a list of the most recent points logs, with |
295 | 295 | * users excluded according to the general settings. |
296 | 296 | * |
297 | - * @return WordPoints_Points_Logs_Query|false Logs query instance, or false. |
|
297 | + * @return WordPoints_Points_Logs_Query Logs query instance, or false. |
|
298 | 298 | */ |
299 | 299 | function wordpoints_get_points_logs_query( $points_type, $query_slug = 'default' ) { |
300 | 300 | |
@@ -466,6 +466,11 @@ discard block |
||
466 | 466 | * @since 1.9.0 |
467 | 467 | * |
468 | 468 | * @WordPress\action wordpoints_points_log-comment_disapprove |
469 | + * @param string $text |
|
470 | + * @param integer $points |
|
471 | + * @param string $points_type |
|
472 | + * @param integer $user_id |
|
473 | + * @param string $log_type |
|
469 | 474 | */ |
470 | 475 | function wordpoints_points_logs_comment_disapprove( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
471 | 476 | |
@@ -492,6 +497,11 @@ discard block |
||
492 | 497 | * @since 1.9.0 |
493 | 498 | * |
494 | 499 | * @WordPress\action wordpoints_points_log-post_delete |
500 | + * @param string $text |
|
501 | + * @param integer $points |
|
502 | + * @param string $points_type |
|
503 | + * @param integer $user_id |
|
504 | + * @param string $log_type |
|
495 | 505 | */ |
496 | 506 | function wordpoints_points_logs_post_delete( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
497 | 507 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | private static function init() { |
57 | 57 | |
58 | - if ( self::$initialized ) { |
|
58 | + if (self::$initialized) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.0.0 |
69 | 69 | */ |
70 | - do_action( 'wordpoints_register_points_logs_queries' ); |
|
70 | + do_action('wordpoints_register_points_logs_queries'); |
|
71 | 71 | |
72 | 72 | // Make sure that the default query is registered. |
73 | - self::register_query( 'default', array(), array( 'cache_queries' => true ) ); |
|
73 | + self::register_query('default', array(), array('cache_queries' => true)); |
|
74 | 74 | |
75 | 75 | self::$initialized = true; |
76 | 76 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return bool Whether the query was registered. |
91 | 91 | */ |
92 | - public static function register_query( $slug, array $args, array $data = array() ) { |
|
92 | + public static function register_query($slug, array $args, array $data = array()) { |
|
93 | 93 | |
94 | - if ( empty( $slug ) || isset( self::$queries[ $slug ] ) ) { |
|
94 | + if (empty($slug) || isset(self::$queries[$slug])) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | 'network_wide' => false, |
102 | 102 | ); |
103 | 103 | |
104 | - self::$queries[ $slug ] = array_merge( $defaults, $data ); |
|
105 | - self::$queries[ $slug ]['args'] = $args; |
|
104 | + self::$queries[$slug] = array_merge($defaults, $data); |
|
105 | + self::$queries[$slug]['args'] = $args; |
|
106 | 106 | |
107 | 107 | return true; |
108 | 108 | } |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return bool Whether $slug is the slug of a registered query. |
118 | 118 | */ |
119 | - public static function is_query( $slug ) { |
|
119 | + public static function is_query($slug) { |
|
120 | 120 | |
121 | 121 | self::init(); |
122 | 122 | |
123 | - return isset( self::$queries[ $slug ] ); |
|
123 | + return isset(self::$queries[$slug]); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return array The query's args. |
148 | 148 | */ |
149 | - public static function get_query_args( $query_slug ) { |
|
149 | + public static function get_query_args($query_slug) { |
|
150 | 150 | |
151 | - return self::get_query_data( $query_slug, 'args' ); |
|
151 | + return self::get_query_data($query_slug, 'args'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -162,16 +162,16 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return mixed The data, or null if not found. |
164 | 164 | */ |
165 | - public static function get_query_data( $query_slug, $data = null ) { |
|
165 | + public static function get_query_data($query_slug, $data = null) { |
|
166 | 166 | |
167 | 167 | self::init(); |
168 | 168 | |
169 | - if ( isset( self::$queries[ $query_slug ] ) ) { |
|
169 | + if (isset(self::$queries[$query_slug])) { |
|
170 | 170 | |
171 | - if ( empty( $data ) ) { |
|
172 | - return self::$queries[ $query_slug ]; |
|
173 | - } elseif ( isset( self::$queries[ $query_slug ][ $data ] ) ) { |
|
174 | - return self::$queries[ $query_slug ][ $data ]; |
|
171 | + if (empty($data)) { |
|
172 | + return self::$queries[$query_slug]; |
|
173 | + } elseif (isset(self::$queries[$query_slug][$data])) { |
|
174 | + return self::$queries[$query_slug][$data]; |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return bool Whether the query was registered. |
212 | 212 | */ |
213 | -function wordpoints_register_points_logs_query( $slug, array $args, array $data = array() ) { |
|
213 | +function wordpoints_register_points_logs_query($slug, array $args, array $data = array()) { |
|
214 | 214 | |
215 | - return WordPoints_Points_Log_Queries::register_query( $slug, $args, $data ); |
|
215 | + return WordPoints_Points_Log_Queries::register_query($slug, $args, $data); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return bool Whether $slug is the slug of a registered query. |
228 | 228 | */ |
229 | -function wordpoints_is_points_logs_query( $slug ) { |
|
229 | +function wordpoints_is_points_logs_query($slug) { |
|
230 | 230 | |
231 | - return WordPoints_Points_Log_Queries::is_query( $slug ); |
|
231 | + return WordPoints_Points_Log_Queries::is_query($slug); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -243,23 +243,23 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @return array|false The args for the query, or false on failure. |
245 | 245 | */ |
246 | -function wordpoints_get_points_logs_query_args( $points_type, $query_slug = 'default' ) { |
|
246 | +function wordpoints_get_points_logs_query_args($points_type, $query_slug = 'default') { |
|
247 | 247 | |
248 | - $args = WordPoints_Points_Log_Queries::get_query_args( $query_slug ); |
|
248 | + $args = WordPoints_Points_Log_Queries::get_query_args($query_slug); |
|
249 | 249 | |
250 | - if ( is_null( $args ) || ! wordpoints_is_points_type( $points_type ) ) { |
|
250 | + if (is_null($args) || ! wordpoints_is_points_type($points_type)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | 254 | $defaults = array( |
255 | - 'user__not_in' => wordpoints_get_excluded_users( 'points_logs' ), |
|
255 | + 'user__not_in' => wordpoints_get_excluded_users('points_logs'), |
|
256 | 256 | 'points_type' => $points_type, |
257 | 257 | ); |
258 | 258 | |
259 | - $args = array_merge( $defaults, $args ); |
|
259 | + $args = array_merge($defaults, $args); |
|
260 | 260 | |
261 | 261 | // The current user needs to be set dynamically, since it can change at times. |
262 | - if ( 'current_user' === $query_slug ) { |
|
262 | + if ('current_user' === $query_slug) { |
|
263 | 263 | $args['user_id'] = get_current_user_id(); |
264 | 264 | } |
265 | 265 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @param string $query_slug The slug for the query. |
277 | 277 | * @param string $points_type The points type the query is being made for. |
278 | 278 | */ |
279 | - return apply_filters( 'wordpoints_points_logs_query_args', $args, $query_slug, $points_type ); |
|
279 | + return apply_filters('wordpoints_points_logs_query_args', $args, $query_slug, $points_type); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -296,19 +296,19 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return WordPoints_Points_Logs_Query|false Logs query instance, or false. |
298 | 298 | */ |
299 | -function wordpoints_get_points_logs_query( $points_type, $query_slug = 'default' ) { |
|
299 | +function wordpoints_get_points_logs_query($points_type, $query_slug = 'default') { |
|
300 | 300 | |
301 | - $args = wordpoints_get_points_logs_query_args( $points_type, $query_slug ); |
|
301 | + $args = wordpoints_get_points_logs_query_args($points_type, $query_slug); |
|
302 | 302 | |
303 | - if ( ! $args ) { |
|
303 | + if ( ! $args) { |
|
304 | 304 | return false; |
305 | 305 | } |
306 | 306 | |
307 | - $query = new WordPoints_Points_Logs_Query( $args ); |
|
307 | + $query = new WordPoints_Points_Logs_Query($args); |
|
308 | 308 | |
309 | - $query_data = WordPoints_Points_Log_Queries::get_query_data( $query_slug ); |
|
309 | + $query_data = WordPoints_Points_Log_Queries::get_query_data($query_slug); |
|
310 | 310 | |
311 | - if ( $query_data['cache_queries'] ) { |
|
311 | + if ($query_data['cache_queries']) { |
|
312 | 312 | |
313 | 313 | $query->prime_cache( |
314 | 314 | $query_data['cache_key'] |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return void |
353 | 353 | */ |
354 | -function wordpoints_show_points_logs( $logs_query, array $args = array() ) { |
|
354 | +function wordpoints_show_points_logs($logs_query, array $args = array()) { |
|
355 | 355 | |
356 | - if ( ! $logs_query instanceof WordPoints_Points_Logs_Query ) { |
|
356 | + if ( ! $logs_query instanceof WordPoints_Points_Logs_Query) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | 'show_users' => true, |
366 | 366 | ); |
367 | 367 | |
368 | - $args = array_merge( $defaults, $args ); |
|
368 | + $args = array_merge($defaults, $args); |
|
369 | 369 | |
370 | - if ( ! $args['datatable'] ) { |
|
370 | + if ( ! $args['datatable']) { |
|
371 | 371 | |
372 | 372 | _deprecated_argument( |
373 | 373 | __FUNCTION__ |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | $args['paginate'] = false; |
379 | 379 | } |
380 | 380 | |
381 | - $view = wordpoints_component( 'points' ) |
|
382 | - ->get_sub_app( 'logs' ) |
|
383 | - ->get_sub_app( 'views' ) |
|
384 | - ->get( $args['view'], array( $logs_query, $args ) ); |
|
381 | + $view = wordpoints_component('points') |
|
382 | + ->get_sub_app('logs') |
|
383 | + ->get_sub_app('views') |
|
384 | + ->get($args['view'], array($logs_query, $args)); |
|
385 | 385 | |
386 | - if ( ! $view instanceof WordPoints_Points_Logs_View ) { |
|
386 | + if ( ! $view instanceof WordPoints_Points_Logs_View) { |
|
387 | 387 | return; |
388 | 388 | } |
389 | 389 | |
@@ -403,9 +403,9 @@ discard block |
||
403 | 403 | * @param string $query_slug The query to use to display the logs. |
404 | 404 | * @param array $args Arguments to pass to wordpoints_show_points_logs(). |
405 | 405 | */ |
406 | -function wordpoints_show_points_logs_query( $points_type, $query_slug = 'default', array $args = array() ) { |
|
406 | +function wordpoints_show_points_logs_query($points_type, $query_slug = 'default', array $args = array()) { |
|
407 | 407 | |
408 | - wordpoints_show_points_logs( wordpoints_get_points_logs_query( $points_type, $query_slug ), $args ); |
|
408 | + wordpoints_show_points_logs(wordpoints_get_points_logs_query($points_type, $query_slug), $args); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | */ |
425 | 425 | wordpoints_register_points_logs_query( |
426 | 426 | 'current_user' |
427 | - , array( 'user_id' => get_current_user_id() ) |
|
427 | + , array('user_id' => get_current_user_id()) |
|
428 | 428 | , array( |
429 | 429 | 'cache_key' => 'current_user:%points_type%:%user_id%', |
430 | 430 | 'cache_queries' => true, |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | */ |
439 | 439 | wordpoints_register_points_logs_query( |
440 | 440 | 'network' |
441 | - , array( 'blog_id' => false ) |
|
441 | + , array('blog_id' => false) |
|
442 | 442 | , array( |
443 | 443 | 'network_wide' => true, |
444 | 444 | 'cache_queries' => true, |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @WordPress\action wordpoints_points_log-profile_edit |
455 | 455 | */ |
456 | -function wordpoints_points_logs_profile_edit( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
456 | +function wordpoints_points_logs_profile_edit($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
457 | 457 | |
458 | - $user_name = sanitize_user_field( 'display_name', get_userdata( $meta['user_id'] )->display_name, $meta['user_id'], 'display' ); |
|
458 | + $user_name = sanitize_user_field('display_name', get_userdata($meta['user_id'])->display_name, $meta['user_id'], 'display'); |
|
459 | 459 | |
460 | - return sprintf( _x( 'Points adjusted by %1$s. Reason: %2$s', 'points log description', 'wordpoints' ), $user_name, esc_html( $meta['reason'] ) ); |
|
460 | + return sprintf(_x('Points adjusted by %1$s. Reason: %2$s', 'points log description', 'wordpoints'), $user_name, esc_html($meta['reason'])); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -467,20 +467,20 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @WordPress\action wordpoints_points_log-comment_disapprove |
469 | 469 | */ |
470 | -function wordpoints_points_logs_comment_disapprove( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
470 | +function wordpoints_points_logs_comment_disapprove($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
471 | 471 | |
472 | - switch ( $meta['status'] ) { |
|
472 | + switch ($meta['status']) { |
|
473 | 473 | |
474 | 474 | case 'spam': |
475 | - $text = _x( 'Comment marked as spam.', 'points log description', 'wordpoints' ); |
|
475 | + $text = _x('Comment marked as spam.', 'points log description', 'wordpoints'); |
|
476 | 476 | break; |
477 | 477 | |
478 | 478 | case 'trash': |
479 | - $text = _x( 'Comment moved to trash.', 'points log description', 'wordpoints' ); |
|
479 | + $text = _x('Comment moved to trash.', 'points log description', 'wordpoints'); |
|
480 | 480 | break; |
481 | 481 | |
482 | 482 | default: |
483 | - $text = _x( 'Comment unapproved.', 'points log description', 'wordpoints' ); |
|
483 | + $text = _x('Comment unapproved.', 'points log description', 'wordpoints'); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | return $text; |
@@ -493,23 +493,23 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @WordPress\action wordpoints_points_log-post_delete |
495 | 495 | */ |
496 | -function wordpoints_points_logs_post_delete( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
496 | +function wordpoints_points_logs_post_delete($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
497 | 497 | |
498 | - if ( isset( $meta['post_type'] ) ) { |
|
498 | + if (isset($meta['post_type'])) { |
|
499 | 499 | |
500 | - $post_type = get_post_type_object( $meta['post_type'] ); |
|
500 | + $post_type = get_post_type_object($meta['post_type']); |
|
501 | 501 | |
502 | - if ( ! is_null( $post_type ) ) { |
|
502 | + if ( ! is_null($post_type)) { |
|
503 | 503 | |
504 | 504 | /* translators: the post type's name. */ |
505 | 505 | return sprintf( |
506 | - _x( '%s deleted.', 'points log description', 'wordpoints' ) |
|
506 | + _x('%s deleted.', 'points log description', 'wordpoints') |
|
507 | 507 | , $post_type->labels->singular_name |
508 | 508 | ); |
509 | 509 | } |
510 | 510 | } |
511 | 511 | |
512 | - return _x( 'Post deleted.', 'points log description', 'wordpoints' ); |
|
512 | + return _x('Post deleted.', 'points log description', 'wordpoints'); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
@@ -525,10 +525,10 @@ discard block |
||
525 | 525 | * @param int $points The number of points. Not used. |
526 | 526 | * @param string $points_type The type of points being awarded. |
527 | 527 | */ |
528 | -function wordpoints_clean_points_logs_cache( $user_id, $points, $points_type ) { |
|
528 | +function wordpoints_clean_points_logs_cache($user_id, $points, $points_type) { |
|
529 | 529 | |
530 | 530 | wordpoints_flush_points_logs_caches( |
531 | - array( 'user_id' => $user_id, 'points_type' => $points_type ) |
|
531 | + array('user_id' => $user_id, 'points_type' => $points_type) |
|
532 | 532 | ); |
533 | 533 | } |
534 | 534 | |
@@ -550,27 +550,27 @@ discard block |
||
550 | 550 | * @type int $user_id Only clear the cache for this user. |
551 | 551 | * } |
552 | 552 | */ |
553 | -function wordpoints_flush_points_logs_caches( $args = array() ) { |
|
553 | +function wordpoints_flush_points_logs_caches($args = array()) { |
|
554 | 554 | |
555 | - $args = array_merge( array( 'points_type' => false, 'user_id' => 0 ), $args ); |
|
555 | + $args = array_merge(array('points_type' => false, 'user_id' => 0), $args); |
|
556 | 556 | |
557 | 557 | $find = array( |
558 | 558 | '%points_type%', |
559 | 559 | '%user_id%', |
560 | 560 | ); |
561 | 561 | |
562 | - if ( empty( $args['points_type'] ) ) { |
|
563 | - $points_types = array_keys( wordpoints_get_points_types() ); |
|
562 | + if (empty($args['points_type'])) { |
|
563 | + $points_types = array_keys(wordpoints_get_points_types()); |
|
564 | 564 | } else { |
565 | 565 | $points_types = (array) $args['points_type']; |
566 | 566 | } |
567 | 567 | |
568 | - foreach ( $points_types as $points_type ) { |
|
569 | - foreach ( WordPoints_Points_Log_Queries::get_queries() as $query ) { |
|
568 | + foreach ($points_types as $points_type) { |
|
569 | + foreach (WordPoints_Points_Log_Queries::get_queries() as $query) { |
|
570 | 570 | |
571 | - if ( ! empty( $query['cache_key'] ) ) { |
|
571 | + if ( ! empty($query['cache_key'])) { |
|
572 | 572 | |
573 | - if ( $query['network_wide'] ) { |
|
573 | + if ($query['network_wide']) { |
|
574 | 574 | $group = 'wordpoints_network_points_logs_query'; |
575 | 575 | } else { |
576 | 576 | $group = 'wordpoints_points_logs_query'; |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | ); |
583 | 583 | |
584 | 584 | wp_cache_delete( |
585 | - str_replace( $find, $replace, $query['cache_key'] ) |
|
585 | + str_replace($find, $replace, $query['cache_key']) |
|
586 | 586 | , $group |
587 | 587 | ); |
588 | 588 | } |
@@ -601,26 +601,26 @@ discard block |
||
601 | 601 | * |
602 | 602 | * @return bool Whether the user can view this points log entry. |
603 | 603 | */ |
604 | -function wordpoints_user_can_view_points_log( $user_id, $log ) { |
|
604 | +function wordpoints_user_can_view_points_log($user_id, $log) { |
|
605 | 605 | |
606 | 606 | // We do this just once here for optimization, as otherwise it would run 3 times. |
607 | - if ( $log->blog_id && get_current_blog_id() !== $log->blog_id ) { |
|
608 | - $switched = switch_to_blog( $log->blog_id ); |
|
607 | + if ($log->blog_id && get_current_blog_id() !== $log->blog_id) { |
|
608 | + $switched = switch_to_blog($log->blog_id); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** @var WordPoints_Points_Logs_Viewing_Restrictions $viewing_restrictions */ |
612 | - $viewing_restrictions = wordpoints_component( 'points' ) |
|
613 | - ->get_sub_app( 'logs' ) |
|
614 | - ->get_sub_app( 'viewing_restrictions' ); |
|
612 | + $viewing_restrictions = wordpoints_component('points') |
|
613 | + ->get_sub_app('logs') |
|
614 | + ->get_sub_app('viewing_restrictions'); |
|
615 | 615 | |
616 | - $can_view = $viewing_restrictions->get_restriction( $log ) |
|
617 | - ->user_can( $user_id ); |
|
616 | + $can_view = $viewing_restrictions->get_restriction($log) |
|
617 | + ->user_can($user_id); |
|
618 | 618 | |
619 | - if ( $can_view ) { |
|
620 | - $can_view = $viewing_restrictions->apply_legacy_filters( $user_id, $log ); |
|
619 | + if ($can_view) { |
|
620 | + $can_view = $viewing_restrictions->apply_legacy_filters($user_id, $log); |
|
621 | 621 | } |
622 | 622 | |
623 | - if ( isset( $switched ) ) { |
|
623 | + if (isset($switched)) { |
|
624 | 624 | restore_current_blog(); |
625 | 625 | } |
626 | 626 | |
@@ -641,17 +641,17 @@ discard block |
||
641 | 641 | * |
642 | 642 | * @return bool Whether the user can view the points log. |
643 | 643 | */ |
644 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $user_id, $log ) { |
|
644 | +function wordpoints_hooks_user_can_view_points_log($can_view, $user_id, $log) { |
|
645 | 645 | |
646 | - _deprecated_function( __FUNCTION__, '2.2.0' ); |
|
646 | + _deprecated_function(__FUNCTION__, '2.2.0'); |
|
647 | 647 | |
648 | - if ( ! $can_view ) { |
|
648 | + if ( ! $can_view) { |
|
649 | 649 | return $can_view; |
650 | 650 | } |
651 | 651 | |
652 | - $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Hooks( $log ); |
|
652 | + $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Hooks($log); |
|
653 | 653 | |
654 | - return $restriction->user_can( $user_id ); |
|
654 | + return $restriction->user_can($user_id); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | // EOF |
@@ -363,7 +363,7 @@ |
||
363 | 363 | * |
364 | 364 | * @param string $type The slug for a points type. |
365 | 365 | * |
366 | - * @return int|false The minimum for this type of points. False if $type is bad. |
|
366 | + * @return integer The minimum for this type of points. False if $type is bad. |
|
367 | 367 | */ |
368 | 368 | function wordpoints_get_points_minimum( $type ) { |
369 | 369 |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return bool Whether a points type with the given slug exists. |
21 | 21 | */ |
22 | -function wordpoints_is_points_type( $slug ) { |
|
22 | +function wordpoints_is_points_type($slug) { |
|
23 | 23 | |
24 | 24 | $points_types = wordpoints_get_points_types(); |
25 | 25 | |
26 | - return isset( $points_types[ $slug ] ); |
|
26 | + return isset($points_types[$slug]); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function wordpoints_get_points_types() { |
57 | 57 | |
58 | - return wordpoints_get_maybe_network_array_option( 'wordpoints_points_types' ); |
|
58 | + return wordpoints_get_maybe_network_array_option('wordpoints_points_types'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return array|false An array of settings for this points type. False on failure. |
69 | 69 | */ |
70 | -function wordpoints_get_points_type( $slug ) { |
|
70 | +function wordpoints_get_points_type($slug) { |
|
71 | 71 | |
72 | 72 | $points_types = wordpoints_get_points_types(); |
73 | 73 | |
74 | - if ( ! isset( $points_types[ $slug ] ) ) { |
|
74 | + if ( ! isset($points_types[$slug])) { |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
78 | - return $points_types[ $slug ]; |
|
78 | + return $points_types[$slug]; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return string|void The value of the setting if it exists, otherwise null. |
93 | 93 | */ |
94 | -function wordpoints_get_points_type_setting( $slug, $setting ) { |
|
94 | +function wordpoints_get_points_type_setting($slug, $setting) { |
|
95 | 95 | |
96 | - $points_type = wordpoints_get_points_type( $slug ); |
|
96 | + $points_type = wordpoints_get_points_type($slug); |
|
97 | 97 | |
98 | - if ( isset( $points_type[ $setting ] ) ) { |
|
99 | - return $points_type[ $setting ]; |
|
98 | + if (isset($points_type[$setting])) { |
|
99 | + return $points_type[$setting]; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -113,21 +113,21 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string|false The slug on success. False on failure. |
115 | 115 | */ |
116 | -function wordpoints_add_points_type( $settings ) { |
|
116 | +function wordpoints_add_points_type($settings) { |
|
117 | 117 | |
118 | - if ( ! is_array( $settings ) || ! isset( $settings['name'] ) ) { |
|
118 | + if ( ! is_array($settings) || ! isset($settings['name'])) { |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | 122 | $slug = $settings['name']; |
123 | - $slug = preg_replace( '/\s+/', '-', $slug ); |
|
124 | - $slug = preg_replace( '/-+/', '-', $slug ); |
|
125 | - $slug = trim( $slug, '-' ); |
|
126 | - $slug = sanitize_key( $slug ); |
|
123 | + $slug = preg_replace('/\s+/', '-', $slug); |
|
124 | + $slug = preg_replace('/-+/', '-', $slug); |
|
125 | + $slug = trim($slug, '-'); |
|
126 | + $slug = sanitize_key($slug); |
|
127 | 127 | |
128 | 128 | $points_types = wordpoints_get_points_types(); |
129 | 129 | |
130 | - if ( empty( $slug ) || isset( $points_types[ $slug ] ) ) { |
|
130 | + if (empty($slug) || isset($points_types[$slug])) { |
|
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | * @param string $slug The slug for this points type. |
141 | 141 | * @param bool $is_new Whether this points type is new, or being updated. |
142 | 142 | */ |
143 | - $points_types[ $slug ] = apply_filters( 'wordpoints_points_settings', $settings, $slug, true ); |
|
143 | + $points_types[$slug] = apply_filters('wordpoints_points_settings', $settings, $slug, true); |
|
144 | 144 | |
145 | - if ( ! wordpoints_update_maybe_network_option( 'wordpoints_points_types', $points_types ) ) { |
|
145 | + if ( ! wordpoints_update_maybe_network_option('wordpoints_points_types', $points_types)) { |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | |
@@ -159,20 +159,20 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return bool True, or false on failure, or if this points type does not exist. |
161 | 161 | */ |
162 | -function wordpoints_update_points_type( $slug, $settings ) { |
|
162 | +function wordpoints_update_points_type($slug, $settings) { |
|
163 | 163 | |
164 | 164 | $points_types = wordpoints_get_points_types(); |
165 | 165 | |
166 | - if ( ! is_array( $settings ) || ! isset( $points_types[ $slug ], $settings['name'] ) ) { |
|
166 | + if ( ! is_array($settings) || ! isset($points_types[$slug], $settings['name'])) { |
|
167 | 167 | return false; |
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | 171 | * @see wordpoints_add_points_type() |
172 | 172 | */ |
173 | - $points_types[ $slug ] = apply_filters( 'wordpoints_points_settings', $settings, $slug, false ); |
|
173 | + $points_types[$slug] = apply_filters('wordpoints_points_settings', $settings, $slug, false); |
|
174 | 174 | |
175 | - return wordpoints_update_maybe_network_option( 'wordpoints_points_types', $points_types ); |
|
175 | + return wordpoints_update_maybe_network_option('wordpoints_points_types', $points_types); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return bool Whether the points type was deleted successfully. |
189 | 189 | */ |
190 | -function wordpoints_delete_points_type( $slug ) { |
|
190 | +function wordpoints_delete_points_type($slug) { |
|
191 | 191 | |
192 | 192 | $points_types = wordpoints_get_points_types(); |
193 | 193 | |
194 | - if ( ! isset( $points_types[ $slug ] ) ) { |
|
194 | + if ( ! isset($points_types[$slug])) { |
|
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | |
@@ -203,48 +203,48 @@ discard block |
||
203 | 203 | * @param string $slug The slug of the points type being deleted. |
204 | 204 | * @param array $settings The settings of the points type being deleted. |
205 | 205 | */ |
206 | - do_action( 'wordpoints_delete_points_type', $slug, $points_types[ $slug ] ); |
|
206 | + do_action('wordpoints_delete_points_type', $slug, $points_types[$slug]); |
|
207 | 207 | |
208 | - $meta_key = wordpoints_get_points_user_meta_key( $slug ); |
|
208 | + $meta_key = wordpoints_get_points_user_meta_key($slug); |
|
209 | 209 | |
210 | 210 | global $wpdb; |
211 | 211 | |
212 | 212 | // Delete log meta for this points type. |
213 | 213 | $query = new WordPoints_Points_Logs_Query( |
214 | - array( 'field' => 'id', 'points_type' => $slug ) |
|
214 | + array('field' => 'id', 'points_type' => $slug) |
|
215 | 215 | ); |
216 | 216 | |
217 | - $log_ids = $query->get( 'col' ); |
|
217 | + $log_ids = $query->get('col'); |
|
218 | 218 | |
219 | - foreach ( $log_ids as $log_id ) { |
|
220 | - wordpoints_points_log_delete_all_metadata( $log_id ); |
|
219 | + foreach ($log_ids as $log_id) { |
|
220 | + wordpoints_points_log_delete_all_metadata($log_id); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | // Delete logs for this points type. |
224 | - $wpdb->delete( $wpdb->wordpoints_points_logs, array( 'points_type' => $slug ) ); |
|
224 | + $wpdb->delete($wpdb->wordpoints_points_logs, array('points_type' => $slug)); |
|
225 | 225 | |
226 | - wordpoints_flush_points_logs_caches( array( 'points_type' => $slug ) ); |
|
226 | + wordpoints_flush_points_logs_caches(array('points_type' => $slug)); |
|
227 | 227 | |
228 | 228 | // Delete all user points of this type. |
229 | - delete_metadata( 'user', 0, wp_slash( $meta_key ), '', true ); |
|
229 | + delete_metadata('user', 0, wp_slash($meta_key), '', true); |
|
230 | 230 | |
231 | 231 | // Delete hooks associated with this points type. |
232 | 232 | $points_types_hooks = WordPoints_Points_Hooks::get_points_types_hooks(); |
233 | 233 | |
234 | - unset( $points_types_hooks[ $slug ] ); |
|
234 | + unset($points_types_hooks[$slug]); |
|
235 | 235 | |
236 | - WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks ); |
|
236 | + WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks); |
|
237 | 237 | |
238 | 238 | // Delete reactions associated with this points type. |
239 | - foreach ( wordpoints_hooks()->get_reaction_stores( 'points' ) as $reaction_store ) { |
|
240 | - foreach ( $reaction_store->get_reactions() as $reaction ) { |
|
241 | - if ( $slug === $reaction->get_meta( 'points_type' ) ) { |
|
242 | - $reaction_store->delete_reaction( $reaction->get_id() ); |
|
239 | + foreach (wordpoints_hooks()->get_reaction_stores('points') as $reaction_store) { |
|
240 | + foreach ($reaction_store->get_reactions() as $reaction) { |
|
241 | + if ($slug === $reaction->get_meta('points_type')) { |
|
242 | + $reaction_store->delete_reaction($reaction->get_id()); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - unset( $points_types[ $slug ] ); |
|
247 | + unset($points_types[$slug]); |
|
248 | 248 | |
249 | 249 | wordpoints_update_maybe_network_option( |
250 | 250 | 'wordpoints_points_types' |
@@ -277,19 +277,19 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string|false The user meta meta_key for a points type, or false. |
279 | 279 | */ |
280 | -function wordpoints_get_points_user_meta_key( $points_type ) { |
|
280 | +function wordpoints_get_points_user_meta_key($points_type) { |
|
281 | 281 | |
282 | - if ( ! wordpoints_is_points_type( $points_type ) ) { |
|
282 | + if ( ! wordpoints_is_points_type($points_type)) { |
|
283 | 283 | return false; |
284 | 284 | } |
285 | 285 | |
286 | - $setting = wordpoints_get_points_type_setting( $points_type, 'meta_key' ); |
|
286 | + $setting = wordpoints_get_points_type_setting($points_type, 'meta_key'); |
|
287 | 287 | |
288 | - if ( ! empty( $setting ) ) { |
|
288 | + if ( ! empty($setting)) { |
|
289 | 289 | |
290 | 290 | $meta_key = $setting; |
291 | 291 | |
292 | - } elseif ( ! is_multisite() || is_wordpoints_network_active() ) { |
|
292 | + } elseif ( ! is_multisite() || is_wordpoints_network_active()) { |
|
293 | 293 | |
294 | 294 | $meta_key = "wordpoints_points-{$points_type}"; |
295 | 295 | |
@@ -315,15 +315,15 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return int|false The user's points, or false on failure. |
317 | 317 | */ |
318 | -function wordpoints_get_points( $user_id, $type ) { |
|
318 | +function wordpoints_get_points($user_id, $type) { |
|
319 | 319 | |
320 | - if ( ! wordpoints_posint( $user_id ) || ! wordpoints_is_points_type( $type ) ) { |
|
320 | + if ( ! wordpoints_posint($user_id) || ! wordpoints_is_points_type($type)) { |
|
321 | 321 | return false; |
322 | 322 | } |
323 | 323 | |
324 | - $points = get_user_meta( $user_id, wordpoints_get_points_user_meta_key( $type ), true ); |
|
324 | + $points = get_user_meta($user_id, wordpoints_get_points_user_meta_key($type), true); |
|
325 | 325 | |
326 | - return (int) wordpoints_int( $points ); |
|
326 | + return (int) wordpoints_int($points); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return int|false The minimum for this type of points. False if $type is bad. |
367 | 367 | */ |
368 | -function wordpoints_get_points_minimum( $type ) { |
|
368 | +function wordpoints_get_points_minimum($type) { |
|
369 | 369 | |
370 | - if ( ! wordpoints_is_points_type( $type ) ) { |
|
370 | + if ( ! wordpoints_is_points_type($type)) { |
|
371 | 371 | return false; |
372 | 372 | } |
373 | 373 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * @param int $minimum The minimum number of points. |
380 | 380 | * @param string $type The points type slug. |
381 | 381 | */ |
382 | - return apply_filters( 'wordpoints_points_minimum', 0, $type ); |
|
382 | + return apply_filters('wordpoints_points_minimum', 0, $type); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string The integer value of $points formatted for display. |
402 | 402 | */ |
403 | -function wordpoints_format_points( $points, $type, $context ) { |
|
403 | +function wordpoints_format_points($points, $type, $context) { |
|
404 | 404 | |
405 | 405 | $_points = $points; |
406 | - wordpoints_int( $_points ); |
|
406 | + wordpoints_int($_points); |
|
407 | 407 | |
408 | - if ( false === $_points || ! wordpoints_is_points_type( $type ) ) { |
|
408 | + if (false === $_points || ! wordpoints_is_points_type($type)) { |
|
409 | 409 | return (string) $points; |
410 | 410 | } |
411 | 411 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * @param string $type The type of points. |
420 | 420 | * @param string $context The context in which the points will be displayed. |
421 | 421 | */ |
422 | - return apply_filters( 'wordpoints_format_points', $_points, $_points, $type, $context ); |
|
422 | + return apply_filters('wordpoints_format_points', $_points, $_points, $type, $context); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -436,15 +436,15 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @return string|false The user's points formatted for display, or false on failure. |
438 | 438 | */ |
439 | -function wordpoints_get_formatted_points( $user_id, $type, $context ) { |
|
439 | +function wordpoints_get_formatted_points($user_id, $type, $context) { |
|
440 | 440 | |
441 | - $points = wordpoints_get_points( $user_id, $type ); |
|
441 | + $points = wordpoints_get_points($user_id, $type); |
|
442 | 442 | |
443 | - if ( false === $points ) { |
|
443 | + if (false === $points) { |
|
444 | 444 | return false; |
445 | 445 | } |
446 | 446 | |
447 | - return wordpoints_format_points( $points, $type, $context ); |
|
447 | + return wordpoints_format_points($points, $type, $context); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | * @param string $type The type of points to display. |
459 | 459 | * @param string $context The context in which the points will be displayed. |
460 | 460 | */ |
461 | -function wordpoints_display_points( $user_id, $type, $context ) { |
|
461 | +function wordpoints_display_points($user_id, $type, $context) { |
|
462 | 462 | |
463 | - echo wordpoints_get_formatted_points( $user_id, $type, $context ); // XSS OK, WPCS |
|
463 | + echo wordpoints_get_formatted_points($user_id, $type, $context); // XSS OK, WPCS |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -483,21 +483,21 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @return int|false False on failure. |
485 | 485 | */ |
486 | -function wordpoints_get_points_above_minimum( $user_id, $type ) { |
|
486 | +function wordpoints_get_points_above_minimum($user_id, $type) { |
|
487 | 487 | |
488 | - $minimum = wordpoints_get_points_minimum( $type ); |
|
488 | + $minimum = wordpoints_get_points_minimum($type); |
|
489 | 489 | |
490 | - if ( false === $minimum ) { |
|
490 | + if (false === $minimum) { |
|
491 | 491 | return false; |
492 | 492 | } |
493 | 493 | |
494 | - $points = wordpoints_get_points( $user_id, $type ); |
|
494 | + $points = wordpoints_get_points($user_id, $type); |
|
495 | 495 | |
496 | - if ( false === $points ) { |
|
496 | + if (false === $points) { |
|
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | - return max( 0, $points - $minimum ); |
|
500 | + return max(0, $points - $minimum); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -519,19 +519,19 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return bool Whether the transaction was successful. |
521 | 521 | */ |
522 | -function wordpoints_set_points( $user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '' ) { |
|
522 | +function wordpoints_set_points($user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '') { |
|
523 | 523 | |
524 | - if ( false === wordpoints_int( $points ) ) { |
|
524 | + if (false === wordpoints_int($points)) { |
|
525 | 525 | return false; |
526 | 526 | } |
527 | 527 | |
528 | - $current = wordpoints_get_points( $user_id, $points_type ); |
|
528 | + $current = wordpoints_get_points($user_id, $points_type); |
|
529 | 529 | |
530 | - if ( false === $current ) { |
|
530 | + if (false === $current) { |
|
531 | 531 | return false; |
532 | 532 | } |
533 | 533 | |
534 | - return wordpoints_alter_points( $user_id, $points - $current, $points_type, $log_type, $meta, $log_text ); |
|
534 | + return wordpoints_alter_points($user_id, $points - $current, $points_type, $log_type, $meta, $log_text); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -574,13 +574,13 @@ discard block |
||
574 | 574 | * @return int|bool On success, the log ID if the transaction is logged, or true if |
575 | 575 | * it is not. False on failure. |
576 | 576 | */ |
577 | -function wordpoints_alter_points( $user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '' ) { |
|
577 | +function wordpoints_alter_points($user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '') { |
|
578 | 578 | |
579 | 579 | if ( |
580 | - ! wordpoints_posint( $user_id ) |
|
581 | - || ! wordpoints_int( $points ) |
|
582 | - || ! wordpoints_is_points_type( $points_type ) |
|
583 | - || empty( $log_type ) |
|
580 | + ! wordpoints_posint($user_id) |
|
581 | + || ! wordpoints_int($points) |
|
582 | + || ! wordpoints_is_points_type($points_type) |
|
583 | + || empty($log_type) |
|
584 | 584 | ) { |
585 | 585 | return false; |
586 | 586 | } |
@@ -604,29 +604,29 @@ discard block |
||
604 | 604 | * @param string $log_type The type of transaction. |
605 | 605 | * @param array $meta Metadata for the transaction. |
606 | 606 | */ |
607 | - $points = apply_filters( 'wordpoints_alter_points', $points, $points_type, $user_id, $log_type, $meta ); |
|
607 | + $points = apply_filters('wordpoints_alter_points', $points, $points_type, $user_id, $log_type, $meta); |
|
608 | 608 | |
609 | - if ( 0 === wordpoints_int( $points ) ) { |
|
609 | + if (0 === wordpoints_int($points)) { |
|
610 | 610 | return true; |
611 | - } elseif ( false === $points ) { |
|
611 | + } elseif (false === $points) { |
|
612 | 612 | return false; |
613 | 613 | } |
614 | 614 | |
615 | 615 | // Get the current points so we can check this won't go below the minimum. |
616 | - $current_points = wordpoints_get_points( $user_id, $points_type ); |
|
617 | - $minimum = wordpoints_get_points_minimum( $points_type ); |
|
616 | + $current_points = wordpoints_get_points($user_id, $points_type); |
|
617 | + $minimum = wordpoints_get_points_minimum($points_type); |
|
618 | 618 | |
619 | - if ( ( $current_points + $points ) < $minimum ) { |
|
619 | + if (($current_points + $points) < $minimum) { |
|
620 | 620 | |
621 | 621 | // The total was less than the minimum, set the number to the minimum. |
622 | 622 | $points = $minimum - $current_points; |
623 | 623 | } |
624 | 624 | |
625 | - $meta_key = wordpoints_get_points_user_meta_key( $points_type ); |
|
625 | + $meta_key = wordpoints_get_points_user_meta_key($points_type); |
|
626 | 626 | |
627 | - if ( '' === get_user_meta( $user_id, $meta_key, true ) ) { |
|
627 | + if ('' === get_user_meta($user_id, $meta_key, true)) { |
|
628 | 628 | |
629 | - $result = add_user_meta( $user_id, wp_slash( $meta_key ), (int) $points, true ); |
|
629 | + $result = add_user_meta($user_id, wp_slash($meta_key), (int) $points, true); |
|
630 | 630 | |
631 | 631 | } else { |
632 | 632 | |
@@ -645,10 +645,10 @@ discard block |
||
645 | 645 | ) |
646 | 646 | ); |
647 | 647 | |
648 | - wp_cache_delete( $user_id, 'user_meta' ); |
|
648 | + wp_cache_delete($user_id, 'user_meta'); |
|
649 | 649 | } |
650 | 650 | |
651 | - if ( ! $result ) { |
|
651 | + if ( ! $result) { |
|
652 | 652 | return false; |
653 | 653 | } |
654 | 654 | |
@@ -662,15 +662,15 @@ discard block |
||
662 | 662 | * @param string $log_type The type of transaction. |
663 | 663 | * @param array $meta The metadata for this transaction. |
664 | 664 | */ |
665 | - $log_transaction = apply_filters( 'wordpoints_points_log', true, $user_id, $points, $points_type, $log_type, $meta ); |
|
665 | + $log_transaction = apply_filters('wordpoints_points_log', true, $user_id, $points, $points_type, $log_type, $meta); |
|
666 | 666 | |
667 | 667 | $log_id = false; |
668 | - if ( $log_transaction ) { |
|
668 | + if ($log_transaction) { |
|
669 | 669 | |
670 | - $log_text = wordpoints_render_points_log_text( $user_id, $points, $points_type, $log_type, $meta, $log_text ); |
|
670 | + $log_text = wordpoints_render_points_log_text($user_id, $points, $points_type, $log_type, $meta, $log_text); |
|
671 | 671 | |
672 | - if ( 'utf8' === $wpdb->get_col_charset( $wpdb->wordpoints_points_logs, 'text' ) ) { |
|
673 | - $log_text = wp_encode_emoji( $log_text ); |
|
672 | + if ('utf8' === $wpdb->get_col_charset($wpdb->wordpoints_points_logs, 'text')) { |
|
673 | + $log_text = wp_encode_emoji($log_text); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | $result = $wpdb->insert( |
@@ -681,20 +681,20 @@ discard block |
||
681 | 681 | 'points_type' => $points_type, |
682 | 682 | 'log_type' => $log_type, |
683 | 683 | 'text' => $log_text, |
684 | - 'date' => current_time( 'mysql', 1 ), |
|
684 | + 'date' => current_time('mysql', 1), |
|
685 | 685 | 'site_id' => $wpdb->siteid, |
686 | 686 | 'blog_id' => $wpdb->blogid, |
687 | 687 | ), |
688 | - array( '%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d' ) |
|
688 | + array('%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d') |
|
689 | 689 | ); |
690 | 690 | |
691 | - if ( false !== $result ) { |
|
691 | + if (false !== $result) { |
|
692 | 692 | |
693 | 693 | $log_id = (int) $wpdb->insert_id; |
694 | 694 | |
695 | - foreach ( $meta as $meta_key => $meta_value ) { |
|
695 | + foreach ($meta as $meta_key => $meta_value) { |
|
696 | 696 | |
697 | - wordpoints_add_points_log_meta( $log_id, $meta_key, $meta_value ); |
|
697 | + wordpoints_add_points_log_meta($log_id, $meta_key, $meta_value); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | * @param array $meta Metadata for the transaction. |
711 | 711 | * @param int $log_id The ID of the transaction log entry. |
712 | 712 | */ |
713 | - do_action( 'wordpoints_points_log', $user_id, $points, $points_type, $log_type, $meta, $log_id ); |
|
713 | + do_action('wordpoints_points_log', $user_id, $points, $points_type, $log_type, $meta, $log_id); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | } // End if ( $log_transaction ). |
@@ -728,9 +728,9 @@ discard block |
||
728 | 728 | * @param array $meta Metadata for the transaction. |
729 | 729 | * @param int|false $log_id The ID of the transaction log, or false if not logged. |
730 | 730 | */ |
731 | - do_action( 'wordpoints_points_altered', $user_id, $points, $points_type, $log_type, $meta, $log_id ); |
|
731 | + do_action('wordpoints_points_altered', $user_id, $points, $points_type, $log_type, $meta, $log_id); |
|
732 | 732 | |
733 | - if ( $log_id ) { |
|
733 | + if ($log_id) { |
|
734 | 734 | return $log_id; |
735 | 735 | } else { |
736 | 736 | return true; |
@@ -756,9 +756,9 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @return bool Whether the points were added successfully. |
758 | 758 | */ |
759 | -function wordpoints_add_points( $user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '' ) { |
|
759 | +function wordpoints_add_points($user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '') { |
|
760 | 760 | |
761 | - return wordpoints_alter_points( $user_id, wordpoints_posint( $points ), $points_type, $log_type, $meta, $log_text ); |
|
761 | + return wordpoints_alter_points($user_id, wordpoints_posint($points), $points_type, $log_type, $meta, $log_text); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | /** |
@@ -779,9 +779,9 @@ discard block |
||
779 | 779 | * |
780 | 780 | * @return bool Whether the points were subtracted successfully. |
781 | 781 | */ |
782 | -function wordpoints_subtract_points( $user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '' ) { |
|
782 | +function wordpoints_subtract_points($user_id, $points, $points_type, $log_type, $meta = array(), $log_text = '') { |
|
783 | 783 | |
784 | - return wordpoints_alter_points( $user_id, -wordpoints_posint( $points ), $points_type, $log_type, $meta, $log_text ); |
|
784 | + return wordpoints_alter_points($user_id, -wordpoints_posint($points), $points_type, $log_type, $meta, $log_text); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | /** |
@@ -793,9 +793,9 @@ discard block |
||
793 | 793 | * |
794 | 794 | * @return string The corrected column name. |
795 | 795 | */ |
796 | -function _wordpoints_points_log_meta_column( $column ) { |
|
796 | +function _wordpoints_points_log_meta_column($column) { |
|
797 | 797 | |
798 | - if ( 'wordpoints_points_log_id' === $column ) { |
|
798 | + if ('wordpoints_points_log_id' === $column) { |
|
799 | 799 | $column = 'log_id'; |
800 | 800 | } |
801 | 801 | |
@@ -820,23 +820,23 @@ discard block |
||
820 | 820 | * |
821 | 821 | * @return bool Whether the metadata was added successfully. |
822 | 822 | */ |
823 | -function wordpoints_add_points_log_meta( $log_id, $meta_key, $meta_value, $unique = false ) { |
|
823 | +function wordpoints_add_points_log_meta($log_id, $meta_key, $meta_value, $unique = false) { |
|
824 | 824 | |
825 | 825 | global $wpdb; |
826 | 826 | |
827 | - add_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
827 | + add_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
828 | 828 | $wpdb->wordpoints_points_logmeta = $wpdb->wordpoints_points_log_meta; |
829 | 829 | |
830 | 830 | $result = add_metadata( |
831 | 831 | 'wordpoints_points_log' |
832 | 832 | , $log_id |
833 | - , wp_slash( $meta_key ) |
|
834 | - , wp_slash( $meta_value ) |
|
833 | + , wp_slash($meta_key) |
|
834 | + , wp_slash($meta_value) |
|
835 | 835 | , $unique |
836 | 836 | ); |
837 | 837 | |
838 | - unset( $wpdb->wordpoints_points_logmeta ); |
|
839 | - remove_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
838 | + unset($wpdb->wordpoints_points_logmeta); |
|
839 | + remove_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
840 | 840 | |
841 | 841 | return $result; |
842 | 842 | } |
@@ -855,15 +855,15 @@ discard block |
||
855 | 855 | * |
856 | 856 | * @return mixed The meta key, or null on failure. |
857 | 857 | */ |
858 | -function wordpoints_get_points_log_meta( $log_id, $meta_key = '', $single = false ) { |
|
858 | +function wordpoints_get_points_log_meta($log_id, $meta_key = '', $single = false) { |
|
859 | 859 | |
860 | 860 | global $wpdb; |
861 | 861 | |
862 | - add_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
862 | + add_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
863 | 863 | $wpdb->wordpoints_points_logmeta = $wpdb->wordpoints_points_log_meta; |
864 | - $result = get_metadata( 'wordpoints_points_log', $log_id, $meta_key, $single ); |
|
865 | - unset( $wpdb->wordpoints_points_logmeta ); |
|
866 | - remove_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
864 | + $result = get_metadata('wordpoints_points_log', $log_id, $meta_key, $single); |
|
865 | + unset($wpdb->wordpoints_points_logmeta); |
|
866 | + remove_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
867 | 867 | |
868 | 868 | return $result; |
869 | 869 | } |
@@ -883,23 +883,23 @@ discard block |
||
883 | 883 | * |
884 | 884 | * @return bool Whether any rows were updated. |
885 | 885 | */ |
886 | -function wordpoints_update_points_log_meta( $log_id, $meta_key, $meta_value, $previous = null ) { |
|
886 | +function wordpoints_update_points_log_meta($log_id, $meta_key, $meta_value, $previous = null) { |
|
887 | 887 | |
888 | 888 | global $wpdb; |
889 | 889 | |
890 | - add_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
890 | + add_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
891 | 891 | $wpdb->wordpoints_points_logmeta = $wpdb->wordpoints_points_log_meta; |
892 | 892 | |
893 | 893 | $result = update_metadata( |
894 | 894 | 'wordpoints_points_log' |
895 | 895 | , $log_id |
896 | - , wp_slash( $meta_key ) |
|
897 | - , wp_slash( $meta_value ) |
|
896 | + , wp_slash($meta_key) |
|
897 | + , wp_slash($meta_value) |
|
898 | 898 | , $previous |
899 | 899 | ); |
900 | 900 | |
901 | - unset( $wpdb->wordpoints_points_logmeta ); |
|
902 | - remove_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
901 | + unset($wpdb->wordpoints_points_logmeta); |
|
902 | + remove_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
903 | 903 | |
904 | 904 | return $result; |
905 | 905 | } |
@@ -920,23 +920,23 @@ discard block |
||
920 | 920 | * |
921 | 921 | * @return bool Whether any rows where deleted. |
922 | 922 | */ |
923 | -function wordpoints_delete_points_log_meta( $log_id, $meta_key = '', $meta_value = null, $delete_all = false ) { |
|
923 | +function wordpoints_delete_points_log_meta($log_id, $meta_key = '', $meta_value = null, $delete_all = false) { |
|
924 | 924 | |
925 | 925 | global $wpdb; |
926 | 926 | |
927 | - add_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
927 | + add_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
928 | 928 | $wpdb->wordpoints_points_logmeta = $wpdb->wordpoints_points_log_meta; |
929 | 929 | |
930 | 930 | $result = delete_metadata( |
931 | 931 | 'wordpoints_points_log' |
932 | 932 | , $log_id |
933 | - , wp_slash( $meta_key ) |
|
934 | - , wp_slash( $meta_value ) |
|
933 | + , wp_slash($meta_key) |
|
934 | + , wp_slash($meta_value) |
|
935 | 935 | , $delete_all |
936 | 936 | ); |
937 | 937 | |
938 | - unset( $wpdb->wordpoints_points_logmeta ); |
|
939 | - remove_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
938 | + unset($wpdb->wordpoints_points_logmeta); |
|
939 | + remove_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
940 | 940 | |
941 | 941 | return $result; |
942 | 942 | } |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | * |
949 | 949 | * @param int $log_id The ID of the points log whose metadata to delete. |
950 | 950 | */ |
951 | -function wordpoints_points_log_delete_all_metadata( $log_id ) { |
|
951 | +function wordpoints_points_log_delete_all_metadata($log_id) { |
|
952 | 952 | |
953 | 953 | global $wpdb; |
954 | 954 | |
@@ -963,15 +963,15 @@ discard block |
||
963 | 963 | ) |
964 | 964 | ); // WPCS: cache pass. |
965 | 965 | |
966 | - add_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
966 | + add_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
967 | 967 | $wpdb->wordpoints_points_logmeta = $wpdb->wordpoints_points_log_meta; |
968 | 968 | |
969 | - foreach ( $meta_ids as $mid ) { |
|
970 | - delete_metadata_by_mid( 'wordpoints_points_log', $mid ); |
|
969 | + foreach ($meta_ids as $mid) { |
|
970 | + delete_metadata_by_mid('wordpoints_points_log', $mid); |
|
971 | 971 | } |
972 | 972 | |
973 | - unset( $wpdb->wordpoints_points_logmeta ); |
|
974 | - remove_filter( 'sanitize_key', '_wordpoints_points_log_meta_column' ); |
|
973 | + unset($wpdb->wordpoints_points_logmeta); |
|
974 | + remove_filter('sanitize_key', '_wordpoints_points_log_meta_column'); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | /** |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | 'wordpoints_default_points_type' |
988 | 988 | ); |
989 | 989 | |
990 | - if ( ! wordpoints_is_points_type( $points_type ) ) { |
|
990 | + if ( ! wordpoints_is_points_type($points_type)) { |
|
991 | 991 | return false; |
992 | 992 | } |
993 | 993 | |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | * |
1009 | 1009 | * @return string The log text. |
1010 | 1010 | */ |
1011 | -function wordpoints_render_points_log_text( $user_id, $points, $points_type, $log_type, $meta, $default_text = '' ) { |
|
1011 | +function wordpoints_render_points_log_text($user_id, $points, $points_type, $log_type, $meta, $default_text = '') { |
|
1012 | 1012 | |
1013 | 1013 | /** |
1014 | 1014 | * The text for a points log entry. |
@@ -1020,10 +1020,10 @@ discard block |
||
1020 | 1020 | * @param string $log_type The type of transaction being logged. |
1021 | 1021 | * @param array $meta The metadata for this transaction. |
1022 | 1022 | */ |
1023 | - $text = apply_filters( "wordpoints_points_log-{$log_type}", $default_text, $user_id, $points, $points_type, $log_type, $meta ); |
|
1023 | + $text = apply_filters("wordpoints_points_log-{$log_type}", $default_text, $user_id, $points, $points_type, $log_type, $meta); |
|
1024 | 1024 | |
1025 | - if ( empty( $text ) ) { |
|
1026 | - $text = _x( '(no description)', 'points log', 'wordpoints' ); |
|
1025 | + if (empty($text)) { |
|
1026 | + $text = _x('(no description)', 'points log', 'wordpoints'); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | return $text; |
@@ -1039,32 +1039,32 @@ discard block |
||
1039 | 1039 | * |
1040 | 1040 | * @return void |
1041 | 1041 | */ |
1042 | -function wordpoints_regenerate_points_logs( $logs ) { |
|
1042 | +function wordpoints_regenerate_points_logs($logs) { |
|
1043 | 1043 | |
1044 | - if ( empty( $logs ) || ! is_array( $logs ) ) { |
|
1044 | + if (empty($logs) || ! is_array($logs)) { |
|
1045 | 1045 | return; |
1046 | 1046 | } |
1047 | 1047 | |
1048 | - if ( ! is_object( current( $logs ) ) ) { |
|
1048 | + if ( ! is_object(current($logs))) { |
|
1049 | 1049 | |
1050 | - _deprecated_argument( __FUNCTION__, '1.6.0', 'The first parameter should be an array of log objects, not log IDs.' ); |
|
1050 | + _deprecated_argument(__FUNCTION__, '1.6.0', 'The first parameter should be an array of log objects, not log IDs.'); |
|
1051 | 1051 | |
1052 | - $logs = new WordPoints_Points_Logs_Query( array( 'id__in' => $logs ) ); |
|
1052 | + $logs = new WordPoints_Points_Logs_Query(array('id__in' => $logs)); |
|
1053 | 1053 | $logs = $logs->get(); |
1054 | 1054 | |
1055 | - if ( ! is_array( $logs ) ) { |
|
1055 | + if ( ! is_array($logs)) { |
|
1056 | 1056 | return; |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | global $wpdb; |
1061 | 1061 | |
1062 | - $flushed = array( 'points_types' => array(), 'user_ids' => array() ); |
|
1062 | + $flushed = array('points_types' => array(), 'user_ids' => array()); |
|
1063 | 1063 | |
1064 | - foreach ( $logs as $log ) { |
|
1064 | + foreach ($logs as $log) { |
|
1065 | 1065 | |
1066 | - $meta = wordpoints_get_points_log_meta( $log->id ); |
|
1067 | - $meta = wp_list_pluck( $meta, 0 ); |
|
1066 | + $meta = wordpoints_get_points_log_meta($log->id); |
|
1067 | + $meta = wp_list_pluck($meta, 0); |
|
1068 | 1068 | |
1069 | 1069 | $new_log_text = wordpoints_render_points_log_text( |
1070 | 1070 | $log->user_id |
@@ -1074,31 +1074,31 @@ discard block |
||
1074 | 1074 | , $meta |
1075 | 1075 | ); |
1076 | 1076 | |
1077 | - if ( $new_log_text !== $log->text ) { |
|
1077 | + if ($new_log_text !== $log->text) { |
|
1078 | 1078 | |
1079 | - if ( ! isset( $is_utf8 ) ) { |
|
1080 | - $is_utf8 = 'utf8' === $wpdb->get_col_charset( $wpdb->wordpoints_points_logs, 'text' ); |
|
1079 | + if ( ! isset($is_utf8)) { |
|
1080 | + $is_utf8 = 'utf8' === $wpdb->get_col_charset($wpdb->wordpoints_points_logs, 'text'); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | - if ( $is_utf8 ) { |
|
1084 | - $new_log_text = wp_encode_emoji( $new_log_text ); |
|
1083 | + if ($is_utf8) { |
|
1084 | + $new_log_text = wp_encode_emoji($new_log_text); |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | $wpdb->update( |
1088 | 1088 | $wpdb->wordpoints_points_logs |
1089 | - , array( 'text' => $new_log_text ) |
|
1090 | - , array( 'id' => $log->id ) |
|
1091 | - , array( '%s' ) |
|
1092 | - , array( '%d' ) |
|
1089 | + , array('text' => $new_log_text) |
|
1090 | + , array('id' => $log->id) |
|
1091 | + , array('%s') |
|
1092 | + , array('%d') |
|
1093 | 1093 | ); |
1094 | 1094 | |
1095 | - if ( ! isset( $flushed['points_types'][ $log->points_type ], $flushed['user_ids'][ $log->user_id ] ) ) { |
|
1095 | + if ( ! isset($flushed['points_types'][$log->points_type], $flushed['user_ids'][$log->user_id])) { |
|
1096 | 1096 | wordpoints_flush_points_logs_caches( |
1097 | - array( 'user_id' => $log->user_id, 'points_type' => $log->points_type ) |
|
1097 | + array('user_id' => $log->user_id, 'points_type' => $log->points_type) |
|
1098 | 1098 | ); |
1099 | 1099 | |
1100 | - $flushed['points_types'][ $log->points_type ] = true; |
|
1101 | - $flushed['user_ids'][ $log->user_id ] = true; |
|
1100 | + $flushed['points_types'][$log->points_type] = true; |
|
1101 | + $flushed['user_ids'][$log->user_id] = true; |
|
1102 | 1102 | } |
1103 | 1103 | } |
1104 | 1104 | |
@@ -1118,35 +1118,35 @@ discard block |
||
1118 | 1118 | * |
1119 | 1119 | * @return int[] The IDs of the users with the most points. |
1120 | 1120 | */ |
1121 | -function wordpoints_points_get_top_users( $num_users, $points_type ) { |
|
1121 | +function wordpoints_points_get_top_users($num_users, $points_type) { |
|
1122 | 1122 | |
1123 | - if ( ! wordpoints_posint( $num_users ) || ! wordpoints_is_points_type( $points_type ) ) { |
|
1123 | + if ( ! wordpoints_posint($num_users) || ! wordpoints_is_points_type($points_type)) { |
|
1124 | 1124 | return; |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - $cache = wp_cache_get( $points_type, 'wordpoints_points_top_users' ); |
|
1127 | + $cache = wp_cache_get($points_type, 'wordpoints_points_top_users'); |
|
1128 | 1128 | |
1129 | - if ( ! is_array( $cache ) ) { |
|
1130 | - $cache = array( 'is_max' => false, 'top_users' => array() ); |
|
1129 | + if ( ! is_array($cache)) { |
|
1130 | + $cache = array('is_max' => false, 'top_users' => array()); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | - $cached_users = count( $cache['top_users'] ); |
|
1133 | + $cached_users = count($cache['top_users']); |
|
1134 | 1134 | |
1135 | - if ( $num_users > $cached_users && ! $cache['is_max'] ) { |
|
1135 | + if ($num_users > $cached_users && ! $cache['is_max']) { |
|
1136 | 1136 | |
1137 | 1137 | global $wpdb; |
1138 | 1138 | |
1139 | - $excluded = wordpoints_get_excluded_users( 'top_users' ); |
|
1139 | + $excluded = wordpoints_get_excluded_users('top_users'); |
|
1140 | 1140 | |
1141 | 1141 | $exclude_users = ''; |
1142 | - if ( ! empty( $excluded ) ) { |
|
1143 | - $exclude_users = 'WHERE `ID` NOT IN (' . wordpoints_prepare__in( $excluded, '%d' ) . ')'; |
|
1142 | + if ( ! empty($excluded)) { |
|
1143 | + $exclude_users = 'WHERE `ID` NOT IN (' . wordpoints_prepare__in($excluded, '%d') . ')'; |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | $multisite_join = ''; |
1147 | - if ( is_multisite() && ! is_wordpoints_network_active() ) { |
|
1147 | + if (is_multisite() && ! is_wordpoints_network_active()) { |
|
1148 | 1148 | |
1149 | - $prefix = $wpdb->get_blog_prefix( get_current_blog_id() ); |
|
1149 | + $prefix = $wpdb->get_blog_prefix(get_current_blog_id()); |
|
1150 | 1150 | |
1151 | 1151 | $multisite_join = " |
1152 | 1152 | INNER JOIN `{$wpdb->usermeta}` AS `cap` |
@@ -1171,27 +1171,27 @@ discard block |
||
1171 | 1171 | ORDER BY COALESCE(CONVERT(`meta`.`meta_value`, SIGNED INTEGER), 0) DESC |
1172 | 1172 | LIMIT %d,%d |
1173 | 1173 | ", |
1174 | - wordpoints_get_points_user_meta_key( $points_type ), |
|
1174 | + wordpoints_get_points_user_meta_key($points_type), |
|
1175 | 1175 | $cached_users, |
1176 | 1176 | $num_users |
1177 | 1177 | ) |
1178 | 1178 | ); |
1179 | 1179 | |
1180 | - if ( ! is_array( $top_users ) ) { |
|
1180 | + if ( ! is_array($top_users)) { |
|
1181 | 1181 | return array(); |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - $cache['top_users'] = array_merge( $cache['top_users'], $top_users ); |
|
1184 | + $cache['top_users'] = array_merge($cache['top_users'], $top_users); |
|
1185 | 1185 | |
1186 | - if ( count( $cache['top_users'] ) < $num_users ) { |
|
1186 | + if (count($cache['top_users']) < $num_users) { |
|
1187 | 1187 | $cache['is_max'] = true; |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - wp_cache_set( $points_type, $cache, 'wordpoints_points_top_users' ); |
|
1190 | + wp_cache_set($points_type, $cache, 'wordpoints_points_top_users'); |
|
1191 | 1191 | |
1192 | 1192 | } // End if ( not cached ). |
1193 | 1193 | |
1194 | - return array_slice( $cache['top_users'], 0, $num_users ); |
|
1194 | + return array_slice($cache['top_users'], 0, $num_users); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | /** |
@@ -1203,25 +1203,25 @@ discard block |
||
1203 | 1203 | * @param string $points_type The type of points. |
1204 | 1204 | * @param string $context The context in which the table is being displayed. |
1205 | 1205 | */ |
1206 | -function wordpoints_points_show_top_users( $num_users, $points_type, $context = 'default' ) { |
|
1206 | +function wordpoints_points_show_top_users($num_users, $points_type, $context = 'default') { |
|
1207 | 1207 | |
1208 | - wp_enqueue_style( 'wordpoints-top-users' ); |
|
1208 | + wp_enqueue_style('wordpoints-top-users'); |
|
1209 | 1209 | |
1210 | - $top_users = wordpoints_points_get_top_users( $num_users, $points_type ); |
|
1210 | + $top_users = wordpoints_points_get_top_users($num_users, $points_type); |
|
1211 | 1211 | |
1212 | - if ( ! $top_users ) { |
|
1212 | + if ( ! $top_users) { |
|
1213 | 1213 | return; |
1214 | 1214 | } |
1215 | 1215 | |
1216 | 1216 | $column_headers = array( |
1217 | - 'position' => _x( 'Position', 'top users table heading', 'wordpoints' ), |
|
1218 | - 'user' => _x( 'User', 'top users table heading', 'wordpoints' ), |
|
1219 | - 'points' => _x( 'Points', 'top users table heading', 'wordpoints' ), |
|
1217 | + 'position' => _x('Position', 'top users table heading', 'wordpoints'), |
|
1218 | + 'user' => _x('User', 'top users table heading', 'wordpoints'), |
|
1219 | + 'points' => _x('Points', 'top users table heading', 'wordpoints'), |
|
1220 | 1220 | ); |
1221 | 1221 | |
1222 | - $points_type_name = wordpoints_get_points_type_setting( $points_type, 'name' ); |
|
1222 | + $points_type_name = wordpoints_get_points_type_setting($points_type, 'name'); |
|
1223 | 1223 | |
1224 | - if ( ! empty( $points_type_name ) ) { |
|
1224 | + if ( ! empty($points_type_name)) { |
|
1225 | 1225 | $column_headers['points'] = $points_type_name; |
1226 | 1226 | } |
1227 | 1227 | |
@@ -1237,18 +1237,18 @@ discard block |
||
1237 | 1237 | $extra_classes = apply_filters( |
1238 | 1238 | 'wordpoints_points_top_users_table_extra_classes' |
1239 | 1239 | , array() |
1240 | - , compact( 'num_users', 'points_type', 'context' ) |
|
1240 | + , compact('num_users', 'points_type', 'context') |
|
1241 | 1241 | , $top_users |
1242 | 1242 | ); |
1243 | 1243 | |
1244 | 1244 | ?> |
1245 | 1245 | |
1246 | - <table class="wordpoints-points-top-users <?php echo esc_attr( implode( ' ', $extra_classes ) ); ?>"> |
|
1246 | + <table class="wordpoints-points-top-users <?php echo esc_attr(implode(' ', $extra_classes)); ?>"> |
|
1247 | 1247 | <thead> |
1248 | 1248 | <tr> |
1249 | - <th scope="col"><?php echo esc_html( $column_headers['position'] ); ?></th> |
|
1250 | - <th scope="col"><?php echo esc_html( $column_headers['user'] ); ?></th> |
|
1251 | - <th scope="col"><?php echo esc_html( $column_headers['points'] ); ?></th> |
|
1249 | + <th scope="col"><?php echo esc_html($column_headers['position']); ?></th> |
|
1250 | + <th scope="col"><?php echo esc_html($column_headers['user']); ?></th> |
|
1251 | + <th scope="col"><?php echo esc_html($column_headers['points']); ?></th> |
|
1252 | 1252 | </tr> |
1253 | 1253 | </thead> |
1254 | 1254 | <tbody> |
@@ -1256,16 +1256,16 @@ discard block |
||
1256 | 1256 | |
1257 | 1257 | $position = 1; |
1258 | 1258 | |
1259 | - foreach ( $top_users as $user_id ) { |
|
1259 | + foreach ($top_users as $user_id) { |
|
1260 | 1260 | |
1261 | - $user = get_userdata( $user_id ); |
|
1261 | + $user = get_userdata($user_id); |
|
1262 | 1262 | |
1263 | 1263 | ?> |
1264 | 1264 | |
1265 | 1265 | <tr class="top-<?php echo (int) $position; ?>"> |
1266 | - <td><?php echo esc_html( number_format_i18n( $position ) ); ?></td> |
|
1266 | + <td><?php echo esc_html(number_format_i18n($position)); ?></td> |
|
1267 | 1267 | <td> |
1268 | - <?php echo get_avatar( $user_id, 32 ); ?> |
|
1268 | + <?php echo get_avatar($user_id, 32); ?> |
|
1269 | 1269 | <?php |
1270 | 1270 | |
1271 | 1271 | $name = sanitize_user_field( |
@@ -1287,13 +1287,13 @@ discard block |
||
1287 | 1287 | * @param string $points_type The points type the table is for. |
1288 | 1288 | * @param string $context The context in which the table is being displayed. |
1289 | 1289 | */ |
1290 | - $name = apply_filters( 'wordpoints_points_top_users_username', $name, $user_id, $points_type, "top_users_{$context}" ); |
|
1290 | + $name = apply_filters('wordpoints_points_top_users_username', $name, $user_id, $points_type, "top_users_{$context}"); |
|
1291 | 1291 | |
1292 | - echo wp_kses( $name, 'wordpoints_top_users_username' ); |
|
1292 | + echo wp_kses($name, 'wordpoints_top_users_username'); |
|
1293 | 1293 | |
1294 | 1294 | ?> |
1295 | 1295 | </td> |
1296 | - <td><?php wordpoints_display_points( $user_id, $points_type, "top_users_{$context}" ); ?></td> |
|
1296 | + <td><?php wordpoints_display_points($user_id, $points_type, "top_users_{$context}"); ?></td> |
|
1297 | 1297 | </tr> |
1298 | 1298 | |
1299 | 1299 | <?php |
@@ -1306,9 +1306,9 @@ discard block |
||
1306 | 1306 | </tbody> |
1307 | 1307 | <tfoot> |
1308 | 1308 | <tr> |
1309 | - <th scope="col"><?php echo esc_html( $column_headers['position'] ); ?></th> |
|
1310 | - <th scope="col"><?php echo esc_html( $column_headers['user'] ); ?></th> |
|
1311 | - <th scope="col"><?php echo esc_html( $column_headers['points'] ); ?></th> |
|
1309 | + <th scope="col"><?php echo esc_html($column_headers['position']); ?></th> |
|
1310 | + <th scope="col"><?php echo esc_html($column_headers['user']); ?></th> |
|
1311 | + <th scope="col"><?php echo esc_html($column_headers['points']); ?></th> |
|
1312 | 1312 | </tr> |
1313 | 1313 | </tfoot> |
1314 | 1314 | </table> |
@@ -1328,9 +1328,9 @@ discard block |
||
1328 | 1328 | * @param int $points The number of points. Not used. |
1329 | 1329 | * @param string $points_type The type of points being awarded. |
1330 | 1330 | */ |
1331 | -function wordpoints_clean_points_top_users_cache( $user_id, $points, $points_type ) { |
|
1331 | +function wordpoints_clean_points_top_users_cache($user_id, $points, $points_type) { |
|
1332 | 1332 | |
1333 | - wp_cache_delete( $points_type, 'wordpoints_points_top_users' ); |
|
1333 | + wp_cache_delete($points_type, 'wordpoints_points_top_users'); |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | /** |
@@ -1342,16 +1342,16 @@ discard block |
||
1342 | 1342 | */ |
1343 | 1343 | function wordpoints_clean_points_top_users_cache_user_register() { |
1344 | 1344 | |
1345 | - foreach ( wordpoints_get_points_types() as $slug => $unused ) { |
|
1345 | + foreach (wordpoints_get_points_types() as $slug => $unused) { |
|
1346 | 1346 | |
1347 | - $cache = wp_cache_get( $slug, 'wordpoints_points_top_users' ); |
|
1347 | + $cache = wp_cache_get($slug, 'wordpoints_points_top_users'); |
|
1348 | 1348 | |
1349 | 1349 | // If there aren't fewer users than the cache holds, we don't need to clear it. |
1350 | - if ( ! is_array( $cache ) || ! $cache['is_max'] ) { |
|
1350 | + if ( ! is_array($cache) || ! $cache['is_max']) { |
|
1351 | 1351 | continue; |
1352 | 1352 | } |
1353 | 1353 | |
1354 | - wp_cache_delete( $slug, 'wordpoints_points_top_users' ); |
|
1354 | + wp_cache_delete($slug, 'wordpoints_points_top_users'); |
|
1355 | 1355 | } |
1356 | 1356 | } |
1357 | 1357 | |
@@ -1365,18 +1365,18 @@ discard block |
||
1365 | 1365 | * |
1366 | 1366 | * @param int $user_id The ID of the user who was deleted. |
1367 | 1367 | */ |
1368 | -function wordpoints_clean_points_top_users_cache_user_deleted( $user_id ) { |
|
1368 | +function wordpoints_clean_points_top_users_cache_user_deleted($user_id) { |
|
1369 | 1369 | |
1370 | - foreach ( wordpoints_get_points_types() as $slug => $unused ) { |
|
1370 | + foreach (wordpoints_get_points_types() as $slug => $unused) { |
|
1371 | 1371 | |
1372 | - $cache = wp_cache_get( $slug, 'wordpoints_points_top_users' ); |
|
1372 | + $cache = wp_cache_get($slug, 'wordpoints_points_top_users'); |
|
1373 | 1373 | |
1374 | 1374 | // If this user isn't in the cache, we don't need to clear it. |
1375 | - if ( ! is_array( $cache ) || ! in_array( $user_id, $cache['top_users'] ) ) { |
|
1375 | + if ( ! is_array($cache) || ! in_array($user_id, $cache['top_users'])) { |
|
1376 | 1376 | continue; |
1377 | 1377 | } |
1378 | 1378 | |
1379 | - wp_cache_delete( $slug, 'wordpoints_points_top_users' ); |
|
1379 | + wp_cache_delete($slug, 'wordpoints_points_top_users'); |
|
1380 | 1380 | } |
1381 | 1381 | } |
1382 | 1382 | |
@@ -1389,18 +1389,18 @@ discard block |
||
1389 | 1389 | */ |
1390 | 1390 | function wordpoints_register_points_hooks() { |
1391 | 1391 | |
1392 | - WordPoints_Points_Hooks::register( 'WordPoints_Comment_Received_Points_Hook' ); |
|
1393 | - WordPoints_Points_Hooks::register( 'WordPoints_Comment_Points_Hook' ); |
|
1394 | - WordPoints_Points_Hooks::register( 'WordPoints_Periodic_Points_Hook' ); |
|
1395 | - WordPoints_Points_Hooks::register( 'WordPoints_Post_Points_Hook' ); |
|
1396 | - WordPoints_Points_Hooks::register( 'WordPoints_Registration_Points_Hook' ); |
|
1392 | + WordPoints_Points_Hooks::register('WordPoints_Comment_Received_Points_Hook'); |
|
1393 | + WordPoints_Points_Hooks::register('WordPoints_Comment_Points_Hook'); |
|
1394 | + WordPoints_Points_Hooks::register('WordPoints_Periodic_Points_Hook'); |
|
1395 | + WordPoints_Points_Hooks::register('WordPoints_Post_Points_Hook'); |
|
1396 | + WordPoints_Points_Hooks::register('WordPoints_Registration_Points_Hook'); |
|
1397 | 1397 | |
1398 | - if ( get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
1399 | - WordPoints_Points_Hooks::register( 'WordPoints_Post_Delete_Points_Hook' ); |
|
1398 | + if (get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
1399 | + WordPoints_Points_Hooks::register('WordPoints_Post_Delete_Points_Hook'); |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | - if ( get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
1403 | - WordPoints_Points_Hooks::register( 'WordPoints_Comment_Removed_Points_Hook' ); |
|
1402 | + if (get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
1403 | + WordPoints_Points_Hooks::register('WordPoints_Comment_Removed_Points_Hook'); |
|
1404 | 1404 | } |
1405 | 1405 | } |
1406 | 1406 |
@@ -402,7 +402,7 @@ |
||
402 | 402 | * |
403 | 403 | * @param int $rank_id The ID of the rank to get the position of. |
404 | 404 | * |
405 | - * @return int|false The rank's position, or false. |
|
405 | + * @return integer The rank's position, or false. |
|
406 | 406 | */ |
407 | 407 | public function get_rank_position( $rank_id ) { |
408 | 408 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @type string[] $types |
54 | 54 | */ |
55 | - private $types = array( 'base' => 'base' ); |
|
55 | + private $types = array('base' => 'base'); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Construct the group with its slug and other data. |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @type string $description A description of this group. |
68 | 68 | * } |
69 | 69 | */ |
70 | - public function __construct( $slug, $data ) { |
|
70 | + public function __construct($slug, $data) { |
|
71 | 71 | |
72 | 72 | $this->slug = $slug; |
73 | 73 | $this->data = $data; |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @since 1.7.0 |
81 | 81 | */ |
82 | - public function __get( $key ) { |
|
82 | + public function __get($key) { |
|
83 | 83 | |
84 | - if ( isset( $this->$key ) ) { |
|
84 | + if (isset($this->$key)) { |
|
85 | 85 | return $this->$key; |
86 | - } elseif ( isset( $this->data[ $key ] ) ) { |
|
87 | - return $this->data[ $key ]; |
|
86 | + } elseif (isset($this->data[$key])) { |
|
87 | + return $this->data[$key]; |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return bool Whether the rank type was registered for this group. |
122 | 122 | */ |
123 | - public function has_type( $type ) { |
|
123 | + public function has_type($type) { |
|
124 | 124 | |
125 | - if ( ! WordPoints_Rank_Types::is_type_registered( $type ) ) { |
|
125 | + if ( ! WordPoints_Rank_Types::is_type_registered($type)) { |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
129 | - return isset( $this->types[ $type ] ); |
|
129 | + return isset($this->types[$type]); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @return bool Whether the type was added successfully. |
140 | 140 | */ |
141 | - public function add_type( $type ) { |
|
141 | + public function add_type($type) { |
|
142 | 142 | |
143 | - if ( ! WordPoints_Rank_Types::is_type_registered( $type ) ) { |
|
143 | + if ( ! WordPoints_Rank_Types::is_type_registered($type)) { |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - if ( isset( $this->types[ $type ] ) ) { |
|
147 | + if (isset($this->types[$type])) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
151 | - $this->types[ $type ] = $type; |
|
151 | + $this->types[$type] = $type; |
|
152 | 152 | |
153 | 153 | return true; |
154 | 154 | } |
@@ -164,21 +164,21 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return bool Whether the type was removed successfully. |
166 | 166 | */ |
167 | - public function remove_type( $type ) { |
|
167 | + public function remove_type($type) { |
|
168 | 168 | |
169 | - if ( 'base' === $type ) { |
|
169 | + if ('base' === $type) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - if ( ! WordPoints_Rank_Types::is_type_registered( $type ) ) { |
|
173 | + if ( ! WordPoints_Rank_Types::is_type_registered($type)) { |
|
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | - if ( ! isset( $this->types[ $type ] ) ) { |
|
177 | + if ( ! isset($this->types[$type])) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
181 | - unset( $this->types[ $type ] ); |
|
181 | + unset($this->types[$type]); |
|
182 | 182 | |
183 | 183 | return true; |
184 | 184 | } |
@@ -197,30 +197,30 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return bool Whether the rank was added successfully. |
199 | 199 | */ |
200 | - public function add_rank( $rank_id, $position ) { |
|
200 | + public function add_rank($rank_id, $position) { |
|
201 | 201 | |
202 | 202 | if ( |
203 | - ! wordpoints_posint( $rank_id ) |
|
204 | - || false === wordpoints_int( $position ) |
|
203 | + ! wordpoints_posint($rank_id) |
|
204 | + || false === wordpoints_int($position) |
|
205 | 205 | || $position < 0 |
206 | 206 | ) { |
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Don't allow a rank to be added to this group more than once. |
211 | - if ( false !== $this->get_rank_position( $rank_id ) ) { |
|
211 | + if (false !== $this->get_rank_position($rank_id)) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
215 | - $ranks = $this->_insert_rank( $this->get_ranks(), $rank_id, $position ); |
|
215 | + $ranks = $this->_insert_rank($this->get_ranks(), $rank_id, $position); |
|
216 | 216 | |
217 | - if ( ! $this->save_ranks( $ranks ) ) { |
|
217 | + if ( ! $this->save_ranks($ranks)) { |
|
218 | 218 | return false; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // If there is a rank before this one, check if any of the users who have it |
222 | 222 | // can increase to this new one. |
223 | - $this->_maybe_increase_users_with_previous_rank( $rank_id ); |
|
223 | + $this->_maybe_increase_users_with_previous_rank($rank_id); |
|
224 | 224 | |
225 | 225 | return true; |
226 | 226 | } |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return bool Whether the rank was moved successfully. |
240 | 240 | */ |
241 | - public function move_rank( $rank_id, $position ) { |
|
241 | + public function move_rank($rank_id, $position) { |
|
242 | 242 | |
243 | - $current_position = $this->get_rank_position( $rank_id ); |
|
243 | + $current_position = $this->get_rank_position($rank_id); |
|
244 | 244 | |
245 | - if ( $current_position === $position ) { |
|
245 | + if ($current_position === $position) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | |
249 | 249 | $ranks = $this->get_ranks(); |
250 | 250 | |
251 | - unset( $ranks[ $current_position ] ); |
|
251 | + unset($ranks[$current_position]); |
|
252 | 252 | |
253 | - ksort( $ranks ); |
|
253 | + ksort($ranks); |
|
254 | 254 | |
255 | - $ranks = $this->_insert_rank( array_values( $ranks ), $rank_id, $position ); |
|
255 | + $ranks = $this->_insert_rank(array_values($ranks), $rank_id, $position); |
|
256 | 256 | |
257 | - if ( ! $this->save_ranks( $ranks ) ) { |
|
257 | + if ( ! $this->save_ranks($ranks)) { |
|
258 | 258 | return false; |
259 | 259 | } |
260 | 260 | |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | // rank's position. |
263 | 263 | $this->_move_users_from_rank_to_rank( |
264 | 264 | $rank_id |
265 | - , $this->get_rank( $current_position - 1 ) |
|
265 | + , $this->get_rank($current_position - 1) |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // The users of the rank previous to this one's new position should maybe be |
269 | 269 | // increased to this rank. |
270 | - $this->_maybe_increase_users_with_previous_rank( $rank_id ); |
|
270 | + $this->_maybe_increase_users_with_previous_rank($rank_id); |
|
271 | 271 | |
272 | 272 | return true; |
273 | 273 | } |
@@ -281,45 +281,45 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return bool Whether the rank was removed successfully. |
283 | 283 | */ |
284 | - public function remove_rank( $rank_id ) { |
|
284 | + public function remove_rank($rank_id) { |
|
285 | 285 | |
286 | 286 | global $wpdb; |
287 | 287 | |
288 | - $position = $this->get_rank_position( $rank_id ); |
|
288 | + $position = $this->get_rank_position($rank_id); |
|
289 | 289 | |
290 | - if ( false === $position ) { |
|
290 | + if (false === $position) { |
|
291 | 291 | return false; |
292 | 292 | } |
293 | 293 | |
294 | 294 | $ranks = $this->get_ranks(); |
295 | 295 | |
296 | - unset( $ranks[ $position ] ); |
|
296 | + unset($ranks[$position]); |
|
297 | 297 | |
298 | - if ( ! $this->save_ranks( $ranks ) ) { |
|
298 | + if ( ! $this->save_ranks($ranks)) { |
|
299 | 299 | return false; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Assign the previous rank to users who have this rank. |
303 | - if ( isset( $ranks[ $position - 1 ] ) ) { |
|
303 | + if (isset($ranks[$position - 1])) { |
|
304 | 304 | |
305 | - $this->_move_users_from_rank_to_rank( $rank_id, $ranks[ $position - 1 ] ); |
|
305 | + $this->_move_users_from_rank_to_rank($rank_id, $ranks[$position - 1]); |
|
306 | 306 | |
307 | 307 | } else { |
308 | 308 | |
309 | 309 | // If there is no previous rank, just delete the rows. |
310 | 310 | $wpdb->delete( |
311 | 311 | $wpdb->wordpoints_user_ranks |
312 | - , array( 'rank_id' => $rank_id ) |
|
312 | + , array('rank_id' => $rank_id) |
|
313 | 313 | , '%d' |
314 | 314 | ); |
315 | 315 | |
316 | - $group_ranks = wp_cache_get( $this->slug, 'wordpoints_user_ranks' ); |
|
317 | - unset( $group_ranks[ $rank_id ] ); |
|
318 | - wp_cache_set( $this->slug, $group_ranks, 'wordpoints_user_ranks' ); |
|
316 | + $group_ranks = wp_cache_get($this->slug, 'wordpoints_user_ranks'); |
|
317 | + unset($group_ranks[$rank_id]); |
|
318 | + wp_cache_set($this->slug, $group_ranks, 'wordpoints_user_ranks'); |
|
319 | 319 | |
320 | - unset( $group_ranks ); |
|
320 | + unset($group_ranks); |
|
321 | 321 | |
322 | - wp_cache_delete( $rank_id, 'wordpoints_users_with_rank' ); |
|
322 | + wp_cache_delete($rank_id, 'wordpoints_users_with_rank'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | return true; |
@@ -336,17 +336,17 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return bool Whether the ranks were saved successfully. |
338 | 338 | */ |
339 | - public function save_ranks( $rank_ids ) { |
|
339 | + public function save_ranks($rank_ids) { |
|
340 | 340 | |
341 | - if ( count( array_unique( $rank_ids ) ) !== count( $rank_ids ) ) { |
|
341 | + if (count(array_unique($rank_ids)) !== count($rank_ids)) { |
|
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | |
345 | - ksort( $rank_ids ); |
|
345 | + ksort($rank_ids); |
|
346 | 346 | |
347 | - $rank_ids = array_values( $rank_ids ); |
|
347 | + $rank_ids = array_values($rank_ids); |
|
348 | 348 | |
349 | - return update_option( $this->option_name, $rank_ids ); |
|
349 | + return update_option($this->option_name, $rank_ids); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | */ |
359 | 359 | public function get_ranks() { |
360 | 360 | |
361 | - return wordpoints_get_array_option( $this->option_name ); |
|
361 | + return wordpoints_get_array_option($this->option_name); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function get_base_rank() { |
374 | 374 | |
375 | - return $this->get_rank( 0 ); |
|
375 | + return $this->get_rank(0); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -384,15 +384,15 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return int|false The ID of the rank, or false if not found. |
386 | 386 | */ |
387 | - public function get_rank( $position ) { |
|
387 | + public function get_rank($position) { |
|
388 | 388 | |
389 | 389 | $ranks = $this->get_ranks(); |
390 | 390 | |
391 | - if ( ! isset( $ranks[ $position ] ) ) { |
|
391 | + if ( ! isset($ranks[$position])) { |
|
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | |
395 | - return $ranks[ $position ]; |
|
395 | + return $ranks[$position]; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -404,10 +404,10 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @return int|false The rank's position, or false. |
406 | 406 | */ |
407 | - public function get_rank_position( $rank_id ) { |
|
407 | + public function get_rank_position($rank_id) { |
|
408 | 408 | |
409 | 409 | return array_search( |
410 | - wordpoints_posint( $rank_id ) |
|
410 | + wordpoints_posint($rank_id) |
|
411 | 411 | , $this->get_ranks() |
412 | 412 | , true |
413 | 413 | ); |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return int[] The list of ranks with the rank insterted. |
430 | 430 | */ |
431 | - private function _insert_rank( $ranks, $rank_id, $position ) { |
|
431 | + private function _insert_rank($ranks, $rank_id, $position) { |
|
432 | 432 | |
433 | - $count = count( $ranks ); |
|
433 | + $count = count($ranks); |
|
434 | 434 | |
435 | - if ( $count === $position ) { |
|
435 | + if ($count === $position) { |
|
436 | 436 | |
437 | - $ranks[ $position ] = $rank_id; |
|
437 | + $ranks[$position] = $rank_id; |
|
438 | 438 | |
439 | - } elseif ( $count < $position ) { |
|
439 | + } elseif ($count < $position) { |
|
440 | 440 | |
441 | 441 | $ranks[] = $rank_id; |
442 | 442 | |
443 | 443 | } else { |
444 | 444 | |
445 | - $lower_ranks = array_slice( $ranks, 0, $position, true ); |
|
446 | - $higher_ranks = array_slice( $ranks, $position, null, true ); |
|
445 | + $lower_ranks = array_slice($ranks, 0, $position, true); |
|
446 | + $higher_ranks = array_slice($ranks, $position, null, true); |
|
447 | 447 | |
448 | 448 | $ranks = array_merge( |
449 | 449 | $lower_ranks |
450 | - , array( $position => $rank_id ) |
|
450 | + , array($position => $rank_id) |
|
451 | 451 | , $higher_ranks |
452 | 452 | ); |
453 | 453 | } |
@@ -463,29 +463,29 @@ discard block |
||
463 | 463 | * @param int $rank_from_id The ID of the rank the users have now. |
464 | 464 | * @param int $rank_to_id The ID of the rank to give the users instead. |
465 | 465 | */ |
466 | - private function _move_users_from_rank_to_rank( $rank_from_id, $rank_to_id ) { |
|
466 | + private function _move_users_from_rank_to_rank($rank_from_id, $rank_to_id) { |
|
467 | 467 | |
468 | 468 | global $wpdb; |
469 | 469 | |
470 | - if ( ! wordpoints_posint( $rank_from_id ) || ! wordpoints_posint( $rank_to_id ) ) { |
|
470 | + if ( ! wordpoints_posint($rank_from_id) || ! wordpoints_posint($rank_to_id)) { |
|
471 | 471 | return; |
472 | 472 | } |
473 | 473 | |
474 | - $group_ranks = wp_cache_get( $this->slug, 'wordpoints_user_ranks' ); |
|
474 | + $group_ranks = wp_cache_get($this->slug, 'wordpoints_user_ranks'); |
|
475 | 475 | |
476 | - unset( $group_ranks[ $rank_from_id ], $group_ranks[ $rank_to_id ] ); |
|
476 | + unset($group_ranks[$rank_from_id], $group_ranks[$rank_to_id]); |
|
477 | 477 | |
478 | - wp_cache_set( $this->slug, $group_ranks, 'wordpoints_user_ranks' ); |
|
478 | + wp_cache_set($this->slug, $group_ranks, 'wordpoints_user_ranks'); |
|
479 | 479 | |
480 | - unset( $group_ranks ); |
|
480 | + unset($group_ranks); |
|
481 | 481 | |
482 | - wp_cache_delete( $rank_from_id, 'wordpoints_users_with_rank' ); |
|
483 | - wp_cache_delete( $rank_to_id, 'wordpoints_users_with_rank' ); |
|
482 | + wp_cache_delete($rank_from_id, 'wordpoints_users_with_rank'); |
|
483 | + wp_cache_delete($rank_to_id, 'wordpoints_users_with_rank'); |
|
484 | 484 | |
485 | 485 | $wpdb->update( |
486 | 486 | $wpdb->wordpoints_user_ranks |
487 | - , array( 'rank_id' => $rank_to_id ) |
|
488 | - , array( 'rank_id' => $rank_from_id ) |
|
487 | + , array('rank_id' => $rank_to_id) |
|
488 | + , array('rank_id' => $rank_from_id) |
|
489 | 489 | , '%d' |
490 | 490 | , '%d' |
491 | 491 | ); |
@@ -498,35 +498,35 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @param int $rank_id A rank ID. |
500 | 500 | */ |
501 | - private function _maybe_increase_users_with_previous_rank( $rank_id ) { |
|
501 | + private function _maybe_increase_users_with_previous_rank($rank_id) { |
|
502 | 502 | |
503 | - $rank = wordpoints_get_rank( $rank_id ); |
|
503 | + $rank = wordpoints_get_rank($rank_id); |
|
504 | 504 | $previous_rank = $rank->get_adjacent( -1 ); |
505 | 505 | |
506 | - if ( ! $previous_rank ) { |
|
506 | + if ( ! $previous_rank) { |
|
507 | 507 | return; |
508 | 508 | } |
509 | 509 | |
510 | - $users = wordpoints_get_users_with_rank( $previous_rank->ID ); |
|
510 | + $users = wordpoints_get_users_with_rank($previous_rank->ID); |
|
511 | 511 | |
512 | - if ( empty( $users ) ) { |
|
512 | + if (empty($users)) { |
|
513 | 513 | return; |
514 | 514 | } |
515 | 515 | |
516 | - $rank_type = WordPoints_Rank_Types::get_type( $rank->type ); |
|
516 | + $rank_type = WordPoints_Rank_Types::get_type($rank->type); |
|
517 | 517 | |
518 | - foreach ( $users as $user_id ) { |
|
518 | + foreach ($users as $user_id) { |
|
519 | 519 | |
520 | 520 | $new_rank = $rank_type->maybe_increase_user_rank( |
521 | 521 | $user_id |
522 | 522 | , $previous_rank |
523 | 523 | ); |
524 | 524 | |
525 | - if ( $new_rank->ID === $previous_rank->ID ) { |
|
525 | + if ($new_rank->ID === $previous_rank->ID) { |
|
526 | 526 | continue; |
527 | 527 | } |
528 | 528 | |
529 | - wordpoints_update_user_rank( $user_id, $new_rank->ID ); |
|
529 | + wordpoints_update_user_rank($user_id, $new_rank->ID); |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | } |
@@ -697,7 +697,7 @@ |
||
697 | 697 | * @since 2.0.0 |
698 | 698 | * |
699 | 699 | * @param string $option The name of the option to set. |
700 | - * @param mixed $value The value of the option. |
|
700 | + * @param string $value The value of the option. |
|
701 | 701 | */ |
702 | 702 | private function _set_option( $option, $value = true ) { |
703 | 703 |
@@ -285,21 +285,21 @@ discard block |
||
285 | 285 | * @param string $slug The slug of the entity. |
286 | 286 | * @param string $version The current code version of the entity. |
287 | 287 | */ |
288 | - public function __construct( $slug = null, $version = null ) { |
|
288 | + public function __construct($slug = null, $version = null) { |
|
289 | 289 | |
290 | - if ( ! isset( $slug ) ) { |
|
291 | - _doing_it_wrong( __METHOD__, 'The $slug parameter is required.', '2.0.0' ); |
|
290 | + if ( ! isset($slug)) { |
|
291 | + _doing_it_wrong(__METHOD__, 'The $slug parameter is required.', '2.0.0'); |
|
292 | 292 | } |
293 | 293 | |
294 | - if ( ! isset( $version ) ) { |
|
295 | - _doing_it_wrong( __METHOD__, 'The $version parameter is required.', '2.0.0' ); |
|
294 | + if ( ! isset($version)) { |
|
295 | + _doing_it_wrong(__METHOD__, 'The $version parameter is required.', '2.0.0'); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | $this->slug = $slug; |
299 | 299 | $this->version = $version; |
300 | 300 | |
301 | - if ( isset( $this->option_prefix ) ) { |
|
302 | - _deprecated_argument( __METHOD__, '2.0.0', 'The $option_prefix property is deprecated.' ); |
|
301 | + if (isset($this->option_prefix)) { |
|
302 | + _deprecated_argument(__METHOD__, '2.0.0', 'The $option_prefix property is deprecated.'); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @param bool $network Whether the install should be network-wide on multisite. |
312 | 312 | */ |
313 | - public function install( $network ) { |
|
313 | + public function install($network) { |
|
314 | 314 | |
315 | 315 | $this->action = 'install'; |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | |
321 | 321 | $hooks = wordpoints_hooks(); |
322 | 322 | $hooks_mode = $hooks->get_current_mode(); |
323 | - $hooks->set_current_mode( 'standard' ); |
|
323 | + $hooks->set_current_mode('standard'); |
|
324 | 324 | |
325 | 325 | $this->before_install(); |
326 | 326 | |
@@ -329,38 +329,38 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @since 1.8.0 |
331 | 331 | */ |
332 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
332 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
333 | 333 | |
334 | - if ( is_multisite() ) { |
|
334 | + if (is_multisite()) { |
|
335 | 335 | |
336 | 336 | $this->context = 'network'; |
337 | - $hooks->set_current_mode( 'network' ); |
|
337 | + $hooks->set_current_mode('network'); |
|
338 | 338 | |
339 | 339 | $this->install_network(); |
340 | 340 | |
341 | 341 | $this->context = 'site'; |
342 | - $hooks->set_current_mode( 'standard' ); |
|
342 | + $hooks->set_current_mode('standard'); |
|
343 | 343 | |
344 | - if ( $network ) { |
|
344 | + if ($network) { |
|
345 | 345 | |
346 | 346 | $this->set_network_installed(); |
347 | 347 | |
348 | 348 | $skip_per_site_install = $this->skip_per_site_install(); |
349 | 349 | |
350 | - if ( ! ( $skip_per_site_install & self::SKIP_INSTALL ) ) { |
|
350 | + if ( ! ($skip_per_site_install & self::SKIP_INSTALL)) { |
|
351 | 351 | |
352 | 352 | $ms_switched_state = new WordPoints_Multisite_Switched_State(); |
353 | 353 | $ms_switched_state->backup(); |
354 | 354 | |
355 | - foreach ( $this->get_all_site_ids() as $blog_id ) { |
|
356 | - switch_to_blog( $blog_id ); |
|
355 | + foreach ($this->get_all_site_ids() as $blog_id) { |
|
356 | + switch_to_blog($blog_id); |
|
357 | 357 | $this->install_site(); |
358 | 358 | } |
359 | 359 | |
360 | 360 | $ms_switched_state->restore(); |
361 | 361 | } |
362 | 362 | |
363 | - if ( $skip_per_site_install & self::REQUIRES_MANUAL_INSTALL ) { |
|
363 | + if ($skip_per_site_install & self::REQUIRES_MANUAL_INSTALL) { |
|
364 | 364 | |
365 | 365 | // We'll check this later and let the user know that per-site |
366 | 366 | // install was skipped. |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | } // End if ( is_multisite() ) else. |
382 | 382 | |
383 | - $hooks->set_current_mode( $hooks_mode ); |
|
383 | + $hooks->set_current_mode($hooks_mode); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @param int $site_id The ID of the site to install on. |
392 | 392 | */ |
393 | - public function install_on_site( $site_id ) { |
|
393 | + public function install_on_site($site_id) { |
|
394 | 394 | |
395 | 395 | $this->action = 'install'; |
396 | 396 | $this->network_wide = true; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | |
400 | 400 | $hooks = wordpoints_hooks(); |
401 | 401 | $hooks_mode = $hooks->get_current_mode(); |
402 | - $hooks->set_current_mode( 'standard' ); |
|
402 | + $hooks->set_current_mode('standard'); |
|
403 | 403 | |
404 | 404 | $this->before_install(); |
405 | 405 | |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @since 1.8.0 |
410 | 410 | */ |
411 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
411 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
412 | 412 | |
413 | 413 | $this->context = 'site'; |
414 | 414 | |
415 | - switch_to_blog( $site_id ); |
|
415 | + switch_to_blog($site_id); |
|
416 | 416 | $this->install_site(); |
417 | 417 | restore_current_blog(); |
418 | 418 | |
419 | - $hooks->set_current_mode( $hooks_mode ); |
|
419 | + $hooks->set_current_mode($hooks_mode); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -435,13 +435,13 @@ discard block |
||
435 | 435 | |
436 | 436 | $hooks = wordpoints_hooks(); |
437 | 437 | $hooks_mode = $hooks->get_current_mode(); |
438 | - $hooks->set_current_mode( 'standard' ); |
|
438 | + $hooks->set_current_mode('standard'); |
|
439 | 439 | |
440 | 440 | $this->before_uninstall(); |
441 | 441 | |
442 | - if ( is_multisite() ) { |
|
442 | + if (is_multisite()) { |
|
443 | 443 | |
444 | - if ( $this->do_per_site_uninstall() ) { |
|
444 | + if ($this->do_per_site_uninstall()) { |
|
445 | 445 | |
446 | 446 | $this->context = 'site'; |
447 | 447 | |
@@ -450,22 +450,22 @@ discard block |
||
450 | 450 | |
451 | 451 | $site_ids = $this->get_installed_site_ids(); |
452 | 452 | |
453 | - if ( ! $this->is_network_installed() ) { |
|
454 | - $site_ids = $this->validate_site_ids( $site_ids ); |
|
453 | + if ( ! $this->is_network_installed()) { |
|
454 | + $site_ids = $this->validate_site_ids($site_ids); |
|
455 | 455 | } |
456 | 456 | |
457 | - foreach ( $site_ids as $blog_id ) { |
|
458 | - switch_to_blog( $blog_id ); |
|
457 | + foreach ($site_ids as $blog_id) { |
|
458 | + switch_to_blog($blog_id); |
|
459 | 459 | $this->uninstall_site(); |
460 | 460 | } |
461 | 461 | |
462 | 462 | $ms_switched_state->restore(); |
463 | 463 | |
464 | - unset( $ms_switched_state, $site_ids ); |
|
464 | + unset($ms_switched_state, $site_ids); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | $this->context = 'network'; |
468 | - $hooks->set_current_mode( 'network' ); |
|
468 | + $hooks->set_current_mode('network'); |
|
469 | 469 | |
470 | 470 | $this->uninstall_network(); |
471 | 471 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | // If WordPoints is being uninstalled, the options will already have been |
475 | 475 | // deleted, and calling these methods will actually create them again. |
476 | - if ( 'wordpoints' !== $this->slug ) { |
|
476 | + if ('wordpoints' !== $this->slug) { |
|
477 | 477 | $this->unset_network_installed(); |
478 | 478 | $this->unset_network_install_skipped(); |
479 | 479 | $this->unset_network_update_skipped(); |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | } // End if ( is_multisite() ) else. |
488 | 488 | |
489 | - $hooks->set_current_mode( $hooks_mode ); |
|
489 | + $hooks->set_current_mode($hooks_mode); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -499,24 +499,24 @@ discard block |
||
499 | 499 | * @param bool $network Whether the entity is network active. Defaults to the |
500 | 500 | * state of WordPoints itself. |
501 | 501 | */ |
502 | - protected function prepare_to_update( $from, $to, $network ) { |
|
502 | + protected function prepare_to_update($from, $to, $network) { |
|
503 | 503 | |
504 | 504 | $this->action = 'update'; |
505 | 505 | |
506 | - if ( null === $network ) { |
|
506 | + if (null === $network) { |
|
507 | 507 | $network = is_wordpoints_network_active(); |
508 | 508 | } |
509 | 509 | |
510 | 510 | $this->network_wide = $network; |
511 | - $this->updating_from = ( null === $from ) ? $this->get_db_version() : $from; |
|
512 | - $this->updating_to = ( null === $to ) ? $this->version : $to; |
|
511 | + $this->updating_from = (null === $from) ? $this->get_db_version() : $from; |
|
512 | + $this->updating_to = (null === $to) ? $this->version : $to; |
|
513 | 513 | |
514 | 514 | $updates = array(); |
515 | 515 | |
516 | - foreach ( $this->updates as $version => $types ) { |
|
516 | + foreach ($this->updates as $version => $types) { |
|
517 | 517 | |
518 | - if ( version_compare( $from, $version, '<' ) ) { |
|
519 | - $updates[ str_replace( array( '.', '-' ), '_', $version ) ] = $types; |
|
518 | + if (version_compare($from, $version, '<')) { |
|
519 | + $updates[str_replace(array('.', '-'), '_', $version)] = $types; |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | * @param bool $network Whether the entity is network active. Defaults to the |
534 | 534 | * state of WordPoints itself. |
535 | 535 | */ |
536 | - public function update( $from = null, $to = null, $network = null ) { |
|
536 | + public function update($from = null, $to = null, $network = null) { |
|
537 | 537 | |
538 | - $this->prepare_to_update( $from, $to, $network ); |
|
538 | + $this->prepare_to_update($from, $to, $network); |
|
539 | 539 | |
540 | - if ( empty( $this->updates ) ) { |
|
540 | + if (empty($this->updates)) { |
|
541 | 541 | return; |
542 | 542 | } |
543 | 543 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | |
546 | 546 | $hooks = wordpoints_hooks(); |
547 | 547 | $hooks_mode = $hooks->get_current_mode(); |
548 | - $hooks->set_current_mode( 'standard' ); |
|
548 | + $hooks->set_current_mode('standard'); |
|
549 | 549 | |
550 | 550 | $this->before_update(); |
551 | 551 | |
@@ -554,32 +554,32 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @since 1.8.0 |
556 | 556 | */ |
557 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
557 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
558 | 558 | |
559 | - if ( is_multisite() ) { |
|
559 | + if (is_multisite()) { |
|
560 | 560 | |
561 | 561 | $this->context = 'network'; |
562 | - $hooks->set_current_mode( 'network' ); |
|
562 | + $hooks->set_current_mode('network'); |
|
563 | 563 | |
564 | - $this->update_( 'network', $this->get_updates_for( 'network' ) ); |
|
564 | + $this->update_('network', $this->get_updates_for('network')); |
|
565 | 565 | |
566 | 566 | $this->context = 'site'; |
567 | - $hooks->set_current_mode( 'standard' ); |
|
567 | + $hooks->set_current_mode('standard'); |
|
568 | 568 | |
569 | - if ( $this->network_wide ) { |
|
569 | + if ($this->network_wide) { |
|
570 | 570 | |
571 | - $updates = $this->get_updates_for( 'site' ); |
|
571 | + $updates = $this->get_updates_for('site'); |
|
572 | 572 | |
573 | - if ( $updates ) { |
|
573 | + if ($updates) { |
|
574 | 574 | |
575 | - if ( $this->do_per_site_update() ) { |
|
575 | + if ($this->do_per_site_update()) { |
|
576 | 576 | |
577 | 577 | $ms_switched_state = new WordPoints_Multisite_Switched_State(); |
578 | 578 | $ms_switched_state->backup(); |
579 | 579 | |
580 | - foreach ( $this->get_installed_site_ids() as $blog_id ) { |
|
581 | - switch_to_blog( $blog_id ); |
|
582 | - $this->update_( 'site', $updates ); |
|
580 | + foreach ($this->get_installed_site_ids() as $blog_id) { |
|
581 | + switch_to_blog($blog_id); |
|
582 | + $this->update_('site', $updates); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | $ms_switched_state->restore(); |
@@ -594,19 +594,19 @@ discard block |
||
594 | 594 | |
595 | 595 | } else { |
596 | 596 | |
597 | - $this->update_( 'site', $this->get_updates_for( 'site' ) ); |
|
597 | + $this->update_('site', $this->get_updates_for('site')); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | } else { |
601 | 601 | |
602 | 602 | $this->context = 'single'; |
603 | - $this->update_( 'single', $this->get_updates_for( 'single' ) ); |
|
603 | + $this->update_('single', $this->get_updates_for('single')); |
|
604 | 604 | |
605 | 605 | } // End if ( is_multisite() ) else. |
606 | 606 | |
607 | 607 | $this->after_update(); |
608 | 608 | |
609 | - $hooks->set_current_mode( $hooks_mode ); |
|
609 | + $hooks->set_current_mode($hooks_mode); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | // |
@@ -620,10 +620,10 @@ discard block |
||
620 | 620 | */ |
621 | 621 | protected function no_interruptions() { |
622 | 622 | |
623 | - ignore_user_abort( true ); |
|
623 | + ignore_user_abort(true); |
|
624 | 624 | |
625 | - if ( ! wordpoints_is_function_disabled( 'set_time_limit' ) ) { |
|
626 | - set_time_limit( 0 ); |
|
625 | + if ( ! wordpoints_is_function_disabled('set_time_limit')) { |
|
626 | + set_time_limit(0); |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | */ |
639 | 639 | protected function skip_per_site_install() { |
640 | 640 | |
641 | - return ( wp_is_large_network() ) |
|
641 | + return (wp_is_large_network()) |
|
642 | 642 | ? self::SKIP_INSTALL | self::REQUIRES_MANUAL_INSTALL |
643 | 643 | : self::DO_INSTALL; |
644 | 644 | } |
@@ -673,9 +673,9 @@ discard block |
||
673 | 673 | */ |
674 | 674 | protected function get_all_site_ids() { |
675 | 675 | |
676 | - $site_ids = get_site_transient( 'wordpoints_all_site_ids' ); |
|
676 | + $site_ids = get_site_transient('wordpoints_all_site_ids'); |
|
677 | 677 | |
678 | - if ( ! $site_ids ) { |
|
678 | + if ( ! $site_ids) { |
|
679 | 679 | |
680 | 680 | $site_ids = get_sites( |
681 | 681 | array( |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | ) |
686 | 686 | ); |
687 | 687 | |
688 | - set_site_transient( 'wordpoints_all_site_ids', $site_ids, 2 * MINUTE_IN_SECONDS ); |
|
688 | + set_site_transient('wordpoints_all_site_ids', $site_ids, 2 * MINUTE_IN_SECONDS); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | return $site_ids; |
@@ -699,11 +699,11 @@ discard block |
||
699 | 699 | * @param string $option The name of the option to set. |
700 | 700 | * @param mixed $value The value of the option. |
701 | 701 | */ |
702 | - private function _set_option( $option, $value = true ) { |
|
702 | + private function _set_option($option, $value = true) { |
|
703 | 703 | |
704 | - if ( isset( $this->option_prefix ) ) { |
|
704 | + if (isset($this->option_prefix)) { |
|
705 | 705 | |
706 | - update_site_option( "{$this->option_prefix}{$option}", $value ); |
|
706 | + update_site_option("{$this->option_prefix}{$option}", $value); |
|
707 | 707 | |
708 | 708 | } else { |
709 | 709 | |
@@ -712,9 +712,9 @@ discard block |
||
712 | 712 | , 'site' |
713 | 713 | ); |
714 | 714 | |
715 | - $data[ $this->type ][ $this->slug ] = $value; |
|
715 | + $data[$this->type][$this->slug] = $value; |
|
716 | 716 | |
717 | - update_site_option( "wordpoints_{$option}", $data ); |
|
717 | + update_site_option("wordpoints_{$option}", $data); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | |
@@ -725,11 +725,11 @@ discard block |
||
725 | 725 | * |
726 | 726 | * @param string $option The name of the option to delete. |
727 | 727 | */ |
728 | - private function _unset_option( $option ) { |
|
728 | + private function _unset_option($option) { |
|
729 | 729 | |
730 | - if ( isset( $this->option_prefix ) ) { |
|
730 | + if (isset($this->option_prefix)) { |
|
731 | 731 | |
732 | - delete_site_option( "{$this->option_prefix}{$option}" ); |
|
732 | + delete_site_option("{$this->option_prefix}{$option}"); |
|
733 | 733 | |
734 | 734 | } else { |
735 | 735 | |
@@ -738,9 +738,9 @@ discard block |
||
738 | 738 | , 'site' |
739 | 739 | ); |
740 | 740 | |
741 | - unset( $data[ $this->type ][ $this->slug ] ); |
|
741 | + unset($data[$this->type][$this->slug]); |
|
742 | 742 | |
743 | - update_site_option( "wordpoints_{$option}", $data ); |
|
743 | + update_site_option("wordpoints_{$option}", $data); |
|
744 | 744 | } |
745 | 745 | } |
746 | 746 | |
@@ -753,9 +753,9 @@ discard block |
||
753 | 753 | */ |
754 | 754 | protected function is_network_installed() { |
755 | 755 | |
756 | - if ( isset( $this->option_prefix ) ) { |
|
756 | + if (isset($this->option_prefix)) { |
|
757 | 757 | |
758 | - return (bool) get_site_option( "{$this->option_prefix}network_installed" ); |
|
758 | + return (bool) get_site_option("{$this->option_prefix}network_installed"); |
|
759 | 759 | |
760 | 760 | } else { |
761 | 761 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | , 'site' |
765 | 765 | ); |
766 | 766 | |
767 | - return isset( $network_installed[ $this->type ][ $this->slug ] ); |
|
767 | + return isset($network_installed[$this->type][$this->slug]); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @since 2.0.0 |
775 | 775 | */ |
776 | 776 | protected function set_network_installed() { |
777 | - $this->_set_option( 'network_installed' ); |
|
777 | + $this->_set_option('network_installed'); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @since 2.0.0 |
784 | 784 | */ |
785 | 785 | protected function unset_network_installed() { |
786 | - $this->_unset_option( 'network_installed' ); |
|
786 | + $this->_unset_option('network_installed'); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | * @since 2.0.0 |
793 | 793 | */ |
794 | 794 | protected function set_network_install_skipped() { |
795 | - $this->_set_option( 'network_install_skipped' ); |
|
795 | + $this->_set_option('network_install_skipped'); |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | /** |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * @since 2.0.0 |
802 | 802 | */ |
803 | 803 | protected function unset_network_install_skipped() { |
804 | - $this->_unset_option( 'network_install_skipped' ); |
|
804 | + $this->_unset_option('network_install_skipped'); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | * @since 2.0.0 |
811 | 811 | */ |
812 | 812 | protected function set_network_update_skipped() { |
813 | - $this->_set_option( 'network_update_skipped', $this->updating_from ); |
|
813 | + $this->_set_option('network_update_skipped', $this->updating_from); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | * @since 2.0.0 |
820 | 820 | */ |
821 | 821 | protected function unset_network_update_skipped() { |
822 | - $this->_unset_option( 'network_update_skipped' ); |
|
822 | + $this->_unset_option('network_update_skipped'); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
@@ -833,11 +833,11 @@ discard block |
||
833 | 833 | */ |
834 | 834 | protected function do_per_site_uninstall() { |
835 | 835 | |
836 | - if ( wp_is_large_network() ) { |
|
836 | + if (wp_is_large_network()) { |
|
837 | 837 | |
838 | - if ( $this->is_network_installed() ) { |
|
838 | + if ($this->is_network_installed()) { |
|
839 | 839 | return false; |
840 | - } elseif ( count( $this->get_installed_site_ids() ) > 10000 ) { |
|
840 | + } elseif (count($this->get_installed_site_ids()) > 10000) { |
|
841 | 841 | return false; |
842 | 842 | } |
843 | 843 | } |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | */ |
857 | 857 | protected function do_per_site_update() { |
858 | 858 | |
859 | - if ( $this->is_network_installed() && wp_is_large_network() ) { |
|
859 | + if ($this->is_network_installed() && wp_is_large_network()) { |
|
860 | 860 | return false; |
861 | 861 | } |
862 | 862 | |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | */ |
873 | 873 | private function _get_installed_site_ids_option_name() { |
874 | 874 | |
875 | - if ( isset( $this->option_prefix ) ) { |
|
875 | + if (isset($this->option_prefix)) { |
|
876 | 876 | $option_prefix = $this->option_prefix; |
877 | - } elseif ( 'wordpoints' === $this->slug ) { |
|
877 | + } elseif ('wordpoints' === $this->slug) { |
|
878 | 878 | $option_prefix = 'wordpoints_'; |
879 | - } elseif ( 'component' === $this->type ) { |
|
879 | + } elseif ('component' === $this->type) { |
|
880 | 880 | $option_prefix = "wordpoints_{$this->slug}_"; |
881 | 881 | } else { |
882 | 882 | $option_prefix = "wordpoints_{$this->type}_{$this->slug}_"; |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | */ |
895 | 895 | protected function get_installed_site_ids() { |
896 | 896 | |
897 | - if ( $this->is_network_installed() ) { |
|
897 | + if ($this->is_network_installed()) { |
|
898 | 898 | $sites = $this->get_all_site_ids(); |
899 | 899 | } else { |
900 | 900 | $sites = wordpoints_get_array_option( |
@@ -913,18 +913,18 @@ discard block |
||
913 | 913 | * |
914 | 914 | * @param int $id The ID of the site to add. Defaults to the current site's ID. |
915 | 915 | */ |
916 | - protected function add_installed_site_id( $id = null ) { |
|
916 | + protected function add_installed_site_id($id = null) { |
|
917 | 917 | |
918 | - if ( empty( $id ) ) { |
|
918 | + if (empty($id)) { |
|
919 | 919 | $id = get_current_blog_id(); |
920 | 920 | } |
921 | 921 | |
922 | 922 | $option_name = $this->_get_installed_site_ids_option_name(); |
923 | 923 | |
924 | - $sites = wordpoints_get_array_option( $option_name, 'site' ); |
|
924 | + $sites = wordpoints_get_array_option($option_name, 'site'); |
|
925 | 925 | $sites[] = $id; |
926 | 926 | |
927 | - update_site_option( $option_name, $sites ); |
|
927 | + update_site_option($option_name, $sites); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | /** |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | * @since 2.0.0 |
934 | 934 | */ |
935 | 935 | protected function delete_installed_site_ids() { |
936 | - delete_site_option( $this->_get_installed_site_ids_option_name() ); |
|
936 | + delete_site_option($this->_get_installed_site_ids_option_name()); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | /** |
@@ -945,9 +945,9 @@ discard block |
||
945 | 945 | * |
946 | 946 | * @return array The validated site IDs. |
947 | 947 | */ |
948 | - protected function validate_site_ids( $site_ids ) { |
|
948 | + protected function validate_site_ids($site_ids) { |
|
949 | 949 | |
950 | - if ( empty( $site_ids ) || ! is_array( $site_ids ) ) { |
|
950 | + if (empty($site_ids) || ! is_array($site_ids)) { |
|
951 | 951 | return array(); |
952 | 952 | } |
953 | 953 | |
@@ -972,20 +972,20 @@ discard block |
||
972 | 972 | */ |
973 | 973 | protected function get_db_version() { |
974 | 974 | |
975 | - if ( 'network' === $this->context ) { |
|
976 | - $wordpoints_data = wordpoints_get_array_option( 'wordpoints_data', 'site' ); |
|
975 | + if ('network' === $this->context) { |
|
976 | + $wordpoints_data = wordpoints_get_array_option('wordpoints_data', 'site'); |
|
977 | 977 | } else { |
978 | - $wordpoints_data = wordpoints_get_array_option( 'wordpoints_data' ); |
|
978 | + $wordpoints_data = wordpoints_get_array_option('wordpoints_data'); |
|
979 | 979 | } |
980 | 980 | |
981 | - if ( 'wordpoints' === $this->slug ) { |
|
981 | + if ('wordpoints' === $this->slug) { |
|
982 | 982 | |
983 | - if ( isset( $wordpoints_data['version'] ) ) { |
|
983 | + if (isset($wordpoints_data['version'])) { |
|
984 | 984 | return $wordpoints_data['version']; |
985 | 985 | } |
986 | 986 | |
987 | - } elseif ( isset( $wordpoints_data[ "{$this->type}s" ][ $this->slug ]['version'] ) ) { |
|
988 | - return $wordpoints_data[ "{$this->type}s" ][ $this->slug ]['version']; |
|
987 | + } elseif (isset($wordpoints_data["{$this->type}s"][$this->slug]['version'])) { |
|
988 | + return $wordpoints_data["{$this->type}s"][$this->slug]['version']; |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | return false; |
@@ -998,28 +998,28 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @param string $version The version of the entity. |
1000 | 1000 | */ |
1001 | - protected function set_db_version( $version = null ) { |
|
1001 | + protected function set_db_version($version = null) { |
|
1002 | 1002 | |
1003 | - if ( null === $version ) { |
|
1003 | + if (null === $version) { |
|
1004 | 1004 | $version = $this->version; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | - if ( 'network' === $this->context ) { |
|
1008 | - $wordpoints_data = wordpoints_get_array_option( 'wordpoints_data', 'site' ); |
|
1007 | + if ('network' === $this->context) { |
|
1008 | + $wordpoints_data = wordpoints_get_array_option('wordpoints_data', 'site'); |
|
1009 | 1009 | } else { |
1010 | - $wordpoints_data = wordpoints_get_array_option( 'wordpoints_data' ); |
|
1010 | + $wordpoints_data = wordpoints_get_array_option('wordpoints_data'); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | - if ( 'wordpoints' === $this->slug ) { |
|
1013 | + if ('wordpoints' === $this->slug) { |
|
1014 | 1014 | $wordpoints_data['version'] = $version; |
1015 | 1015 | } else { |
1016 | - $wordpoints_data[ "{$this->type}s" ][ $this->slug ]['version'] = $version; |
|
1016 | + $wordpoints_data["{$this->type}s"][$this->slug]['version'] = $version; |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | - if ( 'network' === $this->context ) { |
|
1020 | - update_site_option( 'wordpoints_data', $wordpoints_data ); |
|
1019 | + if ('network' === $this->context) { |
|
1020 | + update_site_option('wordpoints_data', $wordpoints_data); |
|
1021 | 1021 | } else { |
1022 | - update_option( 'wordpoints_data', $wordpoints_data ); |
|
1022 | + update_option('wordpoints_data', $wordpoints_data); |
|
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1031,22 +1031,22 @@ discard block |
||
1031 | 1031 | protected function unset_db_version() { |
1032 | 1032 | |
1033 | 1033 | // The whole option will be deleted when WordPoints is uninstalled. |
1034 | - if ( 'wordpoints' === $this->slug ) { |
|
1034 | + if ('wordpoints' === $this->slug) { |
|
1035 | 1035 | return; |
1036 | 1036 | } |
1037 | 1037 | |
1038 | - if ( 'network' === $this->context ) { |
|
1039 | - $wordpoints_data = wordpoints_get_array_option( 'wordpoints_data', 'site' ); |
|
1038 | + if ('network' === $this->context) { |
|
1039 | + $wordpoints_data = wordpoints_get_array_option('wordpoints_data', 'site'); |
|
1040 | 1040 | } else { |
1041 | - $wordpoints_data = wordpoints_get_array_option( 'wordpoints_data' ); |
|
1041 | + $wordpoints_data = wordpoints_get_array_option('wordpoints_data'); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | - unset( $wordpoints_data[ "{$this->type}s" ][ $this->slug ] ); |
|
1044 | + unset($wordpoints_data["{$this->type}s"][$this->slug]); |
|
1045 | 1045 | |
1046 | - if ( 'network' === $this->context ) { |
|
1047 | - update_site_option( 'wordpoints_data', $wordpoints_data ); |
|
1046 | + if ('network' === $this->context) { |
|
1047 | + update_site_option('wordpoints_data', $wordpoints_data); |
|
1048 | 1048 | } else { |
1049 | - update_option( 'wordpoints_data', $wordpoints_data ); |
|
1049 | + update_option('wordpoints_data', $wordpoints_data); |
|
1050 | 1050 | } |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1061,19 +1061,19 @@ discard block |
||
1061 | 1061 | * @param string $component The component's slug. |
1062 | 1062 | * @param string $version The installed component version. |
1063 | 1063 | */ |
1064 | - protected function set_component_version( $component, $version ) { |
|
1064 | + protected function set_component_version($component, $version) { |
|
1065 | 1065 | |
1066 | - _deprecated_function( __METHOD__, '2.0.0', '::set_db_version()' ); |
|
1066 | + _deprecated_function(__METHOD__, '2.0.0', '::set_db_version()'); |
|
1067 | 1067 | |
1068 | 1068 | $wordpoints_data = wordpoints_get_maybe_network_array_option( |
1069 | 1069 | 'wordpoints_data' |
1070 | 1070 | ); |
1071 | 1071 | |
1072 | - if ( empty( $wordpoints_data['components'][ $component ]['version'] ) ) { |
|
1073 | - $wordpoints_data['components'][ $component ]['version'] = $version; |
|
1072 | + if (empty($wordpoints_data['components'][$component]['version'])) { |
|
1073 | + $wordpoints_data['components'][$component]['version'] = $version; |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | - wordpoints_update_maybe_network_option( 'wordpoints_data', $wordpoints_data ); |
|
1076 | + wordpoints_update_maybe_network_option('wordpoints_data', $wordpoints_data); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | /** |
@@ -1083,14 +1083,14 @@ discard block |
||
1083 | 1083 | */ |
1084 | 1084 | protected function maybe_load_custom_caps() { |
1085 | 1085 | |
1086 | - if ( empty( $this->custom_caps_getter ) ) { |
|
1086 | + if (empty($this->custom_caps_getter)) { |
|
1087 | 1087 | return; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - $this->custom_caps = call_user_func( $this->custom_caps_getter ); |
|
1091 | - $this->custom_caps_keys = array_keys( $this->custom_caps ); |
|
1090 | + $this->custom_caps = call_user_func($this->custom_caps_getter); |
|
1091 | + $this->custom_caps_keys = array_keys($this->custom_caps); |
|
1092 | 1092 | |
1093 | - if ( 'uninstall' === $this->action ) { |
|
1093 | + if ('uninstall' === $this->action) { |
|
1094 | 1094 | $this->uninstall['local']['custom_caps'] = true; |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | * @since 1.8.0 |
1102 | 1102 | */ |
1103 | 1103 | protected function before_install() { |
1104 | - $this->map_shortcuts( 'schema' ); |
|
1104 | + $this->map_shortcuts('schema'); |
|
1105 | 1105 | $this->maybe_load_custom_caps(); |
1106 | 1106 | } |
1107 | 1107 | |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | */ |
1113 | 1113 | protected function install_custom_caps() { |
1114 | 1114 | |
1115 | - if ( ! empty( $this->custom_caps ) ) { |
|
1116 | - wordpoints_add_custom_caps( $this->custom_caps ); |
|
1115 | + if ( ! empty($this->custom_caps)) { |
|
1116 | + wordpoints_add_custom_caps($this->custom_caps); |
|
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | |
@@ -1126,8 +1126,8 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | $schema = $this->get_db_schema(); |
1128 | 1128 | |
1129 | - if ( ! empty( $schema ) ) { |
|
1130 | - dbDelta( $schema ); |
|
1129 | + if ( ! empty($schema)) { |
|
1130 | + dbDelta($schema); |
|
1131 | 1131 | } |
1132 | 1132 | } |
1133 | 1133 | |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | */ |
1141 | 1141 | public function get_db_schema() { |
1142 | 1142 | |
1143 | - if ( ! isset( $this->schema[ $this->context ]['tables'] ) ) { |
|
1143 | + if ( ! isset($this->schema[$this->context]['tables'])) { |
|
1144 | 1144 | return ''; |
1145 | 1145 | } |
1146 | 1146 | |
@@ -1150,16 +1150,16 @@ discard block |
||
1150 | 1150 | |
1151 | 1151 | $charset_collate = $wpdb->get_charset_collate(); |
1152 | 1152 | |
1153 | - if ( 'site' === $this->context ) { |
|
1153 | + if ('site' === $this->context) { |
|
1154 | 1154 | $prefix = $wpdb->prefix; |
1155 | 1155 | } else { |
1156 | 1156 | $prefix = $wpdb->base_prefix; |
1157 | 1157 | } |
1158 | 1158 | |
1159 | - foreach ( $this->schema[ $this->context ]['tables'] as $table_name => $table_schema ) { |
|
1159 | + foreach ($this->schema[$this->context]['tables'] as $table_name => $table_schema) { |
|
1160 | 1160 | |
1161 | - $table_name = str_replace( '`', '``', $table_name ); |
|
1162 | - $table_schema = trim( $table_schema ); |
|
1161 | + $table_name = str_replace('`', '``', $table_name); |
|
1162 | + $table_schema = trim($table_schema); |
|
1163 | 1163 | |
1164 | 1164 | $schema .= "CREATE TABLE {$prefix}{$table_name} ( |
1165 | 1165 | {$table_schema} |
@@ -1179,31 +1179,31 @@ discard block |
||
1179 | 1179 | $this->maybe_load_custom_caps(); |
1180 | 1180 | |
1181 | 1181 | $this->prepare_uninstall_list_tables(); |
1182 | - $this->prepare_uninstall_non_per_site_items( 'meta_boxes' ); |
|
1183 | - $this->map_uninstall_shortcut( 'widgets', 'options', array( 'prefix' => 'widget_' ) ); |
|
1184 | - $this->map_uninstall_shortcut( 'points_hooks', 'options', array( 'prefix' => 'wordpoints_hook-' ) ); |
|
1182 | + $this->prepare_uninstall_non_per_site_items('meta_boxes'); |
|
1183 | + $this->map_uninstall_shortcut('widgets', 'options', array('prefix' => 'widget_')); |
|
1184 | + $this->map_uninstall_shortcut('points_hooks', 'options', array('prefix' => 'wordpoints_hook-')); |
|
1185 | 1185 | |
1186 | 1186 | // Add any tables to uninstall based on the db schema. |
1187 | - foreach ( $this->schema as $context => $schema ) { |
|
1187 | + foreach ($this->schema as $context => $schema) { |
|
1188 | 1188 | |
1189 | - if ( ! isset( $schema['tables'] ) ) { |
|
1189 | + if ( ! isset($schema['tables'])) { |
|
1190 | 1190 | continue; |
1191 | 1191 | } |
1192 | 1192 | |
1193 | - if ( ! isset( $this->uninstall[ $context ]['tables'] ) ) { |
|
1194 | - $this->uninstall[ $context ]['tables'] = array(); |
|
1193 | + if ( ! isset($this->uninstall[$context]['tables'])) { |
|
1194 | + $this->uninstall[$context]['tables'] = array(); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | - $this->uninstall[ $context ]['tables'] = array_unique( |
|
1197 | + $this->uninstall[$context]['tables'] = array_unique( |
|
1198 | 1198 | array_merge( |
1199 | - $this->uninstall[ $context ]['tables'] |
|
1200 | - , array_keys( $schema['tables'] ) |
|
1199 | + $this->uninstall[$context]['tables'] |
|
1200 | + , array_keys($schema['tables']) |
|
1201 | 1201 | ) |
1202 | 1202 | ); |
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | // This *must* happen *after* the schema and list tables args are parsed. |
1206 | - $this->map_shortcuts( 'uninstall' ); |
|
1206 | + $this->map_shortcuts('uninstall'); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | /** |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | */ |
1238 | 1238 | protected function prepare_uninstall_list_tables() { |
1239 | 1239 | |
1240 | - if ( ! isset( $this->uninstall['list_tables'] ) ) { |
|
1240 | + if ( ! isset($this->uninstall['list_tables'])) { |
|
1241 | 1241 | return; |
1242 | 1242 | } |
1243 | 1243 | |
@@ -1248,17 +1248,17 @@ discard block |
||
1248 | 1248 | ); |
1249 | 1249 | |
1250 | 1250 | // Loop through all of the list table screens. |
1251 | - foreach ( $this->uninstall['list_tables'] as $screen_id => $args ) { |
|
1251 | + foreach ($this->uninstall['list_tables'] as $screen_id => $args) { |
|
1252 | 1252 | |
1253 | 1253 | // Back-compat for pre-2.1.0. |
1254 | - if ( isset( $args['parent'] ) && '_page' === substr( $args['parent'], -5 /* _page */ ) ) { |
|
1255 | - $args['parent'] = substr( $args['parent'], 0, -5 ); |
|
1254 | + if (isset($args['parent']) && '_page' === substr($args['parent'], -5 /* _page */)) { |
|
1255 | + $args['parent'] = substr($args['parent'], 0, -5); |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | - $this->uninstall['universal']['list_tables'][ $screen_id ] = $args; |
|
1258 | + $this->uninstall['universal']['list_tables'][$screen_id] = $args; |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | - $this->prepare_uninstall_non_per_site_items( 'list_tables' ); |
|
1261 | + $this->prepare_uninstall_non_per_site_items('list_tables'); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | /** |
@@ -1276,22 +1276,22 @@ discard block |
||
1276 | 1276 | * |
1277 | 1277 | * @param string $items_key The key name of the items in the uninstall[*] arrays. |
1278 | 1278 | */ |
1279 | - protected function prepare_uninstall_non_per_site_items( $items_key ) { |
|
1279 | + protected function prepare_uninstall_non_per_site_items($items_key) { |
|
1280 | 1280 | |
1281 | - if ( isset( $this->uninstall['universal'][ $items_key ] ) ) { |
|
1281 | + if (isset($this->uninstall['universal'][$items_key])) { |
|
1282 | 1282 | |
1283 | - $this->uninstall['global'][ $items_key ] |
|
1284 | - = $this->uninstall['universal'][ $items_key ]; |
|
1283 | + $this->uninstall['global'][$items_key] |
|
1284 | + = $this->uninstall['universal'][$items_key]; |
|
1285 | 1285 | |
1286 | - unset( $this->uninstall['universal'][ $items_key ] ); |
|
1286 | + unset($this->uninstall['universal'][$items_key]); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | - if ( isset( $this->uninstall['site'][ $items_key ] ) ) { |
|
1289 | + if (isset($this->uninstall['site'][$items_key])) { |
|
1290 | 1290 | |
1291 | - $this->uninstall['network'][ $items_key ] |
|
1292 | - = $this->uninstall['site'][ $items_key ]; |
|
1291 | + $this->uninstall['network'][$items_key] |
|
1292 | + = $this->uninstall['site'][$items_key]; |
|
1293 | 1293 | |
1294 | - unset( $this->uninstall['site'][ $items_key ] ); |
|
1294 | + unset($this->uninstall['site'][$items_key]); |
|
1295 | 1295 | } |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1328,20 +1328,20 @@ discard block |
||
1328 | 1328 | * adding to them to the canonical array. |
1329 | 1329 | * } |
1330 | 1330 | */ |
1331 | - protected function map_uninstall_shortcut( $shortcut, $canonical, $args ) { |
|
1331 | + protected function map_uninstall_shortcut($shortcut, $canonical, $args) { |
|
1332 | 1332 | |
1333 | - $args = array_merge( array( 'prefix' => '' ), $args ); |
|
1333 | + $args = array_merge(array('prefix' => ''), $args); |
|
1334 | 1334 | |
1335 | - $types = array( 'single', 'site', 'network', 'local', 'global', 'universal' ); |
|
1335 | + $types = array('single', 'site', 'network', 'local', 'global', 'universal'); |
|
1336 | 1336 | |
1337 | - foreach ( $types as $type ) { |
|
1337 | + foreach ($types as $type) { |
|
1338 | 1338 | |
1339 | - if ( ! isset( $this->uninstall[ $type ][ $shortcut ] ) ) { |
|
1339 | + if ( ! isset($this->uninstall[$type][$shortcut])) { |
|
1340 | 1340 | continue; |
1341 | 1341 | } |
1342 | 1342 | |
1343 | - foreach ( $this->uninstall[ $type ][ $shortcut ] as $slug ) { |
|
1344 | - $this->uninstall[ $type ][ $canonical ][] = $args['prefix'] . $slug; |
|
1343 | + foreach ($this->uninstall[$type][$shortcut] as $slug) { |
|
1344 | + $this->uninstall[$type][$canonical][] = $args['prefix'] . $slug; |
|
1345 | 1345 | } |
1346 | 1346 | } |
1347 | 1347 | } |
@@ -1361,28 +1361,28 @@ discard block |
||
1361 | 1361 | * |
1362 | 1362 | * @param string $type The type of shortcuts to map. Corresponds to a member var. |
1363 | 1363 | */ |
1364 | - protected function map_shortcuts( $type ) { |
|
1364 | + protected function map_shortcuts($type) { |
|
1365 | 1365 | |
1366 | 1366 | // shortcut => canonicals |
1367 | 1367 | $map = array( |
1368 | - 'local' => array( 'single', 'site', /* - */ ), |
|
1369 | - 'global' => array( 'single', /* - */ 'network' ), |
|
1370 | - 'universal' => array( 'single', 'site', 'network' ), |
|
1368 | + 'local' => array('single', 'site', /* - */), |
|
1369 | + 'global' => array('single', /* - */ 'network'), |
|
1370 | + 'universal' => array('single', 'site', 'network'), |
|
1371 | 1371 | ); |
1372 | 1372 | |
1373 | 1373 | $this->$type = array_merge( |
1374 | 1374 | array_fill_keys( |
1375 | - array( 'single', 'site', 'network', 'local', 'global', 'universal' ) |
|
1375 | + array('single', 'site', 'network', 'local', 'global', 'universal') |
|
1376 | 1376 | , array() |
1377 | 1377 | ) |
1378 | 1378 | , $this->$type |
1379 | 1379 | ); |
1380 | 1380 | |
1381 | - foreach ( $map as $shortcut => $canonicals ) { |
|
1382 | - foreach ( $canonicals as $canonical ) { |
|
1383 | - $this->{$type}[ $canonical ] = array_merge_recursive( |
|
1384 | - $this->{$type}[ $canonical ] |
|
1385 | - , $this->{$type}[ $shortcut ] |
|
1381 | + foreach ($map as $shortcut => $canonicals) { |
|
1382 | + foreach ($canonicals as $canonical) { |
|
1383 | + $this->{$type}[$canonical] = array_merge_recursive( |
|
1384 | + $this->{$type}[$canonical] |
|
1385 | + , $this->{$type}[$shortcut] |
|
1386 | 1386 | ); |
1387 | 1387 | } |
1388 | 1388 | } |
@@ -1413,9 +1413,9 @@ discard block |
||
1413 | 1413 | * |
1414 | 1414 | * @return array The versions that request this type of update. |
1415 | 1415 | */ |
1416 | - protected function get_updates_for( $type ) { |
|
1416 | + protected function get_updates_for($type) { |
|
1417 | 1417 | |
1418 | - return array_keys( wp_list_filter( $this->updates, array( $type => true ) ) ); |
|
1418 | + return array_keys(wp_list_filter($this->updates, array($type => true))); |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | /** |
@@ -1426,9 +1426,9 @@ discard block |
||
1426 | 1426 | * @param string $type The type of update to run. |
1427 | 1427 | * @param array $versions The versions to run this type of update for. |
1428 | 1428 | */ |
1429 | - protected function update_( $type, $versions ) { |
|
1429 | + protected function update_($type, $versions) { |
|
1430 | 1430 | |
1431 | - foreach ( $versions as $version ) { |
|
1431 | + foreach ($versions as $version) { |
|
1432 | 1432 | $this->{"update_{$type}_to_{$version}"}(); |
1433 | 1433 | } |
1434 | 1434 | } |
@@ -1440,22 +1440,22 @@ discard block |
||
1440 | 1440 | * |
1441 | 1441 | * @param string $type The type of tables to update. |
1442 | 1442 | */ |
1443 | - protected function maybe_update_tables_to_utf8mb4( $type ) { |
|
1443 | + protected function maybe_update_tables_to_utf8mb4($type) { |
|
1444 | 1444 | |
1445 | 1445 | global $wpdb; |
1446 | 1446 | |
1447 | - if ( 'utf8mb4' !== $wpdb->charset ) { |
|
1447 | + if ('utf8mb4' !== $wpdb->charset) { |
|
1448 | 1448 | return; |
1449 | 1449 | } |
1450 | 1450 | |
1451 | - if ( 'global' === $type || 'network' === $type ) { |
|
1451 | + if ('global' === $type || 'network' === $type) { |
|
1452 | 1452 | $prefix = $wpdb->base_prefix; |
1453 | 1453 | } else { |
1454 | 1454 | $prefix = $wpdb->prefix; |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - foreach ( $this->schema[ $type ]['tables'] as $table_name => $schema ) { |
|
1458 | - maybe_convert_table_to_utf8mb4( $prefix . $table_name ); |
|
1457 | + foreach ($this->schema[$type]['tables'] as $table_name => $schema) { |
|
1458 | + maybe_convert_table_to_utf8mb4($prefix . $table_name); |
|
1459 | 1459 | } |
1460 | 1460 | } |
1461 | 1461 | |
@@ -1466,9 +1466,9 @@ discard block |
||
1466 | 1466 | * |
1467 | 1467 | * @param string $type The type of uninstallation to perform. |
1468 | 1468 | */ |
1469 | - protected function uninstall_( $type ) { |
|
1469 | + protected function uninstall_($type) { |
|
1470 | 1470 | |
1471 | - if ( empty( $this->uninstall[ $type ] ) ) { |
|
1471 | + if (empty($this->uninstall[$type])) { |
|
1472 | 1472 | return; |
1473 | 1473 | } |
1474 | 1474 | |
@@ -1481,35 +1481,35 @@ discard block |
||
1481 | 1481 | 'meta_boxes' => array(), |
1482 | 1482 | 'list_tables' => array(), |
1483 | 1483 | ) |
1484 | - , $this->uninstall[ $type ] |
|
1484 | + , $this->uninstall[$type] |
|
1485 | 1485 | ); |
1486 | 1486 | |
1487 | - if ( ! empty( $uninstall['custom_caps'] ) ) { |
|
1488 | - $this->uninstall_custom_caps( $this->custom_caps_keys ); |
|
1487 | + if ( ! empty($uninstall['custom_caps'])) { |
|
1488 | + $this->uninstall_custom_caps($this->custom_caps_keys); |
|
1489 | 1489 | } |
1490 | 1490 | |
1491 | - foreach ( $uninstall['user_meta'] as $meta_key ) { |
|
1492 | - $this->uninstall_metadata( 'user', $meta_key ); |
|
1491 | + foreach ($uninstall['user_meta'] as $meta_key) { |
|
1492 | + $this->uninstall_metadata('user', $meta_key); |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | - foreach ( $uninstall['options'] as $option ) { |
|
1496 | - $this->uninstall_option( $option ); |
|
1495 | + foreach ($uninstall['options'] as $option) { |
|
1496 | + $this->uninstall_option($option); |
|
1497 | 1497 | } |
1498 | 1498 | |
1499 | - foreach ( $uninstall['tables'] as $table ) { |
|
1500 | - $this->uninstall_table( $table ); |
|
1499 | + foreach ($uninstall['tables'] as $table) { |
|
1500 | + $this->uninstall_table($table); |
|
1501 | 1501 | } |
1502 | 1502 | |
1503 | - foreach ( $uninstall['comment_meta'] as $meta_key ) { |
|
1504 | - $this->uninstall_metadata( 'comment', $meta_key ); |
|
1503 | + foreach ($uninstall['comment_meta'] as $meta_key) { |
|
1504 | + $this->uninstall_metadata('comment', $meta_key); |
|
1505 | 1505 | } |
1506 | 1506 | |
1507 | - foreach ( $uninstall['meta_boxes'] as $screen_id => $args ) { |
|
1508 | - $this->uninstall_meta_boxes( $screen_id, $args ); |
|
1507 | + foreach ($uninstall['meta_boxes'] as $screen_id => $args) { |
|
1508 | + $this->uninstall_meta_boxes($screen_id, $args); |
|
1509 | 1509 | } |
1510 | 1510 | |
1511 | - foreach ( $uninstall['list_tables'] as $screen_id => $args ) { |
|
1512 | - $this->uninstall_list_table( $screen_id, $args ); |
|
1511 | + foreach ($uninstall['list_tables'] as $screen_id => $args) { |
|
1512 | + $this->uninstall_list_table($screen_id, $args); |
|
1513 | 1513 | } |
1514 | 1514 | } |
1515 | 1515 | |
@@ -1520,9 +1520,9 @@ discard block |
||
1520 | 1520 | * |
1521 | 1521 | * @param string[] $caps The capabilities to uninstall. |
1522 | 1522 | */ |
1523 | - protected function uninstall_custom_caps( $caps ) { |
|
1523 | + protected function uninstall_custom_caps($caps) { |
|
1524 | 1524 | |
1525 | - wordpoints_remove_custom_caps( $caps ); |
|
1525 | + wordpoints_remove_custom_caps($caps); |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | /** |
@@ -1533,17 +1533,17 @@ discard block |
||
1533 | 1533 | * @param string $type The type of metadata to uninstall, e.g., 'user', 'post'. |
1534 | 1534 | * @param string $key The metadata key to delete. |
1535 | 1535 | */ |
1536 | - protected function uninstall_metadata( $type, $key ) { |
|
1536 | + protected function uninstall_metadata($type, $key) { |
|
1537 | 1537 | |
1538 | - if ( 'user' === $type && 'site' === $this->context ) { |
|
1538 | + if ('user' === $type && 'site' === $this->context) { |
|
1539 | 1539 | $key = $GLOBALS['wpdb']->get_blog_prefix() . $key; |
1540 | 1540 | } |
1541 | 1541 | |
1542 | - if ( false !== strpos( $key, '%' ) ) { |
|
1542 | + if (false !== strpos($key, '%')) { |
|
1543 | 1543 | |
1544 | 1544 | global $wpdb; |
1545 | 1545 | |
1546 | - $table = wordpoints_escape_mysql_identifier( _get_meta_table( $type ) ); |
|
1546 | + $table = wordpoints_escape_mysql_identifier(_get_meta_table($type)); |
|
1547 | 1547 | |
1548 | 1548 | $keys = $wpdb->get_col( // WPCS: unprepared SQL OK. |
1549 | 1549 | $wpdb->prepare( // WPCS: unprepared SQL OK. |
@@ -1557,11 +1557,11 @@ discard block |
||
1557 | 1557 | ); // WPCS: cache pass. |
1558 | 1558 | |
1559 | 1559 | } else { |
1560 | - $keys = array( $key ); |
|
1560 | + $keys = array($key); |
|
1561 | 1561 | } |
1562 | 1562 | |
1563 | - foreach ( $keys as $key ) { |
|
1564 | - delete_metadata( $type, 0, wp_slash( $key ), '', true ); |
|
1563 | + foreach ($keys as $key) { |
|
1564 | + delete_metadata($type, 0, wp_slash($key), '', true); |
|
1565 | 1565 | } |
1566 | 1566 | } |
1567 | 1567 | |
@@ -1595,25 +1595,25 @@ discard block |
||
1595 | 1595 | * 'meta-box-order'. |
1596 | 1596 | * } |
1597 | 1597 | */ |
1598 | - protected function uninstall_meta_boxes( $screen_id, $args ) { |
|
1598 | + protected function uninstall_meta_boxes($screen_id, $args) { |
|
1599 | 1599 | |
1600 | 1600 | $defaults = array( |
1601 | 1601 | 'parent' => 'wordpoints', |
1602 | - 'options' => array( 'closedpostboxes', 'metaboxhidden', 'meta-box-order' ), |
|
1602 | + 'options' => array('closedpostboxes', 'metaboxhidden', 'meta-box-order'), |
|
1603 | 1603 | ); |
1604 | 1604 | |
1605 | - $args = array_merge( $defaults, $args ); |
|
1606 | - $args['options'] = array_merge( $defaults['options'], $args['options'] ); |
|
1605 | + $args = array_merge($defaults, $args); |
|
1606 | + $args['options'] = array_merge($defaults['options'], $args['options']); |
|
1607 | 1607 | |
1608 | 1608 | // Each user gets to set the options to their liking. |
1609 | - foreach ( $args['options'] as $option ) { |
|
1609 | + foreach ($args['options'] as $option) { |
|
1610 | 1610 | |
1611 | 1611 | $this->uninstall_metadata( |
1612 | 1612 | 'user' |
1613 | 1613 | , "{$option}_{$args['parent']}_page_{$screen_id}" |
1614 | 1614 | ); |
1615 | 1615 | |
1616 | - if ( 'network' === $this->context ) { |
|
1616 | + if ('network' === $this->context) { |
|
1617 | 1617 | $this->uninstall_metadata( |
1618 | 1618 | 'user' |
1619 | 1619 | , "{$option}_{$args['parent']}_page_{$screen_id}-network" |
@@ -1654,20 +1654,20 @@ discard block |
||
1654 | 1654 | * 'per_page'. |
1655 | 1655 | * } |
1656 | 1656 | */ |
1657 | - protected function uninstall_list_table( $screen_id, $args ) { |
|
1657 | + protected function uninstall_list_table($screen_id, $args) { |
|
1658 | 1658 | |
1659 | 1659 | $defaults = array( |
1660 | 1660 | 'parent' => 'wordpoints', |
1661 | - 'options' => array( 'per_page' ), |
|
1661 | + 'options' => array('per_page'), |
|
1662 | 1662 | ); |
1663 | 1663 | |
1664 | - $args = array_merge( $defaults, $args ); |
|
1664 | + $args = array_merge($defaults, $args); |
|
1665 | 1665 | |
1666 | 1666 | $parent = $network_parent = $args['parent']; |
1667 | 1667 | |
1668 | 1668 | // The parent page is usually the same on a multisite site, but we need to |
1669 | 1669 | // handle the special case of the modules screen. |
1670 | - if ( 'wordpoints_modules' === $screen_id && is_multisite() ) { |
|
1670 | + if ('wordpoints_modules' === $screen_id && is_multisite()) { |
|
1671 | 1671 | $parent = 'toplevel'; |
1672 | 1672 | } |
1673 | 1673 | |
@@ -1676,23 +1676,23 @@ discard block |
||
1676 | 1676 | // Each user can hide specific columns of the table. |
1677 | 1677 | $meta_keys[] = "manage{$parent}_page_{$screen_id}columnshidden"; |
1678 | 1678 | |
1679 | - if ( 'network' === $this->context ) { |
|
1679 | + if ('network' === $this->context) { |
|
1680 | 1680 | $meta_keys[] = "manage{$network_parent}_page_{$screen_id}-networkcolumnshidden"; |
1681 | 1681 | } |
1682 | 1682 | |
1683 | 1683 | // Loop through each of the other options provided by this list table. |
1684 | - foreach ( $args['options'] as $option ) { |
|
1684 | + foreach ($args['options'] as $option) { |
|
1685 | 1685 | |
1686 | 1686 | // Each user gets to set the options to their liking. |
1687 | 1687 | $meta_keys[] = "{$parent}_page_{$screen_id}_{$option}"; |
1688 | 1688 | |
1689 | - if ( 'network' === $this->context ) { |
|
1689 | + if ('network' === $this->context) { |
|
1690 | 1690 | $meta_keys[] = "{$network_parent}_page_{$screen_id}_network_{$option}"; |
1691 | 1691 | } |
1692 | 1692 | } |
1693 | 1693 | |
1694 | - foreach ( $meta_keys as $meta_key ) { |
|
1695 | - $this->uninstall_metadata( 'user', $meta_key ); |
|
1694 | + foreach ($meta_keys as $meta_key) { |
|
1695 | + $this->uninstall_metadata('user', $meta_key); |
|
1696 | 1696 | } |
1697 | 1697 | } |
1698 | 1698 | |
@@ -1707,14 +1707,14 @@ discard block |
||
1707 | 1707 | * |
1708 | 1708 | * @param string $option The option to uninstall. |
1709 | 1709 | */ |
1710 | - protected function uninstall_option( $option ) { |
|
1710 | + protected function uninstall_option($option) { |
|
1711 | 1711 | |
1712 | - if ( 'network' === $this->context ) { |
|
1713 | - $this->uninstall_network_option( $option ); |
|
1712 | + if ('network' === $this->context) { |
|
1713 | + $this->uninstall_network_option($option); |
|
1714 | 1714 | return; |
1715 | 1715 | } |
1716 | 1716 | |
1717 | - if ( false !== strpos( $option, '%' ) ) { |
|
1717 | + if (false !== strpos($option, '%')) { |
|
1718 | 1718 | |
1719 | 1719 | global $wpdb; |
1720 | 1720 | |
@@ -1730,10 +1730,10 @@ discard block |
||
1730 | 1730 | ); // WPCS: cache pass. |
1731 | 1731 | |
1732 | 1732 | } else { |
1733 | - $options = array( $option ); |
|
1733 | + $options = array($option); |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | - array_map( 'delete_option', $options ); |
|
1736 | + array_map('delete_option', $options); |
|
1737 | 1737 | } |
1738 | 1738 | |
1739 | 1739 | /** |
@@ -1745,9 +1745,9 @@ discard block |
||
1745 | 1745 | * |
1746 | 1746 | * @param string $option The network option to uninstall. |
1747 | 1747 | */ |
1748 | - protected function uninstall_network_option( $option ) { |
|
1748 | + protected function uninstall_network_option($option) { |
|
1749 | 1749 | |
1750 | - if ( false !== strpos( $option, '%' ) ) { |
|
1750 | + if (false !== strpos($option, '%')) { |
|
1751 | 1751 | |
1752 | 1752 | global $wpdb; |
1753 | 1753 | |
@@ -1765,10 +1765,10 @@ discard block |
||
1765 | 1765 | ); // WPCS: cache pass. |
1766 | 1766 | |
1767 | 1767 | } else { |
1768 | - $options = array( $option ); |
|
1768 | + $options = array($option); |
|
1769 | 1769 | } |
1770 | 1770 | |
1771 | - array_map( 'delete_site_option', $options ); |
|
1771 | + array_map('delete_site_option', $options); |
|
1772 | 1772 | } |
1773 | 1773 | |
1774 | 1774 | /** |
@@ -1778,9 +1778,9 @@ discard block |
||
1778 | 1778 | * |
1779 | 1779 | * @param string $id_base The base ID of the widget to uninstall (class name). |
1780 | 1780 | */ |
1781 | - protected function uninstall_widget( $id_base ) { |
|
1781 | + protected function uninstall_widget($id_base) { |
|
1782 | 1782 | |
1783 | - $this->uninstall_option( "widget_{$id_base}" ); |
|
1783 | + $this->uninstall_option("widget_{$id_base}"); |
|
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | /** |
@@ -1790,9 +1790,9 @@ discard block |
||
1790 | 1790 | * |
1791 | 1791 | * @param string $id_base The base ID (class) of the points hook to uninstall. |
1792 | 1792 | */ |
1793 | - protected function uninstall_points_hook( $id_base ) { |
|
1793 | + protected function uninstall_points_hook($id_base) { |
|
1794 | 1794 | |
1795 | - $this->uninstall_option( "wordpoints_hook-{$id_base}" ); |
|
1795 | + $this->uninstall_option("wordpoints_hook-{$id_base}"); |
|
1796 | 1796 | } |
1797 | 1797 | |
1798 | 1798 | /** |
@@ -1802,20 +1802,20 @@ discard block |
||
1802 | 1802 | * |
1803 | 1803 | * @param string $table The name of the table to uninstall, sans DB prefix. |
1804 | 1804 | */ |
1805 | - protected function uninstall_table( $table ) { |
|
1805 | + protected function uninstall_table($table) { |
|
1806 | 1806 | |
1807 | 1807 | global $wpdb; |
1808 | 1808 | |
1809 | 1809 | // Null will use the current blog's prefix, 0 the base prefix. |
1810 | - if ( 'site' === $this->context ) { |
|
1810 | + if ('site' === $this->context) { |
|
1811 | 1811 | $site_id = null; |
1812 | 1812 | } else { |
1813 | 1813 | $site_id = 0; |
1814 | 1814 | } |
1815 | 1815 | |
1816 | - $table = str_replace( '`', '``', $table ); |
|
1816 | + $table = str_replace('`', '``', $table); |
|
1817 | 1817 | |
1818 | - $wpdb->query( 'DROP TABLE IF EXISTS `' . $wpdb->get_blog_prefix( $site_id ) . $table . '`' ); // WPCS: unprepared SQL, cache pass. |
|
1818 | + $wpdb->query('DROP TABLE IF EXISTS `' . $wpdb->get_blog_prefix($site_id) . $table . '`'); // WPCS: unprepared SQL, cache pass. |
|
1819 | 1819 | } |
1820 | 1820 | |
1821 | 1821 | // |
@@ -1835,7 +1835,7 @@ discard block |
||
1835 | 1835 | |
1836 | 1836 | $this->install_db_schema(); |
1837 | 1837 | |
1838 | - if ( $this->network_wide ) { |
|
1838 | + if ($this->network_wide) { |
|
1839 | 1839 | $this->set_db_version(); |
1840 | 1840 | } |
1841 | 1841 | } |
@@ -1851,11 +1851,11 @@ discard block |
||
1851 | 1851 | */ |
1852 | 1852 | protected function install_site() { |
1853 | 1853 | |
1854 | - if ( isset( $this->schema['site'] ) ) { |
|
1854 | + if (isset($this->schema['site'])) { |
|
1855 | 1855 | $this->install_db_schema(); |
1856 | 1856 | } |
1857 | 1857 | |
1858 | - if ( ! $this->network_wide ) { |
|
1858 | + if ( ! $this->network_wide) { |
|
1859 | 1859 | $this->set_db_version(); |
1860 | 1860 | } |
1861 | 1861 | |
@@ -1885,10 +1885,10 @@ discard block |
||
1885 | 1885 | */ |
1886 | 1886 | protected function load_base_dependencies() { |
1887 | 1887 | |
1888 | - require_once dirname( __FILE__ ) . '/constants.php'; |
|
1888 | + require_once dirname(__FILE__) . '/constants.php'; |
|
1889 | 1889 | require_once WORDPOINTS_DIR . '/classes/class/autoloader.php'; |
1890 | 1890 | |
1891 | - WordPoints_Class_Autoloader::register_dir( WORDPOINTS_DIR . '/classes' ); |
|
1891 | + WordPoints_Class_Autoloader::register_dir(WORDPOINTS_DIR . '/classes'); |
|
1892 | 1892 | |
1893 | 1893 | require_once WORDPOINTS_DIR . '/includes/functions.php'; |
1894 | 1894 | require_once WORDPOINTS_DIR . '/includes/apps.php'; |
@@ -1915,8 +1915,8 @@ discard block |
||
1915 | 1915 | */ |
1916 | 1916 | protected function uninstall_network() { |
1917 | 1917 | |
1918 | - if ( ! empty( $this->uninstall['network'] ) ) { |
|
1919 | - $this->uninstall_( 'network' ); |
|
1918 | + if ( ! empty($this->uninstall['network'])) { |
|
1919 | + $this->uninstall_('network'); |
|
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | $this->unset_db_version(); |
@@ -1933,8 +1933,8 @@ discard block |
||
1933 | 1933 | */ |
1934 | 1934 | protected function uninstall_site() { |
1935 | 1935 | |
1936 | - if ( ! empty( $this->uninstall['site'] ) ) { |
|
1937 | - $this->uninstall_( 'site' ); |
|
1936 | + if ( ! empty($this->uninstall['site'])) { |
|
1937 | + $this->uninstall_('site'); |
|
1938 | 1938 | } |
1939 | 1939 | |
1940 | 1940 | $this->unset_db_version(); |
@@ -1951,8 +1951,8 @@ discard block |
||
1951 | 1951 | */ |
1952 | 1952 | protected function uninstall_single() { |
1953 | 1953 | |
1954 | - if ( ! empty( $this->uninstall['single'] ) ) { |
|
1955 | - $this->uninstall_( 'single' ); |
|
1954 | + if ( ! empty($this->uninstall['single'])) { |
|
1955 | + $this->uninstall_('single'); |
|
1956 | 1956 | } |
1957 | 1957 | |
1958 | 1958 | $this->unset_db_version(); |