@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @since 1.7.0 |
40 | 40 | */ |
41 | - public function __construct( array $args ) { |
|
41 | + public function __construct(array $args) { |
|
42 | 42 | |
43 | - parent::__construct( $args ); |
|
43 | + parent::__construct($args); |
|
44 | 44 | |
45 | - $this->name = _x( 'Points', 'rank type', 'wordpoints' ); |
|
45 | + $this->name = _x('Points', 'rank type', 'wordpoints'); |
|
46 | 46 | |
47 | - if ( ! isset( $args['points_type'] ) ) { |
|
47 | + if ( ! isset($args['points_type'])) { |
|
48 | 48 | _doing_it_wrong( |
49 | 49 | __METHOD__ |
50 | 50 | , 'WordPoints Error: The "points_type" argument is required.' |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - $this->meta_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' ); |
|
56 | + $this->meta_fields['points']['label'] = _x('Points', 'form label', 'wordpoints'); |
|
57 | 57 | $this->meta_fields['points_type']['default'] = $args['points_type']; |
58 | 58 | |
59 | - add_action( 'wordpoints_points_altered', array( $this, 'hook' ), 10, 3 ); |
|
59 | + add_action('wordpoints_points_altered', array($this, 'hook'), 10, 3); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function destruct() { |
68 | 68 | |
69 | - remove_action( 'wordpoints_points_altered', array( $this, 'hook' ), 10 ); |
|
69 | + remove_action('wordpoints_points_altered', array($this, 'hook'), 10); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -78,47 +78,47 @@ discard block |
||
78 | 78 | * @param int $points The number of points. |
79 | 79 | * @param string $points_type The type of points. |
80 | 80 | */ |
81 | - public function hook( $user_id, $points, $points_type ) { |
|
81 | + public function hook($user_id, $points, $points_type) { |
|
82 | 82 | |
83 | - if ( $points_type !== $this->meta_fields['points_type']['default'] ) { |
|
83 | + if ($points_type !== $this->meta_fields['points_type']['default']) { |
|
84 | 84 | return; |
85 | 85 | } |
86 | 86 | |
87 | - $this->maybe_transition_user_ranks( $user_id, $points > 0 ); |
|
87 | + $this->maybe_transition_user_ranks($user_id, $points > 0); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @since 1.7.0 |
92 | 92 | */ |
93 | - public function validate_rank_meta( array $meta ) { |
|
93 | + public function validate_rank_meta(array $meta) { |
|
94 | 94 | |
95 | - if ( ! isset( $meta['points'] ) || false === wordpoints_int( $meta['points'] ) ) { |
|
95 | + if ( ! isset($meta['points']) || false === wordpoints_int($meta['points'])) { |
|
96 | 96 | return new WP_Error( |
97 | 97 | 'wordpoints_points_rank_type_invalid_points' |
98 | - , __( 'The amount of points is required, and must be a valid number.', 'wordpoints' ) |
|
99 | - , array( 'field' => 'points' ) |
|
98 | + , __('The amount of points is required, and must be a valid number.', 'wordpoints') |
|
99 | + , array('field' => 'points') |
|
100 | 100 | ); |
101 | 101 | } |
102 | 102 | |
103 | 103 | if ( |
104 | - ! isset( $meta['points_type'] ) |
|
105 | - || ! wordpoints_is_points_type( $meta['points_type'] ) |
|
104 | + ! isset($meta['points_type']) |
|
105 | + || ! wordpoints_is_points_type($meta['points_type']) |
|
106 | 106 | ) { |
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | |
110 | - $minimum = wordpoints_get_points_minimum( $meta['points_type'] ); |
|
110 | + $minimum = wordpoints_get_points_minimum($meta['points_type']); |
|
111 | 111 | |
112 | - if ( $meta['points'] < $minimum ) { |
|
112 | + if ($meta['points'] < $minimum) { |
|
113 | 113 | |
114 | 114 | return new WP_Error( |
115 | 115 | 'wordpoints_points_rank_type_points_less_than_minimum' |
116 | 116 | , sprintf( |
117 | 117 | // translators: Minimum number of points. |
118 | - __( 'The number of points must be more than the minimum (%s).', 'wordpoints' ) |
|
119 | - , wordpoints_format_points( $minimum, $meta['points_type'], 'points_rank_error' ) |
|
118 | + __('The number of points must be more than the minimum (%s).', 'wordpoints') |
|
119 | + , wordpoints_format_points($minimum, $meta['points_type'], 'points_rank_error') |
|
120 | 120 | ) |
121 | - , array( 'field' => 'points' ) |
|
121 | + , array('field' => 'points') |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return bool Whether the user meets the requirements for this rank. |
143 | 143 | */ |
144 | - protected function can_transition_user_rank( $user_id, $rank, array $args ) { |
|
144 | + protected function can_transition_user_rank($user_id, $rank, array $args) { |
|
145 | 145 | |
146 | - if ( $rank->points_type !== $this->meta_fields['points_type']['default'] ) { |
|
146 | + if ($rank->points_type !== $this->meta_fields['points_type']['default']) { |
|
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | |
150 | - $user_points = wordpoints_get_points( $user_id, $rank->points_type ); |
|
150 | + $user_points = wordpoints_get_points($user_id, $rank->points_type); |
|
151 | 151 | |
152 | - if ( $rank->points > $user_points ) { |
|
152 | + if ($rank->points > $user_points) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @WordPress\filter wordpoints_points_widget_text 30 After esc_html(). |
16 | 16 | */ |
17 | -function wordpoints_ranks_points_widget_text_filter( $text, $instance ) { |
|
17 | +function wordpoints_ranks_points_widget_text_filter($text, $instance) { |
|
18 | 18 | |
19 | - if ( is_user_logged_in() ) { |
|
19 | + if (is_user_logged_in()) { |
|
20 | 20 | |
21 | 21 | $rank = wordpoints_get_formatted_user_rank( |
22 | 22 | get_current_user_id() |
23 | 23 | , "points_type-{$instance['points_type']}" |
24 | 24 | , 'my-points-widget' |
25 | - , array( 'widget_settings' => $instance ) |
|
25 | + , array('widget_settings' => $instance) |
|
26 | 26 | ); |
27 | 27 | |
28 | - $text = str_replace( '%rank%', $rank, $text ); |
|
28 | + $text = str_replace('%rank%', $rank, $text); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | return $text; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ?> |
44 | 44 | <br /> |
45 | 45 | <?php // translators: Placeholder name. ?> |
46 | - <small><i><?php echo esc_html( sprintf( __( '%s will be replaced with the rank of the logged in user', 'wordpoints' ), '%rank%' ) ); ?></i></small> |
|
46 | + <small><i><?php echo esc_html(sprintf(__('%s will be replaced with the rank of the logged in user', 'wordpoints'), '%rank%')); ?></i></small> |
|
47 | 47 | <?php |
48 | 48 | } |
49 | 49 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @WordPress\filter wordpoints_points_top_users_username |
56 | 56 | */ |
57 | -function wordpoints_ranks_points_top_users_username_filter( $name, $user_id, $points_type, $context ) { |
|
57 | +function wordpoints_ranks_points_top_users_username_filter($name, $user_id, $points_type, $context) { |
|
58 | 58 | |
59 | 59 | $rank = wordpoints_get_formatted_user_rank( |
60 | 60 | $user_id |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @WordPress\filter shortcode_atts_wordpoints_user_rank |
76 | 76 | */ |
77 | -function wordpoints_user_rank_shortcode_points_type_attr( $out, $pairs, $atts ) { |
|
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 | 83 | $out['rank_group'] = "points_type-{$atts['points_type']}"; |
84 | 84 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $points_type = wordpoints_get_default_points_type(); |
88 | 88 | |
89 | - if ( $points_type ) { |
|
89 | + if ($points_type) { |
|
90 | 90 | $out['rank_group'] = "points_type-{$points_type}"; |
91 | 91 | } |
92 | 92 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function wordpoints_register_points_ranks() { |
106 | 106 | |
107 | - foreach ( wordpoints_get_points_types() as $slug => $points_type ) { |
|
107 | + foreach (wordpoints_get_points_types() as $slug => $points_type) { |
|
108 | 108 | |
109 | 109 | WordPoints_Rank_Groups::register_group( |
110 | 110 | "points_type-{$slug}" |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | 'name' => $points_type['name'], |
113 | 113 | 'description' => sprintf( |
114 | 114 | // translators: Points type name. |
115 | - __( 'This rank group is associated with the “%s” points type.', 'wordpoints' ) |
|
115 | + __('This rank group is associated with the “%s” points type.', 'wordpoints') |
|
116 | 116 | , $points_type['name'] |
117 | 117 | ), |
118 | 118 | ) |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | WordPoints_Rank_Types::register_type( |
122 | 122 | "points-{$slug}" |
123 | 123 | , 'WordPoints_Points_Rank_Type' |
124 | - , array( 'points_type' => $slug ) |
|
124 | + , array('points_type' => $slug) |
|
125 | 125 | ); |
126 | 126 | |
127 | 127 | WordPoints_Rank_Groups::register_type_for_group( |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | |
146 | 146 | $tab = wordpoints_admin_get_current_tab(); |
147 | 147 | |
148 | - if ( 'add-new' === $tab ) { |
|
148 | + if ('add-new' === $tab) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | 152 | add_meta_box( |
153 | 153 | 'ranks' |
154 | - , _x( 'Ranks', 'Points Types screen meta box title', 'wordpoints' ) |
|
154 | + , _x('Ranks', 'Points Types screen meta box title', 'wordpoints') |
|
155 | 155 | , 'wordpoints_ranks_display_points_types_meta_box_ranks' |
156 | 156 | , 'wordpoints_page_wordpoints_points_types' |
157 | 157 | , 'side' |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param array $points_type The data for the points type being edited. |
168 | 168 | */ |
169 | -function wordpoints_ranks_display_points_types_meta_box_ranks( $points_type ) { |
|
169 | +function wordpoints_ranks_display_points_types_meta_box_ranks($points_type) { |
|
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'] ) ); ?>"> |
|
174 | - <?php esc_html_e( 'Go to the ranks for this points type.', 'wordpoints' ); ?> |
|
173 | + <a href="<?php echo esc_url(self_admin_url('admin.php?page=wordpoints_ranks&tab=points_type-' . $points_type['slug'])); ?>"> |
|
174 | + <?php esc_html_e('Go to the ranks for this points type.', 'wordpoints'); ?> |
|
175 | 175 | </a> |
176 | 176 | |
177 | 177 | <?php |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | |
10 | 10 | $rank_groups = WordPoints_Rank_Groups::get(); |
11 | 11 | |
12 | -if ( empty( $rank_groups ) ) { |
|
12 | +if (empty($rank_groups)) { |
|
13 | 13 | |
14 | 14 | ?> |
15 | 15 | <div class="wrap"> |
16 | - <?php wordpoints_show_admin_error( esc_html__( 'No rank groups are currently available.', 'wordpoints' ) ); ?> |
|
16 | + <?php wordpoints_show_admin_error(esc_html__('No rank groups are currently available.', 'wordpoints')); ?> |
|
17 | 17 | </div> |
18 | 18 | <?php |
19 | 19 | |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | -$rank_group = $rank_groups[ wordpoints_admin_get_current_tab( $rank_groups ) ]; |
|
23 | +$rank_group = $rank_groups[wordpoints_admin_get_current_tab($rank_groups)]; |
|
24 | 24 | |
25 | 25 | ?> |
26 | 26 | |
27 | 27 | <div class="wrap"> |
28 | - <h1><?php esc_html_e( 'Ranks', 'wordpoints' ); ?></h1> |
|
28 | + <h1><?php esc_html_e('Ranks', 'wordpoints'); ?></h1> |
|
29 | 29 | |
30 | - <?php wordpoints_admin_show_tabs( wp_list_pluck( $rank_groups, 'name' ), false ) ?> |
|
30 | + <?php wordpoints_admin_show_tabs(wp_list_pluck($rank_groups, 'name'), false) ?> |
|
31 | 31 | |
32 | 32 | <div id="ranks-error-message" class="notice notice-error hidden"> |
33 | 33 | <p></p> |
@@ -42,34 +42,34 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param WordPoints_Rank_Group $rank_group The rank group being displayed. |
44 | 44 | */ |
45 | - do_action( 'wordpoints_ranks_admin_screen_top', $rank_group ); |
|
45 | + do_action('wordpoints_ranks_admin_screen_top', $rank_group); |
|
46 | 46 | |
47 | 47 | ?> |
48 | 48 | |
49 | 49 | <div class="wordpoints-rank-group-container"> |
50 | - <p class="description group-description"><?php echo esc_html( $rank_group->description ); ?></p> |
|
50 | + <p class="description group-description"><?php echo esc_html($rank_group->description); ?></p> |
|
51 | 51 | <ul |
52 | - id="wordpoints-rank-group_<?php echo esc_attr( $rank_group->slug ); ?>" |
|
52 | + id="wordpoints-rank-group_<?php echo esc_attr($rank_group->slug); ?>" |
|
53 | 53 | class="wordpoints-rank-group" |
54 | - data-slug="<?php echo esc_attr( $rank_group->slug ); ?>" |
|
55 | - data-nonce="<?php echo esc_attr( wp_create_nonce( "wordpoints_get_ranks-{$rank_group->slug}" ) ); ?>" |
|
54 | + data-slug="<?php echo esc_attr($rank_group->slug); ?>" |
|
55 | + data-nonce="<?php echo esc_attr(wp_create_nonce("wordpoints_get_ranks-{$rank_group->slug}")); ?>" |
|
56 | 56 | > |
57 | 57 | </ul> |
58 | 58 | <div class="spinner-overlay" style="display: block;"> |
59 | 59 | <span class="spinner is-active"></span> |
60 | 60 | </div> |
61 | 61 | <div class="controls"> |
62 | - <button class="add-rank button-primary"><?php esc_html_e( 'Add Rank', 'wordpoints' ); ?></button> |
|
62 | + <button class="add-rank button-primary"><?php esc_html_e('Add Rank', 'wordpoints'); ?></button> |
|
63 | 63 | <label class="wordpoints-rank-types"> |
64 | - <?php esc_html_e( 'Rank Type:', 'wordpoints' ); ?> |
|
64 | + <?php esc_html_e('Rank Type:', 'wordpoints'); ?> |
|
65 | 65 | <select> |
66 | - <?php foreach ( $rank_group->get_types() as $rank_type ) : ?> |
|
67 | - <?php if ( 'base' !== $rank_type ) : ?> |
|
66 | + <?php foreach ($rank_group->get_types() as $rank_type) : ?> |
|
67 | + <?php if ('base' !== $rank_type) : ?> |
|
68 | 68 | <option |
69 | - value="<?php echo esc_attr( $rank_type ); ?>" |
|
70 | - data-nonce="<?php echo esc_attr( wp_create_nonce( "wordpoints_create_rank|{$rank_group->slug}|{$rank_type}" ) ); ?>" |
|
69 | + value="<?php echo esc_attr($rank_type); ?>" |
|
70 | + data-nonce="<?php echo esc_attr(wp_create_nonce("wordpoints_create_rank|{$rank_group->slug}|{$rank_type}")); ?>" |
|
71 | 71 | > |
72 | - <?php echo esc_html( WordPoints_Rank_Types::get_type( $rank_type )->get_name() ); ?> |
|
72 | + <?php echo esc_html(WordPoints_Rank_Types::get_type($rank_type)->get_name()); ?> |
|
73 | 73 | </option> |
74 | 74 | <?php endif; ?> |
75 | 75 | <?php endforeach; ?> |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param WordPoints_Rank_Group $rank_group The rank group being displayed. |
88 | 88 | */ |
89 | - do_action( 'wordpoints_ranks_admin_screen_bottom', $rank_group ); |
|
89 | + do_action('wordpoints_ranks_admin_screen_bottom', $rank_group); |
|
90 | 90 | |
91 | 91 | ?> |
92 | 92 | </div> |
93 | 93 | |
94 | -<?php foreach ( $rank_group->get_types() as $rank_type ) : ?> |
|
95 | - <script type="text/template" class="rank-template_<?php echo sanitize_html_class( $rank_type ); ?>"> |
|
94 | +<?php foreach ($rank_group->get_types() as $rank_type) : ?> |
|
95 | + <script type="text/template" class="rank-template_<?php echo sanitize_html_class($rank_type); ?>"> |
|
96 | 96 | <div class="view"> |
97 | 97 | <div> |
98 | 98 | <%- name %> |
@@ -100,31 +100,31 @@ discard block |
||
100 | 100 | |
101 | 101 | $field = key( |
102 | 102 | wp_list_filter( |
103 | - WordPoints_Rank_Types::get_type( $rank_type )->get_meta_fields() |
|
104 | - , array( 'in_title' => true ) |
|
103 | + WordPoints_Rank_Types::get_type($rank_type)->get_meta_fields() |
|
104 | + , array('in_title' => true) |
|
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | |
108 | 108 | ?> |
109 | - <?php if ( $field ) : ?> |
|
110 | - <span><% if ( typeof <?php echo preg_replace( '/[^a-z0-9_]/i', '', $field ); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace( '/[^a-z0-9_]/i', '', $field ); // WPCS: XSS OK ?> ); } %></span> |
|
109 | + <?php if ($field) : ?> |
|
110 | + <span><% if ( typeof <?php echo preg_replace('/[^a-z0-9_]/i', '', $field); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace('/[^a-z0-9_]/i', '', $field); // WPCS: XSS OK ?> ); } %></span> |
|
111 | 111 | <?php endif; ?> |
112 | 112 | </div> |
113 | - <a class="edit"><?php echo esc_html_x( 'Edit', 'rank', 'wordpoints' ); ?></a> |
|
114 | - <a class="close"><?php esc_html_e( 'Close', 'wordpoints' ); ?></a> |
|
113 | + <a class="edit"><?php echo esc_html_x('Edit', 'rank', 'wordpoints'); ?></a> |
|
114 | + <a class="close"><?php esc_html_e('Close', 'wordpoints'); ?></a> |
|
115 | 115 | </div> |
116 | 116 | <form> |
117 | 117 | <div class="fields"> |
118 | 118 | <p class="description description-thin"> |
119 | 119 | <label> |
120 | - <?php echo esc_html_x( 'Title', 'rank', 'wordpoints' ); ?> |
|
120 | + <?php echo esc_html_x('Title', 'rank', 'wordpoints'); ?> |
|
121 | 121 | <input class="widefat" type="text" value="<%- name %>" name="name" /> |
122 | 122 | </label> |
123 | 123 | </p> |
124 | - <input type="hidden" name="type" value="<?php echo esc_attr( $rank_type ); ?>" /> |
|
124 | + <input type="hidden" name="type" value="<?php echo esc_attr($rank_type); ?>" /> |
|
125 | 125 | <input type="hidden" name="order" value="<%- order %>" /> |
126 | 126 | <input type="hidden" name="nonce" value="<%- nonce %>" /> |
127 | - <?php WordPoints_Rank_Types::get_type( $rank_type )->display_rank_meta_form_fields( array(), array( 'placeholders' => true ) ); ?> |
|
127 | + <?php WordPoints_Rank_Types::get_type($rank_type)->display_rank_meta_form_fields(array(), array('placeholders' => true)); ?> |
|
128 | 128 | </div> |
129 | 129 | <div class="messages"> |
130 | 130 | <div class="success"></div> |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | <span class="spinner is-active"></span> |
136 | 136 | </div> |
137 | 137 | <div class="action-buttons"> |
138 | - <button class="save button-primary" disabled><?php esc_html_e( 'Save', 'wordpoints' ); ?></button> |
|
139 | - <button class="cancel button-secondary"><?php esc_html_e( 'Cancel', 'wordpoints' ); ?></button> |
|
140 | - <button class="close button-secondary"><?php esc_html_e( 'Close', 'wordpoints' ); ?></button> |
|
141 | - <?php if ( 'base' !== $rank_type ) : ?> |
|
142 | - <button class="delete button-secondary"><?php esc_html_e( 'Delete', 'wordpoints' ); ?></button> |
|
138 | + <button class="save button-primary" disabled><?php esc_html_e('Save', 'wordpoints'); ?></button> |
|
139 | + <button class="cancel button-secondary"><?php esc_html_e('Cancel', 'wordpoints'); ?></button> |
|
140 | + <button class="close button-secondary"><?php esc_html_e('Close', 'wordpoints'); ?></button> |
|
141 | + <?php if ('base' !== $rank_type) : ?> |
|
142 | + <button class="delete button-secondary"><?php esc_html_e('Delete', 'wordpoints'); ?></button> |
|
143 | 143 | <?php endif; ?> |
144 | 144 | </div> |
145 | 145 | </div> |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $rank_groups = WordPoints_Rank_Groups::get(); |
67 | 67 | $ranks = array(); |
68 | 68 | |
69 | - foreach ( $rank_groups as $group ) { |
|
70 | - $ranks[ $group->slug ] = self::prepare_group_ranks( $group ); |
|
69 | + foreach ($rank_groups as $group) { |
|
70 | + $ranks[$group->slug] = self::prepare_group_ranks($group); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $ranks; |
@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return array The ranks of this group, prepared for sending to the JS. |
84 | 84 | */ |
85 | - public static function prepare_group_ranks( $group ) { |
|
85 | + public static function prepare_group_ranks($group) { |
|
86 | 86 | |
87 | 87 | $rank_ids = $group->get_ranks(); |
88 | 88 | $ranks = array(); |
89 | 89 | |
90 | - foreach ( $rank_ids as $order => $rank_id ) { |
|
90 | + foreach ($rank_ids as $order => $rank_id) { |
|
91 | 91 | |
92 | - $rank = wordpoints_get_rank( $rank_id ); |
|
92 | + $rank = wordpoints_get_rank($rank_id); |
|
93 | 93 | |
94 | - if ( ! $rank ) { |
|
94 | + if ( ! $rank) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
98 | - $ranks[] = self::_prepare_rank( $rank ); |
|
98 | + $ranks[] = self::_prepare_rank($rank); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $ranks; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function __construct() { |
114 | 114 | |
115 | - if ( isset( self::$instance ) ) { |
|
116 | - _doing_it_wrong( __METHOD__, 'Class should only be constructed once.', '1.7.0' ); |
|
115 | + if (isset(self::$instance)) { |
|
116 | + _doing_it_wrong(__METHOD__, 'Class should only be constructed once.', '1.7.0'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | self::$instance = $this; |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function hooks() { |
130 | 130 | |
131 | - add_action( 'wp_ajax_wordpoints_admin_get_ranks', array( $this, 'get_ranks' ) ); |
|
132 | - add_action( 'wp_ajax_wordpoints_admin_create_rank', array( $this, 'create_rank' ) ); |
|
133 | - add_action( 'wp_ajax_wordpoints_admin_update_rank', array( $this, 'update_rank' ) ); |
|
134 | - add_action( 'wp_ajax_wordpoints_admin_delete_rank', array( $this, 'delete_rank' ) ); |
|
131 | + add_action('wp_ajax_wordpoints_admin_get_ranks', array($this, 'get_ranks')); |
|
132 | + add_action('wp_ajax_wordpoints_admin_create_rank', array($this, 'create_rank')); |
|
133 | + add_action('wp_ajax_wordpoints_admin_update_rank', array($this, 'update_rank')); |
|
134 | + add_action('wp_ajax_wordpoints_admin_delete_rank', array($this, 'delete_rank')); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | |
146 | 146 | $group = $this->_get_group(); |
147 | 147 | |
148 | - $this->_verify_request( "wordpoints_get_ranks-{$group->slug}" ); |
|
148 | + $this->_verify_request("wordpoints_get_ranks-{$group->slug}"); |
|
149 | 149 | |
150 | - wp_send_json_success( self::prepare_group_ranks( $group ) ); |
|
150 | + wp_send_json_success(self::prepare_group_ranks($group)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $group = $this->_get_group(); |
163 | 163 | $type = $this->_get_rank_type()->get_slug(); |
164 | 164 | |
165 | - $this->_verify_request( "wordpoints_create_rank|{$group->slug}|{$type}" ); |
|
165 | + $this->_verify_request("wordpoints_create_rank|{$group->slug}|{$type}"); |
|
166 | 166 | |
167 | 167 | // Attempt to save the rank. |
168 | 168 | $result = wordpoints_add_rank( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | , $this->_get_rank_meta() |
174 | 174 | ); |
175 | 175 | |
176 | - $this->_send_json_result( $result, 'create' ); |
|
176 | + $this->_send_json_result($result, 'create'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | |
195 | 195 | $type = $this->_get_rank_type()->get_slug(); |
196 | 196 | |
197 | - if ( $type !== $rank->type ) { |
|
198 | - wp_send_json_error( array( 'message' => __( 'This rank does not match any rank in the database, perhaps it was deleted. Refresh the page to update the list of ranks.', 'wordpoints' ) ) ); |
|
197 | + if ($type !== $rank->type) { |
|
198 | + wp_send_json_error(array('message' => __('This rank does not match any rank in the database, perhaps it was deleted. Refresh the page to update the list of ranks.', 'wordpoints'))); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $result = wordpoints_update_rank( |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | , $this->_get_rank_meta() |
208 | 208 | ); |
209 | 209 | |
210 | - $this->_send_json_result( $result, 'update' ); |
|
210 | + $this->_send_json_result($result, 'update'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | "wordpoints_delete_rank|{$group->slug}|{$rank->ID}" |
227 | 227 | ); |
228 | 228 | |
229 | - $result = wordpoints_delete_rank( $rank->ID ); |
|
229 | + $result = wordpoints_delete_rank($rank->ID); |
|
230 | 230 | |
231 | - if ( ! $result ) { |
|
232 | - wp_send_json_error( array( 'message' => __( 'There was an error deleting the rank. Please try again.', 'wordpoints' ) ) ); |
|
231 | + if ( ! $result) { |
|
232 | + wp_send_json_error(array('message' => __('There was an error deleting the rank. Please try again.', 'wordpoints'))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | wp_send_json_success(); |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @param string $debug_context Context sent with the message (for debugging). |
252 | 252 | */ |
253 | - private function _unexpected_error( $debug_context ) { |
|
253 | + private function _unexpected_error($debug_context) { |
|
254 | 254 | |
255 | 255 | wp_send_json_error( |
256 | 256 | array( |
257 | - 'message' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
257 | + 'message' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
258 | 258 | 'debug' => $debug_context, |
259 | 259 | ) |
260 | 260 | ); |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | */ |
271 | 271 | private function _verify_user_can() { |
272 | 272 | |
273 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
274 | - wp_send_json_error( array( 'message' => __( 'Sorry, you are not allowed to perform this action. Maybe you have been logged out?', 'wordpoints' ) ) ); |
|
273 | + if ( ! current_user_can('manage_options')) { |
|
274 | + wp_send_json_error(array('message' => __('Sorry, you are not allowed to perform this action. Maybe you have been logged out?', 'wordpoints'))); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param string $action The action the nonce should be for. |
286 | 286 | */ |
287 | - private function _verify_request( $action ) { |
|
287 | + private function _verify_request($action) { |
|
288 | 288 | |
289 | 289 | if ( |
290 | - empty( $_POST['nonce'] ) |
|
291 | - || ! wordpoints_verify_nonce( 'nonce', $action, null, 'post' ) |
|
290 | + empty($_POST['nonce']) |
|
291 | + || ! wordpoints_verify_nonce('nonce', $action, null, 'post') |
|
292 | 292 | ) { |
293 | 293 | wp_send_json_error( |
294 | - array( 'message' => __( 'Your security token for this action has expired. Refresh the page and try again.', 'wordpoints' ) ) |
|
294 | + array('message' => __('Your security token for this action has expired. Refresh the page and try again.', 'wordpoints')) |
|
295 | 295 | ); |
296 | 296 | } |
297 | 297 | } |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | */ |
306 | 306 | private function _get_group() { |
307 | 307 | |
308 | - if ( ! isset( $_POST['group'] ) ) { // WPCS: CSRF OK. |
|
309 | - $this->_unexpected_error( 'group' ); |
|
308 | + if ( ! isset($_POST['group'])) { // WPCS: CSRF OK. |
|
309 | + $this->_unexpected_error('group'); |
|
310 | 310 | } |
311 | 311 | |
312 | - $group = WordPoints_Rank_Groups::get_group( sanitize_key( $_POST['group'] ) ); // WPCS: CSRF OK. |
|
312 | + $group = WordPoints_Rank_Groups::get_group(sanitize_key($_POST['group'])); // WPCS: CSRF OK. |
|
313 | 313 | |
314 | - if ( ! $group ) { |
|
315 | - wp_send_json_error( array( 'message' => __( 'The rank group passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) ); |
|
314 | + if ( ! $group) { |
|
315 | + wp_send_json_error(array('message' => __('The rank group passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints'))); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | return $group; |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | */ |
328 | 328 | private function _get_rank() { |
329 | 329 | |
330 | - if ( ! isset( $_POST['id'] ) ) { // WPCS: CSRF OK. |
|
331 | - $this->_unexpected_error( 'id' ); |
|
330 | + if ( ! isset($_POST['id'])) { // WPCS: CSRF OK. |
|
331 | + $this->_unexpected_error('id'); |
|
332 | 332 | } |
333 | 333 | |
334 | - $rank = wordpoints_get_rank( wordpoints_int( $_POST['id'] ) ); // WPCS: CSRF OK. |
|
334 | + $rank = wordpoints_get_rank(wordpoints_int($_POST['id'])); // WPCS: CSRF OK. |
|
335 | 335 | |
336 | - if ( ! $rank ) { |
|
337 | - wp_send_json_error( array( 'message' => __( 'The rank ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints' ) ) ); |
|
336 | + if ( ! $rank) { |
|
337 | + wp_send_json_error(array('message' => __('The rank ID passed to the server is invalid. Perhaps it has been deleted. Try reloading the page.', 'wordpoints'))); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $rank; |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | |
352 | 352 | $name = ''; |
353 | 353 | |
354 | - if ( ! empty( $_POST['name'] ) ) { // WPCS: CSRF OK. |
|
355 | - $name = sanitize_text_field( wp_unslash( $_POST['name'] ) ); // WPCS: CSRF OK. |
|
354 | + if ( ! empty($_POST['name'])) { // WPCS: CSRF OK. |
|
355 | + $name = sanitize_text_field(wp_unslash($_POST['name'])); // WPCS: CSRF OK. |
|
356 | 356 | } |
357 | 357 | |
358 | - if ( ! $name ) { |
|
358 | + if ( ! $name) { |
|
359 | 359 | wp_send_json_error( |
360 | 360 | array( |
361 | - 'message' => __( 'Please enter a name for this rank.', 'wordpoints' ), |
|
361 | + 'message' => __('Please enter a name for this rank.', 'wordpoints'), |
|
362 | 362 | 'field' => 'name', |
363 | 363 | ) |
364 | 364 | ); |
@@ -376,17 +376,17 @@ discard block |
||
376 | 376 | */ |
377 | 377 | private function _get_rank_type() { |
378 | 378 | |
379 | - if ( empty( $_POST['type'] ) ) { // WPCS: CSRF OK. |
|
380 | - $this->_unexpected_error( 'type' ); |
|
379 | + if (empty($_POST['type'])) { // WPCS: CSRF OK. |
|
380 | + $this->_unexpected_error('type'); |
|
381 | 381 | } |
382 | 382 | |
383 | - $type = sanitize_text_field( wp_unslash( $_POST['type'] ) ); // WPCS: CSRF OK. |
|
383 | + $type = sanitize_text_field(wp_unslash($_POST['type'])); // WPCS: CSRF OK. |
|
384 | 384 | |
385 | - if ( ! WordPoints_Rank_Types::is_type_registered( $type ) ) { |
|
386 | - wp_send_json_error( array( 'message' => __( 'That rank type was not recognized. It may no longer be available. Try reloading the page.', 'wordpoints' ) ) ); |
|
385 | + if ( ! WordPoints_Rank_Types::is_type_registered($type)) { |
|
386 | + wp_send_json_error(array('message' => __('That rank type was not recognized. It may no longer be available. Try reloading the page.', 'wordpoints'))); |
|
387 | 387 | } |
388 | 388 | |
389 | - $this->rank_type = WordPoints_Rank_Types::get_type( $type ); |
|
389 | + $this->rank_type = WordPoints_Rank_Types::get_type($type); |
|
390 | 390 | |
391 | 391 | return $this->rank_type; |
392 | 392 | } |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | private function _get_rank_position() { |
402 | 402 | |
403 | 403 | if ( |
404 | - ! isset( $_POST['order'] ) // WPCS: CSRF OK. |
|
405 | - || false === wordpoints_int( $_POST['order'] ) // WPCS: CSRF OK. |
|
404 | + ! isset($_POST['order']) // WPCS: CSRF OK. |
|
405 | + || false === wordpoints_int($_POST['order']) // WPCS: CSRF OK. |
|
406 | 406 | ) { |
407 | - $this->_unexpected_error( 'order' ); |
|
407 | + $this->_unexpected_error('order'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | return (int) $_POST['order']; |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | private function _get_rank_meta() { |
421 | 421 | |
422 | 422 | return array_intersect_key( |
423 | - wp_unslash( $_POST ) // WPCS: CSRF OK. |
|
423 | + wp_unslash($_POST) // WPCS: CSRF OK. |
|
424 | 424 | , $this->rank_type->get_meta_fields() |
425 | 425 | ); |
426 | 426 | } |
@@ -433,19 +433,19 @@ discard block |
||
433 | 433 | * @param mixed $result The result of the action. |
434 | 434 | * @param string $action The action being performed: 'create' or 'update'. |
435 | 435 | */ |
436 | - private function _send_json_result( $result, $action ) { |
|
436 | + private function _send_json_result($result, $action) { |
|
437 | 437 | |
438 | - if ( ! $result ) { |
|
438 | + if ( ! $result) { |
|
439 | 439 | |
440 | - if ( 'create' === $action ) { |
|
441 | - $message = __( 'There was an error adding the rank. Please try again.', 'wordpoints' ); |
|
440 | + if ('create' === $action) { |
|
441 | + $message = __('There was an error adding the rank. Please try again.', 'wordpoints'); |
|
442 | 442 | } else { |
443 | - $message = __( 'There was an error updating the rank. Please try again.', 'wordpoints' ); |
|
443 | + $message = __('There was an error updating the rank. Please try again.', 'wordpoints'); |
|
444 | 444 | } |
445 | 445 | |
446 | - wp_send_json_error( array( 'message' => $message ) ); |
|
446 | + wp_send_json_error(array('message' => $message)); |
|
447 | 447 | |
448 | - } elseif ( is_wp_error( $result ) ) { |
|
448 | + } elseif (is_wp_error($result)) { |
|
449 | 449 | |
450 | 450 | wp_send_json_error( |
451 | 451 | array( |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | |
458 | 458 | $data = null; |
459 | 459 | |
460 | - if ( 'create' === $action ) { |
|
461 | - $data = self::_prepare_rank( wordpoints_get_rank( $result ) ); |
|
460 | + if ('create' === $action) { |
|
461 | + $data = self::_prepare_rank(wordpoints_get_rank($result)); |
|
462 | 462 | } |
463 | 463 | |
464 | - wp_send_json_success( $data ); |
|
464 | + wp_send_json_success($data); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | // |
@@ -477,15 +477,15 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return array The rank data extracted into an array. |
479 | 479 | */ |
480 | - private static function _prepare_rank( $rank ) { |
|
480 | + private static function _prepare_rank($rank) { |
|
481 | 481 | |
482 | 482 | $name = $rank->name; |
483 | - if ( empty( $name ) ) { |
|
484 | - $name = __( '(no title)', 'wordpoints' ); |
|
483 | + if (empty($name)) { |
|
484 | + $name = __('(no title)', 'wordpoints'); |
|
485 | 485 | } |
486 | 486 | |
487 | - $order = WordPoints_Rank_Groups::get_group( $rank->rank_group ) |
|
488 | - ->get_rank_position( $rank->ID ); |
|
487 | + $order = WordPoints_Rank_Groups::get_group($rank->rank_group) |
|
488 | + ->get_rank_position($rank->ID); |
|
489 | 489 | |
490 | 490 | $prepared_rank = array( |
491 | 491 | 'id' => $rank->ID, |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | ), |
501 | 501 | ); |
502 | 502 | |
503 | - $rank_type = WordPoints_Rank_Types::get_type( $rank->type ); |
|
503 | + $rank_type = WordPoints_Rank_Types::get_type($rank->type); |
|
504 | 504 | |
505 | - foreach ( $rank_type->get_meta_fields() as $field => $data ) { |
|
506 | - $prepared_rank[ $field ] = $rank->{$field}; |
|
505 | + foreach ($rank_type->get_meta_fields() as $field => $data) { |
|
506 | + $prepared_rank[$field] = $rank->{$field}; |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | return $prepared_rank; |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 | } |