@@ -7,34 +7,34 @@ |
||
7 | 7 | * @since 2.1.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'init', 'wordpoints_points_admin_register_scripts' ); |
|
10 | +add_action('init', 'wordpoints_points_admin_register_scripts'); |
|
11 | 11 | |
12 | -add_action( 'admin_menu', 'wordpoints_points_admin_menu' ); |
|
12 | +add_action('admin_menu', 'wordpoints_points_admin_menu'); |
|
13 | 13 | |
14 | -if ( is_wordpoints_network_active() ) { |
|
15 | - add_action( 'network_admin_menu', 'wordpoints_points_admin_menu' ); |
|
14 | +if (is_wordpoints_network_active()) { |
|
15 | + add_action('network_admin_menu', 'wordpoints_points_admin_menu'); |
|
16 | 16 | } |
17 | 17 | |
18 | -add_action( 'load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_admin_points_hooks_help' ); |
|
18 | +add_action('load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_admin_points_hooks_help'); |
|
19 | 19 | |
20 | -add_action( 'load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_no_js_points_hooks_save' ); |
|
20 | +add_action('load-wordpoints_page_wordpoints_points_hooks', 'wordpoints_no_js_points_hooks_save'); |
|
21 | 21 | |
22 | -add_action( 'screen_settings', 'wordpoints_admin_points_hooks_screen_options', 10, 2 ); |
|
22 | +add_action('screen_settings', 'wordpoints_admin_points_hooks_screen_options', 10, 2); |
|
23 | 23 | |
24 | -add_action( 'wordpoints_in_points_hook_form', 'wordpoints_points_hook_description_form', 10, 3 ); |
|
24 | +add_action('wordpoints_in_points_hook_form', 'wordpoints_points_hook_description_form', 10, 3); |
|
25 | 25 | |
26 | -add_action( 'personal_options', 'wordpoints_points_profile_options', 20 ); |
|
26 | +add_action('personal_options', 'wordpoints_points_profile_options', 20); |
|
27 | 27 | |
28 | -add_action( 'personal_options_update', 'wordpoints_points_profile_options_update' ); |
|
29 | -add_action( 'edit_user_profile_update', 'wordpoints_points_profile_options_update' ); |
|
28 | +add_action('personal_options_update', 'wordpoints_points_profile_options_update'); |
|
29 | +add_action('edit_user_profile_update', 'wordpoints_points_profile_options_update'); |
|
30 | 30 | |
31 | -add_action( 'wordpoints_admin_settings_top', 'wordpoints_points_admin_settings' ); |
|
31 | +add_action('wordpoints_admin_settings_top', 'wordpoints_points_admin_settings'); |
|
32 | 32 | |
33 | -add_action( 'wordpoints_admin_settings_update', 'wordpoints_points_admin_settings_save' ); |
|
33 | +add_action('wordpoints_admin_settings_update', 'wordpoints_points_admin_settings_save'); |
|
34 | 34 | |
35 | -add_action( 'admin_notices', 'wordpoints_points_admin_notices' ); |
|
35 | +add_action('admin_notices', 'wordpoints_points_admin_notices'); |
|
36 | 36 | |
37 | -add_action( 'wp_ajax_wordpoints-points-hooks-order', 'wordpoints_ajax_points_hooks_order' ); |
|
38 | -add_action( 'wp_ajax_save-wordpoints-points-hook', 'wordpoints_ajax_save_points_hook' ); |
|
37 | +add_action('wp_ajax_wordpoints-points-hooks-order', 'wordpoints_ajax_points_hooks_order'); |
|
38 | +add_action('wp_ajax_save-wordpoints-points-hook', 'wordpoints_ajax_save_points_hook'); |
|
39 | 39 | |
40 | 40 | // EOF |
@@ -16,61 +16,61 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function wordpoints_ajax_points_hooks_order() { |
18 | 18 | |
19 | - if ( check_ajax_referer( 'save-network-wordpoints-points-hooks', 'savehooks', false ) ) { |
|
19 | + if (check_ajax_referer('save-network-wordpoints-points-hooks', 'savehooks', false)) { |
|
20 | 20 | |
21 | - if ( ! current_user_can( 'manage_network_wordpoints_points_hooks' ) ) { |
|
22 | - wp_die( -1, '', array( 'response' => 403 ) ); |
|
21 | + if ( ! current_user_can('manage_network_wordpoints_points_hooks')) { |
|
22 | + wp_die( -1, '', array('response' => 403) ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | // Saving network hooks order, turn on network mode. |
26 | - WordPoints_Points_Hooks::set_network_mode( true ); |
|
26 | + WordPoints_Points_Hooks::set_network_mode(true); |
|
27 | 27 | |
28 | - } elseif ( check_ajax_referer( 'save-wordpoints-points-hooks', 'savehooks', false ) ) { |
|
28 | + } elseif (check_ajax_referer('save-wordpoints-points-hooks', 'savehooks', false)) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
31 | - wp_die( -1, '', array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('manage_options')) { |
|
31 | + wp_die( -1, '', array('response' => 403) ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | } else { |
35 | 35 | |
36 | 36 | // CSRF attack (or, more probably, the user left the browser open too long). |
37 | - wp_die( -1, '', array( 'response' => 403 ) ); |
|
37 | + wp_die( -1, '', array('response' => 403) ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // Save hooks order for all points types. |
41 | - if ( ! isset( $_POST['points_types'] ) || ! is_array( $_POST['points_types'] ) ) { |
|
42 | - wp_die( -1, '', array( 'response' => 400 ) ); |
|
41 | + if ( ! isset($_POST['points_types']) || ! is_array($_POST['points_types'])) { |
|
42 | + wp_die( -1, '', array('response' => 400) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $points_types_hooks = array(); |
46 | 46 | |
47 | - foreach ( array_keys( wordpoints_get_points_types() ) as $points_type ) { |
|
47 | + foreach (array_keys(wordpoints_get_points_types()) as $points_type) { |
|
48 | 48 | |
49 | - if ( empty( $_POST['points_types'][ $points_type ] ) ) { |
|
49 | + if (empty($_POST['points_types'][$points_type])) { |
|
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | |
53 | - $hooks = sanitize_text_field( wp_unslash( $_POST['points_types'][ $points_type ] ) ); |
|
53 | + $hooks = sanitize_text_field(wp_unslash($_POST['points_types'][$points_type])); |
|
54 | 54 | |
55 | 55 | $points_type_hooks = array(); |
56 | 56 | |
57 | - $hooks = explode( ',', $hooks ); |
|
57 | + $hooks = explode(',', $hooks); |
|
58 | 58 | |
59 | - foreach ( $hooks as $order => $hook_id ) { |
|
59 | + foreach ($hooks as $order => $hook_id) { |
|
60 | 60 | |
61 | - if ( false === strpos( $hook_id, 'hook-' ) ) { |
|
61 | + if (false === strpos($hook_id, 'hook-')) { |
|
62 | 62 | continue; |
63 | 63 | } |
64 | 64 | |
65 | - $points_type_hooks[ $order ] = substr( $hook_id, strpos( $hook_id, '_' ) + 1 ); |
|
65 | + $points_type_hooks[$order] = substr($hook_id, strpos($hook_id, '_') + 1); |
|
66 | 66 | } |
67 | 67 | |
68 | - $points_types_hooks[ $points_type ] = $points_type_hooks; |
|
68 | + $points_types_hooks[$points_type] = $points_type_hooks; |
|
69 | 69 | } |
70 | 70 | |
71 | - WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks ); |
|
71 | + WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks); |
|
72 | 72 | |
73 | - wp_die( 1, '', array( 'response' => 200 ) ); |
|
73 | + wp_die(1, '', array('response' => 200)); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -83,30 +83,30 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function wordpoints_ajax_save_points_hook() { |
85 | 85 | |
86 | - if ( check_ajax_referer( 'save-network-wordpoints-points-hooks', 'savehooks', false ) ) { |
|
86 | + if (check_ajax_referer('save-network-wordpoints-points-hooks', 'savehooks', false)) { |
|
87 | 87 | |
88 | - if ( ! current_user_can( 'manage_network_wordpoints_points_hooks' ) ) { |
|
89 | - wp_die( -1, '', array( 'response' => 403 ) ); |
|
88 | + if ( ! current_user_can('manage_network_wordpoints_points_hooks')) { |
|
89 | + wp_die( -1, '', array('response' => 403) ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // Saving network hooks, turn on network mode. |
93 | - WordPoints_Points_Hooks::set_network_mode( true ); |
|
93 | + WordPoints_Points_Hooks::set_network_mode(true); |
|
94 | 94 | |
95 | - } elseif ( check_ajax_referer( 'save-wordpoints-points-hooks', 'savehooks', false ) ) { |
|
95 | + } elseif (check_ajax_referer('save-wordpoints-points-hooks', 'savehooks', false)) { |
|
96 | 96 | |
97 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
98 | - wp_die( -1, '', array( 'response' => 403 ) ); |
|
97 | + if ( ! current_user_can('manage_options')) { |
|
98 | + wp_die( -1, '', array('response' => 403) ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | } else { |
102 | 102 | |
103 | 103 | // CSRF attack (or, more probably the user left the browser open too long). |
104 | - wp_die( -1, '', array( 'response' => 403 ) ); |
|
104 | + wp_die( -1, '', array('response' => 403) ); |
|
105 | 105 | } |
106 | 106 | |
107 | - $error = __( 'An error has occurred. Please reload the page and try again.', 'wordpoints' ); |
|
107 | + $error = __('An error has occurred. Please reload the page and try again.', 'wordpoints'); |
|
108 | 108 | |
109 | - if ( isset( $_POST['points-slug'] ) ) { |
|
109 | + if (isset($_POST['points-slug'])) { |
|
110 | 110 | |
111 | 111 | // - We are saving the settings for a points type. |
112 | 112 | |
@@ -117,55 +117,55 @@ discard block |
||
117 | 117 | , 'Performing CRUD actions on points types using this function is deprecated.' |
118 | 118 | ); |
119 | 119 | |
120 | - if ( ! current_user_can( 'manage_wordpoints_points_types' ) ) { |
|
121 | - wp_die( -1, '', array( 'response' => 403 ) ); |
|
120 | + if ( ! current_user_can('manage_wordpoints_points_types')) { |
|
121 | + wp_die( -1, '', array('response' => 403) ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | $settings = array(); |
125 | 125 | |
126 | - if ( isset( $_POST['points-name'] ) ) { |
|
127 | - $settings['name'] = trim( sanitize_text_field( wp_unslash( $_POST['points-name'] ) ) ); |
|
126 | + if (isset($_POST['points-name'])) { |
|
127 | + $settings['name'] = trim(sanitize_text_field(wp_unslash($_POST['points-name']))); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( isset( $_POST['points-prefix'] ) ) { |
|
131 | - $settings['prefix'] = ltrim( sanitize_text_field( wp_unslash( $_POST['points-prefix'] ) ) ); |
|
130 | + if (isset($_POST['points-prefix'])) { |
|
131 | + $settings['prefix'] = ltrim(sanitize_text_field(wp_unslash($_POST['points-prefix']))); |
|
132 | 132 | } |
133 | 133 | |
134 | - if ( isset( $_POST['points-suffix'] ) ) { |
|
135 | - $settings['suffix'] = rtrim( sanitize_text_field( wp_unslash( $_POST['points-suffix'] ) ) ); |
|
134 | + if (isset($_POST['points-suffix'])) { |
|
135 | + $settings['suffix'] = rtrim(sanitize_text_field(wp_unslash($_POST['points-suffix']))); |
|
136 | 136 | } |
137 | 137 | |
138 | - $points_type = sanitize_key( $_POST['points-slug'] ); |
|
138 | + $points_type = sanitize_key($_POST['points-slug']); |
|
139 | 139 | |
140 | - $old_settings = wordpoints_get_points_type( $points_type ); |
|
140 | + $old_settings = wordpoints_get_points_type($points_type); |
|
141 | 141 | |
142 | - if ( false === $old_settings ) { |
|
143 | - wp_die( -1, '', array( 'response' => 200 ) ); |
|
142 | + if (false === $old_settings) { |
|
143 | + wp_die( -1, '', array('response' => 200) ); |
|
144 | 144 | } |
145 | 145 | |
146 | - if ( is_array( $old_settings ) ) { |
|
147 | - $settings = array_merge( $old_settings, $settings ); |
|
146 | + if (is_array($old_settings)) { |
|
147 | + $settings = array_merge($old_settings, $settings); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( ! wordpoints_update_points_type( $points_type, $settings ) ) { |
|
150 | + if ( ! wordpoints_update_points_type($points_type, $settings)) { |
|
151 | 151 | |
152 | 152 | // If this fails, show the user a message along with the form. |
153 | - echo '<p>' . esc_html__( 'An error has occurred. Please try again.', 'wordpoints' ) . '</p>'; |
|
153 | + echo '<p>' . esc_html__('An error has occurred. Please try again.', 'wordpoints') . '</p>'; |
|
154 | 154 | |
155 | - WordPoints_Points_Hooks::points_type_form( $points_type, 'none' ); |
|
155 | + WordPoints_Points_Hooks::points_type_form($points_type, 'none'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | } else { |
159 | 159 | |
160 | 160 | // - We are creating/updating/deleting an instance of a hook. |
161 | 161 | |
162 | - if ( ! isset( $_POST['id_base'], $_POST['hook-id'], $_POST['points_type'], $_POST['hook_number'] ) ) { |
|
163 | - wp_die( -1, '', array( 'response' => 400 ) ); |
|
162 | + if ( ! isset($_POST['id_base'], $_POST['hook-id'], $_POST['points_type'], $_POST['hook_number'])) { |
|
163 | + wp_die( -1, '', array('response' => 400) ); |
|
164 | 164 | } |
165 | 165 | |
166 | - $id_base = sanitize_key( $_POST['id_base'] ); |
|
167 | - $hook_id = sanitize_key( $_POST['hook-id'] ); |
|
168 | - $points_type_id = sanitize_key( $_POST['points_type'] ); |
|
166 | + $id_base = sanitize_key($_POST['id_base']); |
|
167 | + $hook_id = sanitize_key($_POST['hook-id']); |
|
168 | + $points_type_id = sanitize_key($_POST['points_type']); |
|
169 | 169 | $number = (int) $_POST['hook_number']; |
170 | 170 | |
171 | 171 | /* |
@@ -174,48 +174,48 @@ discard block |
||
174 | 174 | * created hook, the ID won't have been set when the form was output, so |
175 | 175 | * 'hook-id' will be empty, and we'll get the ID from 'multi_number'. |
176 | 176 | */ |
177 | - if ( ! $number ) { |
|
177 | + if ( ! $number) { |
|
178 | 178 | |
179 | 179 | // This holds the ID number if the hook is brand new. |
180 | - if ( ! isset( $_POST['multi_number'] ) || ! wordpoints_posint( $_POST['multi_number'] ) ) { |
|
181 | - wp_die( '<p>' . esc_html( $error ) . '</p>', '', array( 'response' => 400 ) ); |
|
180 | + if ( ! isset($_POST['multi_number']) || ! wordpoints_posint($_POST['multi_number'])) { |
|
181 | + wp_die('<p>' . esc_html($error) . '</p>', '', array('response' => 400)); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $number = (int) $_POST['multi_number']; |
185 | 185 | $hook_id = $id_base . '-' . $number; |
186 | 186 | } |
187 | 187 | |
188 | - $hook = WordPoints_Points_Hooks::get_handler( $hook_id ); |
|
188 | + $hook = WordPoints_Points_Hooks::get_handler($hook_id); |
|
189 | 189 | |
190 | 190 | $settings = false; |
191 | 191 | |
192 | - if ( isset( $_POST[ 'hook-' . $id_base ] ) && is_array( $_POST[ 'hook-' . $id_base ] ) ) { |
|
193 | - $settings = wp_unslash( $_POST[ 'hook-' . $id_base ] ); // WPCS: sanitization OK. |
|
192 | + if (isset($_POST['hook-' . $id_base]) && is_array($_POST['hook-' . $id_base])) { |
|
193 | + $settings = wp_unslash($_POST['hook-' . $id_base]); // WPCS: sanitization OK. |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $points_types_hooks = WordPoints_Points_Hooks::get_points_types_hooks(); |
197 | 197 | |
198 | 198 | // Get the hooks for this points type. |
199 | - $points_type_hooks = ( isset( $points_types_hooks[ $points_type_id ] ) ) ? $points_types_hooks[ $points_type_id ] : array(); |
|
199 | + $points_type_hooks = (isset($points_types_hooks[$points_type_id])) ? $points_types_hooks[$points_type_id] : array(); |
|
200 | 200 | |
201 | - if ( ! empty( $_POST['delete_hook'] ) ) { |
|
201 | + if ( ! empty($_POST['delete_hook'])) { |
|
202 | 202 | |
203 | 203 | // - We are deleting a hook instance. |
204 | 204 | |
205 | - if ( false === $hook ) { |
|
206 | - wp_die( '<p>' . esc_html( $error ) . '</p>', '', array( 'response' => 400 ) ); |
|
205 | + if (false === $hook) { |
|
206 | + wp_die('<p>' . esc_html($error) . '</p>', '', array('response' => 400)); |
|
207 | 207 | } |
208 | 208 | |
209 | - $hook->delete_callback( $number ); |
|
209 | + $hook->delete_callback($number); |
|
210 | 210 | |
211 | 211 | // Remove this instance of the hook, and reset the positions (keys). |
212 | - $points_types_hooks[ $points_type_id ] = array_diff( $points_type_hooks, array( $hook_id ) ); |
|
212 | + $points_types_hooks[$points_type_id] = array_diff($points_type_hooks, array($hook_id)); |
|
213 | 213 | |
214 | - WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks ); |
|
214 | + WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks); |
|
215 | 215 | |
216 | - wp_die( esc_html( "deleted:{$hook_id}" ), '', array( 'response' => 200 ) ); |
|
216 | + wp_die(esc_html("deleted:{$hook_id}"), '', array('response' => 200)); |
|
217 | 217 | |
218 | - } elseif ( $settings && false === $hook ) { |
|
218 | + } elseif ($settings && false === $hook) { |
|
219 | 219 | |
220 | 220 | // - We are creating a new a new instance of a hook. |
221 | 221 | |
@@ -224,36 +224,36 @@ discard block |
||
224 | 224 | * since the hook is new, it hasn't been assigned an ID yet, so we can't |
225 | 225 | * just get it from the array of hooks by ID. |
226 | 226 | */ |
227 | - $hook = WordPoints_Points_Hooks::get_handler_by_id_base( $id_base ); |
|
227 | + $hook = WordPoints_Points_Hooks::get_handler_by_id_base($id_base); |
|
228 | 228 | |
229 | - $new_instance = reset( $settings ); |
|
229 | + $new_instance = reset($settings); |
|
230 | 230 | |
231 | 231 | // Save the points types-hooks associations. |
232 | - $points_type_hooks[] = $hook->get_id( $number ); |
|
233 | - $points_types_hooks[ $points_type_id ] = $points_type_hooks; |
|
234 | - WordPoints_Points_Hooks::save_points_types_hooks( $points_types_hooks ); |
|
232 | + $points_type_hooks[] = $hook->get_id($number); |
|
233 | + $points_types_hooks[$points_type_id] = $points_type_hooks; |
|
234 | + WordPoints_Points_Hooks::save_points_types_hooks($points_types_hooks); |
|
235 | 235 | |
236 | 236 | } else { |
237 | 237 | |
238 | 238 | // - We are updating the settings for an instance of a hook. |
239 | 239 | |
240 | - if ( false === $hook ) { |
|
241 | - wp_die( '<p>' . esc_html( $error ) . '</p>', '', array( 'response' => 400 ) ); |
|
240 | + if (false === $hook) { |
|
241 | + wp_die('<p>' . esc_html($error) . '</p>', '', array('response' => 400)); |
|
242 | 242 | } |
243 | 243 | |
244 | - $new_instance = ( ! empty( $settings ) ) ? reset( $settings ) : array(); |
|
244 | + $new_instance = ( ! empty($settings)) ? reset($settings) : array(); |
|
245 | 245 | |
246 | 246 | } // End if ( deleting ) elseif ( creating ) else { updating }. |
247 | 247 | |
248 | - $hook->update_callback( wp_unslash( $new_instance ), $number ); |
|
248 | + $hook->update_callback(wp_unslash($new_instance), $number); |
|
249 | 249 | |
250 | - if ( empty( $_POST['add_new'] ) ) { |
|
251 | - $hook->form_callback( $number ); |
|
250 | + if (empty($_POST['add_new'])) { |
|
251 | + $hook->form_callback($number); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } // End if ( saving points type ) else { deleting/creation/updating hook }. |
255 | 255 | |
256 | - wp_die( '', '', array( 'response' => 200 ) ); |
|
256 | + wp_die('', '', array('response' => 200)); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | // EOF |
@@ -246,9 +246,9 @@ |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | $screen_options = '<p><a id="access-on" href="' . esc_url( wp_nonce_url( $url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce' ) ) . '&accessibility-mode=on">' |
249 | - . esc_html__( 'Enable accessibility mode', 'wordpoints' ) |
|
250 | - . '</a><a id="access-off" href="' . esc_url( wp_nonce_url( $url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce' ) ) . '&accessibility-mode=off">' |
|
251 | - . esc_html__( 'Disable accessibility mode', 'wordpoints' ) . "</a></p>\n"; |
|
249 | + . esc_html__( 'Enable accessibility mode', 'wordpoints' ) |
|
250 | + . '</a><a id="access-off" href="' . esc_url( wp_nonce_url( $url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce' ) ) . '&accessibility-mode=off">' |
|
251 | + . esc_html__( 'Disable accessibility mode', 'wordpoints' ) . "</a></p>\n"; |
|
252 | 252 | break; |
253 | 253 | } |
254 | 254 |
@@ -290,9 +290,12 @@ |
||
290 | 290 | |
291 | 291 | <?php if ( $has_form ) : ?> |
292 | 292 | <hr /> |
293 | - <?php else : ?> |
|
293 | + <?php else { |
|
294 | + : ?> |
|
294 | 295 | <br /> |
295 | - <?php endif; ?> |
|
296 | + <?php endif; |
|
297 | +} |
|
298 | +?> |
|
296 | 299 | |
297 | 300 | <div class="hook-instance-description"> |
298 | 301 | <label for="<?php $hook->the_field_id( '_description' ); ?>"><?php echo esc_html_x( 'Description (optional):', 'points hook', 'wordpoints' ); ?></label> |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | wp_register_style( |
26 | 26 | 'wordpoints-admin-points-hooks' |
27 | 27 | , "{$assets_url}/css/hooks{$suffix}.css" |
28 | - , array( 'dashicons' ) |
|
28 | + , array('dashicons') |
|
29 | 29 | , WORDPOINTS_VERSION |
30 | 30 | ); |
31 | 31 | |
32 | 32 | $styles = wp_styles(); |
33 | - $styles->add_data( 'wordpoints-admin-points-hooks', 'rtl', 'replace' ); |
|
33 | + $styles->add_data('wordpoints-admin-points-hooks', 'rtl', 'replace'); |
|
34 | 34 | |
35 | - if ( $suffix ) { |
|
36 | - $styles->add_data( 'wordpoints-admin-points-hooks', 'suffix', $suffix ); |
|
35 | + if ($suffix) { |
|
36 | + $styles->add_data('wordpoints-admin-points-hooks', 'suffix', $suffix); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // JS |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | wp_register_script( |
42 | 42 | 'wordpoints-admin-points-types' |
43 | 43 | , "{$assets_url}/js/points-types{$suffix}.js" |
44 | - , array( 'backbone', 'jquery-ui-dialog', 'wp-util' ) |
|
44 | + , array('backbone', 'jquery-ui-dialog', 'wp-util') |
|
45 | 45 | , WORDPOINTS_VERSION |
46 | 46 | ); |
47 | 47 | |
@@ -49,25 +49,25 @@ discard block |
||
49 | 49 | 'wordpoints-admin-points-types' |
50 | 50 | , 'WordPointsPointsTypesL10n' |
51 | 51 | , array( |
52 | - 'confirmDelete' => esc_html__( 'Are you sure that you want to delete this points type? This will delete all logs, event reactions, and other data associated with this points type.', 'wordpoints' ) |
|
53 | - . ' ' . esc_html__( 'Once a points type has been deleted, you cannot bring it back.', 'wordpoints' ), |
|
54 | - 'confirmTitle' => esc_html__( 'Are you sure?', 'wordpoints' ), |
|
55 | - 'deleteText' => esc_html__( 'Delete', 'wordpoints' ), |
|
56 | - 'cancelText' => esc_html__( 'Cancel', 'wordpoints' ), |
|
52 | + 'confirmDelete' => esc_html__('Are you sure that you want to delete this points type? This will delete all logs, event reactions, and other data associated with this points type.', 'wordpoints') |
|
53 | + . ' ' . esc_html__('Once a points type has been deleted, you cannot bring it back.', 'wordpoints'), |
|
54 | + 'confirmTitle' => esc_html__('Are you sure?', 'wordpoints'), |
|
55 | + 'deleteText' => esc_html__('Delete', 'wordpoints'), |
|
56 | + 'cancelText' => esc_html__('Cancel', 'wordpoints'), |
|
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | 60 | wp_register_script( |
61 | 61 | 'wordpoints-hooks-reactor-points' |
62 | 62 | , "{$assets_url}/js/hooks/reactors/points{$manifested_suffix}.js" |
63 | - , array( 'wordpoints-hooks-views' ) |
|
63 | + , array('wordpoints-hooks-views') |
|
64 | 64 | , WORDPOINTS_VERSION |
65 | 65 | ); |
66 | 66 | |
67 | 67 | wp_register_script( |
68 | 68 | 'wordpoints-admin-points-hooks' |
69 | 69 | , "{$assets_url}/js/hooks{$suffix}.js" |
70 | - , array( 'jquery', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-dialog' ) |
|
70 | + , array('jquery', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-dialog') |
|
71 | 71 | , WORDPOINTS_VERSION |
72 | 72 | ); |
73 | 73 | } |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | $wordpoints_menu = wordpoints_get_main_admin_menu(); |
86 | 86 | |
87 | 87 | /** @var WordPoints_Admin_Screens $admin_screens */ |
88 | - $admin_screens = wordpoints_apps()->get_sub_app( 'admin' )->get_sub_app( |
|
88 | + $admin_screens = wordpoints_apps()->get_sub_app('admin')->get_sub_app( |
|
89 | 89 | 'screen' |
90 | 90 | ); |
91 | 91 | |
92 | 92 | // Hooks page. |
93 | 93 | $id = add_submenu_page( |
94 | 94 | $wordpoints_menu |
95 | - , __( 'WordPoints — Points Types', 'wordpoints' ) |
|
96 | - , __( 'Points Types', 'wordpoints' ) |
|
95 | + , __('WordPoints — Points Types', 'wordpoints') |
|
96 | + , __('Points Types', 'wordpoints') |
|
97 | 97 | , 'manage_options' |
98 | 98 | , 'wordpoints_points_types' |
99 | - , array( $admin_screens, 'display' ) |
|
99 | + , array($admin_screens, 'display') |
|
100 | 100 | ); |
101 | 101 | |
102 | - if ( $id ) { |
|
103 | - $admin_screens->register( $id, 'WordPoints_Points_Admin_Screen_Points_Types' ); |
|
102 | + if ($id) { |
|
103 | + $admin_screens->register($id, 'WordPoints_Points_Admin_Screen_Points_Types'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // Remove the old hooks screen if not needed. |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | |
114 | 114 | // If all of the registered hooks have been imported and disabled, then there is |
115 | 115 | // no need to keep the old hooks screen. |
116 | - if ( array_diff_key( $hooks, $disabled_hooks ) ) { |
|
116 | + if (array_diff_key($hooks, $disabled_hooks)) { |
|
117 | 117 | // Legacy hooks page. |
118 | 118 | add_submenu_page( |
119 | 119 | $wordpoints_menu |
120 | - ,__( 'WordPoints — Points Hooks', 'wordpoints' ) |
|
121 | - ,__( 'Points Hooks', 'wordpoints' ) |
|
120 | + ,__('WordPoints — Points Hooks', 'wordpoints') |
|
121 | + ,__('Points Hooks', 'wordpoints') |
|
122 | 122 | ,'manage_options' |
123 | 123 | ,'wordpoints_points_hooks' |
124 | 124 | ,'wordpoints_points_admin_screen_hooks' |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | // Logs page. |
129 | 129 | add_submenu_page( |
130 | 130 | $wordpoints_menu |
131 | - ,__( 'WordPoints — Points Logs', 'wordpoints' ) |
|
132 | - ,__( 'Points Logs', 'wordpoints' ) |
|
131 | + ,__('WordPoints — Points Logs', 'wordpoints') |
|
132 | + ,__('Points Logs', 'wordpoints') |
|
133 | 133 | ,'manage_options' |
134 | 134 | ,'wordpoints_points_logs' |
135 | 135 | ,'wordpoints_points_admin_screen_logs' |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | function wordpoints_points_admin_screen_hooks() { |
145 | 145 | |
146 | - if ( isset( $_GET['edithook'] ) || isset( $_POST['savehook'] ) || isset( $_POST['removehook'] ) ) { // WPCS: CSRF OK. |
|
146 | + if (isset($_GET['edithook']) || isset($_POST['savehook']) || isset($_POST['removehook'])) { // WPCS: CSRF OK. |
|
147 | 147 | |
148 | 148 | // - We're doing this without AJAX (JS). |
149 | 149 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function wordpoints_no_js_points_hooks_save() { |
208 | 208 | |
209 | - if ( ! isset( $_POST['savehook'] ) && ! isset( $_POST['removehook'] ) ) { // WPCS: CSRF OK. |
|
209 | + if ( ! isset($_POST['savehook']) && ! isset($_POST['removehook'])) { // WPCS: CSRF OK. |
|
210 | 210 | return; |
211 | 211 | } |
212 | 212 | |
@@ -230,25 +230,25 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return string Options for this screen. |
232 | 232 | */ |
233 | -function wordpoints_admin_points_hooks_screen_options( $screen_options, $screen ) { |
|
233 | +function wordpoints_admin_points_hooks_screen_options($screen_options, $screen) { |
|
234 | 234 | |
235 | 235 | $path = 'admin.php?page=wordpoints_points_hooks'; |
236 | 236 | |
237 | - switch ( $screen->id ) { |
|
237 | + switch ($screen->id) { |
|
238 | 238 | |
239 | 239 | case 'wordpoints_page_wordpoints_points_hooks': |
240 | - $url = admin_url( $path ); |
|
240 | + $url = admin_url($path); |
|
241 | 241 | // Fall through. |
242 | 242 | |
243 | 243 | case 'wordpoints_page_wordpoints_points_hooks-network': |
244 | - if ( ! isset( $url ) ) { |
|
245 | - $url = network_admin_url( $path ); |
|
244 | + if ( ! isset($url)) { |
|
245 | + $url = network_admin_url($path); |
|
246 | 246 | } |
247 | 247 | |
248 | - $screen_options = '<p><a id="access-on" href="' . esc_url( wp_nonce_url( $url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce' ) ) . '&accessibility-mode=on">' |
|
249 | - . esc_html__( 'Enable accessibility mode', 'wordpoints' ) |
|
250 | - . '</a><a id="access-off" href="' . esc_url( wp_nonce_url( $url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce' ) ) . '&accessibility-mode=off">' |
|
251 | - . esc_html__( 'Disable accessibility mode', 'wordpoints' ) . "</a></p>\n"; |
|
248 | + $screen_options = '<p><a id="access-on" href="' . esc_url(wp_nonce_url($url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce')) . '&accessibility-mode=on">' |
|
249 | + . esc_html__('Enable accessibility mode', 'wordpoints') |
|
250 | + . '</a><a id="access-off" href="' . esc_url(wp_nonce_url($url, 'wordpoints_points_hooks_accessiblity', 'wordpoints-accessiblity-nonce')) . '&accessibility-mode=off">' |
|
251 | + . esc_html__('Disable accessibility mode', 'wordpoints') . "</a></p>\n"; |
|
252 | 252 | break; |
253 | 253 | } |
254 | 254 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return string The classes, with 'wordpoints_hooks_access' added. |
268 | 268 | */ |
269 | -function wordpoints_points_hooks_access_body_class( $classes ) { |
|
269 | +function wordpoints_points_hooks_access_body_class($classes) { |
|
270 | 270 | |
271 | 271 | return "{$classes} wordpoints_hooks_access "; |
272 | 272 | } |
@@ -282,29 +282,29 @@ discard block |
||
282 | 282 | * @param array $instance The settings for this hook instance. |
283 | 283 | * @param WordPoints_Points_Hook $hook The points hook object. |
284 | 284 | */ |
285 | -function wordpoints_points_hook_description_form( $has_form, $instance, $hook ) { |
|
285 | +function wordpoints_points_hook_description_form($has_form, $instance, $hook) { |
|
286 | 286 | |
287 | - $description = ( isset( $instance['_description'] ) ) ? $instance['_description'] : ''; |
|
287 | + $description = (isset($instance['_description'])) ? $instance['_description'] : ''; |
|
288 | 288 | |
289 | 289 | ?> |
290 | 290 | |
291 | - <?php if ( $has_form ) : ?> |
|
291 | + <?php if ($has_form) : ?> |
|
292 | 292 | <hr /> |
293 | 293 | <?php else : ?> |
294 | 294 | <br /> |
295 | 295 | <?php endif; ?> |
296 | 296 | |
297 | 297 | <div class="hook-instance-description"> |
298 | - <label for="<?php $hook->the_field_id( '_description' ); ?>"><?php echo esc_html_x( 'Description (optional):', 'points hook', 'wordpoints' ); ?></label> |
|
299 | - <input type="text" id="<?php $hook->the_field_id( '_description' ); ?>" name="<?php $hook->the_field_name( '_description' ); ?>" class="widefat" value="<?php echo esc_attr( $description ); ?>" /> |
|
298 | + <label for="<?php $hook->the_field_id('_description'); ?>"><?php echo esc_html_x('Description (optional):', 'points hook', 'wordpoints'); ?></label> |
|
299 | + <input type="text" id="<?php $hook->the_field_id('_description'); ?>" name="<?php $hook->the_field_name('_description'); ?>" class="widefat" value="<?php echo esc_attr($description); ?>" /> |
|
300 | 300 | <p class="description"> |
301 | 301 | <?php |
302 | 302 | |
303 | 303 | echo esc_html( |
304 | 304 | sprintf( |
305 | 305 | // translators: Default points hook description. |
306 | - _x( 'Default: %s', 'points hook description', 'wordpoints' ) |
|
307 | - , $hook->get_description( 'generated' ) |
|
306 | + _x('Default: %s', 'points hook description', 'wordpoints') |
|
307 | + , $hook->get_description('generated') |
|
308 | 308 | ) |
309 | 309 | ); |
310 | 310 | |
@@ -326,44 +326,44 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @param WP_User $user The user object for the user being edited. |
328 | 328 | */ |
329 | -function wordpoints_points_profile_options( $user ) { |
|
329 | +function wordpoints_points_profile_options($user) { |
|
330 | 330 | |
331 | - if ( current_user_can( 'set_wordpoints_points', $user->ID ) ) { |
|
331 | + if (current_user_can('set_wordpoints_points', $user->ID)) { |
|
332 | 332 | |
333 | 333 | ?> |
334 | 334 | |
335 | 335 | </table> |
336 | 336 | |
337 | - <h2><?php esc_html_e( 'WordPoints', 'wordpoints' ); ?></h2> |
|
338 | - <p><?php esc_html_e( "If you would like to change the value for a type of points, enter the desired value in the text field, and check the checkbox beside it. If you don't check the checkbox, the change will not be saved. To provide a reason for the change, fill out the text field below.", 'wordpoints' ); ?></p> |
|
339 | - <lable><?php esc_html_e( 'Reason', 'wordpoints' ); ?> <input type="text" name="wordpoints_set_reason" /> |
|
337 | + <h2><?php esc_html_e('WordPoints', 'wordpoints'); ?></h2> |
|
338 | + <p><?php esc_html_e("If you would like to change the value for a type of points, enter the desired value in the text field, and check the checkbox beside it. If you don't check the checkbox, the change will not be saved. To provide a reason for the change, fill out the text field below.", 'wordpoints'); ?></p> |
|
339 | + <lable><?php esc_html_e('Reason', 'wordpoints'); ?> <input type="text" name="wordpoints_set_reason" /> |
|
340 | 340 | <table class="form-table"> |
341 | 341 | |
342 | 342 | <?php |
343 | 343 | |
344 | - wp_nonce_field( 'wordpoints_points_set_profile', 'wordpoints_points_set_nonce' ); |
|
344 | + wp_nonce_field('wordpoints_points_set_profile', 'wordpoints_points_set_nonce'); |
|
345 | 345 | |
346 | - foreach ( wordpoints_get_points_types() as $slug => $type ) { |
|
346 | + foreach (wordpoints_get_points_types() as $slug => $type) { |
|
347 | 347 | |
348 | - $points = wordpoints_get_points( $user->ID, $slug ); |
|
348 | + $points = wordpoints_get_points($user->ID, $slug); |
|
349 | 349 | |
350 | 350 | ?> |
351 | 351 | |
352 | 352 | <tr> |
353 | - <th scope="row"><?php echo esc_html( $type['name'] ); ?></th> |
|
353 | + <th scope="row"><?php echo esc_html($type['name']); ?></th> |
|
354 | 354 | <td> |
355 | - <input type="hidden" name="<?php echo esc_attr( "wordpoints_points_old-{$slug}" ); ?>" value="<?php echo esc_attr( $points ); ?>" /> |
|
356 | - <input type="number" name="<?php echo esc_attr( "wordpoints_points-{$slug}" ); ?>" value="<?php echo esc_attr( $points ); ?>" autocomplete="off" /> |
|
357 | - <input type="checkbox" value="1" name="<?php echo esc_attr( "wordpoints_points_set-{$slug}" ); ?>" /> |
|
355 | + <input type="hidden" name="<?php echo esc_attr("wordpoints_points_old-{$slug}"); ?>" value="<?php echo esc_attr($points); ?>" /> |
|
356 | + <input type="number" name="<?php echo esc_attr("wordpoints_points-{$slug}"); ?>" value="<?php echo esc_attr($points); ?>" autocomplete="off" /> |
|
357 | + <input type="checkbox" value="1" name="<?php echo esc_attr("wordpoints_points_set-{$slug}"); ?>" /> |
|
358 | 358 | <?php // translators: Number of points. ?> |
359 | - <span><?php echo esc_html( sprintf( __( '(current: %s)', 'wordpoints' ), $points ) ); ?></span> |
|
359 | + <span><?php echo esc_html(sprintf(__('(current: %s)', 'wordpoints'), $points)); ?></span> |
|
360 | 360 | </td> |
361 | 361 | </tr> |
362 | 362 | |
363 | 363 | <?php |
364 | 364 | } |
365 | 365 | |
366 | - } elseif ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) { |
|
366 | + } elseif (defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE) { |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * My points admin profile heading. |
@@ -377,20 +377,20 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @param string $heading The text for the heading. |
379 | 379 | */ |
380 | - $heading = apply_filters( 'wordpoints_profile_points_heading', __( 'My Points', 'wordpoints' ) ); |
|
380 | + $heading = apply_filters('wordpoints_profile_points_heading', __('My Points', 'wordpoints')); |
|
381 | 381 | |
382 | 382 | ?> |
383 | 383 | |
384 | 384 | </table> |
385 | 385 | |
386 | - <h2><?php echo esc_html( $heading ); ?></h2> |
|
386 | + <h2><?php echo esc_html($heading); ?></h2> |
|
387 | 387 | |
388 | 388 | <table> |
389 | 389 | <tbody> |
390 | - <?php foreach ( wordpoints_get_points_types() as $slug => $type ) : ?> |
|
390 | + <?php foreach (wordpoints_get_points_types() as $slug => $type) : ?> |
|
391 | 391 | <tr> |
392 | - <th scope="row" style="text-align: left;"><?php echo esc_html( $type['name'] ); ?></th> |
|
393 | - <td style="text-align: right;"><?php wordpoints_display_points( $user->ID, $slug, 'profile_page' ); ?></td> |
|
392 | + <th scope="row" style="text-align: left;"><?php echo esc_html($type['name']); ?></th> |
|
393 | + <td style="text-align: right;"><?php wordpoints_display_points($user->ID, $slug, 'profile_page'); ?></td> |
|
394 | 394 | </tr> |
395 | 395 | <?php endforeach; ?> |
396 | 396 | </tbody> |
@@ -412,39 +412,39 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @return void |
414 | 414 | */ |
415 | -function wordpoints_points_profile_options_update( $user_id ) { |
|
415 | +function wordpoints_points_profile_options_update($user_id) { |
|
416 | 416 | |
417 | - if ( ! current_user_can( 'set_wordpoints_points', $user_id ) ) { |
|
417 | + if ( ! current_user_can('set_wordpoints_points', $user_id)) { |
|
418 | 418 | return; |
419 | 419 | } |
420 | 420 | |
421 | 421 | if ( |
422 | - ! isset( $_POST['wordpoints_points_set_nonce'], $_POST['wordpoints_set_reason'] ) |
|
423 | - || ! wordpoints_verify_nonce( 'wordpoints_points_set_nonce', 'wordpoints_points_set_profile', null, 'post' ) |
|
422 | + ! isset($_POST['wordpoints_points_set_nonce'], $_POST['wordpoints_set_reason']) |
|
423 | + || ! wordpoints_verify_nonce('wordpoints_points_set_nonce', 'wordpoints_points_set_profile', null, 'post') |
|
424 | 424 | ) { |
425 | 425 | return; |
426 | 426 | } |
427 | 427 | |
428 | - foreach ( wordpoints_get_points_types() as $slug => $type ) { |
|
428 | + foreach (wordpoints_get_points_types() as $slug => $type) { |
|
429 | 429 | |
430 | 430 | if ( |
431 | 431 | isset( |
432 | - $_POST[ "wordpoints_points_set-{$slug}" ] |
|
433 | - , $_POST[ "wordpoints_points-{$slug}" ] |
|
434 | - , $_POST[ "wordpoints_points_old-{$slug}" ] |
|
432 | + $_POST["wordpoints_points_set-{$slug}"] |
|
433 | + , $_POST["wordpoints_points-{$slug}"] |
|
434 | + , $_POST["wordpoints_points_old-{$slug}"] |
|
435 | 435 | ) |
436 | - && false !== wordpoints_int( $_POST[ "wordpoints_points-{$slug}" ] ) |
|
437 | - && false !== wordpoints_int( $_POST[ "wordpoints_points_old-{$slug}" ] ) |
|
436 | + && false !== wordpoints_int($_POST["wordpoints_points-{$slug}"]) |
|
437 | + && false !== wordpoints_int($_POST["wordpoints_points_old-{$slug}"]) |
|
438 | 438 | ) { |
439 | 439 | |
440 | 440 | wordpoints_alter_points( |
441 | 441 | $user_id |
442 | - , (int) $_POST[ "wordpoints_points-{$slug}" ] - (int) $_POST[ "wordpoints_points_old-{$slug}" ] |
|
442 | + , (int) $_POST["wordpoints_points-{$slug}"] - (int) $_POST["wordpoints_points_old-{$slug}"] |
|
443 | 443 | , $slug |
444 | 444 | , 'profile_edit' |
445 | 445 | , array( |
446 | 446 | 'user_id' => get_current_user_id(), |
447 | - 'reason' => sanitize_text_field( wp_unslash( $_POST['wordpoints_set_reason'] ) ), |
|
447 | + 'reason' => sanitize_text_field(wp_unslash($_POST['wordpoints_set_reason'])), |
|
448 | 448 | ) |
449 | 449 | ); |
450 | 450 | } |
@@ -466,22 +466,22 @@ discard block |
||
466 | 466 | 'selected' => wordpoints_get_default_points_type(), |
467 | 467 | 'id' => 'default_points_type', |
468 | 468 | 'name' => 'default_points_type', |
469 | - 'show_option_none' => __( 'No default', 'wordpoints' ), |
|
469 | + 'show_option_none' => __('No default', 'wordpoints'), |
|
470 | 470 | ); |
471 | 471 | |
472 | 472 | ?> |
473 | 473 | |
474 | - <h3><?php esc_html_e( 'Default Points Type', 'wordpoints' ); ?></h3> |
|
475 | - <p><?php esc_html_e( 'You can optionally set one points type to be the default. The default points type will, for example, be used by shortcodes when no type is specified. This is also useful if you only have one type of points.', 'wordpoints' ); ?></p> |
|
474 | + <h3><?php esc_html_e('Default Points Type', 'wordpoints'); ?></h3> |
|
475 | + <p><?php esc_html_e('You can optionally set one points type to be the default. The default points type will, for example, be used by shortcodes when no type is specified. This is also useful if you only have one type of points.', 'wordpoints'); ?></p> |
|
476 | 476 | <table class="form-table"> |
477 | 477 | <tbody> |
478 | 478 | <tr> |
479 | 479 | <th> |
480 | - <label for="default_points_type"><?php esc_html_e( 'Default', 'wordpoints' ); ?></label> |
|
480 | + <label for="default_points_type"><?php esc_html_e('Default', 'wordpoints'); ?></label> |
|
481 | 481 | </th> |
482 | 482 | <td> |
483 | - <?php wordpoints_points_types_dropdown( $dropdown_args ); ?> |
|
484 | - <?php wp_nonce_field( 'wordpoints_default_points_type', 'wordpoints_default_points_type_nonce' ); ?> |
|
483 | + <?php wordpoints_points_types_dropdown($dropdown_args); ?> |
|
484 | + <?php wp_nonce_field('wordpoints_default_points_type', 'wordpoints_default_points_type_nonce'); ?> |
|
485 | 485 | </td> |
486 | 486 | </tr> |
487 | 487 | </tbody> |
@@ -500,19 +500,19 @@ discard block |
||
500 | 500 | function wordpoints_points_admin_settings_save() { |
501 | 501 | |
502 | 502 | if ( |
503 | - isset( $_POST['default_points_type'] ) |
|
504 | - && wordpoints_verify_nonce( 'wordpoints_default_points_type_nonce', 'wordpoints_default_points_type', null, 'post' ) |
|
503 | + isset($_POST['default_points_type']) |
|
504 | + && wordpoints_verify_nonce('wordpoints_default_points_type_nonce', 'wordpoints_default_points_type', null, 'post') |
|
505 | 505 | ) { |
506 | 506 | |
507 | - $points_type = sanitize_key( $_POST['default_points_type'] ); |
|
507 | + $points_type = sanitize_key($_POST['default_points_type']); |
|
508 | 508 | |
509 | - if ( '-1' === $points_type ) { |
|
509 | + if ('-1' === $points_type) { |
|
510 | 510 | |
511 | - wordpoints_update_maybe_network_option( 'wordpoints_default_points_type', '' ); |
|
511 | + wordpoints_update_maybe_network_option('wordpoints_default_points_type', ''); |
|
512 | 512 | |
513 | - } elseif ( wordpoints_is_points_type( $points_type ) ) { |
|
513 | + } elseif (wordpoints_is_points_type($points_type)) { |
|
514 | 514 | |
515 | - wordpoints_update_maybe_network_option( 'wordpoints_default_points_type', $points_type ); |
|
515 | + wordpoints_update_maybe_network_option('wordpoints_default_points_type', $points_type); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | } |
@@ -527,16 +527,16 @@ discard block |
||
527 | 527 | function wordpoints_points_admin_notices() { |
528 | 528 | |
529 | 529 | if ( |
530 | - ( ! isset( $_GET['page'] ) || 'wordpoints_points_types' !== $_GET['page'] ) |
|
531 | - && current_user_can( 'manage_wordpoints_points_types' ) |
|
530 | + ( ! isset($_GET['page']) || 'wordpoints_points_types' !== $_GET['page']) |
|
531 | + && current_user_can('manage_wordpoints_points_types') |
|
532 | 532 | && ! wordpoints_get_points_types() |
533 | 533 | ) { |
534 | 534 | |
535 | 535 | wordpoints_show_admin_message( |
536 | 536 | sprintf( |
537 | 537 | // translators: URL of Points Types admin screen. |
538 | - __( 'Welcome to WordPoints! Get started by <a href="%s">creating a points type</a>.', 'wordpoints' ) |
|
539 | - , esc_url( self_admin_url( 'admin.php?page=wordpoints_points_types' ) ) |
|
538 | + __('Welcome to WordPoints! Get started by <a href="%s">creating a points type</a>.', 'wordpoints') |
|
539 | + , esc_url(self_admin_url('admin.php?page=wordpoints_points_types')) |
|
540 | 540 | ) |
541 | 541 | , 'info' |
542 | 542 | ); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | include_once WORDPOINTS_DIR . 'components/ranks/includes/deprecated.php'; |
41 | 41 | |
42 | -if ( wordpoints_component_is_active( 'points' ) ) { |
|
42 | +if (wordpoints_component_is_active('points')) { |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Ranks integration with the Points component. |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | include_once WORDPOINTS_DIR . 'components/ranks/includes/integration/points.php'; |
50 | 50 | } |
51 | 51 | |
52 | -if ( is_admin() ) { |
|
52 | +if (is_admin()) { |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Administration-side rank code. |
@@ -7,10 +7,10 @@ |
||
7 | 7 | * @since 2.1.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'wordpoints_modules_loaded', 'WordPoints_Rank_Types::init' ); |
|
10 | +add_action('wordpoints_modules_loaded', 'WordPoints_Rank_Types::init'); |
|
11 | 11 | |
12 | -add_action( 'wordpoints_ranks_register', 'wordpoints_register_core_ranks' ); |
|
12 | +add_action('wordpoints_ranks_register', 'wordpoints_register_core_ranks'); |
|
13 | 13 | |
14 | -WordPoints_Shortcodes::register( 'wordpoints_user_rank', 'WordPoints_User_Rank_Shortcode' ); |
|
14 | +WordPoints_Shortcodes::register('wordpoints_user_rank', 'WordPoints_User_Rank_Shortcode'); |
|
15 | 15 | |
16 | 16 | // EOF |
@@ -19,10 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | protected function verify_atts() { |
21 | 21 | |
22 | - if ( isset( $this->pairs['rank_group'] ) && empty( $this->atts['rank_group'] ) ) { |
|
22 | + if (isset($this->pairs['rank_group']) && empty($this->atts['rank_group'])) { |
|
23 | 23 | |
24 | 24 | return sprintf( |
25 | - __( 'The “%1$s” attribute of the %2$s shortcode must be a rank group slug.', 'wordpoints' ) |
|
25 | + __('The “%1$s” attribute of the %2$s shortcode must be a rank group slug.', 'wordpoints') |
|
26 | 26 | ,'rank_group' |
27 | 27 | , "<code>[{$this->shortcode}]</code>" |
28 | 28 | ); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | function wordpoints_ranks_get_db_schema() { |
19 | 19 | |
20 | - _deprecated_function( __FUNCTION__, '2.0.0' ); |
|
20 | + _deprecated_function(__FUNCTION__, '2.0.0'); |
|
21 | 21 | |
22 | 22 | global $wpdb; |
23 | 23 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return array|false The validated metadata or false if it should't be saved. |
34 | 34 | */ |
35 | - public function validate_rank_meta( array $meta ) { |
|
35 | + public function validate_rank_meta(array $meta) { |
|
36 | 36 | return $meta; |
37 | 37 | } |
38 | 38 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return bool Whether the user meets the requirements for this rank. |
54 | 54 | */ |
55 | - protected function can_transition_user_rank( $user_id, $rank, array $args ) { |
|
55 | + protected function can_transition_user_rank($user_id, $rank, array $args) { |
|
56 | 56 | return true; |
57 | 57 | } |
58 | 58 | } |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param int|WordPoints_Rank $id The ID of a rank. |
77 | 77 | */ |
78 | - public function __construct( $id ) { |
|
78 | + public function __construct($id) { |
|
79 | 79 | |
80 | - if ( is_a( $id, __CLASS__ ) ) { |
|
81 | - $this->init( $id->data ); |
|
80 | + if (is_a($id, __CLASS__)) { |
|
81 | + $this->init($id->data); |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - $id = wordpoints_int( $id ); |
|
85 | + $id = wordpoints_int($id); |
|
86 | 86 | |
87 | - if ( $id ) { |
|
88 | - $this->init( self::get_data( $id ) ); |
|
87 | + if ($id) { |
|
88 | + $this->init(self::get_data($id)); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @since 1.7.0 |
96 | 96 | */ |
97 | - public function __isset( $key ) { |
|
97 | + public function __isset($key) { |
|
98 | 98 | |
99 | - if ( isset( $this->data->$key ) ) { |
|
99 | + if (isset($this->data->$key)) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | |
103 | - return metadata_exists( 'wordpoints_rank', $this->ID, $key ); |
|
103 | + return metadata_exists('wordpoints_rank', $this->ID, $key); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @since 1.7.0 |
110 | 110 | */ |
111 | - public function __get( $key ) { |
|
111 | + public function __get($key) { |
|
112 | 112 | |
113 | - if ( 'ID' === $key ) { |
|
113 | + if ('ID' === $key) { |
|
114 | 114 | return $this->ID; |
115 | - } elseif ( isset( $this->data->$key ) ) { |
|
115 | + } elseif (isset($this->data->$key)) { |
|
116 | 116 | $value = $this->data->$key; |
117 | 117 | } else { |
118 | - $value = wordpoints_get_rank_meta( $this->ID, $key, true ); |
|
118 | + $value = wordpoints_get_rank_meta($this->ID, $key, true); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return $value; |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @since 1.7.0 |
128 | 128 | */ |
129 | - public function __set( $key, $value ) { |
|
129 | + public function __set($key, $value) { |
|
130 | 130 | |
131 | - if ( 'ID' !== $key && 'data' !== $key ) { |
|
131 | + if ('ID' !== $key && 'data' !== $key) { |
|
132 | 132 | |
133 | 133 | _doing_it_wrong( |
134 | 134 | __METHOD__ |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param object $data The data for a rank. |
147 | 147 | */ |
148 | - public function init( $data ) { |
|
148 | + public function init($data) { |
|
149 | 149 | |
150 | - if ( ! isset( $data->id ) ) { |
|
150 | + if ( ! isset($data->id)) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function exists() { |
166 | 166 | |
167 | - return ! empty( $this->ID ); |
|
167 | + return ! empty($this->ID); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -181,23 +181,23 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return WordPoints_Rank|false The adjacent rank, or false. |
183 | 183 | */ |
184 | - public function get_adjacent( $relative_position ) { |
|
184 | + public function get_adjacent($relative_position) { |
|
185 | 185 | |
186 | - if ( 0 === wordpoints_int( $relative_position ) ) { |
|
186 | + if (0 === wordpoints_int($relative_position)) { |
|
187 | 187 | return $this; |
188 | 188 | } |
189 | 189 | |
190 | - $group = WordPoints_Rank_Groups::get_group( $this->rank_group ); |
|
190 | + $group = WordPoints_Rank_Groups::get_group($this->rank_group); |
|
191 | 191 | |
192 | - $position = $group->get_rank_position( $this->ID ); |
|
192 | + $position = $group->get_rank_position($this->ID); |
|
193 | 193 | |
194 | - $adjacent_rank_id = $group->get_rank( $position + $relative_position ); |
|
194 | + $adjacent_rank_id = $group->get_rank($position + $relative_position); |
|
195 | 195 | |
196 | - if ( ! $adjacent_rank_id ) { |
|
196 | + if ( ! $adjacent_rank_id) { |
|
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
200 | - return new WordPoints_Rank( $adjacent_rank_id ); |
|
200 | + return new WordPoints_Rank($adjacent_rank_id); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return object|false The rank's data, or false if not found. |
215 | 215 | */ |
216 | - public static function get_data( $id ) { |
|
216 | + public static function get_data($id) { |
|
217 | 217 | |
218 | - $rank_data = wp_cache_get( $id, 'wordpoints_ranks' ); |
|
218 | + $rank_data = wp_cache_get($id, 'wordpoints_ranks'); |
|
219 | 219 | |
220 | - if ( false !== $rank_data ) { |
|
220 | + if (false !== $rank_data) { |
|
221 | 221 | return $rank_data; |
222 | 222 | } |
223 | 223 | |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | ) |
235 | 235 | ); |
236 | 236 | |
237 | - if ( null === $rank_data ) { |
|
237 | + if (null === $rank_data) { |
|
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | |
241 | - wp_cache_add( $rank_data->id, $rank_data, 'wordpoints_ranks' ); |
|
241 | + wp_cache_add($rank_data->id, $rank_data, 'wordpoints_ranks'); |
|
242 | 242 | |
243 | 243 | return $rank_data; |
244 | 244 | } |