@@ -39,7 +39,7 @@ |
||
| 39 | 39 | |
| 40 | 40 | $expected_settings = array( array( 'current:user' ) ); |
| 41 | 41 | |
| 42 | - if ( ! isset( $settings['args'] ) || $settings['args'] !== $expected_settings ) { |
|
| 42 | + if ( ! isset( $settings[ 'args' ] ) || $settings[ 'args' ] !== $expected_settings ) { |
|
| 43 | 43 | return false; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | protected function get_points_logs_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
| 67 | 67 | |
| 68 | - if ( isset( $fire->data[ $this->slug ]['points_logs'] ) ) { |
|
| 69 | - return $fire->data[ $this->slug ]['points_logs']; |
|
| 68 | + if ( isset( $fire->data[ $this->slug ][ 'points_logs' ] ) ) { |
|
| 69 | + return $fire->data[ $this->slug ][ 'points_logs' ]; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $meta_queries = array( |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | $entities = $fire->event_args->get_signature_args(); |
| 86 | 86 | |
| 87 | 87 | if ( ! $entities ) { |
| 88 | - $fire->data[ $this->slug ]['points_logs'] = array(); |
|
| 88 | + $fire->data[ $this->slug ][ 'points_logs' ] = array(); |
|
| 89 | 89 | return array(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Legacy hooks only ever related to a single entity. |
| 93 | 93 | $entity = reset( $entities ); |
| 94 | 94 | |
| 95 | - $meta_queries[] = array( |
|
| 95 | + $meta_queries[ ] = array( |
|
| 96 | 96 | 'key' => $meta_key, |
| 97 | 97 | 'value' => $entity->get_the_id(), |
| 98 | 98 | ); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $logs = array(); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $fire->data[ $this->slug ]['points_logs'] = $logs; |
|
| 120 | + $fire->data[ $this->slug ][ 'points_logs' ] = $logs; |
|
| 121 | 121 | |
| 122 | 122 | return $logs; |
| 123 | 123 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function get_settings_fields() { |
| 60 | 60 | |
| 61 | - $this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' ); |
|
| 62 | - $this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' ); |
|
| 63 | - $this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' ); |
|
| 61 | + $this->settings_fields[ 'points' ][ 'label' ] = _x( 'Points', 'form label', 'wordpoints' ); |
|
| 62 | + $this->settings_fields[ 'log_text' ][ 'label' ] = _x( 'Log Text', 'form label', 'wordpoints' ); |
|
| 63 | + $this->settings_fields[ 'description' ][ 'label' ] = _x( 'Description', 'form label', 'wordpoints' ); |
|
| 64 | 64 | |
| 65 | 65 | return parent::get_settings_fields(); |
| 66 | 66 | } |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $data = parent::get_ui_script_data(); |
| 74 | 74 | |
| 75 | - $data['target_label'] = __( 'Award To', 'wordpoints' ); |
|
| 76 | - $data['periods_label'] = __( 'Award each user no more than once in:', 'wordpoints' ); |
|
| 75 | + $data[ 'target_label' ] = __( 'Award To', 'wordpoints' ); |
|
| 76 | + $data[ 'periods_label' ] = __( 'Award each user no more than once in:', 'wordpoints' ); |
|
| 77 | 77 | |
| 78 | 78 | return $data; |
| 79 | 79 | } |
@@ -87,19 +87,19 @@ discard block |
||
| 87 | 87 | WordPoints_Hook_Event_Args $event_args |
| 88 | 88 | ) { |
| 89 | 89 | |
| 90 | - if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) { |
|
| 90 | + if ( ! isset( $settings[ 'points' ] ) || false === wordpoints_int( $settings[ 'points' ] ) ) { |
|
| 91 | 91 | $validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' ); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
| 94 | + if ( ! isset( $settings[ 'points_type' ] ) || ! wordpoints_is_points_type( $settings[ 'points_type' ] ) ) { |
|
| 95 | 95 | $validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' ); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( ! isset( $settings['description'] ) ) { |
|
| 98 | + if ( ! isset( $settings[ 'description' ] ) ) { |
|
| 99 | 99 | $validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' ); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( ! isset( $settings['log_text'] ) ) { |
|
| 102 | + if ( ! isset( $settings[ 'log_text' ] ) ) { |
|
| 103 | 103 | $validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' ); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | parent::update_settings( $reaction, $settings ); |
| 118 | 118 | |
| 119 | - $reaction->update_meta( 'points', $settings['points'] ); |
|
| 120 | - $reaction->update_meta( 'points_type', $settings['points_type'] ); |
|
| 121 | - $reaction->update_meta( 'description', $settings['description'] ); |
|
| 122 | - $reaction->update_meta( 'log_text', $settings['log_text'] ); |
|
| 119 | + $reaction->update_meta( 'points', $settings[ 'points' ] ); |
|
| 120 | + $reaction->update_meta( 'points_type', $settings[ 'points_type' ] ); |
|
| 121 | + $reaction->update_meta( 'description', $settings[ 'description' ] ); |
|
| 122 | + $reaction->update_meta( 'log_text', $settings[ 'log_text' ] ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
| 204 | 204 | |
| 205 | 205 | // We closely integrate with the reversals extension to get the hit IDs. |
| 206 | - if ( ! isset( $fire->data['reversals']['hit_ids'] ) ) { |
|
| 206 | + if ( ! isset( $fire->data[ 'reversals' ][ 'hit_ids' ] ) ) { |
|
| 207 | 207 | return array(); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - return $fire->data['reversals']['hit_ids']; |
|
| 210 | + return $fire->data[ 'reversals' ][ 'hit_ids' ]; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | |
| 48 | 48 | $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
| 49 | 49 | |
| 50 | - switch ( $parsed['dynamic'] ) { |
|
| 50 | + switch ( $parsed[ 'dynamic' ] ) { |
|
| 51 | 51 | |
| 52 | 52 | case 'post': |
| 53 | 53 | return __( 'Post deleted.', 'wordpoints' ); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | 275 | $reaction_settings = array( |
| 276 | - 'points' => $legacy_instance['points'], |
|
| 276 | + 'points' => $legacy_instance[ 'points' ], |
|
| 277 | 277 | 'target' => $this->target, |
| 278 | 278 | 'reactor' => 'points_legacy', |
| 279 | 279 | 'event' => $this->event_slug, |
@@ -294,8 +294,8 @@ discard block |
||
| 294 | 294 | $order |
| 295 | 295 | ); |
| 296 | 296 | |
| 297 | - if ( ! isset( $reaction_settings['log_text'] ) ) { |
|
| 298 | - $reaction_settings['log_text'] = $this->get_log_text_for_instance( |
|
| 297 | + if ( ! isset( $reaction_settings[ 'log_text' ] ) ) { |
|
| 298 | + $reaction_settings[ 'log_text' ] = $this->get_log_text_for_instance( |
|
| 299 | 299 | $points_type |
| 300 | 300 | ); |
| 301 | 301 | } |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | if ( |
| 335 | 335 | $this->skip_non_reversing_hooks |
| 336 | - && isset( $this->legacy_instance['auto_reverse'] ) |
|
| 337 | - && ! $this->legacy_instance['auto_reverse'] |
|
| 336 | + && isset( $this->legacy_instance[ 'auto_reverse' ] ) |
|
| 337 | + && ! $this->legacy_instance[ 'auto_reverse' ] |
|
| 338 | 338 | ) { |
| 339 | 339 | return false; |
| 340 | 340 | } |
@@ -359,17 +359,17 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | if ( |
| 362 | - ! isset( $meta['post_type'] ) |
|
| 363 | - && isset( $this->legacy_instance['post_type'] ) |
|
| 362 | + ! isset( $meta[ 'post_type' ] ) |
|
| 363 | + && isset( $this->legacy_instance[ 'post_type' ] ) |
|
| 364 | 364 | ) { |
| 365 | - $meta['post_type'] = $this->legacy_instance['post_type']; |
|
| 365 | + $meta[ 'post_type' ] = $this->legacy_instance[ 'post_type' ]; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | if ( |
| 369 | - ! isset( $meta['period'] ) |
|
| 370 | - && isset( $this->legacy_instance['period'] ) |
|
| 369 | + ! isset( $meta[ 'period' ] ) |
|
| 370 | + && isset( $this->legacy_instance[ 'period' ] ) |
|
| 371 | 371 | ) { |
| 372 | - $meta['period'] = $this->legacy_instance['period']; |
|
| 372 | + $meta[ 'period' ] = $this->legacy_instance[ 'period' ]; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | return $this->legacy_handler->logs( |
@@ -398,10 +398,10 @@ discard block |
||
| 398 | 398 | |
| 399 | 399 | if ( 'wordpoints_periodic_points_hook' === $this->legacy_id_base ) { |
| 400 | 400 | |
| 401 | - $settings['points_legacy_periods'] = array( |
|
| 401 | + $settings[ 'points_legacy_periods' ] = array( |
|
| 402 | 402 | 'fire' => array( |
| 403 | 403 | array( |
| 404 | - 'length' => $this->legacy_instance['period'], |
|
| 404 | + 'length' => $this->legacy_instance[ 'period' ], |
|
| 405 | 405 | 'args' => array( array( 'current:user' ) ), |
| 406 | 406 | ), |
| 407 | 407 | ), |
@@ -411,21 +411,21 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | // We do this even if reversals will be blocked, in case the blocking |
| 413 | 413 | // is ever removed for this reaction. |
| 414 | - $settings['points_legacy_reversals'] = array( |
|
| 414 | + $settings[ 'points_legacy_reversals' ] = array( |
|
| 415 | 415 | 'toggle_off' => 'toggle_on', |
| 416 | 416 | ); |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | if ( |
| 420 | - isset( $this->legacy_instance['auto_reverse'] ) |
|
| 421 | - && ! $this->legacy_instance['auto_reverse'] |
|
| 420 | + isset( $this->legacy_instance[ 'auto_reverse' ] ) |
|
| 421 | + && ! $this->legacy_instance[ 'auto_reverse' ] |
|
| 422 | 422 | ) { |
| 423 | - $settings['blocker']['toggle_off'] = true; |
|
| 423 | + $settings[ 'blocker' ][ 'toggle_off' ] = true; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if ( isset( $this->legacy_instance['post_type'] ) ) { |
|
| 426 | + if ( isset( $this->legacy_instance[ 'post_type' ] ) ) { |
|
| 427 | 427 | |
| 428 | - $post_type = $this->legacy_instance['post_type']; |
|
| 428 | + $post_type = $this->legacy_instance[ 'post_type' ]; |
|
| 429 | 429 | |
| 430 | 430 | if ( 'ALL' === $post_type ) { |
| 431 | 431 | |
@@ -467,36 +467,36 @@ discard block |
||
| 467 | 467 | protected function format_settings_for_post_type( $post_type, $settings ) { |
| 468 | 468 | |
| 469 | 469 | if ( |
| 470 | - 'post_publish\post' === $settings['event'] |
|
| 471 | - || 'points_legacy_post_publish\post' === $settings['event'] |
|
| 470 | + 'post_publish\post' === $settings[ 'event' ] |
|
| 471 | + || 'points_legacy_post_publish\post' === $settings[ 'event' ] |
|
| 472 | 472 | ) { |
| 473 | 473 | |
| 474 | 474 | if ( 'attachment' === $post_type ) { |
| 475 | 475 | |
| 476 | - $settings['event'] = 'media_upload'; |
|
| 476 | + $settings[ 'event' ] = 'media_upload'; |
|
| 477 | 477 | |
| 478 | 478 | } else { |
| 479 | 479 | |
| 480 | - $settings['points_legacy_repeat_blocker'] = array( |
|
| 480 | + $settings[ 'points_legacy_repeat_blocker' ] = array( |
|
| 481 | 481 | 'toggle_on' => true, |
| 482 | 482 | ); |
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - $settings['event'] = str_replace( |
|
| 486 | + $settings[ 'event' ] = str_replace( |
|
| 487 | 487 | '\post' |
| 488 | 488 | , '\\' . $post_type |
| 489 | - , $settings['event'] |
|
| 489 | + , $settings[ 'event' ] |
|
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | - $settings['target'] = str_replace( |
|
| 492 | + $settings[ 'target' ] = str_replace( |
|
| 493 | 493 | '\post' |
| 494 | 494 | , '\\' . $post_type |
| 495 | - , $settings['target'] |
|
| 495 | + , $settings[ 'target' ] |
|
| 496 | 496 | ); |
| 497 | 497 | |
| 498 | - $settings['log_text'] = $this->get_log_text_for_instance( |
|
| 499 | - $settings['points_type'] |
|
| 498 | + $settings[ 'log_text' ] = $this->get_log_text_for_instance( |
|
| 499 | + $settings[ 'points_type' ] |
|
| 500 | 500 | , array( 'post_type' => $post_type ) |
| 501 | 501 | ); |
| 502 | 502 | |
@@ -521,11 +521,11 @@ discard block |
||
| 521 | 521 | return false; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - $this->imported_hooks[] = array( |
|
| 524 | + $this->imported_hooks[ ] = array( |
|
| 525 | 525 | 'order' => $order, |
| 526 | 526 | 'id_base' => $this->legacy_id_base, |
| 527 | 527 | 'instance' => $this->legacy_instance, |
| 528 | - 'points_type' => $settings['points_type'], |
|
| 528 | + 'points_type' => $settings[ 'points_type' ], |
|
| 529 | 529 | 'reaction_id' => $reaction->get_id(), |
| 530 | 530 | ); |
| 531 | 531 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | protected function verify_settings( $instance ) { |
| 52 | 52 | |
| 53 | - if ( empty( $instance['num_users'] ) ) { |
|
| 54 | - $instance['num_users'] = $this->defaults['num_users']; |
|
| 53 | + if ( empty( $instance[ 'num_users' ] ) ) { |
|
| 54 | + $instance[ 'num_users' ] = $this->defaults[ 'num_users' ]; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return parent::verify_settings( $instance ); |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | protected function widget_body( $instance ) { |
| 65 | 65 | |
| 66 | 66 | wordpoints_points_show_top_users( |
| 67 | - $instance['num_users'] |
|
| 68 | - , $instance['points_type'] |
|
| 67 | + $instance[ 'num_users' ] |
|
| 68 | + , $instance[ 'points_type' ] |
|
| 69 | 69 | , 'widget' |
| 70 | 70 | ); |
| 71 | 71 | } |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | parent::update( $new_instance, $old_instance ); |
| 87 | 87 | |
| 88 | - if ( ! wordpoints_posint( $this->instance['num_users'] ) ) { |
|
| 89 | - $this->instance['num_users'] = $this->defaults['num_users']; |
|
| 88 | + if ( ! wordpoints_posint( $this->instance[ 'num_users' ] ) ) { |
|
| 89 | + $this->instance[ 'num_users' ] = $this->defaults[ 'num_users' ]; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $this->instance; |
@@ -100,15 +100,15 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | parent::form( $instance ); |
| 102 | 102 | |
| 103 | - if ( ! wordpoints_posint( $this->instance['num_users'] ) ) { |
|
| 104 | - $this->instance['num_users'] = $this->defaults['num_users']; |
|
| 103 | + if ( ! wordpoints_posint( $this->instance[ 'num_users' ] ) ) { |
|
| 104 | + $this->instance[ 'num_users' ] = $this->defaults[ 'num_users' ]; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | ?> |
| 108 | 108 | |
| 109 | 109 | <p> |
| 110 | 110 | <label for="<?php echo esc_attr( $this->get_field_id( 'num_users' ) ); ?>"><?php esc_html_e( 'Number of top users to show', 'wordpoints' ); ?></label> |
| 111 | - <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'] ); ?>" /> |
|
| 111 | + <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' ] ); ?>" /> |
|
| 112 | 112 | </p> |
| 113 | 113 | |
| 114 | 114 | <?php |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | protected function before_update() { |
| 81 | 81 | |
| 82 | 82 | if ( $this->network_wide ) { |
| 83 | - unset( $this->updates['1_8_0'] ); |
|
| 83 | + unset( $this->updates[ '1_8_0' ] ); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $args['slug'] = $type; |
|
| 63 | + $args[ 'slug' ] = $type; |
|
| 64 | 64 | |
| 65 | 65 | self::$types[ $type ] = new $class( $args ); |
| 66 | 66 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $rank = wordpoints_get_formatted_user_rank( |
| 22 | 22 | get_current_user_id() |
| 23 | - , "points_type-{$instance['points_type']}" |
|
| 23 | + , "points_type-{$instance[ 'points_type' ]}" |
|
| 24 | 24 | , 'my-points-widget' |
| 25 | 25 | , array( 'widget_settings' => $instance ) |
| 26 | 26 | ); |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | function wordpoints_user_rank_shortcode_points_type_attr( $out, $pairs, $atts ) { |
| 78 | 78 | |
| 79 | - if ( empty( $out['rank_group'] ) ) { |
|
| 79 | + if ( empty( $out[ 'rank_group' ] ) ) { |
|
| 80 | 80 | |
| 81 | - if ( isset( $atts['points_type'] ) ) { |
|
| 81 | + if ( isset( $atts[ 'points_type' ] ) ) { |
|
| 82 | 82 | |
| 83 | - $out['rank_group'] = "points_type-{$atts['points_type']}"; |
|
| 83 | + $out[ 'rank_group' ] = "points_type-{$atts[ 'points_type' ]}"; |
|
| 84 | 84 | |
| 85 | 85 | } else { |
| 86 | 86 | |
| 87 | 87 | $points_type = wordpoints_get_default_points_type(); |
| 88 | 88 | |
| 89 | 89 | if ( $points_type ) { |
| 90 | - $out['rank_group'] = "points_type-{$points_type}"; |
|
| 90 | + $out[ 'rank_group' ] = "points_type-{$points_type}"; |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | WordPoints_Rank_Groups::register_group( |
| 110 | 110 | "points_type-{$slug}" |
| 111 | 111 | , array( |
| 112 | - 'name' => $points_type['name'], |
|
| 112 | + 'name' => $points_type[ 'name' ], |
|
| 113 | 113 | 'description' => sprintf( |
| 114 | 114 | // translators: Points type name. |
| 115 | 115 | __( 'This rank group is associated with the “%s” points type.', 'wordpoints' ) |
| 116 | - , $points_type['name'] |
|
| 116 | + , $points_type[ 'name' ] |
|
| 117 | 117 | ), |
| 118 | 118 | ) |
| 119 | 119 | ); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | ?> |
| 172 | 172 | |
| 173 | - <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_ranks&tab=points_type-' . $points_type['slug'] ) ); ?>"> |
|
| 173 | + <a href="<?php echo esc_url( self_admin_url( 'admin.php?page=wordpoints_ranks&tab=points_type-' . $points_type[ 'slug' ] ) ); ?>"> |
|
| 174 | 174 | <?php esc_html_e( 'Go to the ranks for this points type.', 'wordpoints' ); ?> |
| 175 | 175 | </a> |
| 176 | 176 | |