@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @deprecated 2.1.0 |
99 | 99 | */ |
100 | 100 | public static function init() { |
101 | - _deprecated_function( __METHOD__, '2.1.0' ); |
|
101 | + _deprecated_function(__METHOD__, '2.1.0'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $class_name A 'WordPoints_Points_Hook' class name. |
110 | 110 | */ |
111 | - public static function register( $class_name ) { |
|
111 | + public static function register($class_name) { |
|
112 | 112 | |
113 | 113 | self::$classes[] = $class_name; |
114 | 114 | } |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @since 1.4.0 |
129 | 129 | */ |
130 | - do_action( 'wordpoints_points_hooks_register' ); |
|
130 | + do_action('wordpoints_points_hooks_register'); |
|
131 | 131 | |
132 | - $classes = array_unique( self::$classes ); |
|
132 | + $classes = array_unique(self::$classes); |
|
133 | 133 | |
134 | - foreach ( $classes as $class_name ) { |
|
134 | + foreach ($classes as $class_name) { |
|
135 | 135 | |
136 | 136 | $hook_type = new $class_name(); |
137 | - self::$hook_types[ $hook_type->get_id_base() ] = $hook_type; |
|
137 | + self::$hook_types[$hook_type->get_id_base()] = $hook_type; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.0.0 |
144 | 144 | */ |
145 | - do_action( 'wordpoints_points_hooks_registered' ); |
|
145 | + do_action('wordpoints_points_hooks_registered'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -166,25 +166,25 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return WordPoints_Points_Hook|false The hook object, or false for invalid ID. |
168 | 168 | */ |
169 | - public static function get_handler( $hook_id ) { |
|
169 | + public static function get_handler($hook_id) { |
|
170 | 170 | |
171 | - list( $hook_type, $id_number ) = explode( '-', $hook_id ); |
|
171 | + list($hook_type, $id_number) = explode('-', $hook_id); |
|
172 | 172 | |
173 | - $hook_type = self::get_handler_by_id_base( $hook_type ); |
|
173 | + $hook_type = self::get_handler_by_id_base($hook_type); |
|
174 | 174 | |
175 | - if ( false === $hook_type ) { |
|
175 | + if (false === $hook_type) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - $type = ( self::$network_mode ) ? 'network' : 'standard'; |
|
179 | + $type = (self::$network_mode) ? 'network' : 'standard'; |
|
180 | 180 | |
181 | - $instances = $hook_type->get_instances( $type ); |
|
181 | + $instances = $hook_type->get_instances($type); |
|
182 | 182 | |
183 | - if ( ! isset( $instances[ $id_number ] ) ) { |
|
183 | + if ( ! isset($instances[$id_number])) { |
|
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | |
187 | - $hook_type->set_number( $id_number ); |
|
187 | + $hook_type->set_number($id_number); |
|
188 | 188 | |
189 | 189 | return $hook_type; |
190 | 190 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return WordPoints_Points_Hook|false False if no handler found. |
203 | 203 | */ |
204 | - public static function get_handler_by_id_base( $id_base ) { |
|
204 | + public static function get_handler_by_id_base($id_base) { |
|
205 | 205 | |
206 | - if ( ! isset( self::$hook_types[ $id_base ] ) ) { |
|
206 | + if ( ! isset(self::$hook_types[$id_base])) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - return self::$hook_types[ $id_base ]; |
|
210 | + return self::$hook_types[$id_base]; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -221,35 +221,35 @@ discard block |
||
221 | 221 | * installed. Only needed if on multisite. If |
222 | 222 | * omitted, the current site ID is used. |
223 | 223 | */ |
224 | - public static function uninstall_hook_types( $hook_types, array $site_ids = null ) { |
|
224 | + public static function uninstall_hook_types($hook_types, array $site_ids = null) { |
|
225 | 225 | |
226 | - _deprecated_function( __METHOD__, '2.0.0', 'WordPoints_Un_Installer_Base::$uninstall' ); |
|
226 | + _deprecated_function(__METHOD__, '2.0.0', 'WordPoints_Un_Installer_Base::$uninstall'); |
|
227 | 227 | |
228 | 228 | $hook_types = (array) $hook_types; |
229 | 229 | |
230 | - if ( is_multisite() ) { |
|
230 | + if (is_multisite()) { |
|
231 | 231 | |
232 | - foreach ( $hook_types as $hook_type ) { |
|
233 | - delete_site_option( "wordpoints_hook-{$hook_type}" ); |
|
232 | + foreach ($hook_types as $hook_type) { |
|
233 | + delete_site_option("wordpoints_hook-{$hook_type}"); |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( ! isset( $site_ids ) ) { |
|
237 | - $site_ids = array( get_current_blog_id() ); |
|
236 | + if ( ! isset($site_ids)) { |
|
237 | + $site_ids = array(get_current_blog_id()); |
|
238 | 238 | } |
239 | 239 | |
240 | - foreach ( $site_ids as $site_id ) { |
|
240 | + foreach ($site_ids as $site_id) { |
|
241 | 241 | |
242 | - switch_to_blog( $site_id ); |
|
243 | - foreach ( $hook_types as $hook_type ) { |
|
244 | - delete_option( "wordpoints_hook-{$hook_type}" ); |
|
242 | + switch_to_blog($site_id); |
|
243 | + foreach ($hook_types as $hook_type) { |
|
244 | + delete_option("wordpoints_hook-{$hook_type}"); |
|
245 | 245 | } |
246 | 246 | restore_current_blog(); |
247 | 247 | } |
248 | 248 | |
249 | 249 | } else { |
250 | 250 | |
251 | - foreach ( $hook_types as $hook_type ) { |
|
252 | - delete_option( "wordpoints_hook-{$hook_type}" ); |
|
251 | + foreach ($hook_types as $hook_type) { |
|
252 | + delete_option("wordpoints_hook-{$hook_type}"); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | // Sort the hooks by name. |
268 | 268 | $hook_types = self::$hook_types; |
269 | - uasort( $hook_types, array( __CLASS__, '_sort_name_callback' ) ); |
|
269 | + uasort($hook_types, array(__CLASS__, '_sort_name_callback')); |
|
270 | 270 | |
271 | 271 | $disabled_hooks = wordpoints_get_maybe_network_array_option( |
272 | 272 | 'wordpoints_legacy_points_hooks_disabled' |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | $i = 0; |
277 | 277 | |
278 | 278 | // Display a representative for each hook type. |
279 | - foreach ( $hook_types as $id_base => $hook_type ) { |
|
279 | + foreach ($hook_types as $id_base => $hook_type) { |
|
280 | 280 | |
281 | - if ( isset( $disabled_hooks[ $id_base ] ) ) { |
|
281 | + if (isset($disabled_hooks[$id_base])) { |
|
282 | 282 | continue; |
283 | 283 | } |
284 | 284 | |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | $args['_multi_num'] = $hook_type->next_hook_id_number(); |
292 | 292 | $args['_id_slug'] = $i; |
293 | 293 | |
294 | - $hook_type->set_options( $args ); |
|
294 | + $hook_type->set_options($args); |
|
295 | 295 | |
296 | - self::_list_hook( $hook_type->get_id( 0 ), $hook_type ); |
|
296 | + self::_list_hook($hook_type->get_id(0), $hook_type); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | // If there were none, give the user a message. |
300 | - if ( empty( $hook_types ) ) { |
|
300 | + if (empty($hook_types)) { |
|
301 | 301 | |
302 | 302 | echo '<div class="wordpoints-no-hooks">' |
303 | - . esc_html__( 'There are no points hooks currently available.', 'wordpoints' ) |
|
303 | + . esc_html__('There are no points hooks currently available.', 'wordpoints') |
|
304 | 304 | . '</div>'; |
305 | 305 | } |
306 | 306 | } |
@@ -318,21 +318,21 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return void |
320 | 320 | */ |
321 | - public static function list_by_points_type( $slug ) { |
|
321 | + public static function list_by_points_type($slug) { |
|
322 | 322 | |
323 | - if ( '_inactive_hooks' !== $slug && ! wordpoints_is_points_type( $slug ) ) { |
|
323 | + if ('_inactive_hooks' !== $slug && ! wordpoints_is_points_type($slug)) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - $points_type_hooks = self::get_points_type_hooks( $slug ); |
|
327 | + $points_type_hooks = self::get_points_type_hooks($slug); |
|
328 | 328 | |
329 | - foreach ( $points_type_hooks as $hook_id ) { |
|
329 | + foreach ($points_type_hooks as $hook_id) { |
|
330 | 330 | |
331 | - list( $hook_type ) = explode( '-', $hook_id ); |
|
331 | + list($hook_type) = explode('-', $hook_id); |
|
332 | 332 | |
333 | - $hook_type = self::get_handler_by_id_base( $hook_type ); |
|
333 | + $hook_type = self::get_handler_by_id_base($hook_type); |
|
334 | 334 | |
335 | - if ( false === $hook_type ) { |
|
335 | + if (false === $hook_type) { |
|
336 | 336 | continue; |
337 | 337 | } |
338 | 338 | |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | |
341 | 341 | $options['_display'] = 'instance'; |
342 | 342 | |
343 | - unset( $options['_add'] ); |
|
343 | + unset($options['_add']); |
|
344 | 344 | |
345 | 345 | $options['_id_slug'] = $slug; |
346 | 346 | |
347 | - $hook_type->set_options( $options ); |
|
347 | + $hook_type->set_options($options); |
|
348 | 348 | |
349 | - self::_list_hook( $hook_id, $hook_type, $slug ); |
|
349 | + self::_list_hook($hook_id, $hook_type, $slug); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @param bool $on Whether to turn network mode on or off. |
364 | 364 | */ |
365 | - public static function set_network_mode( $on ) { |
|
365 | + public static function set_network_mode($on) { |
|
366 | 366 | |
367 | - if ( $on !== self::$network_mode ) { |
|
367 | + if ($on !== self::$network_mode) { |
|
368 | 368 | self::$network_mode = (bool) $on; |
369 | 369 | } |
370 | 370 | } |
@@ -408,12 +408,12 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return array |
410 | 410 | */ |
411 | - public static function get_points_type_hooks( $slug ) { |
|
411 | + public static function get_points_type_hooks($slug) { |
|
412 | 412 | |
413 | 413 | $points_types_hooks = self::get_points_types_hooks(); |
414 | 414 | |
415 | - if ( isset( $points_types_hooks[ $slug ] ) && is_array( $points_types_hooks[ $slug ] ) ) { |
|
416 | - $points_type_hooks = $points_types_hooks[ $slug ]; |
|
415 | + if (isset($points_types_hooks[$slug]) && is_array($points_types_hooks[$slug])) { |
|
416 | + $points_type_hooks = $points_types_hooks[$slug]; |
|
417 | 417 | } else { |
418 | 418 | $points_type_hooks = array(); |
419 | 419 | } |
@@ -428,12 +428,12 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @param array $points_types_hooks The list of points types and their hooks. |
430 | 430 | */ |
431 | - public static function save_points_types_hooks( array $points_types_hooks ) { |
|
431 | + public static function save_points_types_hooks(array $points_types_hooks) { |
|
432 | 432 | |
433 | - if ( self::$network_mode ) { |
|
434 | - update_site_option( 'wordpoints_points_types_hooks', $points_types_hooks ); |
|
433 | + if (self::$network_mode) { |
|
434 | + update_site_option('wordpoints_points_types_hooks', $points_types_hooks); |
|
435 | 435 | } else { |
436 | - update_option( 'wordpoints_points_types_hooks', $points_types_hooks ); |
|
436 | + update_option('wordpoints_points_types_hooks', $points_types_hooks); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
@@ -446,11 +446,11 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return string|false The points type for the hook. False if not found. |
448 | 448 | */ |
449 | - public static function get_points_type( $hook_id ) { |
|
449 | + public static function get_points_type($hook_id) { |
|
450 | 450 | |
451 | - foreach ( self::get_points_types_hooks() as $points_type => $hooks ) { |
|
451 | + foreach (self::get_points_types_hooks() as $points_type => $hooks) { |
|
452 | 452 | |
453 | - if ( in_array( $hook_id, $hooks ) ) { |
|
453 | + if (in_array($hook_id, $hooks)) { |
|
454 | 454 | return $points_type; |
455 | 455 | } |
456 | 456 | } |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | |
470 | 470 | $defaults = array(); |
471 | 471 | |
472 | - foreach ( wordpoints_get_points_types() as $slug => $settings ) { |
|
472 | + foreach (wordpoints_get_points_types() as $slug => $settings) { |
|
473 | 473 | |
474 | - $defaults[ $slug ] = array(); |
|
474 | + $defaults[$slug] = array(); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | return $defaults; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @param string $slug The slug for this type of points. |
497 | 497 | * @param string $wrap Whether to wrap the form inputs in a "widget" or not. |
498 | 498 | */ |
499 | - public static function points_type_form( $slug = null, $wrap = 'hook' ) { |
|
499 | + public static function points_type_form($slug = null, $wrap = 'hook') { |
|
500 | 500 | |
501 | 501 | _deprecated_function( |
502 | 502 | __METHOD__ |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | |
507 | 507 | $add_new = 0; |
508 | 508 | |
509 | - $points_type = wordpoints_get_points_type( $slug ); |
|
509 | + $points_type = wordpoints_get_points_type($slug); |
|
510 | 510 | |
511 | - if ( ! $points_type ) { |
|
511 | + if ( ! $points_type) { |
|
512 | 512 | |
513 | 513 | $points_type = array(); |
514 | - $add_new = wp_create_nonce( 'wordpoints_add_new_points_type' ); |
|
514 | + $add_new = wp_create_nonce('wordpoints_add_new_points_type'); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $points_type = array_merge( |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | ,$points_type |
524 | 524 | ); |
525 | 525 | |
526 | - if ( ! isset( $slug ) && 'hook' === $wrap ) { |
|
526 | + if ( ! isset($slug) && 'hook' === $wrap) { |
|
527 | 527 | $wrap = 'hook-content'; |
528 | 528 | } |
529 | 529 | |
530 | - switch ( $wrap ) { |
|
530 | + switch ($wrap) { |
|
531 | 531 | |
532 | 532 | case 'hook': |
533 | 533 | $hook_wrap = true; |
@@ -546,25 +546,25 @@ discard block |
||
546 | 546 | |
547 | 547 | ?> |
548 | 548 | |
549 | - <?php if ( $hook_wrap ) : ?> |
|
549 | + <?php if ($hook_wrap) : ?> |
|
550 | 550 | <div class="hook points-settings"> |
551 | 551 | <div class="hook-top"> |
552 | 552 | <div class="hook-title-action"> |
553 | 553 | <a class="hook-action hide-if-no-js" href="#available-hooks"></a> |
554 | 554 | </div> |
555 | - <div class="hook-title"><h3><?php esc_html_e( 'Settings', 'wordpoints' ); ?><span class="in-hook-title"></span></h3></div> |
|
555 | + <div class="hook-title"><h3><?php esc_html_e('Settings', 'wordpoints'); ?><span class="in-hook-title"></span></h3></div> |
|
556 | 556 | </div> |
557 | 557 | |
558 | 558 | <div class="hook-inside"> |
559 | 559 | <?php endif; ?> |
560 | 560 | |
561 | - <?php if ( $hook_content_wrap ) : ?> |
|
561 | + <?php if ($hook_content_wrap) : ?> |
|
562 | 562 | <form method="post"> |
563 | 563 | <div class="hook-content"> |
564 | 564 | <?php endif; ?> |
565 | 565 | |
566 | - <?php if ( $slug ) : ?> |
|
567 | - <p><span class="wordpoints-points-slug"><em><?php esc_html_e( 'Slug', 'wordpoints' ); ?>: <?php echo esc_html( $slug ); ?></em></span></p> |
|
566 | + <?php if ($slug) : ?> |
|
567 | + <p><span class="wordpoints-points-slug"><em><?php esc_html_e('Slug', 'wordpoints'); ?>: <?php echo esc_html($slug); ?></em></span></p> |
|
568 | 568 | <?php endif; ?> |
569 | 569 | |
570 | 570 | <?php |
@@ -578,33 +578,33 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @param string $points_type The slug of the points type. |
580 | 580 | */ |
581 | - do_action( 'wordpoints_points_type_form_top', $slug ); |
|
581 | + do_action('wordpoints_points_type_form_top', $slug); |
|
582 | 582 | |
583 | - if ( 'hook-content' === $wrap ) { |
|
583 | + if ('hook-content' === $wrap) { |
|
584 | 584 | |
585 | 585 | // Mark the prefix and suffix optional on the add new form. |
586 | - $prefix = _x( 'Prefix (optional):', 'points type', 'wordpoints' ); |
|
587 | - $suffix = _x( 'Suffix (optional):', 'points type', 'wordpoints' ); |
|
586 | + $prefix = _x('Prefix (optional):', 'points type', 'wordpoints'); |
|
587 | + $suffix = _x('Suffix (optional):', 'points type', 'wordpoints'); |
|
588 | 588 | |
589 | 589 | } else { |
590 | 590 | |
591 | - $prefix = _x( 'Prefix:', 'points type', 'wordpoints' ); |
|
592 | - $suffix = _x( 'Suffix:', 'points type', 'wordpoints' ); |
|
591 | + $prefix = _x('Prefix:', 'points type', 'wordpoints'); |
|
592 | + $suffix = _x('Suffix:', 'points type', 'wordpoints'); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | ?> |
596 | 596 | |
597 | 597 | <p> |
598 | - <label for="points-name-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html_x( 'Name:', 'points type', 'wordpoints' ); ?></label> |
|
599 | - <input class="widefat" type="text" id="points-name-<?php echo esc_attr( $slug ); ?>" name="points-name" value="<?php echo esc_attr( $points_type['name'] ); ?>" /> |
|
598 | + <label for="points-name-<?php echo esc_attr($slug); ?>"><?php echo esc_html_x('Name:', 'points type', 'wordpoints'); ?></label> |
|
599 | + <input class="widefat" type="text" id="points-name-<?php echo esc_attr($slug); ?>" name="points-name" value="<?php echo esc_attr($points_type['name']); ?>" /> |
|
600 | 600 | </p> |
601 | 601 | <p> |
602 | - <label for="points-prefix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $prefix ); ?></label> |
|
603 | - <input class="widefat" type="text" id="points-prefix-<?php echo esc_attr( $slug ); ?>" name="points-prefix" value="<?php echo esc_attr( $points_type['prefix'] ); ?>" /> |
|
602 | + <label for="points-prefix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($prefix); ?></label> |
|
603 | + <input class="widefat" type="text" id="points-prefix-<?php echo esc_attr($slug); ?>" name="points-prefix" value="<?php echo esc_attr($points_type['prefix']); ?>" /> |
|
604 | 604 | </p> |
605 | 605 | <p> |
606 | - <label for="points-suffix-<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $suffix ); ?></label> |
|
607 | - <input class="widefat" type="text" id="points-suffix-<?php echo esc_attr( $slug ); ?>" name="points-suffix" value="<?php echo esc_attr( $points_type['suffix'] ); ?>" /> |
|
606 | + <label for="points-suffix-<?php echo esc_attr($slug); ?>"><?php echo esc_html($suffix); ?></label> |
|
607 | + <input class="widefat" type="text" id="points-suffix-<?php echo esc_attr($slug); ?>" name="points-suffix" value="<?php echo esc_attr($points_type['suffix']); ?>" /> |
|
608 | 608 | </p> |
609 | 609 | |
610 | 610 | <?php |
@@ -618,30 +618,30 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @param string $points_type The slug of the points type. |
620 | 620 | */ |
621 | - do_action( 'wordpoints_points_type_form_bottom', $slug ); |
|
621 | + do_action('wordpoints_points_type_form_bottom', $slug); |
|
622 | 622 | |
623 | 623 | ?> |
624 | 624 | |
625 | - <?php if ( $hook_content_wrap ) : ?> |
|
625 | + <?php if ($hook_content_wrap) : ?> |
|
626 | 626 | </div> |
627 | 627 | |
628 | - <input type="hidden" name="points-slug" value="<?php echo esc_attr( $slug ); ?>" /> |
|
629 | - <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr( $add_new ); ?>" /> |
|
628 | + <input type="hidden" name="points-slug" value="<?php echo esc_attr($slug); ?>" /> |
|
629 | + <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
|
630 | 630 | |
631 | 631 | <div class="hook-control-actions"> |
632 | 632 | <div class="alignleft"> |
633 | 633 | <?php |
634 | 634 | |
635 | - if ( ! $add_new ) { |
|
636 | - wp_nonce_field( "wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce' ); |
|
637 | - submit_button( _x( 'Delete', 'points type', 'wordpoints' ), 'delete', 'delete-points-type', false, array( 'id' => "delete_points_type-{$slug}" ) ); |
|
635 | + if ( ! $add_new) { |
|
636 | + wp_nonce_field("wordpoints_delete_points_type-{$slug}", 'delete-points-type-nonce'); |
|
637 | + submit_button(_x('Delete', 'points type', 'wordpoints'), 'delete', 'delete-points-type', false, array('id' => "delete_points_type-{$slug}")); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | ?> |
641 | - <a class="hook-control-close" href="#close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
641 | + <a class="hook-control-close" href="#close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
642 | 642 | </div> |
643 | 643 | <div class="alignright"> |
644 | - <?php submit_button( _x( 'Save', 'points type', 'wordpoints' ), 'button-primary hook-control-save right', 'save-points-type', false, array( 'id' => "points-{$slug}-save" ) ); ?> |
|
644 | + <?php submit_button(_x('Save', 'points type', 'wordpoints'), 'button-primary hook-control-save right', 'save-points-type', false, array('id' => "points-{$slug}-save")); ?> |
|
645 | 645 | <span class="spinner"></span> |
646 | 646 | </div> |
647 | 647 | <br class="clear" /> |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | </form> |
650 | 650 | <?php endif; ?> |
651 | 651 | |
652 | - <?php if ( $hook_wrap ) : ?> |
|
652 | + <?php if ($hook_wrap) : ?> |
|
653 | 653 | </div> |
654 | 654 | </div> |
655 | 655 | |
@@ -669,25 +669,25 @@ discard block |
||
669 | 669 | * @param WordPoints_Points_Hook $hook A points hook object. |
670 | 670 | * @param string $points_type The slug for a points type. |
671 | 671 | */ |
672 | - private static function _list_hook( $hook_id, $hook, $points_type = null ) { |
|
672 | + private static function _list_hook($hook_id, $hook, $points_type = null) { |
|
673 | 673 | |
674 | - $number = $hook->get_number_by_id( $hook_id ); |
|
674 | + $number = $hook->get_number_by_id($hook_id); |
|
675 | 675 | $id_base = $hook->get_id_base(); |
676 | 676 | $options = $hook->get_options(); |
677 | 677 | |
678 | 678 | $id_format = $hook_id; |
679 | 679 | |
680 | - $multi_number = ( isset( $options['_multi_num'] ) ) ? $options['_multi_num'] : ''; |
|
681 | - $add_new = ( isset( $options['_add'] ) ) ? $options['_add'] : ''; |
|
680 | + $multi_number = (isset($options['_multi_num'])) ? $options['_multi_num'] : ''; |
|
681 | + $add_new = (isset($options['_add'])) ? $options['_add'] : ''; |
|
682 | 682 | |
683 | 683 | // Prepare the URL query string. |
684 | - $query_arg = array( 'edithook' => $id_format ); |
|
684 | + $query_arg = array('edithook' => $id_format); |
|
685 | 685 | |
686 | - if ( $add_new ) { |
|
686 | + if ($add_new) { |
|
687 | 687 | |
688 | 688 | $query_arg['addnew'] = 1; |
689 | 689 | |
690 | - if ( $multi_number ) { |
|
690 | + if ($multi_number) { |
|
691 | 691 | |
692 | 692 | $query_arg['num'] = $multi_number; |
693 | 693 | $query_arg['base'] = $id_base; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | $query_arg['points_type'] = $points_type; |
699 | 699 | } |
700 | 700 | |
701 | - if ( isset( $options['_display'] ) && 'template' === $options['_display'] ) { |
|
701 | + if (isset($options['_display']) && 'template' === $options['_display']) { |
|
702 | 702 | |
703 | 703 | /* |
704 | 704 | * We aren't outputting the form for a hook, but a template form for this |
@@ -714,17 +714,17 @@ discard block |
||
714 | 714 | |
715 | 715 | ?> |
716 | 716 | |
717 | - <div id="hook-<?php echo esc_html( $options['_id_slug'] ); ?>_<?php echo esc_attr( $id_format ); ?>" class="hook <?php echo esc_attr( $options['_classname'] ); ?>"> |
|
717 | + <div id="hook-<?php echo esc_html($options['_id_slug']); ?>_<?php echo esc_attr($id_format); ?>" class="hook <?php echo esc_attr($options['_classname']); ?>"> |
|
718 | 718 | <div class="hook-top"> |
719 | 719 | <div class="hook-title-action"> |
720 | 720 | <a class="hook-action hide-if-no-js" href="#available-hooks"></a> |
721 | - <a class="hook-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>"> |
|
722 | - <span class="edit"><?php echo esc_html_x( 'Edit', 'hook', 'wordpoints' ); ?></span> |
|
723 | - <span class="add"><?php echo esc_html_x( 'Add', 'hook', 'wordpoints' ); ?></span> |
|
724 | - <span class="screen-reader-text"><?php echo esc_html( strip_tags( $hook->get_name() ) ); ?></span> |
|
721 | + <a class="hook-control-edit hide-if-js" href="<?php echo esc_url(add_query_arg($query_arg)); ?>"> |
|
722 | + <span class="edit"><?php echo esc_html_x('Edit', 'hook', 'wordpoints'); ?></span> |
|
723 | + <span class="add"><?php echo esc_html_x('Add', 'hook', 'wordpoints'); ?></span> |
|
724 | + <span class="screen-reader-text"><?php echo esc_html(strip_tags($hook->get_name())); ?></span> |
|
725 | 725 | </a> |
726 | 726 | </div> |
727 | - <div class="hook-title"><h3><?php echo esc_html( strip_tags( $hook->get_name() ) ) ?><span class="in-hook-title"></span></h3></div> |
|
727 | + <div class="hook-title"><h3><?php echo esc_html(strip_tags($hook->get_name())) ?><span class="in-hook-title"></span></h3></div> |
|
728 | 728 | </div> |
729 | 729 | |
730 | 730 | <div class="hook-inside"> |
@@ -732,26 +732,26 @@ discard block |
||
732 | 732 | <div class="hook-content"> |
733 | 733 | <?php |
734 | 734 | |
735 | - $has_form = $hook->form_callback( $number ); |
|
735 | + $has_form = $hook->form_callback($number); |
|
736 | 736 | |
737 | 737 | ?> |
738 | 738 | </div> |
739 | 739 | |
740 | - <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr( $id_format ); ?>" /> |
|
741 | - <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr( $id_base ); ?>" /> |
|
742 | - <input type="hidden" name="hook-width" class="hook-width" value="<?php echo isset( $options['width'] ) ? esc_attr( $options['width'] ) : ''; ?>" /> |
|
743 | - <input type="hidden" name="hook-height" class="hook-height" value="<?php echo isset( $options['height'] ) ? esc_attr( $options['height'] ) : ''; ?>" /> |
|
744 | - <input type="hidden" name="hook_number" class="hook_number" value="<?php echo esc_attr( $number ); ?>" /> |
|
745 | - <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr( $multi_number ); ?>" /> |
|
746 | - <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr( $add_new ); ?>" /> |
|
740 | + <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr($id_format); ?>" /> |
|
741 | + <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" /> |
|
742 | + <input type="hidden" name="hook-width" class="hook-width" value="<?php echo isset($options['width']) ? esc_attr($options['width']) : ''; ?>" /> |
|
743 | + <input type="hidden" name="hook-height" class="hook-height" value="<?php echo isset($options['height']) ? esc_attr($options['height']) : ''; ?>" /> |
|
744 | + <input type="hidden" name="hook_number" class="hook_number" value="<?php echo esc_attr($number); ?>" /> |
|
745 | + <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" /> |
|
746 | + <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
|
747 | 747 | |
748 | 748 | <div class="hook-control-actions"> |
749 | 749 | <div class="alignleft"> |
750 | - <a class="hook-control-remove" href="#remove"><?php esc_html_e( 'Delete', 'wordpoints' ); ?></a> | |
|
751 | - <a class="hook-control-close" href="#close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
750 | + <a class="hook-control-remove" href="#remove"><?php esc_html_e('Delete', 'wordpoints'); ?></a> | |
|
751 | + <a class="hook-control-close" href="#close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
752 | 752 | </div> |
753 | - <div class="alignright<?php echo ( false === $has_form ) ? ' hook-control-noform' : ''; ?>"> |
|
754 | - <?php submit_button( __( 'Save', 'wordpoints' ), 'button-primary hook-control-save right', 'savehook', false, array( 'id' => "hook-{$id_format}-savehook" ) ); ?> |
|
753 | + <div class="alignright<?php echo (false === $has_form) ? ' hook-control-noform' : ''; ?>"> |
|
754 | + <?php submit_button(__('Save', 'wordpoints'), 'button-primary hook-control-save right', 'savehook', false, array('id' => "hook-{$id_format}-savehook")); ?> |
|
755 | 755 | <span class="spinner"></span> |
756 | 756 | </div> |
757 | 757 | <br class="clear" /> |
@@ -760,8 +760,8 @@ discard block |
||
760 | 760 | </div> |
761 | 761 | |
762 | 762 | <div class="hook-description"> |
763 | - <?php if ( ! empty( $options['description'] ) ) : ?> |
|
764 | - <?php echo esc_html( $options['description'] ); ?> |
|
763 | + <?php if ( ! empty($options['description'])) : ?> |
|
764 | + <?php echo esc_html($options['description']); ?> |
|
765 | 765 | <?php endif; ?> |
766 | 766 | </div> |
767 | 767 | </div> |
@@ -781,9 +781,9 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return int |
783 | 783 | */ |
784 | - private static function _sort_name_callback( $a, $b ) { |
|
784 | + private static function _sort_name_callback($a, $b) { |
|
785 | 785 | |
786 | - return strnatcasecmp( $a->get_name(), $b->get_name() ); |
|
786 | + return strnatcasecmp($a->get_name(), $b->get_name()); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | } // class WordPoints_Points_Hooks |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | * @since 2.3.0 |
28 | 28 | */ |
29 | 29 | protected $columns = array( |
30 | - 'id' => array( 'format' => '%d', 'unsigned' => true ), |
|
31 | - 'user_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
32 | - 'log_type' => array( 'format' => '%s' ), |
|
33 | - 'points' => array( 'format' => '%d' ), |
|
34 | - 'points_type' => array( 'format' => '%s' ), |
|
35 | - 'text' => array( 'format' => '%s' ), |
|
36 | - 'blog_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
37 | - 'site_id' => array( 'format' => '%d', 'unsigned' => true ), |
|
38 | - 'date' => array( 'format' => '%s', 'is_date' => true ), |
|
30 | + 'id' => array('format' => '%d', 'unsigned' => true), |
|
31 | + 'user_id' => array('format' => '%d', 'unsigned' => true), |
|
32 | + 'log_type' => array('format' => '%s'), |
|
33 | + 'points' => array('format' => '%d'), |
|
34 | + 'points_type' => array('format' => '%s'), |
|
35 | + 'text' => array('format' => '%s'), |
|
36 | + 'blog_id' => array('format' => '%d', 'unsigned' => true), |
|
37 | + 'site_id' => array('format' => '%d', 'unsigned' => true), |
|
38 | + 'date' => array('format' => '%s', 'is_date' => true), |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | /** |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @since 2.3.0 |
48 | 48 | */ |
49 | 49 | protected $deprecated_args = array( |
50 | - 'orderby' => array( 'replacement' => 'order_by', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
51 | - 'user__in' => array( 'replacement' => 'user_id__in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
52 | - 'user__not_in' => array( 'replacement' => 'user_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
53 | - 'blog__in' => array( 'replacement' => 'blog_id__in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
54 | - 'blog__not_in' => array( 'replacement' => 'blog_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__ ), |
|
50 | + 'orderby' => array('replacement' => 'order_by', 'version' => '2.3.0', 'class' => __CLASS__), |
|
51 | + 'user__in' => array('replacement' => 'user_id__in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
52 | + 'user__not_in' => array('replacement' => 'user_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
53 | + 'blog__in' => array('replacement' => 'blog_id__in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
54 | + 'blog__not_in' => array('replacement' => 'blog_id__not_in', 'version' => '2.3.0', 'class' => __CLASS__), |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | // |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @type array $meta_query See WP_Meta_Query. |
178 | 178 | * } |
179 | 179 | */ |
180 | - public function __construct( $args = array() ) { |
|
180 | + public function __construct($args = array()) { |
|
181 | 181 | |
182 | 182 | global $wpdb; |
183 | 183 | |
@@ -191,21 +191,21 @@ discard block |
||
191 | 191 | $this->defaults['text__compare'] = 'LIKE'; |
192 | 192 | |
193 | 193 | // Back-compat for pre-2.3.0, in case an object or string is passed. |
194 | - $args = wp_parse_args( $args ); |
|
195 | - $args = $this->convert_deprecated_arg_values( $args ); |
|
194 | + $args = wp_parse_args($args); |
|
195 | + $args = $this->convert_deprecated_arg_values($args); |
|
196 | 196 | |
197 | - parent::__construct( $args ); |
|
197 | + parent::__construct($args); |
|
198 | 198 | |
199 | - if ( is_multisite() ) { |
|
200 | - foreach ( array( 'blog', 'site' ) as $arg ) { |
|
199 | + if (is_multisite()) { |
|
200 | + foreach (array('blog', 'site') as $arg) { |
|
201 | 201 | |
202 | 202 | if ( |
203 | 203 | // Support passing these as null to override the defaults. |
204 | - ! array_key_exists( "{$arg}_id", $this->args ) |
|
205 | - && ! isset( $this->args[ "{$arg}_id__in" ] ) |
|
206 | - && ! isset( $this->args[ "{$arg}_id__not_in" ] ) |
|
204 | + ! array_key_exists("{$arg}_id", $this->args) |
|
205 | + && ! isset($this->args["{$arg}_id__in"]) |
|
206 | + && ! isset($this->args["{$arg}_id__not_in"]) |
|
207 | 207 | ) { |
208 | - $this->args[ "{$arg}_id" ] = $wpdb->{"{$arg}id"}; |
|
208 | + $this->args["{$arg}_id"] = $wpdb->{"{$arg}id"}; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -220,31 +220,31 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return array $args The args, with any values converted as needed. |
222 | 222 | */ |
223 | - protected function convert_deprecated_arg_values( $args ) { |
|
223 | + protected function convert_deprecated_arg_values($args) { |
|
224 | 224 | |
225 | 225 | // Back-compat for pre-2.3.0, when the fields arg supported 'all'. |
226 | - if ( isset( $args['fields'] ) && 'all' === $args['fields'] ) { |
|
226 | + if (isset($args['fields']) && 'all' === $args['fields']) { |
|
227 | 227 | |
228 | 228 | _deprecated_argument( |
229 | 229 | __METHOD__ |
230 | 230 | , '2.3.0' |
231 | - , esc_html( "Passing 'fields' => 'all' is deprecated, just omit the 'fields' arg instead, since all fields returned by default." ) |
|
231 | + , esc_html("Passing 'fields' => 'all' is deprecated, just omit the 'fields' arg instead, since all fields returned by default.") |
|
232 | 232 | ); |
233 | 233 | |
234 | - unset( $args['fields'] ); |
|
234 | + unset($args['fields']); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // Back-compat for pre-2.3.0, when the orderby arg supported 'none'. |
238 | - if ( isset( $args['orderby'] ) && 'none' === $args['orderby'] ) { |
|
238 | + if (isset($args['orderby']) && 'none' === $args['orderby']) { |
|
239 | 239 | |
240 | 240 | _deprecated_argument( |
241 | 241 | __METHOD__ |
242 | 242 | , '2.3.0' |
243 | - , esc_html( "Passing 'orderby' => 'none' is deprecated, pass 'order_by' => null instead." ) |
|
243 | + , esc_html("Passing 'orderby' => 'none' is deprecated, pass 'order_by' => null instead.") |
|
244 | 244 | ); |
245 | 245 | |
246 | 246 | $args['order_by'] = null; |
247 | - unset( $args['orderby'] ); |
|
247 | + unset($args['orderby']); |
|
248 | 248 | |
249 | 249 | return $args; |
250 | 250 | } |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | * @since 1.6.0 |
257 | 257 | * @since 2.3.0 Now returns $this. |
258 | 258 | */ |
259 | - public function set_args( array $args ) { |
|
259 | + public function set_args(array $args) { |
|
260 | 260 | |
261 | 261 | $this->_cache_query_hash = null; |
262 | 262 | |
263 | - return parent::set_args( $this->convert_deprecated_arg_values( $args ) ); |
|
263 | + return parent::set_args($this->convert_deprecated_arg_values($args)); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -279,18 +279,18 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function count() { |
281 | 281 | |
282 | - if ( $this->_is_cached_query ) { |
|
283 | - $cache = $this->_cache_get( 'count' ); |
|
282 | + if ($this->_is_cached_query) { |
|
283 | + $cache = $this->_cache_get('count'); |
|
284 | 284 | |
285 | - if ( false !== $cache ) { |
|
285 | + if (false !== $cache) { |
|
286 | 286 | return $cache; |
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | 290 | $count = parent::count(); |
291 | 291 | |
292 | - if ( $this->_is_cached_query ) { |
|
293 | - $this->_cache_set( $count, 'count' ); |
|
292 | + if ($this->_is_cached_query) { |
|
293 | + $this->_cache_set($count, 'count'); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | return $count; |
@@ -308,23 +308,23 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return mixed The results of the query, or false on failure. |
310 | 310 | */ |
311 | - public function get( $method = 'results' ) { |
|
311 | + public function get($method = 'results') { |
|
312 | 312 | |
313 | - if ( $this->_is_cached_query ) { |
|
314 | - $cache = $this->_cache_get( "get_{$method}" ); |
|
313 | + if ($this->_is_cached_query) { |
|
314 | + $cache = $this->_cache_get("get_{$method}"); |
|
315 | 315 | |
316 | - if ( false !== $cache ) { |
|
316 | + if (false !== $cache) { |
|
317 | 317 | return $cache; |
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | - $result = parent::get( $method ); |
|
321 | + $result = parent::get($method); |
|
322 | 322 | |
323 | - if ( $this->_is_cached_query ) { |
|
324 | - $this->_cache_set( $result, "get_{$method}" ); |
|
323 | + if ($this->_is_cached_query) { |
|
324 | + $this->_cache_set($result, "get_{$method}"); |
|
325 | 325 | |
326 | - if ( 'results' === $method || 'col' === $method ) { |
|
327 | - $this->_cache_set( count( $result ), 'count' ); |
|
326 | + if ('results' === $method || 'col' === $method) { |
|
327 | + $this->_cache_set(count($result), 'count'); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
@@ -351,20 +351,20 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return object[]|false The logs for this page, or false if $page or $per_page is invalid. |
353 | 353 | */ |
354 | - public function get_page( $page, $per_page = 25 ) { |
|
354 | + public function get_page($page, $per_page = 25) { |
|
355 | 355 | |
356 | - if ( ! wordpoints_posint( $page ) || ! wordpoints_posint( $per_page ) ) { |
|
356 | + if ( ! wordpoints_posint($page) || ! wordpoints_posint($per_page)) { |
|
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
360 | - $start = ( $page - 1 ) * $per_page; |
|
360 | + $start = ($page - 1) * $per_page; |
|
361 | 361 | |
362 | 362 | // First try the main cache. |
363 | - if ( $this->_is_cached_query ) { |
|
363 | + if ($this->_is_cached_query) { |
|
364 | 364 | |
365 | - $cache = $this->_cache_get( 'get_results' ); |
|
365 | + $cache = $this->_cache_get('get_results'); |
|
366 | 366 | |
367 | - if ( false !== $cache ) { |
|
367 | + if (false !== $cache) { |
|
368 | 368 | return array_slice( |
369 | 369 | $cache |
370 | 370 | , $start - $this->args['start'] |
@@ -378,18 +378,18 @@ discard block |
||
378 | 378 | |
379 | 379 | $this->args['start'] += $start; |
380 | 380 | |
381 | - if ( ! empty( $this->args['limit'] ) ) { |
|
381 | + if ( ! empty($this->args['limit'])) { |
|
382 | 382 | $this->args['limit'] -= $start; |
383 | 383 | } |
384 | 384 | |
385 | - if ( empty( $this->args['limit'] ) || $this->args['limit'] > $per_page ) { |
|
385 | + if (empty($this->args['limit']) || $this->args['limit'] > $per_page) { |
|
386 | 386 | $this->args['limit'] = $per_page; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Regenerate the query limit after changing the start and limit args. |
390 | 390 | $this->prepare_limit(); |
391 | 391 | |
392 | - unset( $this->_cache_query_hash ); |
|
392 | + unset($this->_cache_query_hash); |
|
393 | 393 | |
394 | 394 | $results = $this->get(); |
395 | 395 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | $this->limit = ''; |
401 | 401 | $this->prepare_limit(); |
402 | 402 | |
403 | - unset( $this->_cache_query_hash ); |
|
403 | + unset($this->_cache_query_hash); |
|
404 | 404 | |
405 | 405 | return $results; |
406 | 406 | } |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | * @param string $deprecated Deprecated; no longer used. |
449 | 449 | * @param bool $network Whether this is a network-wide query. |
450 | 450 | */ |
451 | - public function prime_cache( $key = 'default:%points_type%', $deprecated = null, $network = false ) { |
|
451 | + public function prime_cache($key = 'default:%points_type%', $deprecated = null, $network = false) { |
|
452 | 452 | |
453 | - if ( ! is_null( $deprecated ) ) { |
|
453 | + if ( ! is_null($deprecated)) { |
|
454 | 454 | _deprecated_argument( |
455 | 455 | __METHOD__ |
456 | 456 | , '1.9.0' |
@@ -466,13 +466,13 @@ discard block |
||
466 | 466 | '%user_id%', |
467 | 467 | ) |
468 | 468 | , array( |
469 | - isset( $this->args['points_type'] ) ? $this->args['points_type'] : '', |
|
470 | - isset( $this->args['user_id'] ) ? $this->args['user_id'] : 0, |
|
469 | + isset($this->args['points_type']) ? $this->args['points_type'] : '', |
|
470 | + isset($this->args['user_id']) ? $this->args['user_id'] : 0, |
|
471 | 471 | ) |
472 | 472 | , $key |
473 | 473 | ); |
474 | 474 | |
475 | - if ( $network ) { |
|
475 | + if ($network) { |
|
476 | 476 | $this->_cache_group = 'wordpoints_network_points_logs_query'; |
477 | 477 | } else { |
478 | 478 | $this->_cache_group = 'wordpoints_points_logs_query'; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | * |
489 | 489 | * @return string The correct meta table ID column, if the key is wordpoints_points_log_. |
490 | 490 | */ |
491 | - public function meta_query_meta_table_id_filter( $key ) { |
|
491 | + public function meta_query_meta_table_id_filter($key) { |
|
492 | 492 | |
493 | - if ( 'wordpoints_points_log__id' === $key ) { |
|
493 | + if ('wordpoints_points_log__id' === $key) { |
|
494 | 494 | $key = 'log_id'; |
495 | 495 | } |
496 | 496 | |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | */ |
507 | 507 | protected function prepare_meta_where() { |
508 | 508 | |
509 | - add_filter( 'sanitize_key', array( $this, 'meta_query_meta_table_id_filter' ) ); |
|
509 | + add_filter('sanitize_key', array($this, 'meta_query_meta_table_id_filter')); |
|
510 | 510 | parent::prepare_meta_where(); |
511 | - remove_filter( 'sanitize_key', array( $this, 'meta_query_meta_table_id_filter' ) ); |
|
511 | + remove_filter('sanitize_key', array($this, 'meta_query_meta_table_id_filter')); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | // |
@@ -525,29 +525,29 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @return mixed Cached value, or false if none. |
527 | 527 | */ |
528 | - private function _cache_get( $type = null ) { |
|
528 | + private function _cache_get($type = null) { |
|
529 | 529 | |
530 | - $cache = wp_cache_get( $this->_cache_key, $this->_cache_group ); |
|
530 | + $cache = wp_cache_get($this->_cache_key, $this->_cache_group); |
|
531 | 531 | |
532 | - if ( ! is_array( $cache ) ) { |
|
532 | + if ( ! is_array($cache)) { |
|
533 | 533 | return false; |
534 | 534 | } |
535 | 535 | |
536 | 536 | $this->_calc_cache_query_hash(); |
537 | 537 | |
538 | - if ( ! isset( $cache[ $this->_cache_query_hash ] ) ) { |
|
538 | + if ( ! isset($cache[$this->_cache_query_hash])) { |
|
539 | 539 | return false; |
540 | 540 | } |
541 | 541 | |
542 | - if ( isset( $type ) ) { |
|
543 | - if ( isset( $cache[ $this->_cache_query_hash ][ $type ] ) ) { |
|
544 | - return $cache[ $this->_cache_query_hash ][ $type ]; |
|
542 | + if (isset($type)) { |
|
543 | + if (isset($cache[$this->_cache_query_hash][$type])) { |
|
544 | + return $cache[$this->_cache_query_hash][$type]; |
|
545 | 545 | } else { |
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
550 | - return $cache[ $this->_cache_query_hash ]; |
|
550 | + return $cache[$this->_cache_query_hash]; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -559,26 +559,26 @@ discard block |
||
559 | 559 | * @param string $type Optionally specify a results type to cache. Default is |
560 | 560 | * null, or all types. |
561 | 561 | */ |
562 | - private function _cache_set( $value, $type = null ) { |
|
562 | + private function _cache_set($value, $type = null) { |
|
563 | 563 | |
564 | - $cache = wp_cache_get( $this->_cache_key, $this->_cache_group ); |
|
564 | + $cache = wp_cache_get($this->_cache_key, $this->_cache_group); |
|
565 | 565 | |
566 | 566 | $this->_calc_cache_query_hash(); |
567 | 567 | |
568 | 568 | if ( |
569 | - ! isset( $cache[ $this->_cache_query_hash ] ) |
|
570 | - || ! is_array( $cache[ $this->_cache_query_hash ] ) |
|
569 | + ! isset($cache[$this->_cache_query_hash]) |
|
570 | + || ! is_array($cache[$this->_cache_query_hash]) |
|
571 | 571 | ) { |
572 | - $cache[ $this->_cache_query_hash ] = array(); |
|
572 | + $cache[$this->_cache_query_hash] = array(); |
|
573 | 573 | } |
574 | 574 | |
575 | - if ( isset( $type ) ) { |
|
576 | - $cache[ $this->_cache_query_hash ][ $type ] = $value; |
|
575 | + if (isset($type)) { |
|
576 | + $cache[$this->_cache_query_hash][$type] = $value; |
|
577 | 577 | } else { |
578 | - $cache[ $this->_cache_query_hash ] = $value; |
|
578 | + $cache[$this->_cache_query_hash] = $value; |
|
579 | 579 | } |
580 | 580 | |
581 | - wp_cache_set( $this->_cache_key, $cache, $this->_cache_group ); |
|
581 | + wp_cache_set($this->_cache_key, $cache, $this->_cache_group); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | */ |
589 | 589 | private function _calc_cache_query_hash() { |
590 | 590 | |
591 | - if ( ! isset( $this->_cache_query_hash ) ) { |
|
592 | - $this->_cache_query_hash = wordpoints_hash( $this->get_sql() ); |
|
591 | + if ( ! isset($this->_cache_query_hash)) { |
|
592 | + $this->_cache_query_hash = wordpoints_hash($this->get_sql()); |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 |
@@ -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,31 +236,31 @@ 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 | - $post_type = get_post_field( 'post_type', $post_id ); |
|
255 | + $post_type = get_post_field('post_type', $post_id); |
|
256 | 256 | |
257 | - if ( $text && $post_type && post_type_exists( $post_type ) ) { |
|
258 | - $args[] = get_post_type_object( $post_type )->labels->singular_name; |
|
257 | + if ($text && $post_type && post_type_exists($post_type)) { |
|
258 | + $args[] = get_post_type_object($post_type)->labels->singular_name; |
|
259 | 259 | } else { |
260 | - $text = $this->get_option( 'log_text_post_title' . $reverse ); |
|
260 | + $text = $this->get_option('log_text_post_title' . $reverse); |
|
261 | 261 | } |
262 | 262 | |
263 | - return vsprintf( $text, $args ); |
|
263 | + return vsprintf($text, $args); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return string A description for the hook instance. |
274 | 274 | */ |
275 | - protected function generate_description( $instance = array() ) { |
|
275 | + protected function generate_description($instance = array()) { |
|
276 | 276 | |
277 | - if ( ! empty( $instance['post_type'] ) && 'ALL' !== $instance['post_type'] ) { |
|
278 | - $post_type = get_post_type_object( $instance['post_type'] ); |
|
277 | + if ( ! empty($instance['post_type']) && 'ALL' !== $instance['post_type']) { |
|
278 | + $post_type = get_post_type_object($instance['post_type']); |
|
279 | 279 | |
280 | - if ( $post_type ) { |
|
281 | - return sprintf( $this->get_option( 'post_type_description' ), $post_type->labels->singular_name ); |
|
280 | + if ($post_type) { |
|
281 | + return sprintf($this->get_option('post_type_description'), $post_type->labels->singular_name); |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | - return parent::generate_description( $instance ); |
|
285 | + return parent::generate_description($instance); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -294,43 +294,43 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return bool True. |
296 | 296 | */ |
297 | - protected function form( $instance ) { |
|
297 | + protected function form($instance) { |
|
298 | 298 | |
299 | - $instance = array_merge( $this->defaults, $instance ); |
|
299 | + $instance = array_merge($this->defaults, $instance); |
|
300 | 300 | |
301 | 301 | ?> |
302 | 302 | |
303 | 303 | <p> |
304 | - <label for="<?php $this->the_field_id( 'post_type' ); ?>"><?php esc_html_e( 'Select post type:', 'wordpoints' ); ?></label> |
|
304 | + <label for="<?php $this->the_field_id('post_type'); ?>"><?php esc_html_e('Select post type:', 'wordpoints'); ?></label> |
|
305 | 305 | <?php |
306 | 306 | |
307 | 307 | wordpoints_list_post_types( |
308 | 308 | array( |
309 | 309 | 'selected' => $instance['post_type'], |
310 | - 'id' => $this->get_field_id( 'post_type' ), |
|
311 | - 'name' => $this->get_field_name( 'post_type' ), |
|
310 | + 'id' => $this->get_field_id('post_type'), |
|
311 | + 'name' => $this->get_field_name('post_type'), |
|
312 | 312 | 'class' => 'widefat wordpoints-append-to-hook-title', |
313 | - 'filter' => $this->get_option( 'post_type_filter' ), |
|
313 | + 'filter' => $this->get_option('post_type_filter'), |
|
314 | 314 | ) |
315 | - , array( 'public' => true ) |
|
315 | + , array('public' => true) |
|
316 | 316 | ); |
317 | 317 | |
318 | 318 | ?> |
319 | 319 | </p> |
320 | 320 | |
321 | - <?php parent::form( $instance ); ?> |
|
321 | + <?php parent::form($instance); ?> |
|
322 | 322 | |
323 | 323 | <?php |
324 | 324 | |
325 | - $disable_label = $this->get_option( 'disable_auto_reverse_label' ); |
|
325 | + $disable_label = $this->get_option('disable_auto_reverse_label'); |
|
326 | 326 | |
327 | - if ( $disable_label ) { |
|
327 | + if ($disable_label) { |
|
328 | 328 | |
329 | 329 | ?> |
330 | 330 | |
331 | 331 | <p> |
332 | - <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'] ); ?> /> |
|
333 | - <label for="<?php $this->the_field_id( 'auto_reverse' ); ?>"><?php echo esc_html( $disable_label ); ?></label> |
|
332 | + <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']); ?> /> |
|
333 | + <label for="<?php $this->the_field_id('auto_reverse'); ?>"><?php echo esc_html($disable_label); ?></label> |
|
334 | 334 | </p> |
335 | 335 | |
336 | 336 | <?php |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return bool True if the post type supports comments, false otherwise. |
350 | 350 | */ |
351 | - public function post_type_supports_comments( $post_type ) { |
|
351 | + public function post_type_supports_comments($post_type) { |
|
352 | 352 | |
353 | - return post_type_supports( $post_type->name, 'comments' ); |
|
353 | + return post_type_supports($post_type->name, 'comments'); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return bool Whether the user can view this log. |
370 | 370 | */ |
371 | - public function user_can_view( $can_view, $log, $user_id ) { |
|
371 | + public function user_can_view($can_view, $log, $user_id) { |
|
372 | 372 | |
373 | 373 | _deprecated_function( |
374 | 374 | __METHOD__ |
@@ -376,13 +376,13 @@ discard block |
||
376 | 376 | , 'the points logs viewing restrictions API' |
377 | 377 | ); |
378 | 378 | |
379 | - if ( $can_view ) { |
|
379 | + if ($can_view) { |
|
380 | 380 | |
381 | 381 | $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Read_Post( |
382 | 382 | $log |
383 | 383 | ); |
384 | 384 | |
385 | - $can_view = $restriction->user_can( $user_id ); |
|
385 | + $can_view = $restriction->user_can($user_id); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | return $can_view; |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @param int $post_id The ID of the post being deleted. |
405 | 405 | */ |
406 | - public function clean_logs_on_post_deletion( $post_id ) { |
|
406 | + public function clean_logs_on_post_deletion($post_id) { |
|
407 | 407 | |
408 | 408 | $this->clean_logs( |
409 | 409 | 'post_id' |
410 | 410 | , $post_id |
411 | 411 | , 'post_type' |
412 | - , get_post_field( 'post_type', $post_id ) |
|
412 | + , get_post_field('post_type', $post_id) |
|
413 | 413 | ); |
414 | 414 | } |
415 | 415 | |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @param string $new_key The key for the new meta value to add. |
424 | 424 | * @param mixed $new_value The new meta value to add. If falsey, new meta isn't added. |
425 | 425 | */ |
426 | - protected function clean_logs( $key, $value, $new_key, $new_value ) { |
|
426 | + protected function clean_logs($key, $value, $new_key, $new_value) { |
|
427 | 427 | |
428 | 428 | $logs_query = new WordPoints_Points_Logs_Query( |
429 | 429 | array( |
@@ -439,20 +439,20 @@ discard block |
||
439 | 439 | |
440 | 440 | $logs = $logs_query->get(); |
441 | 441 | |
442 | - if ( ! $logs ) { |
|
442 | + if ( ! $logs) { |
|
443 | 443 | return; |
444 | 444 | } |
445 | 445 | |
446 | - foreach ( $logs as $log ) { |
|
446 | + foreach ($logs as $log) { |
|
447 | 447 | |
448 | - wordpoints_delete_points_log_meta( $log->id, $key ); |
|
448 | + wordpoints_delete_points_log_meta($log->id, $key); |
|
449 | 449 | |
450 | - if ( $new_value ) { |
|
451 | - wordpoints_add_points_log_meta( $log->id, $new_key, $new_value ); |
|
450 | + if ($new_value) { |
|
451 | + wordpoints_add_points_log_meta($log->id, $new_key, $new_value); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
455 | - wordpoints_regenerate_points_logs( $logs ); |
|
455 | + wordpoints_regenerate_points_logs($logs); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry. |
18 | 18 | */ |
19 | -function wordpoints_points_hook_reactors_init( $reactors ) { |
|
19 | +function wordpoints_points_hook_reactors_init($reactors) { |
|
20 | 20 | |
21 | - $reactors->register( 'points', 'WordPoints_Points_Hook_Reactor' ); |
|
22 | - $reactors->register( 'points_legacy', 'WordPoints_Points_Hook_Reactor_Legacy' ); |
|
21 | + $reactors->register('points', 'WordPoints_Points_Hook_Reactor'); |
|
22 | + $reactors->register('points_legacy', 'WordPoints_Points_Hook_Reactor_Legacy'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param WordPoints_Class_Registry_Children $reaction_stores The store registry. |
33 | 33 | */ |
34 | -function wordpoints_points_hook_reaction_stores_init( $reaction_stores ) { |
|
34 | +function wordpoints_points_hook_reaction_stores_init($reaction_stores) { |
|
35 | 35 | |
36 | 36 | $reaction_stores->register( |
37 | 37 | 'standard' |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | , 'WordPoints_Hook_Reaction_Store_Options' |
40 | 40 | ); |
41 | 41 | |
42 | - if ( is_wordpoints_network_active() ) { |
|
42 | + if (is_wordpoints_network_active()) { |
|
43 | 43 | $reaction_stores->register( |
44 | 44 | 'network' |
45 | 45 | , 'points' |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
59 | 59 | */ |
60 | -function wordpoints_points_hook_extensions_init( $extensions ) { |
|
60 | +function wordpoints_points_hook_extensions_init($extensions) { |
|
61 | 61 | |
62 | 62 | $extensions->register( |
63 | 63 | 'points_legacy_reversals' |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param string $slug The slug of the post type. |
87 | 87 | */ |
88 | -function wordpoints_points_register_legacy_post_publish_events( $slug ) { |
|
88 | +function wordpoints_points_register_legacy_post_publish_events($slug) { |
|
89 | 89 | |
90 | - if ( 'attachment' === $slug ) { |
|
90 | + if ('attachment' === $slug) { |
|
91 | 91 | return; |
92 | 92 | } |
93 | 93 | |
94 | - $events = wordpoints_hooks()->get_sub_app( 'events' ); |
|
94 | + $events = wordpoints_hooks()->get_sub_app('events'); |
|
95 | 95 | |
96 | 96 | $events->register( |
97 | 97 | "points_legacy_post_publish\\{$slug}" |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | wp_register_style( |
132 | 132 | 'wordpoints-points-logs' |
133 | 133 | , "{$assets_url}/css/points-logs{$suffix}.css" |
134 | - , array( 'dashicons' ) |
|
134 | + , array('dashicons') |
|
135 | 135 | , WORDPOINTS_VERSION |
136 | 136 | ); |
137 | 137 | |
138 | 138 | $styles = wp_styles(); |
139 | - $rtl_styles = array( 'wordpoints-top-users', 'wordpoints-points-logs' ); |
|
139 | + $rtl_styles = array('wordpoints-top-users', 'wordpoints-points-logs'); |
|
140 | 140 | |
141 | - foreach ( $rtl_styles as $rtl_style ) { |
|
141 | + foreach ($rtl_styles as $rtl_style) { |
|
142 | 142 | |
143 | - $styles->add_data( $rtl_style, 'rtl', 'replace' ); |
|
143 | + $styles->add_data($rtl_style, 'rtl', 'replace'); |
|
144 | 144 | |
145 | - if ( $suffix ) { |
|
146 | - $styles->add_data( $rtl_style, 'suffix', $suffix ); |
|
145 | + if ($suffix) { |
|
146 | + $styles->add_data($rtl_style, 'suffix', $suffix); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | return array( |
161 | 161 | 'set_wordpoints_points' => 'manage_options', |
162 | 162 | 'manage_network_wordpoints_points_hooks' => 'manage_network_options', |
163 | - 'manage_wordpoints_points_types' => ( is_wordpoints_network_active() ) ? 'manage_network_options' : 'manage_options', |
|
163 | + 'manage_wordpoints_points_types' => (is_wordpoints_network_active()) ? 'manage_network_options' : 'manage_options', |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
@@ -178,23 +178,23 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return string $points formatted with prefix and suffix. |
180 | 180 | */ |
181 | -function wordpoints_format_points_filter( $formatted, $points, $type ) { |
|
181 | +function wordpoints_format_points_filter($formatted, $points, $type) { |
|
182 | 182 | |
183 | - $points_type = wordpoints_get_points_type( $type ); |
|
183 | + $points_type = wordpoints_get_points_type($type); |
|
184 | 184 | |
185 | - if ( isset( $points_type['prefix'] ) ) { |
|
185 | + if (isset($points_type['prefix'])) { |
|
186 | 186 | |
187 | - if ( $points < 0 ) { |
|
187 | + if ($points < 0) { |
|
188 | 188 | |
189 | - $points = abs( $points ); |
|
189 | + $points = abs($points); |
|
190 | 190 | $points_type['prefix'] = '-' . $points_type['prefix']; |
191 | 191 | } |
192 | 192 | |
193 | - $formatted = esc_html( $points_type['prefix'] . $points ); |
|
193 | + $formatted = esc_html($points_type['prefix'] . $points); |
|
194 | 194 | } |
195 | 195 | |
196 | - if ( isset( $points_type['suffix'] ) ) { |
|
197 | - $formatted = $formatted . esc_html( $points_type['suffix'] ); |
|
196 | + if (isset($points_type['suffix'])) { |
|
197 | + $formatted = $formatted . esc_html($points_type['suffix']); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | return $formatted; |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | * @param array $args The arguments for the dropdown {@see |
212 | 212 | * WordPoints_Dropdown_Builder::$args}. |
213 | 213 | */ |
214 | -function wordpoints_points_types_dropdown( array $args ) { |
|
214 | +function wordpoints_points_types_dropdown(array $args) { |
|
215 | 215 | |
216 | 216 | $points_types = array(); |
217 | 217 | |
218 | - foreach ( wordpoints_get_points_types() as $slug => $settings ) { |
|
218 | + foreach (wordpoints_get_points_types() as $slug => $settings) { |
|
219 | 219 | |
220 | - $points_types[ $slug ] = $settings['name']; |
|
220 | + $points_types[$slug] = $settings['name']; |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( isset( $args['options'] ) && is_array( $args['options'] ) ) { |
|
223 | + if (isset($args['options']) && is_array($args['options'])) { |
|
224 | 224 | $points_types = $args['options'] + $points_types; |
225 | 225 | } |
226 | 226 | |
227 | - $dropdown = new WordPoints_Dropdown_Builder( $points_types, $args ); |
|
227 | + $dropdown = new WordPoints_Dropdown_Builder($points_types, $args); |
|
228 | 228 | |
229 | 229 | $dropdown->display(); |
230 | 230 | } |
@@ -238,27 +238,27 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param int $user_id The ID of the user just deleted. |
240 | 240 | */ |
241 | -function wordpoints_delete_points_logs_for_user( $user_id ) { |
|
241 | +function wordpoints_delete_points_logs_for_user($user_id) { |
|
242 | 242 | |
243 | 243 | global $wpdb; |
244 | 244 | |
245 | - $query_args = array( 'fields' => 'id', 'user_id' => $user_id ); |
|
245 | + $query_args = array('fields' => 'id', 'user_id' => $user_id); |
|
246 | 246 | |
247 | 247 | // If the user is being deleted from all blogs on multisite. |
248 | - if ( is_multisite() && ! get_userdata( $user_id ) ) { |
|
248 | + if (is_multisite() && ! get_userdata($user_id)) { |
|
249 | 249 | $query_args['blog_id'] = 0; |
250 | 250 | } |
251 | 251 | |
252 | 252 | // Delete log meta. |
253 | - $query = new WordPoints_Points_Logs_Query( $query_args ); |
|
253 | + $query = new WordPoints_Points_Logs_Query($query_args); |
|
254 | 254 | |
255 | - foreach ( $query->get( 'col' ) as $log_id ) { |
|
256 | - wordpoints_points_log_delete_all_metadata( $log_id ); |
|
255 | + foreach ($query->get('col') as $log_id) { |
|
256 | + wordpoints_points_log_delete_all_metadata($log_id); |
|
257 | 257 | } |
258 | 258 | |
259 | - $where = array( 'user_id' => $user_id ); |
|
259 | + $where = array('user_id' => $user_id); |
|
260 | 260 | |
261 | - if ( ! isset( $query_args['blog_id'] ) ) { |
|
261 | + if ( ! isset($query_args['blog_id'])) { |
|
262 | 262 | $where['blog_id'] = $wpdb->blogid; |
263 | 263 | } |
264 | 264 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | ,'%d' |
270 | 270 | ); |
271 | 271 | |
272 | - wordpoints_flush_points_logs_caches( array( 'user_id' => $user_id ) ); |
|
272 | + wordpoints_flush_points_logs_caches(array('user_id' => $user_id)); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @param int $blog_id The ID of the blog being deleted. |
283 | 283 | */ |
284 | -function wordpoints_delete_points_logs_for_blog( $blog_id ) { |
|
284 | +function wordpoints_delete_points_logs_for_blog($blog_id) { |
|
285 | 285 | |
286 | 286 | global $wpdb; |
287 | 287 | |
288 | 288 | // Delete log meta. |
289 | - $query = new WordPoints_Points_Logs_Query( array( 'fields' => 'id' ) ); |
|
289 | + $query = new WordPoints_Points_Logs_Query(array('fields' => 'id')); |
|
290 | 290 | |
291 | - foreach ( $query->get( 'col' ) as $log_id ) { |
|
292 | - wordpoints_points_log_delete_all_metadata( $log_id ); |
|
291 | + foreach ($query->get('col') as $log_id) { |
|
292 | + wordpoints_points_log_delete_all_metadata($log_id); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // Now delete the logs. |
296 | 296 | $wpdb->delete( |
297 | 297 | $wpdb->wordpoints_points_logs |
298 | - ,array( 'blog_id' => $blog_id ) |
|
298 | + ,array('blog_id' => $blog_id) |
|
299 | 299 | ,'%d' |
300 | 300 | ); |
301 | 301 | |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @param string $points_type The type of points the settings are being shown for. |
313 | 313 | */ |
314 | -function wordpoints_points_settings_custom_meta_key_message( $points_type ) { |
|
314 | +function wordpoints_points_settings_custom_meta_key_message($points_type) { |
|
315 | 315 | |
316 | - $custom_key = wordpoints_get_points_type_setting( $points_type, 'meta_key' ); |
|
316 | + $custom_key = wordpoints_get_points_type_setting($points_type, 'meta_key'); |
|
317 | 317 | |
318 | - if ( ! empty( $custom_key ) ) { |
|
318 | + if ( ! empty($custom_key)) { |
|
319 | 319 | // translators: 1. Meta key. |
320 | - echo '<p>' . esc_html( sprintf( __( 'This points type uses a custom meta key: %s', 'wordpoints' ), $custom_key ) ) . '</p>'; |
|
320 | + echo '<p>' . esc_html(sprintf(__('This points type uses a custom meta key: %s', 'wordpoints'), $custom_key)) . '</p>'; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -330,20 +330,20 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @param string $points_type The type of points whose logs are being displayed. |
332 | 332 | */ |
333 | -function wordpoints_points_logs_custom_meta_key_message( $points_type ) { |
|
333 | +function wordpoints_points_logs_custom_meta_key_message($points_type) { |
|
334 | 334 | |
335 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
335 | + if ( ! current_user_can('manage_options')) { |
|
336 | 336 | return; |
337 | 337 | } |
338 | 338 | |
339 | - $custom_key = wordpoints_get_points_type_setting( $points_type, 'meta_key' ); |
|
339 | + $custom_key = wordpoints_get_points_type_setting($points_type, 'meta_key'); |
|
340 | 340 | |
341 | - if ( ! empty( $custom_key ) ) { |
|
341 | + if ( ! empty($custom_key)) { |
|
342 | 342 | wordpoints_show_admin_message( |
343 | 343 | esc_html( |
344 | 344 | sprintf( |
345 | 345 | // translators: Meta key. |
346 | - __( 'This points type uses a custom meta key (“%s”). If this key is also used by another plugin, changes made by it will not be logged. Only transactions performed by WordPoints are included in the logs.', 'wordpoints' ) |
|
346 | + __('This points type uses a custom meta key (“%s”). If this key is also used by another plugin, changes made by it will not be logged. Only transactions performed by WordPoints are included in the logs.', 'wordpoints') |
|
347 | 347 | , $custom_key |
348 | 348 | ) |
349 | 349 | ) |
@@ -362,18 +362,18 @@ discard block |
||
362 | 362 | */ |
363 | 363 | function wordpoints_points_add_global_cache_groups() { |
364 | 364 | |
365 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
365 | + if (function_exists('wp_cache_add_global_groups')) { |
|
366 | 366 | |
367 | 367 | $groups = array( |
368 | 368 | 'wordpoints_network_points_logs_query', |
369 | 369 | 'wordpoints_points_log_meta', |
370 | 370 | ); |
371 | 371 | |
372 | - if ( is_wordpoints_network_active() ) { |
|
372 | + if (is_wordpoints_network_active()) { |
|
373 | 373 | $groups[] = 'wordpoints_points_top_users'; |
374 | 374 | } |
375 | 375 | |
376 | - wp_cache_add_global_groups( $groups ); |
|
376 | + wp_cache_add_global_groups($groups); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 |
@@ -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 | |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return bool Whether the query was registered. |
214 | 214 | */ |
215 | -function wordpoints_register_points_logs_query( $slug, array $args, array $data = array() ) { |
|
215 | +function wordpoints_register_points_logs_query($slug, array $args, array $data = array()) { |
|
216 | 216 | |
217 | - return WordPoints_Points_Log_Queries::register_query( $slug, $args, $data ); |
|
217 | + return WordPoints_Points_Log_Queries::register_query($slug, $args, $data); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return bool Whether $slug is the slug of a registered query. |
230 | 230 | */ |
231 | -function wordpoints_is_points_logs_query( $slug ) { |
|
231 | +function wordpoints_is_points_logs_query($slug) { |
|
232 | 232 | |
233 | - return WordPoints_Points_Log_Queries::is_query( $slug ); |
|
233 | + return WordPoints_Points_Log_Queries::is_query($slug); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -245,23 +245,23 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return array|false The args for the query, or false on failure. |
247 | 247 | */ |
248 | -function wordpoints_get_points_logs_query_args( $points_type, $query_slug = 'default' ) { |
|
248 | +function wordpoints_get_points_logs_query_args($points_type, $query_slug = 'default') { |
|
249 | 249 | |
250 | - $args = WordPoints_Points_Log_Queries::get_query_args( $query_slug ); |
|
250 | + $args = WordPoints_Points_Log_Queries::get_query_args($query_slug); |
|
251 | 251 | |
252 | - if ( is_null( $args ) || ! wordpoints_is_points_type( $points_type ) ) { |
|
252 | + if (is_null($args) || ! wordpoints_is_points_type($points_type)) { |
|
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | |
256 | 256 | $defaults = array( |
257 | - 'user_id__not_in' => wordpoints_get_excluded_users( 'points_logs' ), |
|
257 | + 'user_id__not_in' => wordpoints_get_excluded_users('points_logs'), |
|
258 | 258 | 'points_type' => $points_type, |
259 | 259 | ); |
260 | 260 | |
261 | - $args = array_merge( $defaults, $args ); |
|
261 | + $args = array_merge($defaults, $args); |
|
262 | 262 | |
263 | 263 | // The current user needs to be set dynamically, since it can change at times. |
264 | - if ( 'current_user' === $query_slug ) { |
|
264 | + if ('current_user' === $query_slug) { |
|
265 | 265 | $args['user_id'] = get_current_user_id(); |
266 | 266 | } |
267 | 267 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string $query_slug The slug for the query. |
279 | 279 | * @param string $points_type The points type the query is being made for. |
280 | 280 | */ |
281 | - return apply_filters( 'wordpoints_points_logs_query_args', $args, $query_slug, $points_type ); |
|
281 | + return apply_filters('wordpoints_points_logs_query_args', $args, $query_slug, $points_type); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return WordPoints_Points_Logs_Query|false Logs query instance, or false. |
300 | 300 | */ |
301 | -function wordpoints_get_points_logs_query( $points_type, $query_slug = 'default' ) { |
|
301 | +function wordpoints_get_points_logs_query($points_type, $query_slug = 'default') { |
|
302 | 302 | |
303 | - $args = wordpoints_get_points_logs_query_args( $points_type, $query_slug ); |
|
303 | + $args = wordpoints_get_points_logs_query_args($points_type, $query_slug); |
|
304 | 304 | |
305 | - if ( ! $args ) { |
|
305 | + if ( ! $args) { |
|
306 | 306 | return false; |
307 | 307 | } |
308 | 308 | |
309 | - $query = new WordPoints_Points_Logs_Query( $args ); |
|
309 | + $query = new WordPoints_Points_Logs_Query($args); |
|
310 | 310 | |
311 | - $query_data = WordPoints_Points_Log_Queries::get_query_data( $query_slug ); |
|
311 | + $query_data = WordPoints_Points_Log_Queries::get_query_data($query_slug); |
|
312 | 312 | |
313 | - if ( $query_data['cache_queries'] ) { |
|
313 | + if ($query_data['cache_queries']) { |
|
314 | 314 | |
315 | 315 | $query->prime_cache( |
316 | 316 | $query_data['cache_key'] |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return void |
355 | 355 | */ |
356 | -function wordpoints_show_points_logs( $logs_query, array $args = array() ) { |
|
356 | +function wordpoints_show_points_logs($logs_query, array $args = array()) { |
|
357 | 357 | |
358 | - if ( ! $logs_query instanceof WordPoints_Points_Logs_Query ) { |
|
358 | + if ( ! $logs_query instanceof WordPoints_Points_Logs_Query) { |
|
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | 'show_users' => true, |
368 | 368 | ); |
369 | 369 | |
370 | - $args = array_merge( $defaults, $args ); |
|
370 | + $args = array_merge($defaults, $args); |
|
371 | 371 | |
372 | - if ( ! $args['datatable'] ) { |
|
372 | + if ( ! $args['datatable']) { |
|
373 | 373 | |
374 | 374 | _deprecated_argument( |
375 | 375 | __FUNCTION__ |
@@ -380,12 +380,12 @@ discard block |
||
380 | 380 | $args['paginate'] = false; |
381 | 381 | } |
382 | 382 | |
383 | - $view = wordpoints_component( 'points' ) |
|
384 | - ->get_sub_app( 'logs' ) |
|
385 | - ->get_sub_app( 'views' ) |
|
386 | - ->get( $args['view'], array( $logs_query, $args ) ); |
|
383 | + $view = wordpoints_component('points') |
|
384 | + ->get_sub_app('logs') |
|
385 | + ->get_sub_app('views') |
|
386 | + ->get($args['view'], array($logs_query, $args)); |
|
387 | 387 | |
388 | - if ( ! $view instanceof WordPoints_Points_Logs_View ) { |
|
388 | + if ( ! $view instanceof WordPoints_Points_Logs_View) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | * @param string $query_slug The query to use to display the logs. |
406 | 406 | * @param array $args Arguments to pass to wordpoints_show_points_logs(). |
407 | 407 | */ |
408 | -function wordpoints_show_points_logs_query( $points_type, $query_slug = 'default', array $args = array() ) { |
|
408 | +function wordpoints_show_points_logs_query($points_type, $query_slug = 'default', array $args = array()) { |
|
409 | 409 | |
410 | - wordpoints_show_points_logs( wordpoints_get_points_logs_query( $points_type, $query_slug ), $args ); |
|
410 | + wordpoints_show_points_logs(wordpoints_get_points_logs_query($points_type, $query_slug), $args); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | */ |
427 | 427 | wordpoints_register_points_logs_query( |
428 | 428 | 'current_user' |
429 | - , array( 'user_id' => get_current_user_id() ) |
|
429 | + , array('user_id' => get_current_user_id()) |
|
430 | 430 | , array( |
431 | 431 | 'cache_key' => 'current_user:%points_type%:%user_id%', |
432 | 432 | 'cache_queries' => true, |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | wordpoints_register_points_logs_query( |
442 | 442 | 'network' |
443 | - , array( 'blog_id' => false ) |
|
443 | + , array('blog_id' => false) |
|
444 | 444 | , array( |
445 | 445 | 'network_wide' => true, |
446 | 446 | 'cache_queries' => true, |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @WordPress\action wordpoints_points_log-profile_edit |
457 | 457 | */ |
458 | -function wordpoints_points_logs_profile_edit( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
458 | +function wordpoints_points_logs_profile_edit($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
459 | 459 | |
460 | - $user_name = sanitize_user_field( 'display_name', get_userdata( $meta['user_id'] )->display_name, $meta['user_id'], 'display' ); |
|
460 | + $user_name = sanitize_user_field('display_name', get_userdata($meta['user_id'])->display_name, $meta['user_id'], 'display'); |
|
461 | 461 | |
462 | 462 | // translators: 1. User name; 2. Reason given. |
463 | - return sprintf( _x( 'Points adjusted by %1$s. Reason: %2$s', 'points log description', 'wordpoints' ), $user_name, esc_html( $meta['reason'] ) ); |
|
463 | + return sprintf(_x('Points adjusted by %1$s. Reason: %2$s', 'points log description', 'wordpoints'), $user_name, esc_html($meta['reason'])); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -470,20 +470,20 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @WordPress\action wordpoints_points_log-comment_disapprove |
472 | 472 | */ |
473 | -function wordpoints_points_logs_comment_disapprove( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
473 | +function wordpoints_points_logs_comment_disapprove($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
474 | 474 | |
475 | - switch ( $meta['status'] ) { |
|
475 | + switch ($meta['status']) { |
|
476 | 476 | |
477 | 477 | case 'spam': |
478 | - $text = _x( 'Comment marked as spam.', 'points log description', 'wordpoints' ); |
|
478 | + $text = _x('Comment marked as spam.', 'points log description', 'wordpoints'); |
|
479 | 479 | break; |
480 | 480 | |
481 | 481 | case 'trash': |
482 | - $text = _x( 'Comment moved to trash.', 'points log description', 'wordpoints' ); |
|
482 | + $text = _x('Comment moved to trash.', 'points log description', 'wordpoints'); |
|
483 | 483 | break; |
484 | 484 | |
485 | 485 | default: |
486 | - $text = _x( 'Comment unapproved.', 'points log description', 'wordpoints' ); |
|
486 | + $text = _x('Comment unapproved.', 'points log description', 'wordpoints'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | return $text; |
@@ -496,23 +496,23 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @WordPress\action wordpoints_points_log-post_delete |
498 | 498 | */ |
499 | -function wordpoints_points_logs_post_delete( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
499 | +function wordpoints_points_logs_post_delete($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
500 | 500 | |
501 | - if ( isset( $meta['post_type'] ) ) { |
|
501 | + if (isset($meta['post_type'])) { |
|
502 | 502 | |
503 | - $post_type = get_post_type_object( $meta['post_type'] ); |
|
503 | + $post_type = get_post_type_object($meta['post_type']); |
|
504 | 504 | |
505 | - if ( ! is_null( $post_type ) ) { |
|
505 | + if ( ! is_null($post_type)) { |
|
506 | 506 | |
507 | 507 | return sprintf( |
508 | 508 | // translators: Singular post type name. |
509 | - _x( '%s deleted.', 'points log description', 'wordpoints' ) |
|
509 | + _x('%s deleted.', 'points log description', 'wordpoints') |
|
510 | 510 | , $post_type->labels->singular_name |
511 | 511 | ); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | - return _x( 'Post deleted.', 'points log description', 'wordpoints' ); |
|
515 | + return _x('Post deleted.', 'points log description', 'wordpoints'); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * @param int $points The number of points. Not used. |
529 | 529 | * @param string $points_type The type of points being awarded. |
530 | 530 | */ |
531 | -function wordpoints_clean_points_logs_cache( $user_id, $points, $points_type ) { |
|
531 | +function wordpoints_clean_points_logs_cache($user_id, $points, $points_type) { |
|
532 | 532 | |
533 | 533 | wordpoints_flush_points_logs_caches( |
534 | - array( 'user_id' => $user_id, 'points_type' => $points_type ) |
|
534 | + array('user_id' => $user_id, 'points_type' => $points_type) |
|
535 | 535 | ); |
536 | 536 | } |
537 | 537 | |
@@ -553,27 +553,27 @@ discard block |
||
553 | 553 | * @type int $user_id Only clear the cache for this user. |
554 | 554 | * } |
555 | 555 | */ |
556 | -function wordpoints_flush_points_logs_caches( $args = array() ) { |
|
556 | +function wordpoints_flush_points_logs_caches($args = array()) { |
|
557 | 557 | |
558 | - $args = array_merge( array( 'points_type' => false, 'user_id' => 0 ), $args ); |
|
558 | + $args = array_merge(array('points_type' => false, 'user_id' => 0), $args); |
|
559 | 559 | |
560 | 560 | $find = array( |
561 | 561 | '%points_type%', |
562 | 562 | '%user_id%', |
563 | 563 | ); |
564 | 564 | |
565 | - if ( empty( $args['points_type'] ) ) { |
|
566 | - $points_types = array_keys( wordpoints_get_points_types() ); |
|
565 | + if (empty($args['points_type'])) { |
|
566 | + $points_types = array_keys(wordpoints_get_points_types()); |
|
567 | 567 | } else { |
568 | 568 | $points_types = (array) $args['points_type']; |
569 | 569 | } |
570 | 570 | |
571 | - foreach ( $points_types as $points_type ) { |
|
572 | - foreach ( WordPoints_Points_Log_Queries::get_queries() as $query ) { |
|
571 | + foreach ($points_types as $points_type) { |
|
572 | + foreach (WordPoints_Points_Log_Queries::get_queries() as $query) { |
|
573 | 573 | |
574 | - if ( ! empty( $query['cache_key'] ) ) { |
|
574 | + if ( ! empty($query['cache_key'])) { |
|
575 | 575 | |
576 | - if ( $query['network_wide'] ) { |
|
576 | + if ($query['network_wide']) { |
|
577 | 577 | $group = 'wordpoints_network_points_logs_query'; |
578 | 578 | } else { |
579 | 579 | $group = 'wordpoints_points_logs_query'; |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | ); |
586 | 586 | |
587 | 587 | wp_cache_delete( |
588 | - str_replace( $find, $replace, $query['cache_key'] ) |
|
588 | + str_replace($find, $replace, $query['cache_key']) |
|
589 | 589 | , $group |
590 | 590 | ); |
591 | 591 | } |
@@ -604,26 +604,26 @@ discard block |
||
604 | 604 | * |
605 | 605 | * @return bool Whether the user can view this points log entry. |
606 | 606 | */ |
607 | -function wordpoints_user_can_view_points_log( $user_id, $log ) { |
|
607 | +function wordpoints_user_can_view_points_log($user_id, $log) { |
|
608 | 608 | |
609 | 609 | // We do this just once here for optimization, as otherwise it would run 3 times. |
610 | - if ( $log->blog_id && get_current_blog_id() !== $log->blog_id ) { |
|
611 | - $switched = switch_to_blog( $log->blog_id ); |
|
610 | + if ($log->blog_id && get_current_blog_id() !== $log->blog_id) { |
|
611 | + $switched = switch_to_blog($log->blog_id); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** @var WordPoints_Points_Logs_Viewing_Restrictions $viewing_restrictions */ |
615 | - $viewing_restrictions = wordpoints_component( 'points' ) |
|
616 | - ->get_sub_app( 'logs' ) |
|
617 | - ->get_sub_app( 'viewing_restrictions' ); |
|
615 | + $viewing_restrictions = wordpoints_component('points') |
|
616 | + ->get_sub_app('logs') |
|
617 | + ->get_sub_app('viewing_restrictions'); |
|
618 | 618 | |
619 | - $can_view = $viewing_restrictions->get_restriction( $log ) |
|
620 | - ->user_can( $user_id ); |
|
619 | + $can_view = $viewing_restrictions->get_restriction($log) |
|
620 | + ->user_can($user_id); |
|
621 | 621 | |
622 | - if ( $can_view ) { |
|
623 | - $can_view = $viewing_restrictions->apply_legacy_filters( $user_id, $log ); |
|
622 | + if ($can_view) { |
|
623 | + $can_view = $viewing_restrictions->apply_legacy_filters($user_id, $log); |
|
624 | 624 | } |
625 | 625 | |
626 | - if ( isset( $switched ) ) { |
|
626 | + if (isset($switched)) { |
|
627 | 627 | restore_current_blog(); |
628 | 628 | } |
629 | 629 | |
@@ -644,17 +644,17 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @return bool Whether the user can view the points log. |
646 | 646 | */ |
647 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $user_id, $log ) { |
|
647 | +function wordpoints_hooks_user_can_view_points_log($can_view, $user_id, $log) { |
|
648 | 648 | |
649 | - _deprecated_function( __FUNCTION__, '2.2.0' ); |
|
649 | + _deprecated_function(__FUNCTION__, '2.2.0'); |
|
650 | 650 | |
651 | - if ( ! $can_view ) { |
|
651 | + if ( ! $can_view) { |
|
652 | 652 | return $can_view; |
653 | 653 | } |
654 | 654 | |
655 | - $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Hooks( $log ); |
|
655 | + $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Hooks($log); |
|
656 | 656 | |
657 | - return $restriction->user_can( $user_id ); |
|
657 | + return $restriction->user_can($user_id); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | // EOF |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | function wordpoints_register_points_widgets() { |
18 | 18 | |
19 | 19 | // My points widget. |
20 | - register_widget( 'WordPoints_My_Points_Widget' ); |
|
20 | + register_widget('WordPoints_My_Points_Widget'); |
|
21 | 21 | |
22 | 22 | // Top users widget. |
23 | - register_widget( 'WordPoints_Top_Users_Points_Widget' ); |
|
23 | + register_widget('WordPoints_Top_Users_Points_Widget'); |
|
24 | 24 | |
25 | 25 | // Points logs widget. |
26 | - register_widget( 'WordPoints_Points_Logs_Widget' ); |
|
26 | + register_widget('WordPoints_Points_Logs_Widget'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @since 1.9.0 |
40 | 40 | */ |
41 | - protected function verify_settings( $instance ) { |
|
41 | + protected function verify_settings($instance) { |
|
42 | 42 | |
43 | - if ( isset( $this->defaults['points_type'] ) ) { |
|
43 | + if (isset($this->defaults['points_type'])) { |
|
44 | 44 | |
45 | 45 | if ( |
46 | - empty( $instance['points_type'] ) |
|
47 | - || ! wordpoints_is_points_type( $instance['points_type'] ) |
|
46 | + empty($instance['points_type']) |
|
47 | + || ! wordpoints_is_points_type($instance['points_type']) |
|
48 | 48 | ) { |
49 | 49 | return new WP_Error( |
50 | 50 | 'wordpoints_widget_invalid_points_type' |
51 | - , esc_html__( 'Please select a valid points type.', 'wordpoints' ) |
|
51 | + , esc_html__('Please select a valid points type.', 'wordpoints') |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - return parent::verify_settings( $instance ); |
|
56 | + return parent::verify_settings($instance); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param string $maybe_points_type The variable to insure is a points type. |
69 | 69 | */ |
70 | - protected function make_a_points_type( &$maybe_points_type ) { |
|
70 | + protected function make_a_points_type(&$maybe_points_type) { |
|
71 | 71 | |
72 | - if ( ! wordpoints_is_points_type( $maybe_points_type ) ) { |
|
72 | + if ( ! wordpoints_is_points_type($maybe_points_type)) { |
|
73 | 73 | |
74 | 74 | $maybe_points_type = wordpoints_get_default_points_type(); |
75 | 75 | |
76 | - if ( ! $maybe_points_type ) { |
|
76 | + if ( ! $maybe_points_type) { |
|
77 | 77 | |
78 | 78 | $points_types = wordpoints_get_points_types(); |
79 | 79 | |
80 | - $maybe_points_type = key( $points_types ); |
|
80 | + $maybe_points_type = key($points_types); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * @since 2.0.0 |
87 | 87 | */ |
88 | - public function update( $new_instance, $old_instance ) { |
|
88 | + public function update($new_instance, $old_instance) { |
|
89 | 89 | |
90 | - parent::update( $new_instance, $old_instance ); |
|
90 | + parent::update($new_instance, $old_instance); |
|
91 | 91 | |
92 | - $this->make_a_points_type( $this->instance['points_type'] ); |
|
92 | + $this->make_a_points_type($this->instance['points_type']); |
|
93 | 93 | |
94 | 94 | return $this->instance; |
95 | 95 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * @since 2.0.0 |
99 | 99 | */ |
100 | - public function form( $instance ) { |
|
100 | + public function form($instance) { |
|
101 | 101 | |
102 | - parent::form( $instance ); |
|
102 | + parent::form($instance); |
|
103 | 103 | |
104 | 104 | $this->form_points_type_field(); |
105 | 105 | |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | |
116 | 116 | $dropdown_args = array( |
117 | 117 | 'selected' => $this->instance['points_type'], |
118 | - 'id' => $this->get_field_id( 'points_type' ), |
|
119 | - 'name' => $this->get_field_name( 'points_type' ), |
|
118 | + 'id' => $this->get_field_id('points_type'), |
|
119 | + 'name' => $this->get_field_name('points_type'), |
|
120 | 120 | 'class' => 'widefat', |
121 | 121 | ); |
122 | 122 | |
123 | 123 | ?> |
124 | 124 | |
125 | 125 | <p> |
126 | - <label for="<?php echo esc_attr( $dropdown_args['id'] ); ?>"><?php echo esc_html_x( 'Points type', 'form label', 'wordpoints' ); ?></label> |
|
127 | - <?php wordpoints_points_types_dropdown( $dropdown_args ); ?> |
|
126 | + <label for="<?php echo esc_attr($dropdown_args['id']); ?>"><?php echo esc_html_x('Points type', 'form label', 'wordpoints'); ?></label> |
|
127 | + <?php wordpoints_points_types_dropdown($dropdown_args); ?> |
|
128 | 128 | </p> |
129 | 129 | |
130 | 130 | <?php |
@@ -152,46 +152,46 @@ discard block |
||
152 | 152 | |
153 | 153 | parent::__construct( |
154 | 154 | 'WordPoints_Points_Widget' |
155 | - , __( 'WordPoints', 'wordpoints' ) |
|
155 | + , __('WordPoints', 'wordpoints') |
|
156 | 156 | , array( |
157 | - 'description' => __( 'Display the points of the current logged in user.', 'wordpoints' ), |
|
157 | + 'description' => __('Display the points of the current logged in user.', 'wordpoints'), |
|
158 | 158 | 'wordpoints_hook_slug' => 'points', |
159 | 159 | ) |
160 | 160 | ); |
161 | 161 | |
162 | 162 | $this->defaults = array( |
163 | - 'title' => _x( 'My Points', 'widget title', 'wordpoints' ), |
|
163 | + 'title' => _x('My Points', 'widget title', 'wordpoints'), |
|
164 | 164 | 'points_type' => wordpoints_get_default_points_type(), |
165 | 165 | // translators: Number of points. |
166 | - 'text' => sprintf( __( 'Points: %s', 'wordpoints' ), '%points%' ), |
|
167 | - 'alt_text' => __( 'You must be logged in to view your points.', 'wordpoints' ), |
|
166 | + 'text' => sprintf(__('Points: %s', 'wordpoints'), '%points%'), |
|
167 | + 'alt_text' => __('You must be logged in to view your points.', 'wordpoints'), |
|
168 | 168 | 'number_logs' => 5, |
169 | 169 | ); |
170 | 170 | |
171 | - add_filter( 'wordpoints_points_widget_text', 'esc_html', 20 ); |
|
171 | + add_filter('wordpoints_points_widget_text', 'esc_html', 20); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
175 | 175 | * @since 1.9.0 |
176 | 176 | */ |
177 | - protected function verify_settings( $instance ) { |
|
177 | + protected function verify_settings($instance) { |
|
178 | 178 | |
179 | - if ( ! is_user_logged_in() && empty( $instance['alt_text'] ) ) { |
|
179 | + if ( ! is_user_logged_in() && empty($instance['alt_text'])) { |
|
180 | 180 | return new WP_Error; |
181 | 181 | } |
182 | 182 | |
183 | 183 | if ( |
184 | - ! isset( $instance['number_logs'] ) |
|
185 | - || ! wordpoints_posint( $instance['number_logs'] ) |
|
184 | + ! isset($instance['number_logs']) |
|
185 | + || ! wordpoints_posint($instance['number_logs']) |
|
186 | 186 | ) { |
187 | 187 | $instance['number_logs'] = 0; |
188 | 188 | } |
189 | 189 | |
190 | 190 | // In case the points type isn't set, we do this first. |
191 | - $instance = parent::verify_settings( $instance ); |
|
191 | + $instance = parent::verify_settings($instance); |
|
192 | 192 | |
193 | - if ( ! is_wp_error( $instance ) && is_user_logged_in() && empty( $instance['text'] ) ) { |
|
194 | - $instance['text'] = wordpoints_get_points_type_setting( $instance['points_type'], 'name' ) . ': %points%'; |
|
193 | + if ( ! is_wp_error($instance) && is_user_logged_in() && empty($instance['text'])) { |
|
194 | + $instance['text'] = wordpoints_get_points_type_setting($instance['points_type'], 'name') . ': %points%'; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $instance; |
@@ -200,14 +200,14 @@ discard block |
||
200 | 200 | /** |
201 | 201 | * @since 1.9.0 |
202 | 202 | */ |
203 | - protected function widget_body( $instance ) { |
|
203 | + protected function widget_body($instance) { |
|
204 | 204 | |
205 | - if ( is_user_logged_in() ) { |
|
205 | + if (is_user_logged_in()) { |
|
206 | 206 | |
207 | 207 | $text = str_replace( |
208 | 208 | '%points%', |
209 | 209 | wordpoints_format_points( |
210 | - wordpoints_get_points( get_current_user_id(), $instance['points_type'] ), |
|
210 | + wordpoints_get_points(get_current_user_id(), $instance['points_type']), |
|
211 | 211 | $instance['points_type'], |
212 | 212 | 'my_points_widget' |
213 | 213 | ), |
@@ -233,20 +233,20 @@ discard block |
||
233 | 233 | * @param string $text The text for the widget set by the user. |
234 | 234 | * @param array $instance The settings for this instance of the widget. |
235 | 235 | */ |
236 | - $text = apply_filters( 'wordpoints_points_widget_text', $text, $instance ); |
|
236 | + $text = apply_filters('wordpoints_points_widget_text', $text, $instance); |
|
237 | 237 | |
238 | 238 | echo '<div class="wordpoints-points-widget-text">', $text, '</div><br />'; // XSS OK, WPCS |
239 | 239 | |
240 | - if ( is_user_logged_in() && 0 !== $instance['number_logs'] ) { |
|
240 | + if (is_user_logged_in() && 0 !== $instance['number_logs']) { |
|
241 | 241 | |
242 | - $query_args = wordpoints_get_points_logs_query_args( $instance['points_type'], 'current_user' ); |
|
242 | + $query_args = wordpoints_get_points_logs_query_args($instance['points_type'], 'current_user'); |
|
243 | 243 | |
244 | 244 | $query_args['limit'] = $instance['number_logs']; |
245 | 245 | |
246 | - $logs_query = new WordPoints_Points_Logs_Query( $query_args ); |
|
247 | - $logs_query->prime_cache( 'current_user:%points_type%:%user_id%' ); |
|
246 | + $logs_query = new WordPoints_Points_Logs_Query($query_args); |
|
247 | + $logs_query->prime_cache('current_user:%points_type%:%user_id%'); |
|
248 | 248 | |
249 | - wordpoints_show_points_logs( $logs_query, array( 'paginate' => false, 'searchable' => false, 'show_users' => false ) ); |
|
249 | + wordpoints_show_points_logs($logs_query, array('paginate' => false, 'searchable' => false, 'show_users' => false)); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return array The updated settings for the widget instance. |
262 | 262 | */ |
263 | - public function update( $new_instance, $old_instance ) { |
|
263 | + public function update($new_instance, $old_instance) { |
|
264 | 264 | |
265 | - parent::update( $new_instance, $old_instance ); |
|
265 | + parent::update($new_instance, $old_instance); |
|
266 | 266 | |
267 | - $this->instance['text'] = trim( $this->instance['text'] ); |
|
268 | - $this->instance['alt_text'] = trim( $this->instance['alt_text'] ); |
|
267 | + $this->instance['text'] = trim($this->instance['text']); |
|
268 | + $this->instance['alt_text'] = trim($this->instance['alt_text']); |
|
269 | 269 | |
270 | - if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) { |
|
270 | + if ( ! wordpoints_posint($this->instance['number_logs'])) { |
|
271 | 271 | $this->instance['number_logs'] = 0; |
272 | 272 | } |
273 | 273 | |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | /** |
278 | 278 | * @since 1.0.0 |
279 | 279 | */ |
280 | - public function form( $instance ) { |
|
280 | + public function form($instance) { |
|
281 | 281 | |
282 | - parent::form( $instance ); |
|
282 | + parent::form($instance); |
|
283 | 283 | |
284 | 284 | ?> |
285 | 285 | |
286 | 286 | <p> |
287 | - <label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php esc_html_e( 'Widget text', 'wordpoints' ); ?></label> |
|
288 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" value="<?php echo esc_attr( $this->instance['text'] ); ?>" /> |
|
287 | + <label for="<?php echo esc_attr($this->get_field_id('text')); ?>"><?php esc_html_e('Widget text', 'wordpoints'); ?></label> |
|
288 | + <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('text')); ?>" name="<?php echo esc_attr($this->get_field_name('text')); ?>" value="<?php echo esc_attr($this->instance['text']); ?>" /> |
|
289 | 289 | <?php // translators: Placeholder name. ?> |
290 | - <small><i><?php echo esc_html( sprintf( __( '%s will be replaced with the points of the logged in user', 'wordpoints' ), '%points%' ) ); ?></i></small> |
|
290 | + <small><i><?php echo esc_html(sprintf(__('%s will be replaced with the points of the logged in user', 'wordpoints'), '%points%')); ?></i></small> |
|
291 | 291 | <?php |
292 | 292 | |
293 | 293 | /** |
@@ -297,19 +297,19 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @param array $instance The settings of the current widget instance. |
299 | 299 | */ |
300 | - do_action( 'wordpoints_my_points_widget_below_text_field', $this->instance ); |
|
300 | + do_action('wordpoints_my_points_widget_below_text_field', $this->instance); |
|
301 | 301 | |
302 | 302 | ?> |
303 | 303 | </p> |
304 | 304 | <p> |
305 | - <label for="<?php echo esc_attr( $this->get_field_id( 'alt_text' ) ); ?>"><?php esc_html_e( 'Text if the user is not logged in', 'wordpoints' ); ?></label> |
|
306 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'alt_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'alt_text' ) ); ?>" value="<?php echo esc_attr( $this->instance['alt_text'] ); ?>" /> |
|
307 | - <small><i><?php esc_html_e( 'Leave this field blank to hide the widget if the user is not logged in', 'wordpoints' ); ?></i></small> |
|
305 | + <label for="<?php echo esc_attr($this->get_field_id('alt_text')); ?>"><?php esc_html_e('Text if the user is not logged in', 'wordpoints'); ?></label> |
|
306 | + <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('alt_text')); ?>" name="<?php echo esc_attr($this->get_field_name('alt_text')); ?>" value="<?php echo esc_attr($this->instance['alt_text']); ?>" /> |
|
307 | + <small><i><?php esc_html_e('Leave this field blank to hide the widget if the user is not logged in', 'wordpoints'); ?></i></small> |
|
308 | 308 | </p> |
309 | 309 | <p> |
310 | - <label for="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>"><?php esc_html_e( 'Number of latest log entries for this user to display', 'wordpoints' ); ?></label> |
|
311 | - <input type="number" min="0" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number_logs' ) ); ?>" value="<?php echo esc_attr( $this->instance['number_logs'] ); ?>" /> |
|
312 | - <small><i><?php esc_html_e( 'Set this to 0 to keep from showing any logs', 'wordpoints' ); ?></i></small> |
|
310 | + <label for="<?php echo esc_attr($this->get_field_id('number_logs')); ?>"><?php esc_html_e('Number of latest log entries for this user to display', 'wordpoints'); ?></label> |
|
311 | + <input type="number" min="0" class="widefat" id="<?php echo esc_attr($this->get_field_id('number_logs')); ?>" name="<?php echo esc_attr($this->get_field_name('number_logs')); ?>" value="<?php echo esc_attr($this->instance['number_logs']); ?>" /> |
|
312 | + <small><i><?php esc_html_e('Set this to 0 to keep from showing any logs', 'wordpoints'); ?></i></small> |
|
313 | 313 | </p> |
314 | 314 | |
315 | 315 | <?php |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | |
341 | 341 | parent::__construct( |
342 | 342 | 'WordPoints_Top_Users_Widget' |
343 | - , _x( 'WordPoints Top Users', 'widget name', 'wordpoints' ) |
|
343 | + , _x('WordPoints Top Users', 'widget name', 'wordpoints') |
|
344 | 344 | , array( |
345 | - 'description' => __( 'Showcase the users with the most points.', 'wordpoints' ), |
|
345 | + 'description' => __('Showcase the users with the most points.', 'wordpoints'), |
|
346 | 346 | 'wordpoints_hook_slug' => 'top_users', |
347 | 347 | ) |
348 | 348 | ); |
349 | 349 | |
350 | 350 | $this->defaults = array( |
351 | - 'title' => _x( 'Top Users', 'widget title', 'wordpoints' ), |
|
351 | + 'title' => _x('Top Users', 'widget title', 'wordpoints'), |
|
352 | 352 | 'points_type' => wordpoints_get_default_points_type(), |
353 | 353 | 'num_users' => 3, |
354 | 354 | ); |
@@ -357,19 +357,19 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * @since 1.9.0 |
359 | 359 | */ |
360 | - protected function verify_settings( $instance ) { |
|
360 | + protected function verify_settings($instance) { |
|
361 | 361 | |
362 | - if ( empty( $instance['num_users'] ) ) { |
|
362 | + if (empty($instance['num_users'])) { |
|
363 | 363 | $instance['num_users'] = $this->defaults['num_users']; |
364 | 364 | } |
365 | 365 | |
366 | - return parent::verify_settings( $instance ); |
|
366 | + return parent::verify_settings($instance); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
370 | 370 | * @since 1.9.0 |
371 | 371 | */ |
372 | - protected function widget_body( $instance ) { |
|
372 | + protected function widget_body($instance) { |
|
373 | 373 | |
374 | 374 | wordpoints_points_show_top_users( |
375 | 375 | $instance['num_users'] |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @return array The updated settings for the widget instance. |
390 | 390 | */ |
391 | - public function update( $new_instance, $old_instance ) { |
|
391 | + public function update($new_instance, $old_instance) { |
|
392 | 392 | |
393 | - parent::update( $new_instance, $old_instance ); |
|
393 | + parent::update($new_instance, $old_instance); |
|
394 | 394 | |
395 | - if ( ! wordpoints_posint( $this->instance['num_users'] ) ) { |
|
395 | + if ( ! wordpoints_posint($this->instance['num_users'])) { |
|
396 | 396 | $this->instance['num_users'] = $this->defaults['num_users']; |
397 | 397 | } |
398 | 398 | |
@@ -402,19 +402,19 @@ discard block |
||
402 | 402 | /** |
403 | 403 | * @since 1.0.0 |
404 | 404 | */ |
405 | - public function form( $instance ) { |
|
405 | + public function form($instance) { |
|
406 | 406 | |
407 | - parent::form( $instance ); |
|
407 | + parent::form($instance); |
|
408 | 408 | |
409 | - if ( ! wordpoints_posint( $this->instance['num_users'] ) ) { |
|
409 | + if ( ! wordpoints_posint($this->instance['num_users'])) { |
|
410 | 410 | $this->instance['num_users'] = $this->defaults['num_users']; |
411 | 411 | } |
412 | 412 | |
413 | 413 | ?> |
414 | 414 | |
415 | 415 | <p> |
416 | - <label for="<?php echo esc_attr( $this->get_field_id( 'num_users' ) ); ?>"><?php esc_html_e( 'Number of top users to show', 'wordpoints' ); ?></label> |
|
417 | - <input type="number" min="1" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'num_users' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'num_users' ) ); ?>" value="<?php echo absint( $this->instance['num_users'] ); ?>" /> |
|
416 | + <label for="<?php echo esc_attr($this->get_field_id('num_users')); ?>"><?php esc_html_e('Number of top users to show', 'wordpoints'); ?></label> |
|
417 | + <input type="number" min="1" class="widefat" id="<?php echo esc_attr($this->get_field_id('num_users')); ?>" name="<?php echo esc_attr($this->get_field_name('num_users')); ?>" value="<?php echo absint($this->instance['num_users']); ?>" /> |
|
418 | 418 | </p> |
419 | 419 | |
420 | 420 | <?php |
@@ -439,15 +439,15 @@ discard block |
||
439 | 439 | |
440 | 440 | parent::__construct( |
441 | 441 | 'WordPoints_Points_Logs_Widget' |
442 | - , _x( 'Points Logs', 'widget name', 'wordpoints' ) |
|
442 | + , _x('Points Logs', 'widget name', 'wordpoints') |
|
443 | 443 | , array( |
444 | - 'description' => __( 'Display the latest points activity.', 'wordpoints' ), |
|
444 | + 'description' => __('Display the latest points activity.', 'wordpoints'), |
|
445 | 445 | 'wordpoints_hook_slug' => 'points_logs', |
446 | 446 | ) |
447 | 447 | ); |
448 | 448 | |
449 | 449 | $this->defaults = array( |
450 | - 'title' => _x( 'Points Logs', 'widget title', 'wordpoints' ), |
|
450 | + 'title' => _x('Points Logs', 'widget title', 'wordpoints'), |
|
451 | 451 | 'number_logs' => 10, |
452 | 452 | 'points_type' => wordpoints_get_default_points_type(), |
453 | 453 | ); |
@@ -456,28 +456,28 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @since 1.9.0 |
458 | 458 | */ |
459 | - protected function verify_settings( $instance ) { |
|
459 | + protected function verify_settings($instance) { |
|
460 | 460 | |
461 | - if ( ! wordpoints_posint( $instance['number_logs'] ) ) { |
|
461 | + if ( ! wordpoints_posint($instance['number_logs'])) { |
|
462 | 462 | $instance['number_logs'] = $this->defaults['number_logs']; |
463 | 463 | } |
464 | 464 | |
465 | - return parent::verify_settings( $instance ); |
|
465 | + return parent::verify_settings($instance); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
469 | 469 | * @since 1.9.0 |
470 | 470 | */ |
471 | - public function widget_body( $instance ) { |
|
471 | + public function widget_body($instance) { |
|
472 | 472 | |
473 | - $query_args = wordpoints_get_points_logs_query_args( $instance['points_type'] ); |
|
473 | + $query_args = wordpoints_get_points_logs_query_args($instance['points_type']); |
|
474 | 474 | |
475 | 475 | $query_args['limit'] = $instance['number_logs']; |
476 | 476 | |
477 | - $logs_query = new WordPoints_Points_Logs_Query( $query_args ); |
|
477 | + $logs_query = new WordPoints_Points_Logs_Query($query_args); |
|
478 | 478 | $logs_query->prime_cache(); |
479 | 479 | |
480 | - wordpoints_show_points_logs( $logs_query, array( 'paginate' => false, 'searchable' => false ) ); |
|
480 | + wordpoints_show_points_logs($logs_query, array('paginate' => false, 'searchable' => false)); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * |
491 | 491 | * @return array The updated settings for the widget instance. |
492 | 492 | */ |
493 | - public function update( $new_instance, $old_instance ) { |
|
493 | + public function update($new_instance, $old_instance) { |
|
494 | 494 | |
495 | - parent::update( $new_instance, $old_instance ); |
|
495 | + parent::update($new_instance, $old_instance); |
|
496 | 496 | |
497 | - if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) { |
|
497 | + if ( ! wordpoints_posint($this->instance['number_logs'])) { |
|
498 | 498 | $this->instance['number_logs'] = $this->defaults['number_logs']; |
499 | 499 | } |
500 | 500 | |
@@ -504,19 +504,19 @@ discard block |
||
504 | 504 | /** |
505 | 505 | * @since 1.0.0 |
506 | 506 | */ |
507 | - public function form( $instance ) { |
|
507 | + public function form($instance) { |
|
508 | 508 | |
509 | - parent::form( $instance ); |
|
509 | + parent::form($instance); |
|
510 | 510 | |
511 | - if ( ! wordpoints_posint( $this->instance['number_logs'] ) ) { |
|
511 | + if ( ! wordpoints_posint($this->instance['number_logs'])) { |
|
512 | 512 | $this->instance['number_logs'] = $this->defaults['number_logs']; |
513 | 513 | } |
514 | 514 | |
515 | 515 | ?> |
516 | 516 | |
517 | 517 | <p> |
518 | - <label for="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>"><?php esc_html_e( 'Number of log entries to display', 'wordpoints' ); ?></label> |
|
519 | - <input type="number" min="1" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number_logs' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number_logs' ) ); ?>" value="<?php echo absint( $this->instance['number_logs'] ); ?>" /> |
|
518 | + <label for="<?php echo esc_attr($this->get_field_id('number_logs')); ?>"><?php esc_html_e('Number of log entries to display', 'wordpoints'); ?></label> |
|
519 | + <input type="number" min="1" class="widefat" id="<?php echo esc_attr($this->get_field_id('number_logs')); ?>" name="<?php echo esc_attr($this->get_field_name('number_logs')); ?>" value="<?php echo absint($this->instance['number_logs']); ?>" /> |
|
520 | 520 | </p> |
521 | 521 | |
522 | 522 | <?php |
@@ -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 | return null; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @param array $options The options for the hook. |
358 | 358 | */ |
359 | - final public function set_options( array $options ) { |
|
359 | + final public function set_options(array $options) { |
|
360 | 360 | $this->options = $options; |
361 | 361 | } |
362 | 362 | |
@@ -369,9 +369,9 @@ discard block |
||
369 | 369 | * @param string $option The index for the option. |
370 | 370 | * @param mixed $value The value to assign to this option. |
371 | 371 | */ |
372 | - final public function set_option( $option, $value ) { |
|
372 | + final public function set_option($option, $value) { |
|
373 | 373 | |
374 | - $this->options[ $option ] = $value; |
|
374 | + $this->options[$option] = $value; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | */ |
388 | 388 | final public function next_hook_id_number() { |
389 | 389 | |
390 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
390 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
391 | 391 | $type = 'network'; |
392 | 392 | } else { |
393 | 393 | $type = 'standard'; |
394 | 394 | } |
395 | 395 | |
396 | - return 1 + max( array_keys( $this->get_instances( $type ) ) + array( 0 ) ); |
|
396 | + return 1 + max(array_keys($this->get_instances($type)) + array(0)); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -415,34 +415,34 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @return array The saved instances of this hook. |
417 | 417 | */ |
418 | - final public function get_instances( $type = 'all' ) { |
|
418 | + final public function get_instances($type = 'all') { |
|
419 | 419 | |
420 | - switch ( $type ) { |
|
420 | + switch ($type) { |
|
421 | 421 | |
422 | 422 | case 'standard': |
423 | - $instances = wordpoints_get_array_option( $this->option_name ); |
|
423 | + $instances = wordpoints_get_array_option($this->option_name); |
|
424 | 424 | break; |
425 | 425 | |
426 | 426 | case 'network': |
427 | - if ( is_multisite() ) { |
|
428 | - $instances = wordpoints_get_array_option( $this->option_name, 'site' ); |
|
427 | + if (is_multisite()) { |
|
428 | + $instances = wordpoints_get_array_option($this->option_name, 'site'); |
|
429 | 429 | } else { |
430 | 430 | $instances = array(); |
431 | 431 | } |
432 | 432 | break; |
433 | 433 | |
434 | 434 | case 'all': |
435 | - $instances = wordpoints_get_array_option( $this->option_name ); |
|
435 | + $instances = wordpoints_get_array_option($this->option_name); |
|
436 | 436 | |
437 | - if ( is_multisite() ) { |
|
438 | - foreach ( wordpoints_get_array_option( $this->option_name, 'site' ) as $number => $instance ) { |
|
439 | - $instances[ 'network_' . $number ] = $instance; |
|
437 | + if (is_multisite()) { |
|
438 | + foreach (wordpoints_get_array_option($this->option_name, 'site') as $number => $instance) { |
|
439 | + $instances['network_' . $number] = $instance; |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | break; |
443 | 443 | } |
444 | 444 | |
445 | - unset( $instances['__i__'] ); |
|
445 | + unset($instances['__i__']); |
|
446 | 446 | |
447 | 447 | return $instances; |
448 | 448 | } |
@@ -457,22 +457,22 @@ discard block |
||
457 | 457 | * @param array $new_instance The new instance of this hooks settings. |
458 | 458 | * @param int $number The ID number for this hook. |
459 | 459 | */ |
460 | - final public function update_callback( $new_instance, $number ) { |
|
460 | + final public function update_callback($new_instance, $number) { |
|
461 | 461 | |
462 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
462 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
463 | 463 | $type = 'network'; |
464 | 464 | } else { |
465 | 465 | $type = 'standard'; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Get all saved instances of this points hook. |
469 | - $all_instances = $this->get_instances( $type ); |
|
469 | + $all_instances = $this->get_instances($type); |
|
470 | 470 | |
471 | - $this->set_number( $number ); |
|
471 | + $this->set_number($number); |
|
472 | 472 | |
473 | - $old_instance = isset( $all_instances[ $this->number ] ) ? $all_instances[ $this->number ] : array(); |
|
473 | + $old_instance = isset($all_instances[$this->number]) ? $all_instances[$this->number] : array(); |
|
474 | 474 | |
475 | - $instance = $this->update( $new_instance, $old_instance ); |
|
475 | + $instance = $this->update($new_instance, $old_instance); |
|
476 | 476 | |
477 | 477 | /** |
478 | 478 | * Filter a points hook's settings before saving. |
@@ -488,13 +488,13 @@ discard block |
||
488 | 488 | * @param array $old_instance The old instance of the hook. |
489 | 489 | * @param WordPoints_Points_Hook $hook The hook object. |
490 | 490 | */ |
491 | - $instance = apply_filters( 'wordpoints_points_hook_update_callback', $instance, $new_instance, $old_instance, $this ); |
|
491 | + $instance = apply_filters('wordpoints_points_hook_update_callback', $instance, $new_instance, $old_instance, $this); |
|
492 | 492 | |
493 | - if ( false !== $instance ) { |
|
494 | - $all_instances[ $this->number ] = $instance; |
|
493 | + if (false !== $instance) { |
|
494 | + $all_instances[$this->number] = $instance; |
|
495 | 495 | } |
496 | 496 | |
497 | - $this->_save_instances( $all_instances ); |
|
497 | + $this->_save_instances($all_instances); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
@@ -504,24 +504,24 @@ discard block |
||
504 | 504 | * |
505 | 505 | * @param string $hook_id The ID of the instance to delete. |
506 | 506 | */ |
507 | - final public function delete_callback( $hook_id ) { |
|
507 | + final public function delete_callback($hook_id) { |
|
508 | 508 | |
509 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
509 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
510 | 510 | $type = 'network'; |
511 | 511 | } else { |
512 | 512 | $type = 'standard'; |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Get all saved instances of this points hook. |
516 | - $all_instances = $this->get_instances( $type ); |
|
516 | + $all_instances = $this->get_instances($type); |
|
517 | 517 | |
518 | - $number = $this->get_number_by_id( $hook_id ); |
|
518 | + $number = $this->get_number_by_id($hook_id); |
|
519 | 519 | |
520 | - if ( isset( $all_instances[ $number ] ) ) { |
|
520 | + if (isset($all_instances[$number])) { |
|
521 | 521 | |
522 | - unset( $all_instances[ $number ] ); |
|
522 | + unset($all_instances[$number]); |
|
523 | 523 | |
524 | - $this->_save_instances( $all_instances ); |
|
524 | + $this->_save_instances($all_instances); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
@@ -534,27 +534,27 @@ discard block |
||
534 | 534 | * |
535 | 535 | * @return bool|null Whether the form was displayed. |
536 | 536 | */ |
537 | - final public function form_callback( $number ) { |
|
537 | + final public function form_callback($number) { |
|
538 | 538 | |
539 | - $this->set_number( $number ); |
|
539 | + $this->set_number($number); |
|
540 | 540 | |
541 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
541 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
542 | 542 | $type = 'network'; |
543 | 543 | } else { |
544 | 544 | $type = 'standard'; |
545 | 545 | } |
546 | 546 | |
547 | - $all_instances = $this->get_instances( $type ); |
|
547 | + $all_instances = $this->get_instances($type); |
|
548 | 548 | |
549 | - if ( 0 === $this->number || '0' === $this->number ) { |
|
549 | + if (0 === $this->number || '0' === $this->number) { |
|
550 | 550 | |
551 | 551 | // We echo out a form where 'number' can be set later. |
552 | - $this->set_number( '__i__' ); |
|
552 | + $this->set_number('__i__'); |
|
553 | 553 | $instance = array(); |
554 | 554 | |
555 | 555 | } else { |
556 | 556 | |
557 | - $instance = $all_instances[ $this->number ]; |
|
557 | + $instance = $all_instances[$this->number]; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -567,11 +567,11 @@ discard block |
||
567 | 567 | * @param array $instance The settings for this instance. |
568 | 568 | * @param WordPoints_Points_Hook $hook The hook object. |
569 | 569 | */ |
570 | - $instance = apply_filters( 'wordpoints_points_hook_form_callback', $instance, $this ); |
|
570 | + $instance = apply_filters('wordpoints_points_hook_form_callback', $instance, $this); |
|
571 | 571 | |
572 | - if ( false !== $instance ) { |
|
572 | + if (false !== $instance) { |
|
573 | 573 | |
574 | - $has_form = $this->form( $instance ); |
|
574 | + $has_form = $this->form($instance); |
|
575 | 575 | |
576 | 576 | /** |
577 | 577 | * Inside the points hook form. |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * @param array $instance Settings for this instance. |
584 | 584 | * @param WordPoints_Points_Hook $hook The hook object. |
585 | 585 | */ |
586 | - do_action( 'wordpoints_in_points_hook_form', $has_form, $instance, $this ); |
|
586 | + do_action('wordpoints_in_points_hook_form', $has_form, $instance, $this); |
|
587 | 587 | |
588 | 588 | return $has_form; |
589 | 589 | } |
@@ -606,9 +606,9 @@ discard block |
||
606 | 606 | * |
607 | 607 | * @return string Name attribute for $field_name. |
608 | 608 | */ |
609 | - final public function get_field_name( $field_name ) { |
|
609 | + final public function get_field_name($field_name) { |
|
610 | 610 | |
611 | - return esc_attr( 'hook-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']' ); |
|
611 | + return esc_attr('hook-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @param string $field_name The field name. |
622 | 622 | */ |
623 | - final public function the_field_name( $field_name ) { |
|
623 | + final public function the_field_name($field_name) { |
|
624 | 624 | |
625 | - echo esc_attr( $this->get_field_name( $field_name ) ); |
|
625 | + echo esc_attr($this->get_field_name($field_name)); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -640,9 +640,9 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @return string ID attribute for $field_name. |
642 | 642 | */ |
643 | - final public function get_field_id( $field_name ) { |
|
643 | + final public function get_field_id($field_name) { |
|
644 | 644 | |
645 | - return esc_attr( 'hook-' . $this->id_base . '-' . $this->number . '-' . $field_name ); |
|
645 | + return esc_attr('hook-' . $this->id_base . '-' . $this->number . '-' . $field_name); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | /** |
@@ -654,9 +654,9 @@ discard block |
||
654 | 654 | * |
655 | 655 | * @param string $field_name The field name. |
656 | 656 | */ |
657 | - final public function the_field_id( $field_name ) { |
|
657 | + final public function the_field_id($field_name) { |
|
658 | 658 | |
659 | - echo esc_attr( $this->get_field_id( $field_name ) ); |
|
659 | + echo esc_attr($this->get_field_id($field_name)); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
@@ -669,15 +669,15 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @return string The hook's description. |
671 | 671 | */ |
672 | - final public function get_description( $type = 'any' ) { |
|
672 | + final public function get_description($type = 'any') { |
|
673 | 673 | |
674 | 674 | $instances = $this->get_instances(); |
675 | 675 | |
676 | - if ( 'generated' !== $type && ! empty( $instances[ $this->number ]['_description'] ) ) { |
|
677 | - return $instances[ $this->number ]['_description']; |
|
676 | + if ('generated' !== $type && ! empty($instances[$this->number]['_description'])) { |
|
677 | + return $instances[$this->number]['_description']; |
|
678 | 678 | } |
679 | 679 | |
680 | - $instance = ( isset( $instances[ $this->number ] ) ) ? $instances[ $this->number ] : array(); |
|
680 | + $instance = (isset($instances[$this->number])) ? $instances[$this->number] : array(); |
|
681 | 681 | |
682 | 682 | /** |
683 | 683 | * Filter the description for a points hook. |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @param WordPoints_Points_Hook $hook The points hook object. |
689 | 689 | * @param array $instance The settings for this instance. |
690 | 690 | */ |
691 | - return apply_filters( 'wordpoints_points_hook_description', $this->generate_description( $instance ), $this, $instance ); |
|
691 | + return apply_filters('wordpoints_points_hook_description', $this->generate_description($instance), $this, $instance); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -701,31 +701,31 @@ discard block |
||
701 | 701 | * |
702 | 702 | * @return string|false The type of points, or false if none found. |
703 | 703 | */ |
704 | - final public function points_type( $number = null ) { |
|
704 | + final public function points_type($number = null) { |
|
705 | 705 | |
706 | 706 | $network_mode = false; |
707 | 707 | |
708 | - if ( ! isset( $number ) ) { |
|
708 | + if ( ! isset($number)) { |
|
709 | 709 | |
710 | 710 | $number = $this->number; |
711 | 711 | |
712 | - } elseif ( is_string( $number ) && 'network_' === substr( $number, 0, 8 ) ) { |
|
712 | + } elseif (is_string($number) && 'network_' === substr($number, 0, 8)) { |
|
713 | 713 | |
714 | 714 | $network_mode = true; |
715 | - $number = (int) substr( $number, 8 ); |
|
715 | + $number = (int) substr($number, 8); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | $current_mode = WordPoints_Points_Hooks::get_network_mode(); |
719 | 719 | |
720 | - if ( $current_mode !== $network_mode ) { |
|
721 | - WordPoints_Points_Hooks::set_network_mode( $network_mode ); |
|
720 | + if ($current_mode !== $network_mode) { |
|
721 | + WordPoints_Points_Hooks::set_network_mode($network_mode); |
|
722 | 722 | } |
723 | 723 | |
724 | - $points_type = WordPoints_Points_Hooks::get_points_type( $this->get_id( $number ) ); |
|
724 | + $points_type = WordPoints_Points_Hooks::get_points_type($this->get_id($number)); |
|
725 | 725 | |
726 | 726 | // Reset network mode if it was changed. |
727 | - if ( $current_mode !== $network_mode ) { |
|
728 | - WordPoints_Points_Hooks::set_network_mode( $current_mode ); |
|
727 | + if ($current_mode !== $network_mode) { |
|
728 | + WordPoints_Points_Hooks::set_network_mode($current_mode); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | return $points_type; |
@@ -754,15 +754,15 @@ discard block |
||
754 | 754 | * overriding that function, you can ignore this option. |
755 | 755 | * } |
756 | 756 | */ |
757 | - final protected function init( $name, array $options = array() ) { |
|
757 | + final protected function init($name, array $options = array()) { |
|
758 | 758 | |
759 | - $this->id_base = strtolower( get_class( $this ) ); |
|
759 | + $this->id_base = strtolower(get_class($this)); |
|
760 | 760 | $this->name = $name; |
761 | 761 | $this->option_name = 'wordpoints_hook-' . $this->id_base; |
762 | 762 | |
763 | 763 | // Option names can only be 191 characters long. |
764 | - if ( isset( $this->option_name{191} ) ) { |
|
765 | - _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' ); |
|
764 | + if (isset($this->option_name{191} )) { |
|
765 | + _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'); |
|
766 | 766 | return; |
767 | 767 | } |
768 | 768 | |
@@ -770,12 +770,12 @@ discard block |
||
770 | 770 | array( |
771 | 771 | 'width' => 250, |
772 | 772 | 'description' => '', |
773 | - 'points_label' => __( 'Points:', 'wordpoints' ), |
|
773 | + 'points_label' => __('Points:', 'wordpoints'), |
|
774 | 774 | ) |
775 | 775 | , $options |
776 | 776 | ); |
777 | 777 | |
778 | - $this->options['_classname'] = $this->option_name; |
|
778 | + $this->options['_classname'] = $this->option_name; |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | // |
@@ -789,15 +789,15 @@ discard block |
||
789 | 789 | * |
790 | 790 | * @param array $instances All settings, indexed by instance number. |
791 | 791 | */ |
792 | - final private function _save_instances( $instances ) { |
|
792 | + final private function _save_instances($instances) { |
|
793 | 793 | |
794 | 794 | // This needs to start at 1. |
795 | - unset( $instances[0] ); |
|
795 | + unset($instances[0]); |
|
796 | 796 | |
797 | - if ( WordPoints_Points_Hooks::get_network_mode() ) { |
|
798 | - update_site_option( $this->option_name, $instances ); |
|
797 | + if (WordPoints_Points_Hooks::get_network_mode()) { |
|
798 | + update_site_option($this->option_name, $instances); |
|
799 | 799 | } else { |
800 | - update_option( $this->option_name, $instances ); |
|
800 | + update_option($this->option_name, $instances); |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @since 2.2.0 |
20 | 20 | */ |
21 | 21 | public function get_description() { |
22 | - return __( 'This log entry is only visible to users who can view the post that the comment is on.', 'wordpoints' ); |
|
22 | + return __('This log entry is only visible to users who can view the post that the comment is on.', 'wordpoints'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | , true |
34 | 34 | ); |
35 | 35 | |
36 | - if ( $comment_id ) { |
|
37 | - $comment = get_comment( $comment_id ); |
|
36 | + if ($comment_id) { |
|
37 | + $comment = get_comment($comment_id); |
|
38 | 38 | |
39 | - if ( $comment ) { |
|
39 | + if ($comment) { |
|
40 | 40 | return $comment->comment_post_ID; |
41 | 41 | } |
42 | 42 | } |
@@ -7,44 +7,44 @@ discard block |
||
7 | 7 | * @since 1.0.0 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! isset( $_GET['edithook'] ) ) { |
|
10 | +if ( ! isset($_GET['edithook'])) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
14 | -$hook_id = sanitize_key( $_GET['edithook'] ); |
|
14 | +$hook_id = sanitize_key($_GET['edithook']); |
|
15 | 15 | |
16 | 16 | $points_types = wordpoints_get_points_types(); |
17 | 17 | |
18 | -if ( isset( $_GET['addnew'] ) ) { |
|
18 | +if (isset($_GET['addnew'])) { |
|
19 | 19 | |
20 | 20 | // - We are adding a new points hook. |
21 | 21 | |
22 | 22 | $points_type = wordpoints_get_default_points_type(); |
23 | 23 | |
24 | 24 | // Default to the first points type. |
25 | - if ( ! $points_type ) { |
|
26 | - reset( $points_types ); |
|
27 | - $points_type = key( $points_types ); |
|
25 | + if ( ! $points_type) { |
|
26 | + reset($points_types); |
|
27 | + $points_type = key($points_types); |
|
28 | 28 | } |
29 | 29 | |
30 | - if ( ! $points_type ) { |
|
30 | + if ( ! $points_type) { |
|
31 | 31 | |
32 | - wordpoints_show_admin_error( esc_html__( 'You need to add a points type before you can add any hooks.', 'wordpoints' ) ); |
|
32 | + wordpoints_show_admin_error(esc_html__('You need to add a points type before you can add any hooks.', 'wordpoints')); |
|
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | - if ( isset( $_GET['base'], $_GET['num'] ) ) { |
|
36 | + if (isset($_GET['base'], $_GET['num'])) { |
|
37 | 37 | |
38 | 38 | // Copy minimal info from an existing instance of this hook to a new instance. |
39 | 39 | $hook = WordPoints_Points_Hooks::get_handler_by_id_base( |
40 | - sanitize_key( $_GET['base'] ) |
|
40 | + sanitize_key($_GET['base']) |
|
41 | 41 | ); |
42 | 42 | |
43 | - if ( ! $hook ) { |
|
43 | + if ( ! $hook) { |
|
44 | 44 | |
45 | 45 | wordpoints_show_admin_error( |
46 | - esc_html__( 'Unable to add the points hook, please try again.', 'wordpoints' ) |
|
47 | - , array( 'dismissible' => true ) |
|
46 | + esc_html__('Unable to add the points hook, please try again.', 'wordpoints') |
|
47 | + , array('dismissible' => true) |
|
48 | 48 | ); |
49 | 49 | |
50 | 50 | return; |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | |
53 | 53 | $multi_number = (int) $_GET['num']; |
54 | 54 | $number = 0; |
55 | - $hook_id = $hook->get_id( $multi_number ); |
|
55 | + $hook_id = $hook->get_id($multi_number); |
|
56 | 56 | $_hook = $hook; |
57 | 57 | $id_base = $hook->get_id_base(); |
58 | 58 | |
59 | 59 | } else { |
60 | 60 | |
61 | 61 | wordpoints_show_admin_error( |
62 | - esc_html__( 'Unable to add the points hook, please try again.', 'wordpoints' ) |
|
63 | - , array( 'dismissible' => true ) |
|
62 | + esc_html__('Unable to add the points hook, please try again.', 'wordpoints') |
|
63 | + , array('dismissible' => true) |
|
64 | 64 | ); |
65 | 65 | |
66 | 66 | return; |
@@ -70,43 +70,43 @@ discard block |
||
70 | 70 | |
71 | 71 | // We are editing an existing points hook. |
72 | 72 | |
73 | - $points_type = isset( $_GET['points_type'] ) ? sanitize_key( $_GET['points_type'] ) : '_inactive_hooks'; |
|
73 | + $points_type = isset($_GET['points_type']) ? sanitize_key($_GET['points_type']) : '_inactive_hooks'; |
|
74 | 74 | |
75 | - $hook = WordPoints_Points_Hooks::get_handler( $hook_id ); |
|
75 | + $hook = WordPoints_Points_Hooks::get_handler($hook_id); |
|
76 | 76 | |
77 | - if ( ! $hook ) { |
|
77 | + if ( ! $hook) { |
|
78 | 78 | |
79 | - wordpoints_show_admin_error( esc_html__( 'The hook you have asked to edit could not be found. Please go back and try again.', 'wordpoints' ) ); |
|
79 | + wordpoints_show_admin_error(esc_html__('The hook you have asked to edit could not be found. Please go back and try again.', 'wordpoints')); |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
83 | 83 | $id_base = $hook->get_id_base(); |
84 | 84 | $multi_number = 0; |
85 | - $number = $hook->get_number_by_id( $hook_id ); |
|
85 | + $number = $hook->get_number_by_id($hook_id); |
|
86 | 86 | |
87 | 87 | } // End if ( adding hook ) else { updating hook }. |
88 | 88 | |
89 | -$name = esc_html( $hook->get_name() ); |
|
89 | +$name = esc_html($hook->get_name()); |
|
90 | 90 | |
91 | 91 | // Show the hook form. |
92 | 92 | |
93 | 93 | ?> |
94 | 94 | |
95 | 95 | <div class="wrap"> |
96 | - <h1><?php esc_html_e( 'Points Hooks', 'wordpoints' ); ?></h1> |
|
97 | - <div class="edithook" style="width:<?php echo absint( $hook->get_option( 'width' ) ); ?>px"> |
|
96 | + <h1><?php esc_html_e('Points Hooks', 'wordpoints'); ?></h1> |
|
97 | + <div class="edithook" style="width:<?php echo absint($hook->get_option('width')); ?>px"> |
|
98 | 98 | <?php // translators: Hook name. ?> |
99 | - <h2><?php echo esc_html( sprintf( __( 'Hook %s', 'wordpoints' ), $name ) ); ?></h2> |
|
99 | + <h2><?php echo esc_html(sprintf(__('Hook %s', 'wordpoints'), $name)); ?></h2> |
|
100 | 100 | |
101 | - <form action="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_hooks' ) ); ?>" method="post"> |
|
101 | + <form action="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_points_hooks')); ?>" method="post"> |
|
102 | 102 | <div class="hook-inside"> |
103 | - <?php $hook->form_callback( $number ); ?> |
|
103 | + <?php $hook->form_callback($number); ?> |
|
104 | 104 | </div> |
105 | 105 | |
106 | - <p class="describe"><?php esc_html_e( 'Select the points type to attach this hook to.', 'wordpoints' ); ?></p> |
|
106 | + <p class="describe"><?php esc_html_e('Select the points type to attach this hook to.', 'wordpoints'); ?></p> |
|
107 | 107 | <div class="hook-position"> |
108 | 108 | <label for="points_type" class="screen-reader-text"> |
109 | - <?php esc_html_e( 'Points Type:', 'wordpoints' ); ?> |
|
109 | + <?php esc_html_e('Points Type:', 'wordpoints'); ?> |
|
110 | 110 | </label> |
111 | 111 | <?php |
112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | 'name' => 'points_type', |
117 | 117 | 'id' => 'points_type', |
118 | 118 | 'class' => 'widefat', |
119 | - 'options' => array( '_inactive_hooks' => __( 'Inactive Hooks', 'wordpoints' ) ), |
|
119 | + 'options' => array('_inactive_hooks' => __('Inactive Hooks', 'wordpoints')), |
|
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | |
@@ -124,19 +124,19 @@ discard block |
||
124 | 124 | </div> |
125 | 125 | <br /> |
126 | 126 | <div class="hook-control-actions"> |
127 | - <?php if ( isset( $_GET['addnew'] ) ) : ?> |
|
128 | - <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_points_hooks' ) ); ?>" class="button alignleft"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></a> |
|
127 | + <?php if (isset($_GET['addnew'])) : ?> |
|
128 | + <a href="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_points_hooks')); ?>" class="button alignleft"><?php esc_html_e('Cancel', 'wordpoints'); ?></a> |
|
129 | 129 | <?php else : |
130 | - submit_button( _x( 'Delete', 'points hook', 'wordpoints' ), 'button alignleft', 'removehook', false ); |
|
130 | + submit_button(_x('Delete', 'points hook', 'wordpoints'), 'button alignleft', 'removehook', false); |
|
131 | 131 | endif; |
132 | 132 | |
133 | - submit_button( __( 'Save Hook', 'wordpoints' ), 'button-primary alignright', 'savehook', false ); |
|
133 | + submit_button(__('Save Hook', 'wordpoints'), 'button-primary alignright', 'savehook', false); |
|
134 | 134 | ?> |
135 | 135 | |
136 | - <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr( $hook_id ); ?>" /> |
|
137 | - <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr( $id_base ); ?>" /> |
|
138 | - <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr( $multi_number ); ?>" /> |
|
139 | - <?php wp_nonce_field( "save-delete-hook-{$hook_id}" ); ?> |
|
136 | + <input type="hidden" name="hook-id" class="hook-id" value="<?php echo esc_attr($hook_id); ?>" /> |
|
137 | + <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" /> |
|
138 | + <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" /> |
|
139 | + <?php wp_nonce_field("save-delete-hook-{$hook_id}"); ?> |
|
140 | 140 | <br class="clear" /> |
141 | 141 | </div> |
142 | 142 | </form> |