@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return string |
24 | 24 | */ |
25 | -function wordpoints_points_top_shortcode( $atts ) { |
|
25 | +function wordpoints_points_top_shortcode($atts) { |
|
26 | 26 | |
27 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
27 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
28 | 28 | |
29 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_points_top' ); |
|
29 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_points_top'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return string |
53 | 53 | */ |
54 | -function wordpoints_points_logs_shortcode( $atts ) { |
|
54 | +function wordpoints_points_logs_shortcode($atts) { |
|
55 | 55 | |
56 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
56 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
57 | 57 | |
58 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_points_logs' ); |
|
58 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_points_logs'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return string The points for the user. |
78 | 78 | */ |
79 | -function wordpoints_points_shortcode( $atts ) { |
|
79 | +function wordpoints_points_shortcode($atts) { |
|
80 | 80 | |
81 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
81 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
82 | 82 | |
83 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_points' ); |
|
83 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_points'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return string A list of points hooks describing how the user can earn points. |
99 | 99 | */ |
100 | -function wordpoints_how_to_get_points_shortcode( $atts ) { |
|
100 | +function wordpoints_how_to_get_points_shortcode($atts) { |
|
101 | 101 | |
102 | - _deprecated_function( __FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()' ); |
|
102 | + _deprecated_function(__FUNCTION__, '1.8.0', 'WordPoints_Shortcodes::do_shortcode()'); |
|
103 | 103 | |
104 | - return WordPoints_Shortcodes::do_shortcode( $atts, null, 'wordpoints_how_to_get_points' ); |
|
104 | + return WordPoints_Shortcodes::do_shortcode($atts, null, 'wordpoints_how_to_get_points'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @type array $defaults |
125 | 125 | */ |
126 | - protected $defaults = array( 'points' => 10, 'post_type' => 'ALL' ); |
|
126 | + protected $defaults = array('points' => 10, 'post_type' => 'ALL'); |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Initialize the hook. |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function __construct() { |
134 | 134 | |
135 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
136 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
135 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
136 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $this->init( |
140 | - _x( 'Comment Removed', 'points hook name', 'wordpoints' ) |
|
140 | + _x('Comment Removed', 'points hook name', 'wordpoints') |
|
141 | 141 | , array( |
142 | - 'description' => __( 'Comment removed from the site.', 'wordpoints' ), |
|
142 | + 'description' => __('Comment removed from the site.', 'wordpoints'), |
|
143 | 143 | // translators: Singular post type name. |
144 | - 'post_type_description' => __( 'Comment on a %s removed from the site.', 'wordpoints' ), |
|
145 | - 'post_type_filter' => array( $this, 'post_type_supports_comments' ), |
|
146 | - 'points_label' => __( 'Points subtracted if comment removed:', 'wordpoints' ), |
|
144 | + 'post_type_description' => __('Comment on a %s removed from the site.', 'wordpoints'), |
|
145 | + 'post_type_filter' => array($this, 'post_type_supports_comments'), |
|
146 | + 'points_label' => __('Points subtracted if comment removed:', 'wordpoints'), |
|
147 | 147 | ) |
148 | 148 | ); |
149 | 149 | |
150 | - add_action( 'transition_comment_status', array( $this, 'hook' ), 10, 3 ); |
|
151 | - add_filter( 'wordpoints_points_log-comment_disapprove', array( $this, 'logs' ), 10, 6 ); |
|
150 | + add_action('transition_comment_status', array($this, 'hook'), 10, 3); |
|
151 | + add_filter('wordpoints_points_log-comment_disapprove', array($this, 'logs'), 10, 6); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -166,36 +166,36 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public function hook( $new_status, $old_status, $comment ) { |
|
169 | + public function hook($new_status, $old_status, $comment) { |
|
170 | 170 | |
171 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
172 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
171 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
172 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
173 | 173 | } |
174 | 174 | |
175 | - if ( ! $comment->user_id || $old_status === $new_status ) { |
|
175 | + if ( ! $comment->user_id || $old_status === $new_status) { |
|
176 | 176 | return; |
177 | 177 | } |
178 | 178 | |
179 | - $post = get_post( $comment->comment_post_ID ); |
|
179 | + $post = get_post($comment->comment_post_ID); |
|
180 | 180 | |
181 | - if ( 'approved' === $old_status ) { |
|
181 | + if ('approved' === $old_status) { |
|
182 | 182 | |
183 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
183 | + foreach ($this->get_instances() as $number => $instance) { |
|
184 | 184 | |
185 | - $instance = array_merge( $this->defaults, $instance ); |
|
185 | + $instance = array_merge($this->defaults, $instance); |
|
186 | 186 | |
187 | - if ( ! $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) ) { |
|
187 | + if ( ! $this->is_matching_post_type($post->post_type, $instance['post_type'])) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | 190 | |
191 | - $points_type = $this->points_type( $number ); |
|
191 | + $points_type = $this->points_type($number); |
|
192 | 192 | |
193 | - wordpoints_subtract_points( $comment->user_id, $instance['points'], $points_type, 'comment_disapprove', array( 'status' => $new_status ) ); |
|
193 | + wordpoints_subtract_points($comment->user_id, $instance['points'], $points_type, 'comment_disapprove', array('status' => $new_status)); |
|
194 | 194 | |
195 | 195 | update_comment_meta( |
196 | 196 | $comment->comment_ID |
197 | - , wp_slash( "wordpoints_last_status-{$points_type}" ) |
|
198 | - , wp_slash( $new_status ) |
|
197 | + , wp_slash("wordpoints_last_status-{$points_type}") |
|
198 | + , wp_slash($new_status) |
|
199 | 199 | ); |
200 | 200 | } |
201 | 201 | } |
@@ -220,17 +220,17 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return void |
222 | 222 | */ |
223 | - public function new_comment_hook( $comment_id, $comment ) { |
|
223 | + public function new_comment_hook($comment_id, $comment) { |
|
224 | 224 | |
225 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
226 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
225 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
226 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( 0 === (int) $comment->user_id ) { |
|
229 | + if (0 === (int) $comment->user_id) { |
|
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | - switch ( $comment->comment_approved ) { |
|
233 | + switch ($comment->comment_approved) { |
|
234 | 234 | |
235 | 235 | // Comment hasn't been approved yet. |
236 | 236 | case 0: return; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $old_status = 'approved'; |
245 | 245 | } |
246 | 246 | |
247 | - $this->hook( $new_status, $old_status, $comment ); |
|
247 | + $this->hook($new_status, $old_status, $comment); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return string |
265 | 265 | */ |
266 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
266 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
267 | 267 | |
268 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
269 | - _deprecated_function( __METHOD__, '1.9.0', 'wordpoints_points_logs_comment_disapprove' ); |
|
268 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
269 | + _deprecated_function(__METHOD__, '1.9.0', 'wordpoints_points_logs_comment_disapprove'); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | return wordpoints_points_logs_comment_disapprove( |
@@ -288,15 +288,15 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return int|false The number of points, or false. |
290 | 290 | */ |
291 | - public function get_points( $number = null ) { |
|
291 | + public function get_points($number = null) { |
|
292 | 292 | |
293 | - if ( ! get_site_option( 'wordpoints_comment_removed_hook_legacy' ) ) { |
|
294 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
293 | + if ( ! get_site_option('wordpoints_comment_removed_hook_legacy')) { |
|
294 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
295 | 295 | } |
296 | 296 | |
297 | - $points = parent::get_points( $number ); |
|
297 | + $points = parent::get_points($number); |
|
298 | 298 | |
299 | - if ( $points ) { |
|
299 | + if ($points) { |
|
300 | 300 | $points = -$points; |
301 | 301 | } |
302 | 302 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @type array $defaults |
324 | 324 | */ |
325 | - protected $defaults = array( 'points' => 20, 'post_type' => 'ALL' ); |
|
325 | + protected $defaults = array('points' => 20, 'post_type' => 'ALL'); |
|
326 | 326 | |
327 | 327 | // |
328 | 328 | // Public Methods. |
@@ -335,22 +335,22 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function __construct() { |
337 | 337 | |
338 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
339 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
338 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
339 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | $this->init( |
343 | - _x( 'Post Delete', 'points hook name', 'wordpoints' ) |
|
343 | + _x('Post Delete', 'points hook name', 'wordpoints') |
|
344 | 344 | ,array( |
345 | - 'description' => __( 'A post is permanently deleted.', 'wordpoints' ), |
|
346 | - 'points_label' => __( 'Points removed when deleted:', 'wordpoints' ), |
|
345 | + 'description' => __('A post is permanently deleted.', 'wordpoints'), |
|
346 | + 'points_label' => __('Points removed when deleted:', 'wordpoints'), |
|
347 | 347 | // translators: Singular post type name. |
348 | - 'post_type_description' => __( '%s permanently deleted.', 'wordpoints' ), |
|
348 | + 'post_type_description' => __('%s permanently deleted.', 'wordpoints'), |
|
349 | 349 | ) |
350 | 350 | ); |
351 | 351 | |
352 | - add_action( 'delete_post', array( $this, 'hook' ) ); |
|
353 | - add_filter( 'wordpoints_points_log-post_delete', array( $this, 'logs' ), 10, 6 ); |
|
352 | + add_action('delete_post', array($this, 'hook')); |
|
353 | + add_filter('wordpoints_points_log-post_delete', array($this, 'logs'), 10, 6); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -362,30 +362,30 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @param int $post_id The post's ID. |
364 | 364 | */ |
365 | - public function hook( $post_id ) { |
|
365 | + public function hook($post_id) { |
|
366 | 366 | |
367 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
368 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
367 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
368 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
369 | 369 | } |
370 | 370 | |
371 | - $post = get_post( $post_id, OBJECT, 'display' ); |
|
371 | + $post = get_post($post_id, OBJECT, 'display'); |
|
372 | 372 | |
373 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
373 | + foreach ($this->get_instances() as $number => $instance) { |
|
374 | 374 | |
375 | - $instance = array_merge( $this->defaults, $instance ); |
|
375 | + $instance = array_merge($this->defaults, $instance); |
|
376 | 376 | |
377 | 377 | if ( |
378 | - $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) |
|
378 | + $this->is_matching_post_type($post->post_type, $instance['post_type']) |
|
379 | 379 | && 'auto-draft' !== $post->post_status |
380 | - && __( 'Auto Draft', 'default' ) !== $post->post_title |
|
380 | + && __('Auto Draft', 'default') !== $post->post_title |
|
381 | 381 | ) { |
382 | 382 | |
383 | 383 | wordpoints_alter_points( |
384 | 384 | $post->post_author |
385 | 385 | , -$instance['points'] |
386 | - , $this->points_type( $number ) |
|
386 | + , $this->points_type($number) |
|
387 | 387 | , 'post_delete' |
388 | - , array( 'post_title' => $post->post_title, 'post_type' => $post->post_type ) |
|
388 | + , array('post_title' => $post->post_title, 'post_type' => $post->post_type) |
|
389 | 389 | ); |
390 | 390 | } |
391 | 391 | } |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return string |
411 | 411 | */ |
412 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
412 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
413 | 413 | |
414 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
415 | - _deprecated_function( __METHOD__, '1.9.0', 'wordpoints_points_logs_post_delete' ); |
|
414 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
415 | + _deprecated_function(__METHOD__, '1.9.0', 'wordpoints_points_logs_post_delete'); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | return wordpoints_points_logs_post_delete( |
@@ -434,15 +434,15 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @return int|false The number of points, or false. |
436 | 436 | */ |
437 | - public function get_points( $number = null ) { |
|
437 | + public function get_points($number = null) { |
|
438 | 438 | |
439 | - if ( ! get_site_option( 'wordpoints_post_delete_hook_legacy' ) ) { |
|
440 | - _deprecated_function( __METHOD__, '1.9.0' ); |
|
439 | + if ( ! get_site_option('wordpoints_post_delete_hook_legacy')) { |
|
440 | + _deprecated_function(__METHOD__, '1.9.0'); |
|
441 | 441 | } |
442 | 442 | |
443 | - $points = parent::get_points( $number ); |
|
443 | + $points = parent::get_points($number); |
|
444 | 444 | |
445 | - if ( $points ) { |
|
445 | + if ($points) { |
|
446 | 446 | $points = -$points; |
447 | 447 | } |
448 | 448 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function wordpoints_points_get_db_schema() { |
463 | 463 | |
464 | - _deprecated_function( __FUNCTION__, '2.0.0' ); |
|
464 | + _deprecated_function(__FUNCTION__, '2.0.0'); |
|
465 | 465 | |
466 | 466 | global $wpdb; |
467 | 467 | |
@@ -500,16 +500,16 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @param int $blog_id The ID of the new site. |
502 | 502 | */ |
503 | -function wordpoints_points_add_custom_caps_to_new_sites( $blog_id ) { |
|
503 | +function wordpoints_points_add_custom_caps_to_new_sites($blog_id) { |
|
504 | 504 | |
505 | - _deprecated_function( __FUNCTION__, '2.0.0' ); |
|
505 | + _deprecated_function(__FUNCTION__, '2.0.0'); |
|
506 | 506 | |
507 | - if ( ! is_wordpoints_network_active() ) { |
|
507 | + if ( ! is_wordpoints_network_active()) { |
|
508 | 508 | return; |
509 | 509 | } |
510 | 510 | |
511 | - switch_to_blog( $blog_id ); |
|
512 | - wordpoints_add_custom_caps( wordpoints_points_get_custom_caps() ); |
|
511 | + switch_to_blog($blog_id); |
|
512 | + wordpoints_add_custom_caps(wordpoints_points_get_custom_caps()); |
|
513 | 513 | restore_current_blog(); |
514 | 514 | } |
515 | 515 |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | public function __construct() { |
37 | 37 | |
38 | 38 | parent::__construct( |
39 | - _x( 'Comment', 'points hook name', 'wordpoints' ) |
|
39 | + _x('Comment', 'points hook name', 'wordpoints') |
|
40 | 40 | , array( |
41 | - 'description' => __( 'Leaving a new comment.', 'wordpoints' ), |
|
41 | + 'description' => __('Leaving a new comment.', 'wordpoints'), |
|
42 | 42 | // translators: Singular post type name. |
43 | - 'post_type_description' => __( 'Leaving a new comment on a %s.', 'wordpoints' ), |
|
43 | + 'post_type_description' => __('Leaving a new comment on a %s.', 'wordpoints'), |
|
44 | 44 | // translators: Post title. |
45 | - 'log_text_post_title' => _x( 'Comment on %s.', 'points log description', 'wordpoints' ), |
|
46 | - 'log_text_no_post_title' => _x( 'Comment', 'points log description', 'wordpoints' ), |
|
45 | + 'log_text_post_title' => _x('Comment on %s.', 'points log description', 'wordpoints'), |
|
46 | + 'log_text_no_post_title' => _x('Comment', 'points log description', 'wordpoints'), |
|
47 | 47 | // translators: Singular post type name. |
48 | - 'log_text_post_type' => _x( 'Comment on a %s.', 'points log description', 'wordpoints' ), |
|
48 | + 'log_text_post_type' => _x('Comment on a %s.', 'points log description', 'wordpoints'), |
|
49 | 49 | // translators: Post title. |
50 | - 'log_text_post_title_reverse' => _x( 'Comment on %s removed.', 'points log description', 'wordpoints' ), |
|
51 | - 'log_text_no_post_title_reverse' => _x( 'Comment removed.', 'points log description', 'wordpoints' ), |
|
50 | + 'log_text_post_title_reverse' => _x('Comment on %s removed.', 'points log description', 'wordpoints'), |
|
51 | + 'log_text_no_post_title_reverse' => _x('Comment removed.', 'points log description', 'wordpoints'), |
|
52 | 52 | // translators: Singular post type name. |
53 | - 'log_text_post_type_reverse' => _x( 'Comment on a %s removed.', 'points log description', 'wordpoints' ), |
|
53 | + 'log_text_post_type_reverse' => _x('Comment on a %s removed.', 'points log description', 'wordpoints'), |
|
54 | 54 | 'last_status_meta_key' => 'wordpoints_last_status', |
55 | 55 | ) |
56 | 56 | ); |
57 | 57 | |
58 | - if ( get_site_option( 'wordpoints_comment_hook_legacy' ) ) { |
|
58 | + if (get_site_option('wordpoints_comment_hook_legacy')) { |
|
59 | 59 | $this->set_option( |
60 | 60 | 'disable_auto_reverse_label' |
61 | - , __( 'Revoke the points if the comment is removed.', 'wordpoints' ) |
|
61 | + , __('Revoke the points if the comment is removed.', 'wordpoints') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | } |
@@ -90,19 +90,19 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return bool Whether points have been awarded. |
92 | 92 | */ |
93 | - public function awarded_points_already( $comment_id, $points_type ) { |
|
93 | + public function awarded_points_already($comment_id, $points_type) { |
|
94 | 94 | |
95 | - _deprecated_function( __METHOD__, '1.8.0' ); |
|
95 | + _deprecated_function(__METHOD__, '1.8.0'); |
|
96 | 96 | |
97 | - $meta_key = $this->get_last_status_comment_meta_key( $points_type ); |
|
97 | + $meta_key = $this->get_last_status_comment_meta_key($points_type); |
|
98 | 98 | |
99 | - $last_status = get_comment_meta( $comment_id, $meta_key, true ); |
|
99 | + $last_status = get_comment_meta($comment_id, $meta_key, true); |
|
100 | 100 | |
101 | - if ( 'approved' !== $last_status ) { |
|
101 | + if ('approved' !== $last_status) { |
|
102 | 102 | |
103 | 103 | update_comment_meta( |
104 | 104 | $comment_id |
105 | - , wp_slash( $meta_key ) |
|
105 | + , wp_slash($meta_key) |
|
106 | 106 | , 'approved' |
107 | 107 | , $last_status |
108 | 108 | ); |
@@ -52,37 +52,37 @@ discard block |
||
52 | 52 | public function __construct() { |
53 | 53 | |
54 | 54 | parent::__construct( |
55 | - _x( 'Post Publish', 'points hook name', 'wordpoints' ) |
|
55 | + _x('Post Publish', 'points hook name', 'wordpoints') |
|
56 | 56 | , array( |
57 | - 'description' => __( 'New post published.', 'wordpoints' ), |
|
57 | + 'description' => __('New post published.', 'wordpoints'), |
|
58 | 58 | // translators: Singular post type name. |
59 | - 'post_type_description' => __( 'New %s published.', 'wordpoints' ), |
|
59 | + 'post_type_description' => __('New %s published.', 'wordpoints'), |
|
60 | 60 | // translators: Post title. |
61 | - 'log_text_post_title' => _x( 'Post %s published.', 'points log description', 'wordpoints' ), |
|
61 | + 'log_text_post_title' => _x('Post %s published.', 'points log description', 'wordpoints'), |
|
62 | 62 | // translators: 1. Singular post type name; 2. Post title. |
63 | - 'log_text_post_title_and_type' => _x( '%2$s %1$s published.', 'points log description', 'wordpoints' ), |
|
63 | + 'log_text_post_title_and_type' => _x('%2$s %1$s published.', 'points log description', 'wordpoints'), |
|
64 | 64 | // translators: Singular post type name. |
65 | - 'log_text_post_type' => _x( '%s published.', 'points log description', 'wordpoints' ), |
|
66 | - 'log_text_no_post_title' => _x( 'Post published.', 'points log description', 'wordpoints' ), |
|
65 | + 'log_text_post_type' => _x('%s published.', 'points log description', 'wordpoints'), |
|
66 | + 'log_text_no_post_title' => _x('Post published.', 'points log description', 'wordpoints'), |
|
67 | 67 | // translators: Singular post type name. |
68 | - 'log_text_post_type_reverse' => _x( '%s deleted.', 'points log description', 'wordpoints' ), |
|
68 | + 'log_text_post_type_reverse' => _x('%s deleted.', 'points log description', 'wordpoints'), |
|
69 | 69 | // translators: 1. Singular post type name; 2. Post title. |
70 | - 'log_text_post_title_and_type_reverse' => _x( '%1$s “%2$s” deleted.', 'points log description', 'wordpoints' ), |
|
70 | + 'log_text_post_title_and_type_reverse' => _x('%1$s “%2$s” deleted.', 'points log description', 'wordpoints'), |
|
71 | 71 | // translators: Post title. |
72 | - 'log_text_post_title_reverse' => _x( 'Post “%s” deleted.', 'points log description', 'wordpoints' ), |
|
73 | - 'log_text_no_post_title_reverse' => _x( 'Post deleted.', 'points log description', 'wordpoints' ), |
|
72 | + 'log_text_post_title_reverse' => _x('Post “%s” deleted.', 'points log description', 'wordpoints'), |
|
73 | + 'log_text_no_post_title_reverse' => _x('Post deleted.', 'points log description', 'wordpoints'), |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | |
77 | - if ( get_site_option( 'wordpoints_post_hook_legacy' ) ) { |
|
77 | + if (get_site_option('wordpoints_post_hook_legacy')) { |
|
78 | 78 | $this->set_option( |
79 | 79 | 'disable_auto_reverse_label' |
80 | - , __( 'Revoke the points if the post is permanently deleted.', 'wordpoints' ) |
|
80 | + , __('Revoke the points if the post is permanently deleted.', 'wordpoints') |
|
81 | 81 | ); |
82 | 82 | } |
83 | 83 | |
84 | - add_action( 'transition_post_status', array( $this, 'hook' ), 10, 3 ); |
|
85 | - add_action( 'delete_post', array( $this, 'reverse_hook' ) ); |
|
84 | + add_action('transition_post_status', array($this, 'hook'), 10, 3); |
|
85 | + add_action('delete_post', array($this, 'reverse_hook')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -98,29 +98,29 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function hook( $new_status, $old_status, $post ) { |
|
101 | + public function hook($new_status, $old_status, $post) { |
|
102 | 102 | |
103 | - if ( 'publish' !== $new_status ) { |
|
103 | + if ('publish' !== $new_status) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
107 | + foreach ($this->get_instances() as $number => $instance) { |
|
108 | 108 | |
109 | - $instance = array_merge( $this->defaults, $instance ); |
|
109 | + $instance = array_merge($this->defaults, $instance); |
|
110 | 110 | |
111 | - $points_type = $this->points_type( $number ); |
|
111 | + $points_type = $this->points_type($number); |
|
112 | 112 | |
113 | 113 | if ( |
114 | - $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) |
|
115 | - && ! $this->awarded_points_already( $post->ID, $points_type ) |
|
114 | + $this->is_matching_post_type($post->post_type, $instance['post_type']) |
|
115 | + && ! $this->awarded_points_already($post->ID, $points_type) |
|
116 | 116 | ) { |
117 | 117 | |
118 | - if ( isset( $instance['publish'] ) ) { |
|
119 | - _deprecated_argument( __METHOD__, '1.4.0', 'The "publish" hook setting is no longer used to hold the value for the points. Use "points" instead.' ); |
|
118 | + if (isset($instance['publish'])) { |
|
119 | + _deprecated_argument(__METHOD__, '1.4.0', 'The "publish" hook setting is no longer used to hold the value for the points. Use "points" instead.'); |
|
120 | 120 | $instance['points'] = $instance['publish']; |
121 | 121 | } |
122 | 122 | |
123 | - if ( ! isset( $instance['points'] ) ) { |
|
123 | + if ( ! isset($instance['points'])) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | , $instance['points'] |
130 | 130 | , $points_type |
131 | 131 | , 'post_publish' |
132 | - , array( 'post_id' => $post->ID ) |
|
132 | + , array('post_id' => $post->ID) |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | } |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function publish_hook( $new_status, $old_status, $post ) { |
|
150 | + public function publish_hook($new_status, $old_status, $post) { |
|
151 | 151 | |
152 | - _deprecated_function( __METHOD__, '2.0.0', __CLASS__ . '::hook' ); |
|
152 | + _deprecated_function(__METHOD__, '2.0.0', __CLASS__ . '::hook'); |
|
153 | 153 | |
154 | - $this->hook( $new_status, $old_status, $post ); |
|
154 | + $this->hook($new_status, $old_status, $post); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param int $post_id The ID of the post being deleted. |
165 | 165 | */ |
166 | - public function reverse_hook( $post_id ) { |
|
166 | + public function reverse_hook($post_id) { |
|
167 | 167 | |
168 | - $post_type = get_post_field( 'post_type', $post_id ); |
|
169 | - if ( ! $this->should_do_auto_reversals_for_post_type( $post_type ) ) { |
|
168 | + $post_type = get_post_field('post_type', $post_id); |
|
169 | + if ( ! $this->should_do_auto_reversals_for_post_type($post_type)) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | ) |
178 | 178 | ); |
179 | 179 | |
180 | - foreach ( $logs as $log ) { |
|
181 | - $this->auto_reverse_log( $log ); |
|
180 | + foreach ($logs as $log) { |
|
181 | + $this->auto_reverse_log($log); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - public function publish_logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
200 | + public function publish_logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
201 | 201 | |
202 | - _deprecated_function( __METHOD__, '2.0.0', __CLASS__ . '::logs' ); |
|
202 | + _deprecated_function(__METHOD__, '2.0.0', __CLASS__ . '::logs'); |
|
203 | 203 | |
204 | - return $this->logs( $text, $points, $points_type, $user_id, $log_type, $meta ); |
|
204 | + return $this->logs($text, $points, $points_type, $user_id, $log_type, $meta); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return bool Whether points have been awarded for publishing this post before. |
216 | 216 | */ |
217 | - public function awarded_points_already( $post_id, $points_type ) { |
|
217 | + public function awarded_points_already($post_id, $points_type) { |
|
218 | 218 | |
219 | 219 | $query = new WordPoints_Points_Logs_Query( |
220 | 220 | array( |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | ) |
227 | 227 | ); |
228 | 228 | |
229 | - return ( $query->count() > 0 ); |
|
229 | + return ($query->count() > 0); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | } // class WordPoints_Post_Points_Hook |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | public function __construct() { |
34 | 34 | |
35 | 35 | parent::__construct( |
36 | - _x( 'Comment Received', 'points hook name', 'wordpoints' ) |
|
36 | + _x('Comment Received', 'points hook name', 'wordpoints') |
|
37 | 37 | , array( |
38 | - 'description' => __( 'Receiving a comment.', 'wordpoints' ), |
|
38 | + 'description' => __('Receiving a comment.', 'wordpoints'), |
|
39 | 39 | // translators: Singular post type name. |
40 | - 'post_type_description' => __( 'Receiving a comment on a %s.', 'wordpoints' ), |
|
40 | + 'post_type_description' => __('Receiving a comment on a %s.', 'wordpoints'), |
|
41 | 41 | // translators: Post title. |
42 | - 'log_text_post_title' => _x( 'Received a comment on %s.', 'points log description', 'wordpoints' ), |
|
43 | - 'log_text_no_post_title' => _x( 'Received a comment.', 'points log description', 'wordpoints' ), |
|
42 | + 'log_text_post_title' => _x('Received a comment on %s.', 'points log description', 'wordpoints'), |
|
43 | + 'log_text_no_post_title' => _x('Received a comment.', 'points log description', 'wordpoints'), |
|
44 | 44 | // translators: Post title. |
45 | - 'log_text_post_title_reverse' => _x( 'Comment received on %s removed.', 'points log description', 'wordpoints' ), |
|
46 | - 'log_text_no_post_title_reverse' => _x( 'Comment received removed.', 'points log description', 'wordpoints' ), |
|
45 | + 'log_text_post_title_reverse' => _x('Comment received on %s removed.', 'points log description', 'wordpoints'), |
|
46 | + 'log_text_no_post_title_reverse' => _x('Comment received removed.', 'points log description', 'wordpoints'), |
|
47 | 47 | // translators: Singular post type name. |
48 | - 'log_text_post_type' => _x( 'Received a comment on a %s.', 'points log description', 'wordpoints' ), |
|
48 | + 'log_text_post_type' => _x('Received a comment on a %s.', 'points log description', 'wordpoints'), |
|
49 | 49 | // translators: Singular post type name. |
50 | - 'log_text_post_type_reverse' => _x( 'Comment received on a %s removed.', 'points log description', 'wordpoints' ), |
|
50 | + 'log_text_post_type_reverse' => _x('Comment received on a %s removed.', 'points log description', 'wordpoints'), |
|
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | } |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @since 1.8.0 |
57 | 57 | */ |
58 | - protected function shortcircuit_hook( $new_status, $old_status, $comment ) { |
|
58 | + protected function shortcircuit_hook($new_status, $old_status, $comment) { |
|
59 | 59 | |
60 | - if ( parent::shortcircuit_hook( $new_status, $old_status, $comment ) ) { |
|
60 | + if (parent::shortcircuit_hook($new_status, $old_status, $comment)) { |
|
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | |
64 | - $post = get_post( $comment->comment_post_ID ); |
|
64 | + $post = get_post($comment->comment_post_ID); |
|
65 | 65 | |
66 | - if ( $post && (int) $post->post_author === (int) $comment->user_id ) { |
|
66 | + if ($post && (int) $post->post_author === (int) $comment->user_id) { |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * @since 1.8.0 |
75 | 75 | */ |
76 | - protected function select_user_to_award( $comment, $post ) { |
|
76 | + protected function select_user_to_award($comment, $post) { |
|
77 | 77 | return $post->post_author; |
78 | 78 | } |
79 | 79 |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @since 1.8.0 |
32 | 32 | */ |
33 | - public function __construct( $title, $args ) { |
|
33 | + public function __construct($title, $args) { |
|
34 | 34 | |
35 | 35 | $defaults = array( |
36 | - 'post_type_filter' => array( $this, 'post_type_supports_comments' ), |
|
36 | + 'post_type_filter' => array($this, 'post_type_supports_comments'), |
|
37 | 37 | ); |
38 | 38 | |
39 | - $args = array_merge( $defaults, $args ); |
|
39 | + $args = array_merge($defaults, $args); |
|
40 | 40 | |
41 | - parent::__construct( $title, $args ); |
|
41 | + parent::__construct($title, $args); |
|
42 | 42 | |
43 | - add_action( 'transition_comment_status', array( $this, 'hook' ), 10, 3 ); |
|
44 | - add_action( 'transition_comment_status', array( $this, 'reverse_hook' ), 10, 3 ); |
|
45 | - add_action( 'wp_insert_comment', array( $this, 'new_comment_hook' ), 10, 2 ); |
|
43 | + add_action('transition_comment_status', array($this, 'hook'), 10, 3); |
|
44 | + add_action('transition_comment_status', array($this, 'reverse_hook'), 10, 3); |
|
45 | + add_action('wp_insert_comment', array($this, 'new_comment_hook'), 10, 2); |
|
46 | 46 | |
47 | - add_action( 'delete_comment', array( $this, 'clean_logs_on_comment_deletion' ) ); |
|
47 | + add_action('delete_comment', array($this, 'clean_logs_on_comment_deletion')); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -62,46 +62,46 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - public function hook( $new_status, $old_status, $comment ) { |
|
65 | + public function hook($new_status, $old_status, $comment) { |
|
66 | 66 | |
67 | - if ( $this->shortcircuit_hook( $new_status, $old_status, $comment ) ) { |
|
67 | + if ($this->shortcircuit_hook($new_status, $old_status, $comment)) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | - $post = get_post( $comment->comment_post_ID ); |
|
71 | + $post = get_post($comment->comment_post_ID); |
|
72 | 72 | |
73 | - if ( ! $post ) { |
|
73 | + if ( ! $post) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
77 | + foreach ($this->get_instances() as $number => $instance) { |
|
78 | 78 | |
79 | - $instance = array_merge( $this->defaults, $instance ); |
|
79 | + $instance = array_merge($this->defaults, $instance); |
|
80 | 80 | |
81 | - $points_type = $this->points_type( $number ); |
|
81 | + $points_type = $this->points_type($number); |
|
82 | 82 | |
83 | - $meta_key = $this->get_last_status_comment_meta_key( $points_type ); |
|
83 | + $meta_key = $this->get_last_status_comment_meta_key($points_type); |
|
84 | 84 | |
85 | - $last_status = get_comment_meta( $comment->comment_ID, $meta_key, true ); |
|
85 | + $last_status = get_comment_meta($comment->comment_ID, $meta_key, true); |
|
86 | 86 | |
87 | 87 | if ( |
88 | 88 | 'approved' === $last_status |
89 | - || ! $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) |
|
89 | + || ! $this->is_matching_post_type($post->post_type, $instance['post_type']) |
|
90 | 90 | ) { |
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | 94 | wordpoints_add_points( |
95 | - $this->select_user_to_award( $comment, $post ) |
|
95 | + $this->select_user_to_award($comment, $post) |
|
96 | 96 | , $instance['points'] |
97 | 97 | , $points_type |
98 | 98 | , $this->log_type |
99 | - , array( 'comment_id' => $comment->comment_ID ) |
|
99 | + , array('comment_id' => $comment->comment_ID) |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | update_comment_meta( |
103 | 103 | $comment->comment_ID |
104 | - , wp_slash( $meta_key ) |
|
104 | + , wp_slash($meta_key) |
|
105 | 105 | , 'approved' |
106 | 106 | , $last_status |
107 | 107 | ); |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return bool Whether the hook should short-circuit and not award any points. |
121 | 121 | */ |
122 | - protected function shortcircuit_hook( $new_status, $old_status, $comment ) { |
|
122 | + protected function shortcircuit_hook($new_status, $old_status, $comment) { |
|
123 | 123 | |
124 | - if ( 'approved' !== $new_status || $old_status === $new_status ) { |
|
124 | + if ('approved' !== $new_status || $old_status === $new_status) { |
|
125 | 125 | return true; |
126 | 126 | } |
127 | 127 | |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function new_comment_hook( $comment_id, $comment ) { |
|
150 | + public function new_comment_hook($comment_id, $comment) { |
|
151 | 151 | |
152 | - switch ( $comment->comment_approved ) { |
|
152 | + switch ($comment->comment_approved) { |
|
153 | 153 | |
154 | 154 | // Comment hasn't been approved yet. |
155 | 155 | case 0: return; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $old_status = 'approved'; |
167 | 167 | } |
168 | 168 | |
169 | - $this->hook( $new_status, $old_status, $comment ); |
|
169 | + $this->hook($new_status, $old_status, $comment); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return void |
184 | 184 | */ |
185 | - public function reverse_hook( $new_status, $old_status, $comment ) { |
|
185 | + public function reverse_hook($new_status, $old_status, $comment) { |
|
186 | 186 | |
187 | - if ( 'approved' !== $old_status || $old_status === $new_status ) { |
|
187 | + if ('approved' !== $old_status || $old_status === $new_status) { |
|
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | - $post_type = get_post_field( 'post_type', $comment->comment_post_ID ); |
|
192 | - if ( ! $this->should_do_auto_reversals_for_post_type( $post_type ) ) { |
|
191 | + $post_type = get_post_field('post_type', $comment->comment_post_ID); |
|
192 | + if ( ! $this->should_do_auto_reversals_for_post_type($post_type)) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | ) |
201 | 201 | ); |
202 | 202 | |
203 | - foreach ( $logs as $log ) { |
|
203 | + foreach ($logs as $log) { |
|
204 | 204 | |
205 | - $meta_key = $this->get_last_status_comment_meta_key( $log->points_type ); |
|
205 | + $meta_key = $this->get_last_status_comment_meta_key($log->points_type); |
|
206 | 206 | |
207 | - if ( 'approved' !== get_comment_meta( $comment->comment_ID, $meta_key, true ) ) { |
|
207 | + if ('approved' !== get_comment_meta($comment->comment_ID, $meta_key, true)) { |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
211 | - $this->auto_reverse_log( $log ); |
|
211 | + $this->auto_reverse_log($log); |
|
212 | 212 | |
213 | - delete_comment_meta( $comment->comment_ID, wp_slash( $meta_key ) ); |
|
213 | + delete_comment_meta($comment->comment_ID, wp_slash($meta_key)); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return int The ID of the user the points should be awarded to. |
230 | 230 | */ |
231 | - protected function select_user_to_award( $comment, $post ) { |
|
231 | + protected function select_user_to_award($comment, $post) { |
|
232 | 232 | return $comment->user_id; |
233 | 233 | } |
234 | 234 | |
@@ -248,30 +248,30 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
251 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
252 | 252 | |
253 | 253 | $reverse = ''; |
254 | 254 | |
255 | - if ( "reverse_{$this->log_type}" === $log_type ) { |
|
255 | + if ("reverse_{$this->log_type}" === $log_type) { |
|
256 | 256 | $reverse = '_reverse'; |
257 | 257 | } |
258 | 258 | |
259 | 259 | $comment = false; |
260 | 260 | |
261 | - if ( isset( $meta['comment_id'] ) ) { |
|
262 | - $comment = get_comment( $meta['comment_id'] ); |
|
261 | + if (isset($meta['comment_id'])) { |
|
262 | + $comment = get_comment($meta['comment_id']); |
|
263 | 263 | } |
264 | 264 | |
265 | - if ( ! $comment ) { |
|
265 | + if ( ! $comment) { |
|
266 | 266 | |
267 | - $text = parent::logs( $text, $points, $points_type, $user_id, $log_type, $meta ); |
|
267 | + $text = parent::logs($text, $points, $points_type, $user_id, $log_type, $meta); |
|
268 | 268 | |
269 | 269 | } else { |
270 | 270 | |
271 | 271 | $text = $this->log_with_post_title_link( |
272 | 272 | $comment->comment_post_ID |
273 | 273 | , $reverse |
274 | - , get_comment_link( $comment ) |
|
274 | + , get_comment_link($comment) |
|
275 | 275 | ); |
276 | 276 | } |
277 | 277 | |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return string The meta key where the last status is stored. |
289 | 289 | */ |
290 | - protected function get_last_status_comment_meta_key( $points_type ) { |
|
290 | + protected function get_last_status_comment_meta_key($points_type) { |
|
291 | 291 | |
292 | - $meta_key = $this->get_option( 'last_status_meta_key' ); |
|
292 | + $meta_key = $this->get_option('last_status_meta_key'); |
|
293 | 293 | |
294 | - if ( empty( $meta_key ) ) { |
|
294 | + if (empty($meta_key)) { |
|
295 | 295 | $meta_key = "wordpoints_last_status-{$this->log_type}"; |
296 | 296 | } |
297 | 297 | |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param int $comment_id The ID of the comment being deleted. |
315 | 315 | */ |
316 | - public function clean_logs_on_comment_deletion( $comment_id ) { |
|
316 | + public function clean_logs_on_comment_deletion($comment_id) { |
|
317 | 317 | |
318 | 318 | $post_id = false; |
319 | - $comment = get_comment( $comment_id ); |
|
319 | + $comment = get_comment($comment_id); |
|
320 | 320 | |
321 | - if ( $comment ) { |
|
321 | + if ($comment) { |
|
322 | 322 | $post_id = $comment->comment_post_ID; |
323 | 323 | } |
324 | 324 | |
325 | - $this->clean_logs( 'comment_id', $comment_id, 'post_id', $post_id ); |
|
325 | + $this->clean_logs('comment_id', $comment_id, 'post_id', $post_id); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return bool Whether the user can view this log. |
342 | 342 | */ |
343 | - public function user_can_view( $can_view, $log, $user_id ) { |
|
343 | + public function user_can_view($can_view, $log, $user_id) { |
|
344 | 344 | |
345 | 345 | _deprecated_function( |
346 | 346 | __METHOD__ |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | , 'the points logs viewing restrictions API' |
349 | 349 | ); |
350 | 350 | |
351 | - if ( $can_view ) { |
|
351 | + if ($can_view) { |
|
352 | 352 | |
353 | 353 | $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Read_Post( |
354 | 354 | $log |
355 | 355 | ); |
356 | 356 | |
357 | - $can_view = $restriction->user_can( $user_id ); |
|
357 | + $can_view = $restriction->user_can($user_id); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $can_view; |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( is_network_admin() ) { |
|
11 | - $title = __( 'WordPoints — Network Points Logs', 'wordpoints' ); |
|
10 | +if (is_network_admin()) { |
|
11 | + $title = __('WordPoints — Network Points Logs', 'wordpoints'); |
|
12 | 12 | } else { |
13 | - $title = __( 'WordPoints — Points Logs', 'wordpoints' ); |
|
13 | + $title = __('WordPoints — Points Logs', 'wordpoints'); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | ?> |
17 | 17 | |
18 | 18 | <div class="wrap"> |
19 | - <h1><?php echo esc_html( $title ); ?></h1> |
|
20 | - <p class="wordpoints-admin-panel-desc"><?php esc_html_e( 'View recent points transactions.', 'wordpoints' ); ?></p> |
|
19 | + <h1><?php echo esc_html($title); ?></h1> |
|
20 | + <p class="wordpoints-admin-panel-desc"><?php esc_html_e('View recent points transactions.', 'wordpoints'); ?></p> |
|
21 | 21 | |
22 | 22 | <?php |
23 | 23 | |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @since 1.0.0 |
28 | 28 | */ |
29 | - do_action( 'wordpoints_admin_points_logs' ); |
|
29 | + do_action('wordpoints_admin_points_logs'); |
|
30 | 30 | |
31 | 31 | $points_types = wordpoints_get_points_types(); |
32 | 32 | |
33 | - if ( empty( $points_types ) ) { |
|
33 | + if (empty($points_types)) { |
|
34 | 34 | |
35 | 35 | wordpoints_show_admin_error( |
36 | 36 | sprintf( |
37 | 37 | // translators: URL of Points Types admin screen. |
38 | - __( 'You need to <a href="%s">create a type of points</a> before you can use this page.', 'wordpoints' ) |
|
39 | - , esc_url( self_admin_url( 'admin.php?page=wordpoints_points_types' ) ) |
|
38 | + __('You need to <a href="%s">create a type of points</a> before you can use this page.', 'wordpoints') |
|
39 | + , esc_url(self_admin_url('admin.php?page=wordpoints_points_types')) |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | // Show a tab for each points type. |
46 | 46 | $tabs = array(); |
47 | 47 | |
48 | - foreach ( $points_types as $slug => $settings ) { |
|
48 | + foreach ($points_types as $slug => $settings) { |
|
49 | 49 | |
50 | - $tabs[ $slug ] = $settings['name']; |
|
50 | + $tabs[$slug] = $settings['name']; |
|
51 | 51 | } |
52 | 52 | |
53 | - wordpoints_admin_show_tabs( $tabs, false ); |
|
53 | + wordpoints_admin_show_tabs($tabs, false); |
|
54 | 54 | |
55 | - if ( is_network_admin() ) { |
|
55 | + if (is_network_admin()) { |
|
56 | 56 | $query = 'network'; |
57 | 57 | } else { |
58 | 58 | $query = 'default'; |
59 | 59 | } |
60 | 60 | |
61 | - $current_type = wordpoints_admin_get_current_tab( $tabs ); |
|
61 | + $current_type = wordpoints_admin_get_current_tab($tabs); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * At the top of one of the tabs on the points logs admin panel. |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * @param string $points_type The points type the current tab is for. |
69 | 69 | * @param string $query The current logs query being performed. |
70 | 70 | */ |
71 | - do_action( 'wordpoints_admin_points_logs_tab', $current_type, $query ); |
|
71 | + do_action('wordpoints_admin_points_logs_tab', $current_type, $query); |
|
72 | 72 | |
73 | 73 | // Get and display the logs based on current points type. |
74 | - wordpoints_show_points_logs_query( $current_type, $query ); |
|
74 | + wordpoints_show_points_logs_query($current_type, $query); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * At the bottom of one of the tabs on the points logs admin panel. |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param string $points_type The points type the current tab is for. |
82 | 82 | * @param string $query The current logs query being performed. |
83 | 83 | */ |
84 | - do_action( 'wordpoints_admin_points_logs_tab_after', $current_type, $query ); |
|
84 | + do_action('wordpoints_admin_points_logs_tab_after', $current_type, $query); |
|
85 | 85 | |
86 | 86 | } // End if ( empty( $points_types ) ) else. |
87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @since 1.0.0 |
92 | 92 | */ |
93 | - do_action( 'wordpoints_admin_points_logs_after' ); |
|
93 | + do_action('wordpoints_admin_points_logs_after'); |
|
94 | 94 | |
95 | 95 | ?> |
96 | 96 |
@@ -40,35 +40,35 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected function before() { |
42 | 42 | |
43 | - wp_enqueue_style( 'wordpoints-points-logs' ); |
|
43 | + wp_enqueue_style('wordpoints-points-logs'); |
|
44 | 44 | |
45 | - $this->current_time = current_time( 'timestamp', true ); |
|
45 | + $this->current_time = current_time('timestamp', true); |
|
46 | 46 | |
47 | 47 | $this->column_headings = array( |
48 | - 'user' => _x( 'User', 'points logs table heading', 'wordpoints' ), |
|
49 | - 'points' => _x( 'Points', 'points logs table heading', 'wordpoints' ), |
|
50 | - 'description' => _x( 'Description', 'points logs table heading', 'wordpoints' ), |
|
51 | - 'time' => _x( 'Time', 'points logs table heading', 'wordpoints' ), |
|
48 | + 'user' => _x('User', 'points logs table heading', 'wordpoints'), |
|
49 | + 'points' => _x('Points', 'points logs table heading', 'wordpoints'), |
|
50 | + 'description' => _x('Description', 'points logs table heading', 'wordpoints'), |
|
51 | + 'time' => _x('Time', 'points logs table heading', 'wordpoints'), |
|
52 | 52 | ); |
53 | 53 | |
54 | - $points_type = $this->logs_query->get_arg( 'points_type' ); |
|
54 | + $points_type = $this->logs_query->get_arg('points_type'); |
|
55 | 55 | |
56 | - if ( ! empty( $points_type ) ) { |
|
56 | + if ( ! empty($points_type)) { |
|
57 | 57 | |
58 | 58 | $points_type_name = wordpoints_get_points_type_setting( |
59 | 59 | $points_type |
60 | 60 | , 'name' |
61 | 61 | ); |
62 | 62 | |
63 | - if ( ! empty( $points_type_name ) ) { |
|
63 | + if ( ! empty($points_type_name)) { |
|
64 | 64 | $this->column_headings['points'] = $points_type_name; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | 68 | $extra_classes = array(); |
69 | 69 | |
70 | - foreach ( array( 'searchable', 'paginate' ) as $arg ) { |
|
71 | - if ( $this->args[ $arg ] ) { |
|
70 | + foreach (array('searchable', 'paginate') as $arg) { |
|
71 | + if ($this->args[$arg]) { |
|
72 | 72 | $extra_classes[] = $arg; |
73 | 73 | } |
74 | 74 | } |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | ?> |
93 | 93 | |
94 | 94 | <div class="wordpoints-points-logs-wrapper"> |
95 | - <?php if ( $this->args['searchable'] ) : ?> |
|
95 | + <?php if ($this->args['searchable']) : ?> |
|
96 | 96 | <?php $this->search_box(); ?> |
97 | 97 | <?php endif; ?> |
98 | 98 | |
99 | - <table class="wordpoints-points-logs widefat <?php echo esc_attr( implode( ' ', $extra_classes ) ); ?>"> |
|
99 | + <table class="wordpoints-points-logs widefat <?php echo esc_attr(implode(' ', $extra_classes)); ?>"> |
|
100 | 100 | <thead> |
101 | 101 | <tr> |
102 | - <?php if ( $this->args['show_users'] ) : ?> |
|
103 | - <th scope="col"><?php echo esc_html( $this->column_headings['user'] ); ?></th> |
|
102 | + <?php if ($this->args['show_users']) : ?> |
|
103 | + <th scope="col"><?php echo esc_html($this->column_headings['user']); ?></th> |
|
104 | 104 | <?php endif; ?> |
105 | - <th scope="col"><?php echo esc_html( $this->column_headings['points'] ); ?></th> |
|
106 | - <th scope="col"><?php echo esc_html( $this->column_headings['description'] ); ?></th> |
|
107 | - <th scope="col"><?php echo esc_html( $this->column_headings['time'] ); ?></th> |
|
105 | + <th scope="col"><?php echo esc_html($this->column_headings['points']); ?></th> |
|
106 | + <th scope="col"><?php echo esc_html($this->column_headings['description']); ?></th> |
|
107 | + <th scope="col"><?php echo esc_html($this->column_headings['time']); ?></th> |
|
108 | 108 | </tr> |
109 | 109 | </thead> |
110 | 110 | <tbody> |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | |
119 | 119 | ?> |
120 | 120 | <tr> |
121 | - <td colspan="<?php echo ( $this->args['show_users'] ) ? 4 : 3; ?>"> |
|
122 | - <?php esc_html_e( 'No matching logs found.', 'wordpoints' ); ?> |
|
121 | + <td colspan="<?php echo ($this->args['show_users']) ? 4 : 3; ?>"> |
|
122 | + <?php esc_html_e('No matching logs found.', 'wordpoints'); ?> |
|
123 | 123 | </td> |
124 | 124 | </tr> |
125 | 125 | <?php |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * @since 2.2.0 |
130 | 130 | */ |
131 | - protected function log( $log ) { |
|
131 | + protected function log($log) { |
|
132 | 132 | |
133 | - $user = get_userdata( $log->user_id ); |
|
133 | + $user = get_userdata($log->user_id); |
|
134 | 134 | |
135 | 135 | ?> |
136 | 136 | |
137 | - <tr class="wordpoints-log-id-<?php echo (int) $log->id; ?> <?php echo ( $this->i % 2 ) ? 'odd' : 'even'; ?>"> |
|
138 | - <?php if ( $this->args['show_users'] ) : ?> |
|
137 | + <tr class="wordpoints-log-id-<?php echo (int) $log->id; ?> <?php echo ($this->i % 2) ? 'odd' : 'even'; ?>"> |
|
138 | + <?php if ($this->args['show_users']) : ?> |
|
139 | 139 | <td> |
140 | - <?php echo get_avatar( $user->ID, 32 ); ?> |
|
140 | + <?php echo get_avatar($user->ID, 32); ?> |
|
141 | 141 | <?php |
142 | 142 | |
143 | 143 | /** |
@@ -155,33 +155,33 @@ discard block |
||
155 | 155 | */ |
156 | 156 | $name = apply_filters( |
157 | 157 | 'wordpoints_points_logs_table_username' |
158 | - , sanitize_user_field( 'display_name', $user->display_name, $log->user_id, 'display' ) |
|
158 | + , sanitize_user_field('display_name', $user->display_name, $log->user_id, 'display') |
|
159 | 159 | , $user |
160 | 160 | , $log |
161 | 161 | ); |
162 | 162 | |
163 | - echo wp_kses( $name, 'wordpoints_points_logs_username' ); |
|
163 | + echo wp_kses($name, 'wordpoints_points_logs_username'); |
|
164 | 164 | |
165 | 165 | ?> |
166 | 166 | </td> |
167 | 167 | <?php endif; ?> |
168 | - <td><?php echo wordpoints_format_points( $log->points, $log->points_type, 'logs' ); ?></td> |
|
168 | + <td><?php echo wordpoints_format_points($log->points, $log->points_type, 'logs'); ?></td> |
|
169 | 169 | <td> |
170 | 170 | <div class="wordpoints-log-text"> |
171 | - <?php echo wp_kses( $log->text, 'wordpoints_points_log' ); ?> |
|
171 | + <?php echo wp_kses($log->text, 'wordpoints_points_log'); ?> |
|
172 | 172 | </div> |
173 | - <?php if ( $this->restriction->applies() ) : ?> |
|
173 | + <?php if ($this->restriction->applies()) : ?> |
|
174 | 174 | <div class="wordpoints-log-viewing-restrictions"> |
175 | - <?php foreach ( (array) $this->restriction->get_description() as $description ) : ?> |
|
175 | + <?php foreach ((array) $this->restriction->get_description() as $description) : ?> |
|
176 | 176 | <div class="wordpoints-log-viewing-restriction"> |
177 | - <?php echo esc_html( $description ); ?> |
|
177 | + <?php echo esc_html($description); ?> |
|
178 | 178 | </div> |
179 | 179 | <?php endforeach; ?> |
180 | 180 | </div> |
181 | 181 | <?php endif; ?> |
182 | 182 | </td> |
183 | - <td title="<?php echo esc_attr( $log->date ); ?> <?php /* translators: coordinated universal time */ esc_attr_e( 'UTC', 'wordpoints' ); ?>"> |
|
184 | - <?php echo esc_html( human_time_diff( strtotime( $log->date ), $this->current_time ) ); ?> |
|
183 | + <td title="<?php echo esc_attr($log->date); ?> <?php /* translators: coordinated universal time */ esc_attr_e('UTC', 'wordpoints'); ?>"> |
|
184 | + <?php echo esc_html(human_time_diff(strtotime($log->date), $this->current_time)); ?> |
|
185 | 185 | </td> |
186 | 186 | </tr> |
187 | 187 | |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | </tbody> |
198 | 198 | <tfoot> |
199 | 199 | <tr> |
200 | - <?php if ( $this->args['show_users'] ) : ?> |
|
201 | - <th scope="col"><?php echo esc_html( $this->column_headings['user'] ); ?></th> |
|
200 | + <?php if ($this->args['show_users']) : ?> |
|
201 | + <th scope="col"><?php echo esc_html($this->column_headings['user']); ?></th> |
|
202 | 202 | <?php endif; ?> |
203 | - <th scope="col"><?php echo esc_html( $this->column_headings['points'] ); ?></th> |
|
204 | - <th scope="col"><?php echo esc_html( $this->column_headings['description'] ); ?></th> |
|
205 | - <th scope="col"><?php echo esc_html( $this->column_headings['time'] ); ?></th> |
|
203 | + <th scope="col"><?php echo esc_html($this->column_headings['points']); ?></th> |
|
204 | + <th scope="col"><?php echo esc_html($this->column_headings['description']); ?></th> |
|
205 | + <th scope="col"><?php echo esc_html($this->column_headings['time']); ?></th> |
|
206 | 206 | </tr> |
207 | 207 | </tfoot> |
208 | 208 | </table> |
209 | 209 | |
210 | - <?php if ( $this->args['paginate'] ) : ?> |
|
210 | + <?php if ($this->args['paginate']) : ?> |
|
211 | 211 | <?php $this->pagination(); ?> |
212 | 212 | <?php endif; ?> |
213 | 213 | </div> |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | |
223 | 223 | $search_term = ''; |
224 | 224 | |
225 | - if ( isset( $_POST['wordpoints_points_logs_search'] ) ) { // WPCS: CSRF OK |
|
225 | + if (isset($_POST['wordpoints_points_logs_search'])) { // WPCS: CSRF OK |
|
226 | 226 | $search_term = trim( |
227 | 227 | sanitize_text_field( |
228 | - wp_unslash( $_POST['wordpoints_points_logs_search'] ) // WPCS: CSRF OK |
|
228 | + wp_unslash($_POST['wordpoints_points_logs_search']) // WPCS: CSRF OK |
|
229 | 229 | ) |
230 | 230 | ); |
231 | 231 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | $page = 1; |
244 | 244 | |
245 | 245 | if ( |
246 | - isset( $_GET['wordpoints_points_logs_page'] ) |
|
247 | - && wordpoints_posint( $_GET['wordpoints_points_logs_page'] ) |
|
246 | + isset($_GET['wordpoints_points_logs_page']) |
|
247 | + && wordpoints_posint($_GET['wordpoints_points_logs_page']) |
|
248 | 248 | ) { |
249 | 249 | $page = (int) $_GET['wordpoints_points_logs_page']; |
250 | 250 | } |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | $per_page = 25; |
261 | 261 | |
262 | 262 | if ( |
263 | - isset( $_GET['wordpoints_points_logs_per_page'] ) |
|
264 | - && wordpoints_posint( $_GET['wordpoints_points_logs_per_page'] ) |
|
263 | + isset($_GET['wordpoints_points_logs_per_page']) |
|
264 | + && wordpoints_posint($_GET['wordpoints_points_logs_per_page']) |
|
265 | 265 | ) { |
266 | 266 | $per_page = (int) $_GET['wordpoints_points_logs_per_page']; |
267 | 267 | } |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | |
279 | 279 | ?> |
280 | 280 | |
281 | - <?php if ( ! empty( $search_term ) ) : ?> |
|
281 | + <?php if ( ! empty($search_term)) : ?> |
|
282 | 282 | <div class="wordpoints-points-logs-searching"> |
283 | 283 | <?php |
284 | 284 | |
285 | 285 | echo esc_html( |
286 | 286 | sprintf( |
287 | 287 | // translators: Search term. |
288 | - __( 'Searching for “%s”', 'wordpoints' ) |
|
288 | + __('Searching for “%s”', 'wordpoints') |
|
289 | 289 | , $search_term |
290 | 290 | ) |
291 | 291 | ); |
@@ -295,20 +295,20 @@ discard block |
||
295 | 295 | <?php endif; ?> |
296 | 296 | |
297 | 297 | <div class="wordpoints-points-logs-search"> |
298 | - <form method="POST" action="<?php echo esc_url( remove_query_arg( 'wordpoints_points_logs_page' ) ); ?>"> |
|
298 | + <form method="POST" action="<?php echo esc_url(remove_query_arg('wordpoints_points_logs_page')); ?>"> |
|
299 | 299 | <label class="screen-reader-text" for="wordpoints_points_logs_search"> |
300 | - <?php esc_html_e( 'Search Logs:', 'wordpoints' ); ?> |
|
300 | + <?php esc_html_e('Search Logs:', 'wordpoints'); ?> |
|
301 | 301 | </label> |
302 | 302 | <input |
303 | 303 | type="text" |
304 | 304 | name="wordpoints_points_logs_search" |
305 | 305 | id="wordpoints_points_logs_search" |
306 | - value="<?php echo esc_attr( $search_term ); ?>" |
|
306 | + value="<?php echo esc_attr($search_term); ?>" |
|
307 | 307 | /> |
308 | 308 | <input |
309 | 309 | name="" |
310 | 310 | class="button" |
311 | - value="<?php esc_attr_e( 'Search Logs', 'wordpoints' ); ?>" |
|
311 | + value="<?php esc_attr_e('Search Logs', 'wordpoints'); ?>" |
|
312 | 312 | type="submit" |
313 | 313 | /> |
314 | 314 | </form> |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | |
327 | 327 | echo paginate_links( // XSS pass WPCS. |
328 | 328 | array( |
329 | - 'base' => add_query_arg( '%_%', '' ), |
|
329 | + 'base' => add_query_arg('%_%', ''), |
|
330 | 330 | 'format' => 'wordpoints_points_logs_page=%#%', |
331 | - 'total' => ceil( $this->logs_query->count() / $per_page ), |
|
331 | + 'total' => ceil($this->logs_query->count() / $per_page), |
|
332 | 332 | 'current' => $this->get_page_number(), |
333 | 333 | 'add_args' => array( |
334 | 334 | 'wordpoints_points_logs_per_page' => $per_page, |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @since 2.1.0 |
29 | 29 | */ |
30 | - protected $action_types = array( 'fire', 'toggle_on', 'toggle_off' ); |
|
30 | + protected $action_types = array('fire', 'toggle_on', 'toggle_off'); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @since 2.1.0 |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function get_settings_fields() { |
60 | 60 | |
61 | - $this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' ); |
|
62 | - $this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' ); |
|
63 | - $this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' ); |
|
61 | + $this->settings_fields['points']['label'] = _x('Points', 'form label', 'wordpoints'); |
|
62 | + $this->settings_fields['log_text']['label'] = _x('Log Text', 'form label', 'wordpoints'); |
|
63 | + $this->settings_fields['description']['label'] = _x('Description', 'form label', 'wordpoints'); |
|
64 | 64 | |
65 | 65 | return parent::get_settings_fields(); |
66 | 66 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | |
73 | 73 | $data = parent::get_ui_script_data(); |
74 | 74 | |
75 | - $data['target_label'] = __( 'Award To', 'wordpoints' ); |
|
76 | - $data['periods_label'] = __( 'Award each user no more than once in:', 'wordpoints' ); |
|
75 | + $data['target_label'] = __('Award To', 'wordpoints'); |
|
76 | + $data['periods_label'] = __('Award each user no more than once in:', 'wordpoints'); |
|
77 | 77 | |
78 | 78 | return $data; |
79 | 79 | } |
@@ -87,23 +87,23 @@ discard block |
||
87 | 87 | WordPoints_Hook_Event_Args $event_args |
88 | 88 | ) { |
89 | 89 | |
90 | - if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) { |
|
91 | - $validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' ); |
|
90 | + if ( ! isset($settings['points']) || false === wordpoints_int($settings['points'])) { |
|
91 | + $validator->add_error(__('Points must be an integer.', 'wordpoints'), 'points'); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
95 | - $validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' ); |
|
94 | + if ( ! isset($settings['points_type']) || ! wordpoints_is_points_type($settings['points_type'])) { |
|
95 | + $validator->add_error(__('Invalid points type.', 'wordpoints'), 'points_type'); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! isset( $settings['description'] ) ) { |
|
99 | - $validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' ); |
|
98 | + if ( ! isset($settings['description'])) { |
|
99 | + $validator->add_error(__('Description is required.', 'wordpoints'), 'description'); |
|
100 | 100 | } |
101 | 101 | |
102 | - if ( ! isset( $settings['log_text'] ) ) { |
|
103 | - $validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' ); |
|
102 | + if ( ! isset($settings['log_text'])) { |
|
103 | + $validator->add_error(__('Log Text is required.', 'wordpoints'), 'log_text'); |
|
104 | 104 | } |
105 | 105 | |
106 | - return parent::validate_settings( $settings, $validator, $event_args ); |
|
106 | + return parent::validate_settings($settings, $validator, $event_args); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -114,59 +114,59 @@ discard block |
||
114 | 114 | array $settings |
115 | 115 | ) { |
116 | 116 | |
117 | - parent::update_settings( $reaction, $settings ); |
|
117 | + parent::update_settings($reaction, $settings); |
|
118 | 118 | |
119 | - $reaction->update_meta( 'points', $settings['points'] ); |
|
120 | - $reaction->update_meta( 'points_type', $settings['points_type'] ); |
|
121 | - $reaction->update_meta( 'description', $settings['description'] ); |
|
122 | - $reaction->update_meta( 'log_text', $settings['log_text'] ); |
|
119 | + $reaction->update_meta('points', $settings['points']); |
|
120 | + $reaction->update_meta('points_type', $settings['points_type']); |
|
121 | + $reaction->update_meta('description', $settings['description']); |
|
122 | + $reaction->update_meta('log_text', $settings['log_text']); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @since 2.1.0 |
127 | 127 | */ |
128 | - public function hit( WordPoints_Hook_Fire $fire ) { |
|
128 | + public function hit(WordPoints_Hook_Fire $fire) { |
|
129 | 129 | |
130 | - if ( 'toggle_off' === $fire->action_type ) { |
|
131 | - $this->reverse_hit( $fire ); |
|
130 | + if ('toggle_off' === $fire->action_type) { |
|
131 | + $this->reverse_hit($fire); |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | 135 | $reaction = $fire->reaction; |
136 | 136 | |
137 | 137 | $target = $fire->event_args->get_from_hierarchy( |
138 | - $reaction->get_meta( 'target' ) |
|
138 | + $reaction->get_meta('target') |
|
139 | 139 | ); |
140 | 140 | |
141 | - if ( ! $target instanceof WordPoints_Entity ) { |
|
141 | + if ( ! $target instanceof WordPoints_Entity) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - $meta = array( 'hook_hit_id' => $fire->hit_id ); |
|
145 | + $meta = array('hook_hit_id' => $fire->hit_id); |
|
146 | 146 | |
147 | - foreach ( $fire->event_args->get_entities() as $entity ) { |
|
148 | - $meta[ $entity->get_slug() ] = $entity->get_the_id(); |
|
149 | - $meta[ $entity->get_slug() . '_guid' ] = $entity->get_the_guid(); |
|
147 | + foreach ($fire->event_args->get_entities() as $entity) { |
|
148 | + $meta[$entity->get_slug()] = $entity->get_the_id(); |
|
149 | + $meta[$entity->get_slug() . '_guid'] = $entity->get_the_guid(); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | wordpoints_alter_points( |
153 | 153 | $target->get_the_id() |
154 | - , $this->get_points_to_award( $fire ) |
|
155 | - , $reaction->get_meta( 'points_type' ) |
|
154 | + , $this->get_points_to_award($fire) |
|
155 | + , $reaction->get_meta('points_type') |
|
156 | 156 | , $reaction->get_event_slug() |
157 | 157 | , $meta |
158 | - , $reaction->get_meta( 'log_text' ) |
|
158 | + , $reaction->get_meta('log_text') |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * @since 2.1.0 |
164 | 164 | */ |
165 | - public function reverse_hit( WordPoints_Hook_Fire $fire ) { |
|
165 | + public function reverse_hit(WordPoints_Hook_Fire $fire) { |
|
166 | 166 | |
167 | - $hit_ids = $this->get_hit_ids_to_be_reversed( $fire ); |
|
167 | + $hit_ids = $this->get_hit_ids_to_be_reversed($fire); |
|
168 | 168 | |
169 | - if ( empty( $hit_ids ) ) { |
|
169 | + if (empty($hit_ids)) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | |
185 | 185 | $logs = $query->get(); |
186 | 186 | |
187 | - if ( ! $logs ) { |
|
187 | + if ( ! $logs) { |
|
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | - $this->reverse_logs( $logs, $fire ); |
|
191 | + $this->reverse_logs($logs, $fire); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array The IDs of the hits to be reversed. |
202 | 202 | */ |
203 | - protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
|
203 | + protected function get_hit_ids_to_be_reversed(WordPoints_Hook_Fire $fire) { |
|
204 | 204 | |
205 | 205 | // We closely integrate with the reversals extension to get the hit IDs. |
206 | - if ( ! isset( $fire->data['reversals']['hit_ids'] ) ) { |
|
206 | + if ( ! isset($fire->data['reversals']['hit_ids'])) { |
|
207 | 207 | return array(); |
208 | 208 | } |
209 | 209 | |
@@ -218,28 +218,28 @@ discard block |
||
218 | 218 | * @param object[] $logs The logs to reverse. |
219 | 219 | * @param WordPoints_Hook_Fire $fire The fire object. |
220 | 220 | */ |
221 | - protected function reverse_logs( $logs, WordPoints_Hook_Fire $fire ) { |
|
221 | + protected function reverse_logs($logs, WordPoints_Hook_Fire $fire) { |
|
222 | 222 | |
223 | - $event = wordpoints_hooks()->get_sub_app( 'events' )->get( |
|
223 | + $event = wordpoints_hooks()->get_sub_app('events')->get( |
|
224 | 224 | $fire->reaction->get_event_slug() |
225 | 225 | ); |
226 | 226 | |
227 | - if ( $event instanceof WordPoints_Hook_Event_ReversingI ) { |
|
227 | + if ($event instanceof WordPoints_Hook_Event_ReversingI) { |
|
228 | 228 | |
229 | 229 | // translators: 1. Log text for reversed transaction; 2. Reason for reversal. |
230 | - $template = __( 'Reversed “%1$s” (%2$s)', 'wordpoints' ); |
|
230 | + $template = __('Reversed “%1$s” (%2$s)', 'wordpoints'); |
|
231 | 231 | |
232 | 232 | $event_description = $event->get_reversal_text(); |
233 | 233 | |
234 | 234 | } else { |
235 | 235 | |
236 | 236 | // translators: 1. Log text for reversed transaction. |
237 | - $template = __( 'Reversed “%1$s”', 'wordpoints' ); |
|
237 | + $template = __('Reversed “%1$s”', 'wordpoints'); |
|
238 | 238 | |
239 | 239 | $event_description = ''; |
240 | 240 | } |
241 | 241 | |
242 | - foreach ( $logs as $log ) { |
|
242 | + foreach ($logs as $log) { |
|
243 | 243 | |
244 | 244 | $log_id = wordpoints_alter_points( |
245 | 245 | $log->user_id |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | 'original_log_id' => $log->id, |
251 | 251 | 'hook_hit_id' => $fire->hit_id, |
252 | 252 | ) |
253 | - , sprintf( $template, $log->text, $event_description ) |
|
253 | + , sprintf($template, $log->text, $event_description) |
|
254 | 254 | ); |
255 | 255 | |
256 | 256 | // Mark the old log as reversed by this one. |
257 | - wordpoints_update_points_log_meta( $log->id, 'auto_reversed', $log_id ); |
|
257 | + wordpoints_update_points_log_meta($log->id, 'auto_reversed', $log_id); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return int The number of points to award. |
269 | 269 | */ |
270 | - protected function get_points_to_award( WordPoints_Hook_Fire $fire ) { |
|
270 | + protected function get_points_to_award(WordPoints_Hook_Fire $fire) { |
|
271 | 271 | |
272 | - $points = $fire->reaction->get_meta( 'points' ); |
|
272 | + $points = $fire->reaction->get_meta('points'); |
|
273 | 273 | |
274 | 274 | /** |
275 | 275 | * Filters the number of points to award in the Points hook reactor. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function get_title() { |
25 | 25 | |
26 | 26 | // translators: Hook event title. |
27 | - return sprintf( __( '%s (Legacy)', 'wordpoints' ), parent::get_title() ); |
|
27 | + return sprintf(__('%s (Legacy)', 'wordpoints'), parent::get_title()); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function get_reversal_text() { |
47 | 47 | |
48 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
48 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
49 | 49 | |
50 | - switch ( $parsed['dynamic'] ) { |
|
50 | + switch ($parsed['dynamic']) { |
|
51 | 51 | |
52 | 52 | case 'post': |
53 | - return __( 'Post deleted.', 'wordpoints' ); |
|
53 | + return __('Post deleted.', 'wordpoints'); |
|
54 | 54 | |
55 | 55 | case 'page': |
56 | - return __( 'Page deleted.', 'wordpoints' ); |
|
56 | + return __('Page deleted.', 'wordpoints'); |
|
57 | 57 | |
58 | 58 | default: |
59 | 59 | return sprintf( |
60 | 60 | // translators: Singular post type name. |
61 | - _x( '%s deleted.', 'post type', 'wordpoints' ) |
|
61 | + _x('%s deleted.', 'post type', 'wordpoints') |
|
62 | 62 | , $this->get_entity_title() |
63 | 63 | ); |
64 | 64 | } |