@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_donors_page, $give_tools_page; |
33 | 33 | |
34 | 34 | //Payments |
35 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
35 | + $give_payment = get_post_type_object('give_payment'); |
|
36 | 36 | $give_payments_page = add_submenu_page( |
37 | 37 | 'edit.php?post_type=give_forms', |
38 | 38 | $give_payment->labels->name, |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | //Donors |
46 | 46 | $give_donors_page = add_submenu_page( |
47 | 47 | 'edit.php?post_type=give_forms', |
48 | - esc_html__( 'Donors', 'give' ), |
|
49 | - esc_html__( 'Donors', 'give' ), |
|
48 | + esc_html__('Donors', 'give'), |
|
49 | + esc_html__('Donors', 'give'), |
|
50 | 50 | 'view_give_reports', |
51 | 51 | 'give-donors', |
52 | 52 | 'give_donors_page' |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | //Reports` |
56 | 56 | $give_reports_page = add_submenu_page( |
57 | 57 | 'edit.php?post_type=give_forms', |
58 | - esc_html__( 'Donation Reports', 'give' ), |
|
59 | - esc_html__( 'Reports', 'give' ), |
|
58 | + esc_html__('Donation Reports', 'give'), |
|
59 | + esc_html__('Reports', 'give'), |
|
60 | 60 | 'view_give_reports', |
61 | 61 | 'give-reports', |
62 | 62 | array( |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | //Settings |
69 | 69 | $give_settings_page = add_submenu_page( |
70 | 70 | 'edit.php?post_type=give_forms', |
71 | - esc_html__( 'Give Settings', 'give' ), |
|
72 | - esc_html__( 'Settings', 'give' ), |
|
71 | + esc_html__('Give Settings', 'give'), |
|
72 | + esc_html__('Settings', 'give'), |
|
73 | 73 | 'manage_give_settings', |
74 | 74 | 'give-settings', |
75 | 75 | array( |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | //Tools. |
82 | 82 | $give_tools_page = add_submenu_page( |
83 | 83 | 'edit.php?post_type=give_forms', |
84 | - esc_html__( 'Give Tools', 'give' ), |
|
85 | - esc_html__( 'Tools', 'give' ), |
|
84 | + esc_html__('Give Tools', 'give'), |
|
85 | + esc_html__('Tools', 'give'), |
|
86 | 86 | 'manage_give_settings', |
87 | 87 | 'give-tools', |
88 | 88 | array( |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | //Add-ons |
95 | 95 | $give_add_ons_page = add_submenu_page( |
96 | 96 | 'edit.php?post_type=give_forms', |
97 | - esc_html__( 'Give Add-ons', 'give' ), |
|
98 | - esc_html__( 'Add-ons', 'give' ), |
|
97 | + esc_html__('Give Add-ons', 'give'), |
|
98 | + esc_html__('Add-ons', 'give'), |
|
99 | 99 | 'install_plugins', |
100 | 100 | 'give-addons', |
101 | 101 | 'give_add_ons_page' |
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | -add_action( 'admin_menu', 'give_add_options_links', 10 ); |
|
105 | +add_action('admin_menu', 'give_add_options_links', 10); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Determines whether the current admin page is a Give admin page. |
@@ -118,28 +118,28 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return bool True if Give admin page. |
120 | 120 | */ |
121 | -function give_is_admin_page( $passed_page = '', $passed_view = '' ) { |
|
121 | +function give_is_admin_page($passed_page = '', $passed_view = '') { |
|
122 | 122 | global $pagenow, $typenow; |
123 | 123 | |
124 | 124 | $found = true; |
125 | - $get_query_args = ! empty( $_GET ) ? @array_map( 'strtolower', $_GET ) : array(); |
|
125 | + $get_query_args = ! empty($_GET) ? @array_map('strtolower', $_GET) : array(); |
|
126 | 126 | |
127 | 127 | // Set default argument, if not passed. |
128 | - $query_args = wp_parse_args( $get_query_args, array_fill_keys( array( 'post_type', 'action', 'taxonomy', 'page', 'view', 'tab' ), false ) ); |
|
128 | + $query_args = wp_parse_args($get_query_args, array_fill_keys(array('post_type', 'action', 'taxonomy', 'page', 'view', 'tab'), false)); |
|
129 | 129 | |
130 | - switch ( $passed_page ) { |
|
130 | + switch ($passed_page) { |
|
131 | 131 | case 'categories': |
132 | 132 | case 'tags': |
133 | - $has_view = in_array( $passed_view, array( 'list-table', 'edit', 'new' ), true ); |
|
133 | + $has_view = in_array($passed_view, array('list-table', 'edit', 'new'), true); |
|
134 | 134 | |
135 | 135 | if ( |
136 | - ! in_array( $query_args['taxonomy'], array( 'give_forms_category', 'give_forms_tag' ), true ) && |
|
136 | + ! in_array($query_args['taxonomy'], array('give_forms_category', 'give_forms_tag'), true) && |
|
137 | 137 | 'edit-tags.php' !== $pagenow && |
138 | 138 | ( |
139 | 139 | $has_view || |
140 | 140 | ( |
141 | - ( in_array( $passed_view, array( 'list-table', 'new' ), true ) && 'edit' === $query_args['action'] ) || |
|
142 | - ( 'edit' !== $passed_view && 'edit' !== $query_args['action'] ) && |
|
141 | + (in_array($passed_view, array('list-table', 'new'), true) && 'edit' === $query_args['action']) || |
|
142 | + ('edit' !== $passed_view && 'edit' !== $query_args['action']) && |
|
143 | 143 | ! $has_view |
144 | 144 | ) |
145 | 145 | ) |
@@ -149,18 +149,18 @@ discard block |
||
149 | 149 | break; |
150 | 150 | // Give Donation form page. |
151 | 151 | case 'give_forms': |
152 | - $has_view = in_array( $passed_view, array( 'new', 'list-table', 'edit' ), true ); |
|
152 | + $has_view = in_array($passed_view, array('new', 'list-table', 'edit'), true); |
|
153 | 153 | |
154 | 154 | if ( |
155 | 155 | 'give_forms' !== $typenow && |
156 | 156 | ( |
157 | - ( 'list-table' !== $passed_view && 'edit.php' !== $pagenow ) && |
|
158 | - ( 'edit' !== $passed_view && 'post.php' !== $pagenow ) && |
|
159 | - ( 'new' !== $passed_view && 'post-new.php' !== $pagenow ) |
|
157 | + ('list-table' !== $passed_view && 'edit.php' !== $pagenow) && |
|
158 | + ('edit' !== $passed_view && 'post.php' !== $pagenow) && |
|
159 | + ('new' !== $passed_view && 'post-new.php' !== $pagenow) |
|
160 | 160 | ) || |
161 | 161 | ( |
162 | 162 | ! $has_view && |
163 | - ( 'post-new.php' !== $pagenow && 'give_forms' !== $query_args['post_type'] ) |
|
163 | + ('post-new.php' !== $pagenow && 'give_forms' !== $query_args['post_type']) |
|
164 | 164 | ) |
165 | 165 | ) { |
166 | 166 | $found = false; |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | break; |
169 | 169 | // Give Donors page. |
170 | 170 | case 'donors': |
171 | - $has_view = array_intersect( array( $passed_view, $query_args['view'] ), array( 'list-table', 'overview', 'notes' ) ); |
|
171 | + $has_view = array_intersect(array($passed_view, $query_args['view']), array('list-table', 'overview', 'notes')); |
|
172 | 172 | |
173 | 173 | if ( |
174 | - ( 'give-donors' !== $query_args['page'] || 'edit.php' !== $pagenow ) && |
|
174 | + ('give-donors' !== $query_args['page'] || 'edit.php' !== $pagenow) && |
|
175 | 175 | ( |
176 | - ( $passed_view !== $query_args['view'] || ! empty( $has_view ) ) || |
|
177 | - ( false !== $query_args['view'] && 'list-table' !== $passed_view ) |
|
176 | + ($passed_view !== $query_args['view'] || ! empty($has_view)) || |
|
177 | + (false !== $query_args['view'] && 'list-table' !== $passed_view) |
|
178 | 178 | ) |
179 | 179 | ) { |
180 | 180 | $found = false; |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | // Give Donations page. |
184 | 184 | case 'payments': |
185 | 185 | if ( |
186 | - ( 'give-payment-history' !== $query_args['page'] || 'edit.php' !== $pagenow ) && |
|
186 | + ('give-payment-history' !== $query_args['page'] || 'edit.php' !== $pagenow) && |
|
187 | 187 | ( |
188 | - ! in_array( $passed_view, array( 'list-table', 'edit' ), true ) || |
|
188 | + ! in_array($passed_view, array('list-table', 'edit'), true) || |
|
189 | 189 | ( |
190 | - ( 'list-table' !== $passed_view && false !== $query_args['view'] ) || |
|
191 | - ( 'edit' !== $passed_view && 'view-payment-details' !== $query_args['view'] ) |
|
190 | + ('list-table' !== $passed_view && false !== $query_args['view']) || |
|
191 | + ('edit' !== $passed_view && 'view-payment-details' !== $query_args['view']) |
|
192 | 192 | ) |
193 | 193 | ) |
194 | 194 | ) { |
@@ -199,20 +199,20 @@ discard block |
||
199 | 199 | case 'settings': |
200 | 200 | case 'addons': |
201 | 201 | // Get current tab. |
202 | - $current_tab = empty( $passed_view ) ? $query_args['tab'] : $passed_view; |
|
203 | - $give_setting_page = in_array( $query_args['page'], array( 'give-reports', 'give-settings', 'give-addons' ), true ); |
|
202 | + $current_tab = empty($passed_view) ? $query_args['tab'] : $passed_view; |
|
203 | + $give_setting_page = in_array($query_args['page'], array('give-reports', 'give-settings', 'give-addons'), true); |
|
204 | 204 | |
205 | 205 | // Check if it's Give Setting page or not. |
206 | 206 | if ( |
207 | - ( 'edit.php' !== $pagenow || ! $give_setting_page ) && |
|
208 | - ! Give_Admin_Settings::is_setting_page( $current_tab ) |
|
207 | + ('edit.php' !== $pagenow || ! $give_setting_page) && |
|
208 | + ! Give_Admin_Settings::is_setting_page($current_tab) |
|
209 | 209 | ) { |
210 | 210 | $found = false; |
211 | 211 | } |
212 | 212 | break; |
213 | 213 | default: |
214 | 214 | global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_donors_page, $give_tools_page; |
215 | - $admin_pages = apply_filters( 'give_admin_pages', array( |
|
215 | + $admin_pages = apply_filters('give_admin_pages', array( |
|
216 | 216 | $give_payments_page, |
217 | 217 | $give_settings_page, |
218 | 218 | $give_reports_page, |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | $give_donors_page, |
223 | 223 | $give_tools_page, |
224 | 224 | 'widgets.php', |
225 | - ) ); |
|
225 | + )); |
|
226 | 226 | |
227 | - $found = ( 'give_forms' === $typenow || in_array( $pagenow, array_merge( $admin_pages, array( 'index.php', 'post-new.php', 'post.php' ) ), true ) ) ? true : false; |
|
227 | + $found = ('give_forms' === $typenow || in_array($pagenow, array_merge($admin_pages, array('index.php', 'post-new.php', 'post.php')), true)) ? true : false; |
|
228 | 228 | } |
229 | - return (bool) apply_filters( 'give_is_admin_page', $found, $query_args['page'], $query_args['view'], $passed_page, $passed_view ); |
|
229 | + return (bool) apply_filters('give_is_admin_page', $found, $query_args['page'], $query_args['view'], $passed_page, $passed_view); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -236,37 +236,37 @@ discard block |
||
236 | 236 | * @param array $settings |
237 | 237 | * @return array |
238 | 238 | */ |
239 | -function give_settings_page_pages( $settings ) { |
|
240 | - include( 'abstract-admin-settings-page.php' ); |
|
241 | - include( 'settings/class-settings-cmb2-backward-compatibility.php' ); |
|
239 | +function give_settings_page_pages($settings) { |
|
240 | + include('abstract-admin-settings-page.php'); |
|
241 | + include('settings/class-settings-cmb2-backward-compatibility.php'); |
|
242 | 242 | |
243 | 243 | $settings = array( |
244 | 244 | // General settings. |
245 | - include( GIVE_PLUGIN_DIR . 'includes/admin/settings/class-settings-general.php' ), |
|
245 | + include(GIVE_PLUGIN_DIR.'includes/admin/settings/class-settings-general.php'), |
|
246 | 246 | |
247 | 247 | // Payment Gateways Settings. |
248 | - include( GIVE_PLUGIN_DIR . 'includes/admin/settings/class-settings-gateways.php' ), |
|
248 | + include(GIVE_PLUGIN_DIR.'includes/admin/settings/class-settings-gateways.php'), |
|
249 | 249 | |
250 | 250 | // Display settings. |
251 | - include( GIVE_PLUGIN_DIR . 'includes/admin/settings/class-settings-display.php' ), |
|
251 | + include(GIVE_PLUGIN_DIR.'includes/admin/settings/class-settings-display.php'), |
|
252 | 252 | |
253 | 253 | // Emails settings. |
254 | - include( GIVE_PLUGIN_DIR . 'includes/admin/settings/class-settings-email.php' ), |
|
254 | + include(GIVE_PLUGIN_DIR.'includes/admin/settings/class-settings-email.php'), |
|
255 | 255 | |
256 | 256 | // Addons settings. |
257 | - include( GIVE_PLUGIN_DIR . 'includes/admin/settings/class-settings-addon.php' ), |
|
257 | + include(GIVE_PLUGIN_DIR.'includes/admin/settings/class-settings-addon.php'), |
|
258 | 258 | |
259 | 259 | // License settings. |
260 | - include( GIVE_PLUGIN_DIR . 'includes/admin/settings/class-settings-license.php' ), |
|
260 | + include(GIVE_PLUGIN_DIR.'includes/admin/settings/class-settings-license.php'), |
|
261 | 261 | |
262 | 262 | // Advanced settings. |
263 | - include( GIVE_PLUGIN_DIR . 'includes/admin/settings/class-settings-advanced.php' ), |
|
263 | + include(GIVE_PLUGIN_DIR.'includes/admin/settings/class-settings-advanced.php'), |
|
264 | 264 | ); |
265 | 265 | |
266 | 266 | // Output. |
267 | 267 | return $settings; |
268 | 268 | } |
269 | -add_filter( 'give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1 ); |
|
269 | +add_filter('give-settings_get_settings_pages', 'give_settings_page_pages', 0, 1); |
|
270 | 270 | |
271 | 271 | |
272 | 272 | /** |
@@ -276,25 +276,25 @@ discard block |
||
276 | 276 | * @param array $settings |
277 | 277 | * @return array |
278 | 278 | */ |
279 | -function give_reports_page_pages( $settings ) { |
|
280 | - include( 'abstract-admin-settings-page.php' ); |
|
279 | +function give_reports_page_pages($settings) { |
|
280 | + include('abstract-admin-settings-page.php'); |
|
281 | 281 | |
282 | 282 | $settings = array( |
283 | 283 | // Earnings. |
284 | - include( 'reports/class-earnings-report.php' ), |
|
284 | + include('reports/class-earnings-report.php'), |
|
285 | 285 | |
286 | 286 | // Forms. |
287 | - include( 'reports/class-forms-report.php' ), |
|
287 | + include('reports/class-forms-report.php'), |
|
288 | 288 | |
289 | 289 | // Gateways. |
290 | - include( 'reports/class-gateways-report.php' ), |
|
290 | + include('reports/class-gateways-report.php'), |
|
291 | 291 | |
292 | 292 | ); |
293 | 293 | |
294 | 294 | // Output. |
295 | 295 | return $settings; |
296 | 296 | } |
297 | -add_filter( 'give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1 ); |
|
297 | +add_filter('give-reports_get_settings_pages', 'give_reports_page_pages', 0, 1); |
|
298 | 298 | |
299 | 299 | /** |
300 | 300 | * Add setting tab to give-settings page |
@@ -303,34 +303,34 @@ discard block |
||
303 | 303 | * @param array $settings |
304 | 304 | * @return array |
305 | 305 | */ |
306 | -function give_tools_page_pages( $settings ) { |
|
307 | - include( 'abstract-admin-settings-page.php' ); |
|
306 | +function give_tools_page_pages($settings) { |
|
307 | + include('abstract-admin-settings-page.php'); |
|
308 | 308 | |
309 | 309 | $settings = array( |
310 | 310 | |
311 | 311 | // Export. |
312 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/class-settings-export.php' ), |
|
312 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/class-settings-export.php'), |
|
313 | 313 | |
314 | 314 | // Import |
315 | - include_once( GIVE_PLUGIN_DIR . 'includes/admin/tools/class-settings-import.php' ), |
|
315 | + include_once(GIVE_PLUGIN_DIR.'includes/admin/tools/class-settings-import.php'), |
|
316 | 316 | |
317 | 317 | // Logs. |
318 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/class-settings-logs.php' ), |
|
318 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/class-settings-logs.php'), |
|
319 | 319 | |
320 | 320 | // API. |
321 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/class-settings-api.php' ), |
|
321 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/class-settings-api.php'), |
|
322 | 322 | |
323 | 323 | // Data. |
324 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/class-settings-data.php' ), |
|
324 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/class-settings-data.php'), |
|
325 | 325 | |
326 | 326 | // System Info. |
327 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/class-settings-system-info.php' ), |
|
327 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/class-settings-system-info.php'), |
|
328 | 328 | ); |
329 | 329 | |
330 | 330 | // Output. |
331 | 331 | return $settings; |
332 | 332 | } |
333 | -add_filter( 'give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1 ); |
|
333 | +add_filter('give-tools_get_settings_pages', 'give_tools_page_pages', 0, 1); |
|
334 | 334 | |
335 | 335 | /** |
336 | 336 | * Set default tools page tab. |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | * @param string $default_tab Default tab name. |
340 | 340 | * @return string |
341 | 341 | */ |
342 | -function give_set_default_tab_form_tools_page( $default_tab ) { |
|
342 | +function give_set_default_tab_form_tools_page($default_tab) { |
|
343 | 343 | return 'export'; |
344 | 344 | } |
345 | -add_filter( 'give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1 ); |
|
345 | +add_filter('give_default_setting_tab_give-tools', 'give_set_default_tab_form_tools_page', 10, 1); |
|
346 | 346 | |
347 | 347 | |
348 | 348 | /** |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | * @param string $default_tab Default tab name. |
353 | 353 | * @return string |
354 | 354 | */ |
355 | -function give_set_default_tab_form_reports_page( $default_tab ) { |
|
355 | +function give_set_default_tab_form_reports_page($default_tab) { |
|
356 | 356 | return 'earnings'; |
357 | 357 | } |
358 | -add_filter( 'give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1 ); |
|
358 | +add_filter('give_default_setting_tab_give-reports', 'give_set_default_tab_form_reports_page', 10, 1); |
|
359 | 359 | |
360 | 360 | |
361 | 361 | /** |
@@ -368,19 +368,19 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return array |
370 | 370 | */ |
371 | -function give_add_display_page_states( $post_states, $post ) { |
|
371 | +function give_add_display_page_states($post_states, $post) { |
|
372 | 372 | |
373 | - switch ( $post->ID ) { |
|
374 | - case give_get_option( 'success_page' ): |
|
375 | - $post_states['give_successfully_page'] = __( 'Donation Success Page', 'give' ); |
|
373 | + switch ($post->ID) { |
|
374 | + case give_get_option('success_page'): |
|
375 | + $post_states['give_successfully_page'] = __('Donation Success Page', 'give'); |
|
376 | 376 | break; |
377 | 377 | |
378 | - case give_get_option( 'failure_page' ): |
|
379 | - $post_states['give_failure_page'] = __( 'Donation Failed Page', 'give' ); |
|
378 | + case give_get_option('failure_page'): |
|
379 | + $post_states['give_failure_page'] = __('Donation Failed Page', 'give'); |
|
380 | 380 | break; |
381 | 381 | |
382 | - case give_get_option( 'history_page' ): |
|
383 | - $post_states['give_history_page'] = __( 'Donation History Page', 'give' ); |
|
382 | + case give_get_option('history_page'): |
|
383 | + $post_states['give_history_page'] = __('Donation History Page', 'give'); |
|
384 | 384 | break; |
385 | 385 | } |
386 | 386 | |
@@ -388,4 +388,4 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | // Add a post display state for special Give pages. |
391 | -add_filter( 'display_post_states', 'give_add_display_page_states', 10, 2 ); |
|
391 | +add_filter('display_post_states', 'give_add_display_page_states', 10, 2); |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | global $status, $page; |
54 | 54 | |
55 | 55 | // Set parent defaults |
56 | - parent::__construct( array( |
|
57 | - 'singular' => esc_html__( 'API Key', 'give' ), // Singular name of the listed records |
|
58 | - 'plural' => esc_html__( 'API Keys', 'give' ), // Plural name of the listed records |
|
56 | + parent::__construct(array( |
|
57 | + 'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records |
|
58 | + 'plural' => esc_html__('API Keys', 'give'), // Plural name of the listed records |
|
59 | 59 | 'ajax' => false, // Does this table support ajax? |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | 62 | $this->query(); |
63 | 63 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string Column Name |
75 | 75 | */ |
76 | - public function column_default( $item, $column_name ) { |
|
77 | - return $item[ $column_name ]; |
|
76 | + public function column_default($item, $column_name) { |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string Column Name |
89 | 89 | */ |
90 | - public function column_key( $item ) { |
|
91 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>'; |
|
90 | + public function column_key($item) { |
|
91 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string Column Name |
103 | 103 | */ |
104 | - public function column_token( $item ) { |
|
105 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>'; |
|
104 | + public function column_token($item) { |
|
105 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string Column Name |
117 | 117 | */ |
118 | - public function column_secret( $item ) { |
|
119 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>'; |
|
118 | + public function column_secret($item) { |
|
119 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['secret']).'"/>'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,46 +126,46 @@ discard block |
||
126 | 126 | * @since 1.1 |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function column_user( $item ) { |
|
129 | + public function column_user($item) { |
|
130 | 130 | |
131 | 131 | $actions = array(); |
132 | 132 | |
133 | - if ( apply_filters( 'give_api_log_requests', true ) ) { |
|
133 | + if (apply_filters('give_api_log_requests', true)) { |
|
134 | 134 | $actions['view'] = sprintf( |
135 | 135 | '<a href="%s">%s</a>', |
136 | - esc_url( add_query_arg( array( |
|
136 | + esc_url(add_query_arg(array( |
|
137 | 137 | 'section' => 'api_requests', |
138 | 138 | 'post_type' => 'give_forms', |
139 | 139 | 'page' => 'give-tools', |
140 | 140 | 'tab' => 'logs', |
141 | 141 | 's' => $item['email'], |
142 | - ), 'edit.php' ) ), |
|
143 | - esc_html__( 'View API Log', 'give' ) |
|
142 | + ), 'edit.php')), |
|
143 | + esc_html__('View API Log', 'give') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $actions['reissue'] = sprintf( |
148 | 148 | '<a href="%s" class="give-regenerate-api-key">%s</a>', |
149 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
149 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
150 | 150 | 'user_id' => $item['id'], |
151 | 151 | 'give_action' => 'process_api_key', |
152 | 152 | 'give_api_process' => 'regenerate', |
153 | - ) ), 'give-api-nonce' ) ), |
|
154 | - esc_html__( 'Reissue', 'give' ) |
|
153 | + )), 'give-api-nonce')), |
|
154 | + esc_html__('Reissue', 'give') |
|
155 | 155 | ); |
156 | - $actions['revoke'] = sprintf( |
|
156 | + $actions['revoke'] = sprintf( |
|
157 | 157 | '<a href="%s" class="give-revoke-api-key give-delete">%s</a>', |
158 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
158 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
159 | 159 | 'user_id' => $item['id'], |
160 | 160 | 'give_action' => 'process_api_key', |
161 | 161 | 'give_api_process' => 'revoke', |
162 | - ) ), 'give-api-nonce' ) ), |
|
163 | - esc_html__( 'Revoke', 'give' ) |
|
162 | + )), 'give-api-nonce')), |
|
163 | + esc_html__('Revoke', 'give') |
|
164 | 164 | ); |
165 | 165 | |
166 | - $actions = apply_filters( 'give_api_row_actions', array_filter( $actions ) ); |
|
166 | + $actions = apply_filters('give_api_row_actions', array_filter($actions)); |
|
167 | 167 | |
168 | - return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) ); |
|
168 | + return sprintf('%1$s %2$s', $item['user'], $this->row_actions($actions)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | - 'user' => esc_html__( 'Username', 'give' ), |
|
193 | - 'key' => esc_html__( 'Public Key', 'give' ), |
|
194 | - 'token' => esc_html__( 'Token', 'give' ), |
|
195 | - 'secret' => esc_html__( 'Secret Key', 'give' ), |
|
192 | + 'user' => esc_html__('Username', 'give'), |
|
193 | + 'key' => esc_html__('Public Key', 'give'), |
|
194 | + 'token' => esc_html__('Token', 'give'), |
|
195 | + 'secret' => esc_html__('Secret Key', 'give'), |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | return $columns; |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param string $which |
208 | 208 | */ |
209 | - protected function display_tablenav( $which ) { |
|
210 | - if ( 'top' === $which ) { |
|
211 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
209 | + protected function display_tablenav($which) { |
|
210 | + if ('top' === $which) { |
|
211 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
212 | 212 | } |
213 | 213 | ?> |
214 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
214 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
215 | 215 | |
216 | 216 | <div class="alignleft actions bulkactions"> |
217 | - <?php $this->bulk_actions( $which ); ?> |
|
217 | + <?php $this->bulk_actions($which); ?> |
|
218 | 218 | </div> |
219 | 219 | |
220 | 220 | <?php |
221 | - $this->extra_tablenav( $which ); |
|
222 | - $this->pagination( $which ); |
|
221 | + $this->extra_tablenav($which); |
|
222 | + $this->pagination($which); |
|
223 | 223 | ?> |
224 | 224 | |
225 | 225 | <br class="clear"/> |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - function bulk_actions( $which = '' ) { |
|
240 | + function bulk_actions($which = '') { |
|
241 | 241 | // These aren't really bulk actions but this outputs the markup in the right place. |
242 | 242 | static $give_api_is_bottom; |
243 | 243 | |
244 | - if ( $give_api_is_bottom ) { |
|
244 | + if ($give_api_is_bottom) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | ?> |
248 | 248 | <input type="hidden" name="give_action" value="process_api_key"/> |
249 | 249 | <input type="hidden" name="give_api_process" value="generate"/> |
250 | 250 | <?php |
251 | - wp_nonce_field( 'give-api-nonce' ); |
|
251 | + wp_nonce_field('give-api-nonce'); |
|
252 | 252 | /** |
253 | 253 | * API Key user search. |
254 | 254 | */ |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | 'name' => 'user_id', |
258 | 258 | ); |
259 | 259 | |
260 | - echo Give()->html->ajax_user_search( $args ); |
|
260 | + echo Give()->html->ajax_user_search($args); |
|
261 | 261 | |
262 | - submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); |
|
262 | + submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); |
|
263 | 263 | |
264 | 264 | $give_api_is_bottom = true; |
265 | 265 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return int Current page number |
273 | 273 | */ |
274 | 274 | public function get_paged() { |
275 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
275 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -283,21 +283,21 @@ discard block |
||
283 | 283 | * @return array |
284 | 284 | */ |
285 | 285 | public function query() { |
286 | - $users = get_users( array( |
|
286 | + $users = get_users(array( |
|
287 | 287 | 'meta_value' => 'give_user_secret_key', |
288 | 288 | 'number' => $this->per_page, |
289 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
290 | - ) ); |
|
291 | - $keys = array(); |
|
292 | - |
|
293 | - foreach ( $users as $user ) { |
|
294 | - $keys[ $user->ID ]['id'] = $user->ID; |
|
295 | - $keys[ $user->ID ]['email'] = $user->user_email; |
|
296 | - $keys[ $user->ID ]['user'] = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>'; |
|
297 | - |
|
298 | - $keys[ $user->ID ]['key'] = Give()->api->get_user_public_key( $user->ID ); |
|
299 | - $keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID ); |
|
300 | - $keys[ $user->ID ]['token'] = Give()->api->get_token( $user->ID ); |
|
289 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
290 | + )); |
|
291 | + $keys = array(); |
|
292 | + |
|
293 | + foreach ($users as $user) { |
|
294 | + $keys[$user->ID]['id'] = $user->ID; |
|
295 | + $keys[$user->ID]['email'] = $user->user_email; |
|
296 | + $keys[$user->ID]['user'] = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>'; |
|
297 | + |
|
298 | + $keys[$user->ID]['key'] = Give()->api->get_user_public_key($user->ID); |
|
299 | + $keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID); |
|
300 | + $keys[$user->ID]['token'] = Give()->api->get_token($user->ID); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | return $keys; |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | public function total_items() { |
315 | 315 | global $wpdb; |
316 | 316 | |
317 | - $total_items = Give_Cache::get( 'give_total_api_keys', true ); |
|
317 | + $total_items = Give_Cache::get('give_total_api_keys', true); |
|
318 | 318 | |
319 | - if ( ! $total_items ) { |
|
319 | + if ( ! $total_items) { |
|
320 | 320 | $total_items = $wpdb->get_var( |
321 | 321 | $wpdb->prepare( |
322 | 322 | "SELECT count(user_id) |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | ) |
326 | 326 | ); |
327 | 327 | |
328 | - Give_Cache::set( 'give_total_api_keys', $total_items, HOUR_IN_SECONDS, true ); |
|
328 | + Give_Cache::set('give_total_api_keys', $total_items, HOUR_IN_SECONDS, true); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $total_items; |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $hidden = array(); // No hidden columns |
345 | 345 | $sortable = array(); // Not sortable... for now |
346 | 346 | |
347 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
347 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
348 | 348 | |
349 | 349 | $data = $this->query(); |
350 | 350 | |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | |
353 | 353 | $this->items = $data; |
354 | 354 | |
355 | - $this->set_pagination_args( array( |
|
355 | + $this->set_pagination_args(array( |
|
356 | 356 | 'total_items' => $total_items, |
357 | 357 | 'per_page' => $this->per_page, |
358 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
359 | - ) ); |
|
358 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
359 | + )); |
|
360 | 360 | } |
361 | 361 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return string |
27 | 27 | */ |
28 | -function __give_get_format_address( $address, $address_args = array() ) { |
|
28 | +function __give_get_format_address($address, $address_args = array()) { |
|
29 | 29 | $address_html = ''; |
30 | 30 | $address_args = wp_parse_args( |
31 | 31 | $address_args, |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $address_id = $address_args['type']; |
41 | 41 | |
42 | 42 | // Bailout. |
43 | - if ( empty( $address ) || ! is_array( $address ) ) { |
|
43 | + if (empty($address) || ! is_array($address)) { |
|
44 | 44 | return $address_html; |
45 | 45 | } |
46 | 46 | |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | $address_html .= sprintf( |
50 | 50 | '<span data-address-type="line1">%1$s</span>%2$s', |
51 | 51 | $address['line1'], |
52 | - ( ! empty( $address['line2'] ) ? '<br>' : '' ) |
|
52 | + ( ! empty($address['line2']) ? '<br>' : '') |
|
53 | 53 | ); |
54 | 54 | $address_html .= sprintf( |
55 | 55 | '<span data-address-type="line2">%1$s</span>%2$s', |
56 | 56 | $address['line2'], |
57 | - ( ! empty( $address['city'] ) ? '<br>' : '' ) |
|
57 | + ( ! empty($address['city']) ? '<br>' : '') |
|
58 | 58 | ); |
59 | 59 | $address_html .= sprintf( |
60 | 60 | '<span data-address-type="city">%1$s</span><span data-address-type="state">%2$s</span><span data-address-type="zip">%3$s</span>%4$s', |
61 | 61 | $address['city'], |
62 | - ( ! empty( $address['state'] ) ? ", {$address['state']}" : '' ), |
|
63 | - ( ! empty( $address['zip'] ) ? " {$address['zip']}" : '' ), |
|
64 | - ( ! empty( $address['country'] ) ? '<br>' : '' ) |
|
62 | + ( ! empty($address['state']) ? ", {$address['state']}" : ''), |
|
63 | + ( ! empty($address['zip']) ? " {$address['zip']}" : ''), |
|
64 | + ( ! empty($address['country']) ? '<br>' : '') |
|
65 | 65 | ); |
66 | 66 | $address_html .= sprintf( |
67 | 67 | '<span data-address-type="country">%s</span><br>', |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | // Address action. |
72 | 72 | $address_html .= sprintf( |
73 | 73 | '<br><a href="#" class="js-edit">%1$s</a> | <a href="#" class="js-remove">%2$s</a>', |
74 | - __( 'Edit', 'give' ), |
|
75 | - __( 'Remove', 'give' ) |
|
74 | + __('Edit', 'give'), |
|
75 | + __('Remove', 'give') |
|
76 | 76 | ); |
77 | 77 | |
78 | 78 | /** |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 2.0 |
82 | 82 | */ |
83 | - $address_label = apply_filters( "give_donor_{$address_args['type']}_address_label", ucfirst( $address_args['type'] ), $address_args ); |
|
83 | + $address_label = apply_filters("give_donor_{$address_args['type']}_address_label", ucfirst($address_args['type']), $address_args); |
|
84 | 84 | |
85 | 85 | // Set unique id and index for multi type address. |
86 | - if ( isset( $address_args['index'] ) ) { |
|
86 | + if (isset($address_args['index'])) { |
|
87 | 87 | $address_label = "{$address_label} #{$address_args['index']}"; |
88 | 88 | } |
89 | 89 | |
90 | - if ( isset( $address_args['id'] ) ) { |
|
90 | + if (isset($address_args['id'])) { |
|
91 | 91 | $address_id = "{$address_id}_{$address_args['id']}"; |
92 | 92 | } |
93 | 93 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function give_donors_page() { |
114 | 114 | $default_views = give_donor_views(); |
115 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
|
116 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
117 | - give_render_donor_view( $requested_view, $default_views ); |
|
115 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors'; |
|
116 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
117 | + give_render_donor_view($requested_view, $default_views); |
|
118 | 118 | } else { |
119 | 119 | give_donors_list(); |
120 | 120 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | $views = array(); |
132 | 132 | |
133 | - return apply_filters( 'give_donor_views', $views ); |
|
133 | + return apply_filters('give_donor_views', $views); |
|
134 | 134 | |
135 | 135 | } |
136 | 136 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | $tabs = array(); |
146 | 146 | |
147 | - return apply_filters( 'give_donor_tabs', $tabs ); |
|
147 | + return apply_filters('give_donor_tabs', $tabs); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | function give_donors_list() { |
158 | 158 | |
159 | - include GIVE_PLUGIN_DIR . 'includes/admin/donors/class-donor-table.php'; |
|
159 | + include GIVE_PLUGIN_DIR.'includes/admin/donors/class-donor-table.php'; |
|
160 | 160 | |
161 | 161 | $donors_table = new Give_Donor_List_Table(); |
162 | 162 | $donors_table->prepare_items(); |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @since 1.0 |
171 | 171 | */ |
172 | - do_action( 'give_donors_table_top' ); |
|
172 | + do_action('give_donors_table_top'); |
|
173 | 173 | ?> |
174 | 174 | |
175 | 175 | <hr class="wp-header-end"> |
176 | - <form id="give-donors-search-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
177 | - <?php $donors_table->search_box( __( 'Search Donors', 'give' ), 'give-donors' ); ?> |
|
176 | + <form id="give-donors-search-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
177 | + <?php $donors_table->search_box(__('Search Donors', 'give'), 'give-donors'); ?> |
|
178 | 178 | <input type="hidden" name="post_type" value="give_forms" /> |
179 | 179 | <input type="hidden" name="page" value="give-donors" /> |
180 | 180 | <input type="hidden" name="view" value="donors" /> |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @since 1.0 |
193 | 193 | */ |
194 | - do_action( 'give_donors_table_bottom' ); |
|
194 | + do_action('give_donors_table_bottom'); |
|
195 | 195 | ?> |
196 | 196 | </div> |
197 | 197 | <?php |
@@ -207,33 +207,33 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return void |
209 | 209 | */ |
210 | -function give_render_donor_view( $view, $callbacks ) { |
|
210 | +function give_render_donor_view($view, $callbacks) { |
|
211 | 211 | |
212 | 212 | $render = true; |
213 | 213 | |
214 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
214 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
215 | 215 | |
216 | - if ( ! current_user_can( $donor_view_role ) ) { |
|
217 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
216 | + if ( ! current_user_can($donor_view_role)) { |
|
217 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
218 | 218 | $render = false; |
219 | 219 | } |
220 | 220 | |
221 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
222 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
221 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
222 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
223 | 223 | $render = false; |
224 | 224 | } |
225 | 225 | |
226 | 226 | $donor_id = (int) $_GET['id']; |
227 | - $reconnect_user_id = ! empty( $_GET['user_id'] ) ? (int) $_GET['user_id'] : ''; |
|
228 | - $donor = new Give_Donor( $donor_id ); |
|
227 | + $reconnect_user_id = ! empty($_GET['user_id']) ? (int) $_GET['user_id'] : ''; |
|
228 | + $donor = new Give_Donor($donor_id); |
|
229 | 229 | |
230 | 230 | // Reconnect User with Donor profile. |
231 | - if ( $reconnect_user_id ) { |
|
232 | - give_connect_user_donor_profile( $donor, array( 'user_id' => $reconnect_user_id ), array() ); |
|
231 | + if ($reconnect_user_id) { |
|
232 | + give_connect_user_donor_profile($donor, array('user_id' => $reconnect_user_id), array()); |
|
233 | 233 | } |
234 | 234 | |
235 | - if ( empty( $donor->id ) ) { |
|
236 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
235 | + if (empty($donor->id)) { |
|
236 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
237 | 237 | $render = false; |
238 | 238 | } |
239 | 239 | |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | |
243 | 243 | <div class='wrap'> |
244 | 244 | |
245 | - <?php if ( give_get_errors() ) : ?> |
|
245 | + <?php if (give_get_errors()) : ?> |
|
246 | 246 | <div class="error settings-error"> |
247 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
247 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
248 | 248 | </div> |
249 | 249 | <?php endif; ?> |
250 | 250 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | <?php |
253 | 253 | printf( |
254 | 254 | /* translators: %s: donor first name */ |
255 | - __( 'Edit Donor: %s %s', 'give' ), |
|
255 | + __('Edit Donor: %s %s', 'give'), |
|
256 | 256 | $donor->get_first_name(), |
257 | 257 | $donor->get_last_name() |
258 | 258 | ); |
@@ -261,26 +261,26 @@ discard block |
||
261 | 261 | |
262 | 262 | <hr class="wp-header-end"> |
263 | 263 | |
264 | - <?php if ( $donor && $render ) : ?> |
|
264 | + <?php if ($donor && $render) : ?> |
|
265 | 265 | |
266 | 266 | <h2 class="nav-tab-wrapper"> |
267 | 267 | <?php |
268 | - foreach ( $donor_tabs as $key => $tab ) : |
|
268 | + foreach ($donor_tabs as $key => $tab) : |
|
269 | 269 | $active = $key === $view ? true : false; |
270 | 270 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
271 | 271 | printf( |
272 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
273 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
|
274 | - esc_attr( $class ), |
|
275 | - sanitize_html_class( $tab['dashicon'] ), |
|
276 | - esc_html( $tab['title'] ) |
|
272 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
273 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)), |
|
274 | + esc_attr($class), |
|
275 | + sanitize_html_class($tab['dashicon']), |
|
276 | + esc_html($tab['title']) |
|
277 | 277 | ); |
278 | 278 | endforeach; |
279 | 279 | ?> |
280 | 280 | </h2> |
281 | 281 | |
282 | 282 | <div id="give-donor-card-wrapper"> |
283 | - <?php $callbacks[ $view ]( $donor ) ?> |
|
283 | + <?php $callbacks[$view]($donor) ?> |
|
284 | 284 | </div> |
285 | 285 | |
286 | 286 | <?php endif; ?> |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return void |
302 | 302 | */ |
303 | -function give_donor_view( $donor ) { |
|
303 | +function give_donor_view($donor) { |
|
304 | 304 | |
305 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
305 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
306 | 306 | |
307 | 307 | /** |
308 | 308 | * Fires in donor profile screen, above the donor card. |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @param object $donor The donor object being displayed. |
313 | 313 | */ |
314 | - do_action( 'give_donor_card_top', $donor ); |
|
314 | + do_action('give_donor_card_top', $donor); |
|
315 | 315 | |
316 | 316 | // Set Read only to the fields which needs to be locked. |
317 | 317 | $read_only = ''; |
318 | - if ( $donor->user_id ) { |
|
318 | + if ($donor->user_id) { |
|
319 | 319 | $read_only = 'readonly="readonly"'; |
320 | 320 | } |
321 | 321 | ?> |
@@ -323,32 +323,32 @@ discard block |
||
323 | 323 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
324 | 324 | |
325 | 325 | <form id="edit-donor-info" method="post" |
326 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
326 | + action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
327 | 327 | |
328 | 328 | <div class="donor-info"> |
329 | 329 | |
330 | 330 | <div class="donor-bio-header clearfix"> |
331 | 331 | |
332 | 332 | <div class="avatar-wrap left" id="donor-avatar"> |
333 | - <?php echo get_avatar( $donor->email ); ?> |
|
333 | + <?php echo get_avatar($donor->email); ?> |
|
334 | 334 | </div> |
335 | 335 | |
336 | 336 | <div id="donor-name-wrap" class="left"> |
337 | 337 | <span class="donor-name info-item edit-item"> |
338 | 338 | <input <?php echo $read_only; ?> size="15" data-key="first_name" |
339 | 339 | name="customerinfo[first_name]" type="text" |
340 | - value="<?php esc_attr_e( $donor->get_first_name() ); ?>" |
|
341 | - placeholder="<?php _e( 'First Name', 'give' ); ?>"/> |
|
342 | - <?php if ( $donor->user_id ) : ?> |
|
340 | + value="<?php esc_attr_e($donor->get_first_name()); ?>" |
|
341 | + placeholder="<?php _e('First Name', 'give'); ?>"/> |
|
342 | + <?php if ($donor->user_id) : ?> |
|
343 | 343 | <a href="#" class="give-lock-block"> |
344 | 344 | <i class="give-icon give-icon-locked"></i> |
345 | 345 | </a> |
346 | 346 | <?php endif; ?> |
347 | 347 | <input <?php echo $read_only; ?> size="15" data-key="last_name" |
348 | 348 | name="customerinfo[last_name]" type="text" |
349 | - value="<?php esc_attr_e( $donor->get_last_name() ); ?>" |
|
350 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>"/> |
|
351 | - <?php if ( $donor->user_id ) : ?> |
|
349 | + value="<?php esc_attr_e($donor->get_last_name()); ?>" |
|
350 | + placeholder="<?php _e('Last Name', 'give'); ?>"/> |
|
351 | + <?php if ($donor->user_id) : ?> |
|
352 | 352 | <a href="#" class="give-lock-block"> |
353 | 353 | <i class="give-icon give-icon-locked"></i> |
354 | 354 | </a> |
@@ -358,12 +358,12 @@ discard block |
||
358 | 358 | data-key="name"><?php echo $donor->name; ?></span></span> |
359 | 359 | </div> |
360 | 360 | <p class="donor-since info-item"> |
361 | - <?php _e( 'Donor since', 'give' ); ?> |
|
362 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
|
361 | + <?php _e('Donor since', 'give'); ?> |
|
362 | + <?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?> |
|
363 | 363 | </p> |
364 | - <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
|
364 | + <?php if (current_user_can($donor_edit_role)) : ?> |
|
365 | 365 | <a href="#" id="edit-donor" |
366 | - class="button info-item editable donor-edit-link"><?php _e( 'Edit Donor', 'give' ); ?></a> |
|
366 | + class="button info-item editable donor-edit-link"><?php _e('Edit Donor', 'give'); ?></a> |
|
367 | 367 | <?php endif; ?> |
368 | 368 | </div> |
369 | 369 | <!-- /donor-bio-header --> |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | <table class="widefat striped"> |
374 | 374 | <tbody> |
375 | 375 | <tr> |
376 | - <th scope="col"><label for="tablecell"><?php _e( 'Donor ID:', 'give' ); ?></label></th> |
|
376 | + <th scope="col"><label for="tablecell"><?php _e('Donor ID:', 'give'); ?></label></th> |
|
377 | 377 | <td><?php echo $donor->id; ?></td> |
378 | 378 | </tr> |
379 | 379 | <tr> |
380 | - <th scope="col"><label for="tablecell"><?php _e( 'User ID:', 'give' ); ?></label></th> |
|
380 | + <th scope="col"><label for="tablecell"><?php _e('User ID:', 'give'); ?></label></th> |
|
381 | 381 | <td> |
382 | 382 | <span class="donor-user-id info-item edit-item"> |
383 | 383 | <?php |
@@ -394,22 +394,22 @@ discard block |
||
394 | 394 | 'data' => $data_atts, |
395 | 395 | ); |
396 | 396 | |
397 | - if ( ! empty( $user_id ) ) { |
|
398 | - $userdata = get_userdata( $user_id ); |
|
397 | + if ( ! empty($user_id)) { |
|
398 | + $userdata = get_userdata($user_id); |
|
399 | 399 | $user_args['selected'] = $user_id; |
400 | 400 | } |
401 | 401 | |
402 | - echo Give()->html->ajax_user_search( $user_args ); |
|
402 | + echo Give()->html->ajax_user_search($user_args); |
|
403 | 403 | ?> |
404 | 404 | </span> |
405 | 405 | |
406 | 406 | <span class="donor-user-id info-item editable"> |
407 | - <?php if ( ! empty( $userdata ) ) : ?> |
|
408 | - <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
|
407 | + <?php if ( ! empty($userdata)) : ?> |
|
408 | + <span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span> |
|
409 | 409 | <?php else: ?> |
410 | - <span data-key="user_id"><?php _e( 'Unregistered', 'give' ); ?></span> |
|
410 | + <span data-key="user_id"><?php _e('Unregistered', 'give'); ?></span> |
|
411 | 411 | <?php endif; ?> |
412 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ): |
|
412 | + <?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0): |
|
413 | 413 | |
414 | 414 | echo sprintf( |
415 | 415 | '- <span class="disconnect-user"> |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | | <span class="view-user-profile"> |
419 | 419 | <a id="view-user-profile" href="%3$s" aria-label="%4$s">%5$s</a> |
420 | 420 | </span>', |
421 | - __( 'Disconnects the current user ID from this donor record.', 'give' ), |
|
422 | - __( 'Disconnect User', 'give' ), |
|
423 | - 'user-edit.php?user_id=' . $donor->user_id, |
|
424 | - __( 'View User Profile of current user ID.', 'give' ), |
|
425 | - __( 'View User Profile', 'give' ) |
|
421 | + __('Disconnects the current user ID from this donor record.', 'give'), |
|
422 | + __('Disconnect User', 'give'), |
|
423 | + 'user-edit.php?user_id='.$donor->user_id, |
|
424 | + __('View User Profile of current user ID.', 'give'), |
|
425 | + __('View User Profile', 'give') |
|
426 | 426 | ); |
427 | 427 | |
428 | 428 | endif; ?> |
@@ -431,13 +431,13 @@ discard block |
||
431 | 431 | </tr> |
432 | 432 | |
433 | 433 | <?php |
434 | - $donor_company = $donor->get_meta( '_give_donor_company', true ); |
|
434 | + $donor_company = $donor->get_meta('_give_donor_company', true); |
|
435 | 435 | |
436 | - if ( ! empty( $donor_company ) ) { |
|
436 | + if ( ! empty($donor_company)) { |
|
437 | 437 | ?> |
438 | 438 | <tr class="alternate"> |
439 | 439 | <th scope="col"> |
440 | - <label for="tablecell"><?php _e( 'Company Name:', 'give' ); ?></label> |
|
440 | + <label for="tablecell"><?php _e('Company Name:', 'give'); ?></label> |
|
441 | 441 | </th> |
442 | 442 | <td><?php echo $donor_company; ?></td> |
443 | 443 | </tr> |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | |
454 | 454 | <span id="donor-edit-actions" class="edit-item"> |
455 | 455 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>"/> |
456 | - <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
|
456 | + <?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?> |
|
457 | 457 | <input type="hidden" name="give_action" value="edit-donor"/> |
458 | 458 | <input type="submit" id="give-edit-donor-save" class="button-secondary" |
459 | - value="<?php _e( 'Update Donor', 'give' ); ?>"/> |
|
460 | - <a id="give-edit-donor-cancel" href="" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
459 | + value="<?php _e('Update Donor', 'give'); ?>"/> |
|
460 | + <a id="give-edit-donor-cancel" href="" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
461 | 461 | </span> |
462 | 462 | |
463 | 463 | </form> |
@@ -472,24 +472,24 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @param Give_Donor $donor The donor object being displayed. |
474 | 474 | */ |
475 | - do_action( 'give_donor_before_stats', $donor ); |
|
475 | + do_action('give_donor_before_stats', $donor); |
|
476 | 476 | ?> |
477 | 477 | |
478 | 478 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
479 | 479 | <ul> |
480 | 480 | <li> |
481 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>"> |
|
481 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>"> |
|
482 | 482 | <span class="dashicons dashicons-heart"></span> |
483 | 483 | <?php |
484 | 484 | // Completed Donations. |
485 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
|
486 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
|
485 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count); |
|
486 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor); |
|
487 | 487 | ?> |
488 | 488 | </a> |
489 | 489 | </li> |
490 | 490 | <li> |
491 | 491 | <span class="dashicons dashicons-chart-area"></span> |
492 | - <?php echo give_currency_filter( give_format_amount( $donor->get_total_donation_amount(), array( 'sanitize' => false ) ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?> |
|
492 | + <?php echo give_currency_filter(give_format_amount($donor->get_total_donation_amount(), array('sanitize' => false))); ?> <?php _e('Lifetime Donations', 'give'); ?> |
|
493 | 493 | </li> |
494 | 494 | <?php |
495 | 495 | /** |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * |
502 | 502 | * @param object $donor The donor object being displayed. |
503 | 503 | */ |
504 | - do_action( 'give_donor_stats_list', $donor ); |
|
504 | + do_action('give_donor_stats_list', $donor); |
|
505 | 505 | ?> |
506 | 506 | </ul> |
507 | 507 | </div> |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @param Give_Donor $donor The donor object being displayed. |
516 | 516 | */ |
517 | - do_action( 'give_donor_before_address', $donor ); |
|
517 | + do_action('give_donor_before_address', $donor); |
|
518 | 518 | ?> |
519 | 519 | |
520 | 520 | <div id="donor-address-wrapper" class="donor-section clear"> |
521 | - <h3><?php _e( 'Addresses', 'give' ); ?></h3> |
|
521 | + <h3><?php _e('Addresses', 'give'); ?></h3> |
|
522 | 522 | |
523 | 523 | <div class="postbox"> |
524 | 524 | <div class="give-spinner-wrapper"> |
@@ -528,16 +528,16 @@ discard block |
||
528 | 528 | <div class="all-address"> |
529 | 529 | <div class="give-grid-row"> |
530 | 530 | <?php |
531 | - if ( ! empty( $donor->address ) ) : |
|
531 | + if ( ! empty($donor->address)) : |
|
532 | 532 | // Default address always will be at zero array index. |
533 | 533 | $is_set_as_default = null; |
534 | 534 | |
535 | - foreach ( $donor->address as $address_type => $addresses ) { |
|
535 | + foreach ($donor->address as $address_type => $addresses) { |
|
536 | 536 | |
537 | - switch ( true ) { |
|
538 | - case is_array( end( $addresses ) ): |
|
537 | + switch (true) { |
|
538 | + case is_array(end($addresses)): |
|
539 | 539 | $index = 1; |
540 | - foreach ( $addresses as $id => $address ) { |
|
540 | + foreach ($addresses as $id => $address) { |
|
541 | 541 | echo __give_get_format_address( |
542 | 542 | $address, |
543 | 543 | array( |
@@ -547,11 +547,11 @@ discard block |
||
547 | 547 | ) |
548 | 548 | ); |
549 | 549 | |
550 | - $index ++; |
|
550 | + $index++; |
|
551 | 551 | } |
552 | 552 | break; |
553 | 553 | |
554 | - case is_string( end( $addresses ) ): |
|
554 | + case is_string(end($addresses)): |
|
555 | 555 | echo __give_get_format_address( |
556 | 556 | $addresses, |
557 | 557 | array( |
@@ -564,13 +564,13 @@ discard block |
||
564 | 564 | endif; |
565 | 565 | ?> |
566 | 566 | </div> |
567 | - <span class="give-no-address-message<?php if ( ! empty( $donor->address ) ) { |
|
567 | + <span class="give-no-address-message<?php if ( ! empty($donor->address)) { |
|
568 | 568 | echo ' give-hidden'; |
569 | 569 | } ?>"> |
570 | - <?php _e( 'This donor does not have any addresses saved.', 'give' ); ?> |
|
570 | + <?php _e('This donor does not have any addresses saved.', 'give'); ?> |
|
571 | 571 | </span> |
572 | 572 | <button class="button add-new-address"> |
573 | - <?php _e( 'Add Address', 'give' ); ?> |
|
573 | + <?php _e('Add Address', 'give'); ?> |
|
574 | 574 | </button> |
575 | 575 | </div> |
576 | 576 | |
@@ -580,26 +580,26 @@ discard block |
||
580 | 580 | <tbody> |
581 | 581 | <tr> |
582 | 582 | <th class="col"> |
583 | - <label class="country"><?php esc_html_e( 'Country:', 'give' ); ?></label> |
|
583 | + <label class="country"><?php esc_html_e('Country:', 'give'); ?></label> |
|
584 | 584 | </th> |
585 | 585 | <td> |
586 | 586 | <?php |
587 | - echo Give()->html->select( array( |
|
587 | + echo Give()->html->select(array( |
|
588 | 588 | 'options' => give_get_country_list(), |
589 | 589 | 'name' => 'country', |
590 | - 'selected' => give_get_option( 'base_country' ), |
|
590 | + 'selected' => give_get_option('base_country'), |
|
591 | 591 | 'show_option_all' => false, |
592 | 592 | 'show_option_none' => false, |
593 | 593 | 'chosen' => true, |
594 | - 'placeholder' => esc_attr__( 'Select a country', 'give' ), |
|
595 | - 'data' => array( 'search-type' => 'no_ajax' ), |
|
596 | - ) ); |
|
594 | + 'placeholder' => esc_attr__('Select a country', 'give'), |
|
595 | + 'data' => array('search-type' => 'no_ajax'), |
|
596 | + )); |
|
597 | 597 | ?> |
598 | 598 | </td> |
599 | 599 | </tr> |
600 | 600 | <tr> |
601 | 601 | <th class="col"> |
602 | - <label for="line1"><?php esc_html_e( 'Address 1:', 'give' ); ?></label> |
|
602 | + <label for="line1"><?php esc_html_e('Address 1:', 'give'); ?></label> |
|
603 | 603 | </th> |
604 | 604 | <td> |
605 | 605 | <input id="line1" name="line1" type="text" class="medium-text"/> |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | </tr> |
608 | 608 | <tr> |
609 | 609 | <th class="col"> |
610 | - <label for="line2"><?php esc_html_e( 'Address 2:', 'give' ); ?></label> |
|
610 | + <label for="line2"><?php esc_html_e('Address 2:', 'give'); ?></label> |
|
611 | 611 | </th> |
612 | 612 | <td> |
613 | 613 | <input id="line2" type="text" name="line2" value="" class="medium-text"/> |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | </tr> |
617 | 617 | <tr> |
618 | 618 | <th class="col"> |
619 | - <label for="city"><?php esc_html_e( 'City:', 'give' ); ?></label> |
|
619 | + <label for="city"><?php esc_html_e('City:', 'give'); ?></label> |
|
620 | 620 | </th> |
621 | 621 | <td> |
622 | 622 | <input id="city" type="text" name="city" value="" class="medium-text"/> |
@@ -624,41 +624,41 @@ discard block |
||
624 | 624 | </tr> |
625 | 625 | <?php |
626 | 626 | $no_states_country = give_no_states_country_list(); |
627 | - $base_country = give_get_option( 'base_country' ); |
|
628 | - if ( ! array_key_exists( $base_country, $no_states_country ) ) { |
|
627 | + $base_country = give_get_option('base_country'); |
|
628 | + if ( ! array_key_exists($base_country, $no_states_country)) { |
|
629 | 629 | ?> |
630 | 630 | <tr class="give-field-wrap"> |
631 | 631 | <th class="col"> |
632 | - <label for="state"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label> |
|
632 | + <label for="state"><?php esc_html_e('State / Province / County:', 'give'); ?></label> |
|
633 | 633 | </th> |
634 | 634 | <td> |
635 | 635 | <?php |
636 | - $states = give_get_states( $base_country ); |
|
636 | + $states = give_get_states($base_country); |
|
637 | 637 | $state_args = array( |
638 | 638 | 'name' => 'state', |
639 | 639 | 'class' => 'regular-text', |
640 | 640 | ); |
641 | 641 | |
642 | - if ( empty( $states ) ) { |
|
642 | + if (empty($states)) { |
|
643 | 643 | |
644 | 644 | // Show Text field, if empty states. |
645 | - $state_args = wp_parse_args( $state_args, array( |
|
646 | - 'value' => give_get_option( 'base_state' ), |
|
647 | - ) ); |
|
648 | - echo Give()->html->text( $state_args ); |
|
645 | + $state_args = wp_parse_args($state_args, array( |
|
646 | + 'value' => give_get_option('base_state'), |
|
647 | + )); |
|
648 | + echo Give()->html->text($state_args); |
|
649 | 649 | } else { |
650 | 650 | |
651 | 651 | // Show Chosen DropDown, if states are not empty. |
652 | - $state_args = wp_parse_args( $state_args, array( |
|
652 | + $state_args = wp_parse_args($state_args, array( |
|
653 | 653 | 'options' => $states, |
654 | - 'selected' => give_get_option( 'base_state' ), |
|
654 | + 'selected' => give_get_option('base_state'), |
|
655 | 655 | 'show_option_all' => false, |
656 | 656 | 'show_option_none' => false, |
657 | 657 | 'chosen' => true, |
658 | - 'placeholder' => __( 'Select a state', 'give' ), |
|
659 | - 'data' => array( 'search-type' => 'no_ajax' ), |
|
660 | - ) ); |
|
661 | - echo Give()->html->select( $state_args ); |
|
658 | + 'placeholder' => __('Select a state', 'give'), |
|
659 | + 'data' => array('search-type' => 'no_ajax'), |
|
660 | + )); |
|
661 | + echo Give()->html->select($state_args); |
|
662 | 662 | } |
663 | 663 | ?> |
664 | 664 | </td> |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | ?> |
669 | 669 | <tr> |
670 | 670 | <th class="col"> |
671 | - <label for="zip"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label> |
|
671 | + <label for="zip"><?php esc_html_e('Zip / Postal Code:', 'give'); ?></label> |
|
672 | 672 | </th> |
673 | 673 | <td> |
674 | 674 | <input id="zip" type="text" name="zip" value="" class="medium-text"/> |
@@ -676,12 +676,12 @@ discard block |
||
676 | 676 | </tr> |
677 | 677 | <tr> |
678 | 678 | <td colspan="2"> |
679 | - <?php wp_nonce_field( 'give-manage-donor-addresses', '_wpnonce', false ); ?> |
|
679 | + <?php wp_nonce_field('give-manage-donor-addresses', '_wpnonce', false); ?> |
|
680 | 680 | <input type="hidden" name="address-action" value="add"> |
681 | 681 | <input type="hidden" name="address-id" value=""> |
682 | 682 | <input type="submit" class="button button-primary js-save" |
683 | - value="<?php _e( 'Save', 'give' ); ?>"> <button |
|
684 | - class="button js-cancel"><?php _e( 'Cancel', 'give' ); ?></button> |
|
683 | + value="<?php _e('Save', 'give'); ?>"> <button |
|
684 | + class="button js-cancel"><?php _e('Cancel', 'give'); ?></button> |
|
685 | 685 | </td> |
686 | 686 | </tr> |
687 | 687 | </tbody> |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @param Give_Donor $donor The donor object being displayed. |
702 | 702 | */ |
703 | - do_action( 'give_donor_before_tables_wrapper', $donor ); |
|
703 | + do_action('give_donor_before_tables_wrapper', $donor); |
|
704 | 704 | ?> |
705 | 705 | |
706 | 706 | <div id="donor-tables-wrapper" class="donor-section"> |
@@ -713,46 +713,46 @@ discard block |
||
713 | 713 | * |
714 | 714 | * @param object $donor The donor object being displayed. |
715 | 715 | */ |
716 | - do_action( 'give_donor_before_tables', $donor ); |
|
716 | + do_action('give_donor_before_tables', $donor); |
|
717 | 717 | ?> |
718 | 718 | |
719 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
719 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
720 | 720 | |
721 | 721 | <table class="wp-list-table widefat striped emails"> |
722 | 722 | <thead> |
723 | 723 | <tr> |
724 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
725 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
724 | + <th><?php _e('Email', 'give'); ?></th> |
|
725 | + <th><?php _e('Actions', 'give'); ?></th> |
|
726 | 726 | </tr> |
727 | 727 | </thead> |
728 | 728 | |
729 | 729 | <tbody> |
730 | - <?php if ( ! empty( $donor->emails ) ) { ?> |
|
730 | + <?php if ( ! empty($donor->emails)) { ?> |
|
731 | 731 | |
732 | - <?php foreach ( $donor->emails as $key => $email ) : ?> |
|
732 | + <?php foreach ($donor->emails as $key => $email) : ?> |
|
733 | 733 | <tr data-key="<?php echo $key; ?>"> |
734 | 734 | <td> |
735 | 735 | <?php echo $email; ?> |
736 | - <?php if ( 'primary' === $key ) : ?> |
|
736 | + <?php if ('primary' === $key) : ?> |
|
737 | 737 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
738 | 738 | <?php endif; ?> |
739 | 739 | </td> |
740 | 740 | <td> |
741 | - <?php if ( 'primary' !== $key ) : ?> |
|
741 | + <?php if ('primary' !== $key) : ?> |
|
742 | 742 | <?php |
743 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
|
744 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
745 | - 'email' => rawurlencode( $email ), |
|
743 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); |
|
744 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
745 | + 'email' => rawurlencode($email), |
|
746 | 746 | 'give_action' => 'set_donor_primary_email', |
747 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
748 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
749 | - 'email' => rawurlencode( $email ), |
|
747 | + ), $base_url), 'give-set-donor-primary-email'); |
|
748 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
749 | + 'email' => rawurlencode($email), |
|
750 | 750 | 'give_action' => 'remove_donor_email', |
751 | - ), $base_url ), 'give-remove-donor-email' ); |
|
751 | + ), $base_url), 'give-remove-donor-email'); |
|
752 | 752 | ?> |
753 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
753 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
754 | 754 | | |
755 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
755 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
756 | 756 | <?php endif; ?> |
757 | 757 | </td> |
758 | 758 | </tr> |
@@ -762,14 +762,14 @@ discard block |
||
762 | 762 | <td colspan="2" class="add-donor-email-td"> |
763 | 763 | <div class="add-donor-email-wrapper"> |
764 | 764 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>"/> |
765 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
765 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
766 | 766 | <input type="email" name="additional-email" value="" |
767 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>"/> |
|
767 | + placeholder="<?php _e('Email Address', 'give'); ?>"/> |
|
768 | 768 | <input type="checkbox" name="make-additional-primary" value="1" |
769 | 769 | id="make-additional-primary"/> <label |
770 | - for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
770 | + for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
771 | 771 | <button class="button-secondary give-add-donor-email" |
772 | - id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
772 | + id="add-donor-email"><?php _e('Add Email', 'give'); ?></button> |
|
773 | 773 | <span class="spinner"></span> |
774 | 774 | </div> |
775 | 775 | <div class="notice-wrap"></div> |
@@ -777,50 +777,50 @@ discard block |
||
777 | 777 | </tr> |
778 | 778 | <?php } else { ?> |
779 | 779 | <tr> |
780 | - <td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td> |
|
780 | + <td colspan="2"><?php _e('No Emails Found', 'give'); ?></td> |
|
781 | 781 | </tr> |
782 | 782 | <?php }// End if(). |
783 | 783 | ?> |
784 | 784 | </tbody> |
785 | 785 | </table> |
786 | 786 | |
787 | - <h3><?php _e( 'Recent Donations', 'give' ); ?></h3> |
|
787 | + <h3><?php _e('Recent Donations', 'give'); ?></h3> |
|
788 | 788 | <?php |
789 | - $payment_ids = explode( ',', $donor->payment_ids ); |
|
790 | - $payments = give_get_payments( array( |
|
789 | + $payment_ids = explode(',', $donor->payment_ids); |
|
790 | + $payments = give_get_payments(array( |
|
791 | 791 | 'post__in' => $payment_ids, |
792 | - ) ); |
|
793 | - $payments = array_slice( $payments, 0, 10 ); |
|
792 | + )); |
|
793 | + $payments = array_slice($payments, 0, 10); |
|
794 | 794 | ?> |
795 | 795 | <table class="wp-list-table widefat striped payments"> |
796 | 796 | <thead> |
797 | 797 | <tr> |
798 | - <th scope="col"><?php _e( 'ID', 'give' ); ?></th> |
|
799 | - <th scope="col"><?php _e( 'Amount', 'give' ); ?></th> |
|
800 | - <th scope="col"><?php _e( 'Date', 'give' ); ?></th> |
|
801 | - <th scope="col"><?php _e( 'Status', 'give' ); ?></th> |
|
802 | - <th scope="col"><?php _e( 'Actions', 'give' ); ?></th> |
|
798 | + <th scope="col"><?php _e('ID', 'give'); ?></th> |
|
799 | + <th scope="col"><?php _e('Amount', 'give'); ?></th> |
|
800 | + <th scope="col"><?php _e('Date', 'give'); ?></th> |
|
801 | + <th scope="col"><?php _e('Status', 'give'); ?></th> |
|
802 | + <th scope="col"><?php _e('Actions', 'give'); ?></th> |
|
803 | 803 | </tr> |
804 | 804 | </thead> |
805 | 805 | <tbody> |
806 | - <?php if ( ! empty( $payments ) ) { ?> |
|
807 | - <?php foreach ( $payments as $payment ) : ?> |
|
806 | + <?php if ( ! empty($payments)) { ?> |
|
807 | + <?php foreach ($payments as $payment) : ?> |
|
808 | 808 | <tr> |
809 | - <td><?php echo Give()->seq_donation_number->get_serial_code( $payment->ID ); ?></td> |
|
810 | - <td><?php echo give_donation_amount( $payment->ID, array( 'currency' => true, 'amount' => true, 'type' => 'donor' ) ); ?></td> |
|
811 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
812 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
809 | + <td><?php echo Give()->seq_donation_number->get_serial_code($payment->ID); ?></td> |
|
810 | + <td><?php echo give_donation_amount($payment->ID, array('currency' => true, 'amount' => true, 'type' => 'donor')); ?></td> |
|
811 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
812 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
813 | 813 | <td> |
814 | 814 | <?php |
815 | 815 | printf( |
816 | 816 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
817 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
|
817 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID), |
|
818 | 818 | sprintf( |
819 | 819 | /* translators: %s: Donation ID */ |
820 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
820 | + esc_attr__('View Donation %s.', 'give'), |
|
821 | 821 | $payment->ID |
822 | 822 | ), |
823 | - __( 'View Donation', 'give' ) |
|
823 | + __('View Donation', 'give') |
|
824 | 824 | ); |
825 | 825 | ?> |
826 | 826 | |
@@ -835,47 +835,47 @@ discard block |
||
835 | 835 | * @param object $donor The donor object being displayed. |
836 | 836 | * @param object $payment The payment object being displayed. |
837 | 837 | */ |
838 | - do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
|
838 | + do_action('give_donor_recent_purchases_actions', $donor, $payment); |
|
839 | 839 | ?> |
840 | 840 | </td> |
841 | 841 | </tr> |
842 | 842 | <?php endforeach; ?> |
843 | 843 | <?php } else { ?> |
844 | 844 | <tr> |
845 | - <td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td> |
|
845 | + <td colspan="5"><?php _e('No donations found.', 'give'); ?></td> |
|
846 | 846 | </tr> |
847 | 847 | <?php }// End if(). |
848 | 848 | ?> |
849 | 849 | </tbody> |
850 | 850 | </table> |
851 | 851 | |
852 | - <h3><?php _e( 'Completed Forms', 'give' ); ?></h3> |
|
852 | + <h3><?php _e('Completed Forms', 'give'); ?></h3> |
|
853 | 853 | <?php |
854 | - $donations = give_get_users_completed_donations( $donor->email ); |
|
854 | + $donations = give_get_users_completed_donations($donor->email); |
|
855 | 855 | ?> |
856 | 856 | <table class="wp-list-table widefat striped donations"> |
857 | 857 | <thead> |
858 | 858 | <tr> |
859 | - <th scope="col"><?php _e( 'Form', 'give' ); ?></th> |
|
860 | - <th scope="col" width="120px"><?php _e( 'Actions', 'give' ); ?></th> |
|
859 | + <th scope="col"><?php _e('Form', 'give'); ?></th> |
|
860 | + <th scope="col" width="120px"><?php _e('Actions', 'give'); ?></th> |
|
861 | 861 | </tr> |
862 | 862 | </thead> |
863 | 863 | <tbody> |
864 | - <?php if ( ! empty( $donations ) ) { ?> |
|
865 | - <?php foreach ( $donations as $donation ) : ?> |
|
864 | + <?php if ( ! empty($donations)) { ?> |
|
865 | + <?php foreach ($donations as $donation) : ?> |
|
866 | 866 | <tr> |
867 | 867 | <td><?php echo $donation->post_title; ?></td> |
868 | 868 | <td> |
869 | 869 | <?php |
870 | 870 | printf( |
871 | 871 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
872 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
872 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
873 | 873 | sprintf( |
874 | 874 | /* translators: %s: form name */ |
875 | - esc_attr__( 'View Form %s.', 'give' ), |
|
875 | + esc_attr__('View Form %s.', 'give'), |
|
876 | 876 | $donation->post_title |
877 | 877 | ), |
878 | - __( 'View Form', 'give' ) |
|
878 | + __('View Form', 'give') |
|
879 | 879 | ); |
880 | 880 | ?> |
881 | 881 | </td> |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | <?php endforeach; ?> |
884 | 884 | <?php } else { ?> |
885 | 885 | <tr> |
886 | - <td colspan="2"><?php _e( 'No completed donations found.', 'give' ); ?></td> |
|
886 | + <td colspan="2"><?php _e('No completed donations found.', 'give'); ?></td> |
|
887 | 887 | </tr> |
888 | 888 | <?php } ?> |
889 | 889 | </tbody> |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * |
898 | 898 | * @param object $donor The donor object being displayed. |
899 | 899 | */ |
900 | - do_action( 'give_donor_after_tables', $donor ); |
|
900 | + do_action('give_donor_after_tables', $donor); |
|
901 | 901 | ?> |
902 | 902 | |
903 | 903 | </div> |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | * |
911 | 911 | * @param object $donor The donor object being displayed. |
912 | 912 | */ |
913 | - do_action( 'give_donor_card_bottom', $donor ); |
|
913 | + do_action('give_donor_card_bottom', $donor); |
|
914 | 914 | |
915 | 915 | } |
916 | 916 | |
@@ -923,31 +923,31 @@ discard block |
||
923 | 923 | * |
924 | 924 | * @return void |
925 | 925 | */ |
926 | -function give_donor_notes_view( $donor ) { |
|
926 | +function give_donor_notes_view($donor) { |
|
927 | 927 | |
928 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
929 | - $paged = absint( $paged ); |
|
928 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
929 | + $paged = absint($paged); |
|
930 | 930 | $note_count = $donor->get_notes_count(); |
931 | - $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
|
932 | - $total_pages = ceil( $note_count / $per_page ); |
|
933 | - $donor_notes = $donor->get_notes( $per_page, $paged ); |
|
931 | + $per_page = apply_filters('give_donor_notes_per_page', 20); |
|
932 | + $total_pages = ceil($note_count / $per_page); |
|
933 | + $donor_notes = $donor->get_notes($per_page, $paged); |
|
934 | 934 | ?> |
935 | 935 | |
936 | 936 | <div id="donor-notes-wrapper"> |
937 | 937 | <div class="donor-notes-header"> |
938 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
938 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
939 | 939 | </div> |
940 | - <h3><?php _e( 'Notes', 'give' ); ?></h3> |
|
940 | + <h3><?php _e('Notes', 'give'); ?></h3> |
|
941 | 941 | |
942 | - <?php if ( 1 == $paged ) : ?> |
|
942 | + <?php if (1 == $paged) : ?> |
|
943 | 943 | <div style="display: block; margin-bottom: 55px;"> |
944 | 944 | <form id="give-add-donor-note" method="post" |
945 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
|
945 | + action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>"> |
|
946 | 946 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
947 | 947 | <br/> |
948 | 948 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>"/> |
949 | 949 | <input type="hidden" name="give_action" value="add-donor-note"/> |
950 | - <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
|
950 | + <?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?> |
|
951 | 951 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note"/> |
952 | 952 | </form> |
953 | 953 | </div> |
@@ -962,26 +962,26 @@ discard block |
||
962 | 962 | 'show_all' => true, |
963 | 963 | ); |
964 | 964 | |
965 | - echo paginate_links( $pagination_args ); |
|
965 | + echo paginate_links($pagination_args); |
|
966 | 966 | ?> |
967 | 967 | |
968 | 968 | <div id="give-donor-notes" class="postbox"> |
969 | - <?php if ( count( $donor_notes ) > 0 ) { ?> |
|
970 | - <?php foreach ( $donor_notes as $key => $note ) : ?> |
|
969 | + <?php if (count($donor_notes) > 0) { ?> |
|
970 | + <?php foreach ($donor_notes as $key => $note) : ?> |
|
971 | 971 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
972 | 972 | <span class="note-content-wrap"> |
973 | - <?php echo stripslashes( $note ); ?> |
|
973 | + <?php echo stripslashes($note); ?> |
|
974 | 974 | </span> |
975 | 975 | </div> |
976 | 976 | <?php endforeach; ?> |
977 | 977 | <?php } else { ?> |
978 | 978 | <div class="give-no-donor-notes"> |
979 | - <?php _e( 'No donor notes found.', 'give' ); ?> |
|
979 | + <?php _e('No donor notes found.', 'give'); ?> |
|
980 | 980 | </div> |
981 | 981 | <?php } ?> |
982 | 982 | </div> |
983 | 983 | |
984 | - <?php echo paginate_links( $pagination_args ); ?> |
|
984 | + <?php echo paginate_links($pagination_args); ?> |
|
985 | 985 | |
986 | 986 | </div> |
987 | 987 | |
@@ -997,9 +997,9 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @return void |
999 | 999 | */ |
1000 | -function give_donor_delete_view( $donor ) { |
|
1000 | +function give_donor_delete_view($donor) { |
|
1001 | 1001 | |
1002 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
1002 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
1003 | 1003 | |
1004 | 1004 | /** |
1005 | 1005 | * Fires in donor delete screen, above the content. |
@@ -1008,16 +1008,16 @@ discard block |
||
1008 | 1008 | * |
1009 | 1009 | * @param object $donor The donor object being displayed. |
1010 | 1010 | */ |
1011 | - do_action( 'give_donor_delete_top', $donor ); |
|
1011 | + do_action('give_donor_delete_top', $donor); |
|
1012 | 1012 | ?> |
1013 | 1013 | |
1014 | 1014 | <div class="info-wrapper donor-section"> |
1015 | 1015 | |
1016 | 1016 | <form id="delete-donor" method="post" |
1017 | - action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
|
1017 | + action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>"> |
|
1018 | 1018 | |
1019 | 1019 | <div class="donor-notes-header"> |
1020 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
1020 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
1021 | 1021 | </div> |
1022 | 1022 | |
1023 | 1023 | |
@@ -1025,20 +1025,20 @@ discard block |
||
1025 | 1025 | |
1026 | 1026 | <span class="delete-donor-options"> |
1027 | 1027 | <p> |
1028 | - <?php echo Give()->html->checkbox( array( |
|
1028 | + <?php echo Give()->html->checkbox(array( |
|
1029 | 1029 | 'name' => 'give-donor-delete-confirm', |
1030 | - ) ); ?> |
|
1031 | - <label for="give-donor-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
1030 | + )); ?> |
|
1031 | + <label for="give-donor-delete-confirm"><?php _e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
1032 | 1032 | </p> |
1033 | 1033 | |
1034 | 1034 | <p> |
1035 | - <?php echo Give()->html->checkbox( array( |
|
1035 | + <?php echo Give()->html->checkbox(array( |
|
1036 | 1036 | 'name' => 'give-donor-delete-records', |
1037 | 1037 | 'options' => array( |
1038 | 1038 | 'disabled' => true, |
1039 | 1039 | ), |
1040 | - ) ); ?> |
|
1041 | - <label for="give-donor-delete-records"><?php _e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
1040 | + )); ?> |
|
1041 | + <label for="give-donor-delete-records"><?php _e('Delete all associated donations and records?', 'give'); ?></label> |
|
1042 | 1042 | </p> |
1043 | 1043 | |
1044 | 1044 | <?php |
@@ -1051,19 +1051,19 @@ discard block |
||
1051 | 1051 | * |
1052 | 1052 | * @param object $donor The donor object being displayed. |
1053 | 1053 | */ |
1054 | - do_action( 'give_donor_delete_inputs', $donor ); |
|
1054 | + do_action('give_donor_delete_inputs', $donor); |
|
1055 | 1055 | ?> |
1056 | 1056 | </span> |
1057 | 1057 | |
1058 | 1058 | <span id="donor-edit-actions"> |
1059 | 1059 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>"/> |
1060 | - <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
|
1060 | + <?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?> |
|
1061 | 1061 | <input type="hidden" name="give_action" value="delete-donor"/> |
1062 | 1062 | <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" |
1063 | - value="<?php _e( 'Delete Donor', 'give' ); ?>"/> |
|
1063 | + value="<?php _e('Delete Donor', 'give'); ?>"/> |
|
1064 | 1064 | <a id="give-delete-donor-cancel" |
1065 | - href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" |
|
1066 | - class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
1065 | + href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" |
|
1066 | + class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
1067 | 1067 | </span> |
1068 | 1068 | |
1069 | 1069 | </div> |
@@ -1079,5 +1079,5 @@ discard block |
||
1079 | 1079 | * |
1080 | 1080 | * @param object $donor The donor object being displayed. |
1081 | 1081 | */ |
1082 | - do_action( 'give_donor_delete_bottom', $donor ); |
|
1082 | + do_action('give_donor_delete_bottom', $donor); |
|
1083 | 1083 | } |
@@ -406,8 +406,11 @@ |
||
406 | 406 | <span class="donor-user-id info-item editable"> |
407 | 407 | <?php if ( ! empty( $userdata ) ) : ?> |
408 | 408 | <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
409 | - <?php else: ?> |
|
410 | - <span data-key="user_id"><?php _e( 'Unregistered', 'give' ); ?></span> |
|
409 | + <?php else { |
|
410 | + : ?> |
|
411 | + <span data-key="user_id"><?php _e( 'Unregistered', 'give' ); |
|
412 | +} |
|
413 | +?></span> |
|
411 | 414 | <?php endif; ?> |
412 | 415 | <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ): |
413 | 416 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | function give_add_ons_page() { |
26 | 26 | ?> |
27 | 27 | <div class="wrap" id="give-add-ons"> |
28 | - <h1><?php echo esc_html( get_admin_page_title() ); ?> |
|
29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?> |
|
28 | + <h1><?php echo esc_html(get_admin_page_title()); ?> |
|
29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e('View All Add-ons', 'give'); ?> |
|
30 | 30 | <span class="dashicons dashicons-external"></span></a> |
31 | 31 | </h1> |
32 | 32 | |
33 | 33 | <hr class="wp-header-end"> |
34 | 34 | |
35 | - <p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
35 | + <p><?php esc_html_e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
36 | 36 | <?php give_add_ons_feed(); ?> |
37 | 37 | </div> |
38 | 38 | <?php |
@@ -49,27 +49,27 @@ discard block |
||
49 | 49 | function give_add_ons_feed() { |
50 | 50 | |
51 | 51 | $addons_debug = false; //set to true to debug |
52 | - $cache = Give_Cache::get( 'give_add_ons_feed', true ); |
|
52 | + $cache = Give_Cache::get('give_add_ons_feed', true); |
|
53 | 53 | |
54 | - if ( false === $cache || ( true === $addons_debug && true === WP_DEBUG ) ) { |
|
55 | - if ( function_exists( 'vip_safe_wp_remote_get' ) ) { |
|
56 | - $feed = vip_safe_wp_remote_get( 'https://givewp.com/downloads/feed/', false, 3, 1, 20, array( 'sslverify' => false ) ); |
|
54 | + if (false === $cache || (true === $addons_debug && true === WP_DEBUG)) { |
|
55 | + if (function_exists('vip_safe_wp_remote_get')) { |
|
56 | + $feed = vip_safe_wp_remote_get('https://givewp.com/downloads/feed/', false, 3, 1, 20, array('sslverify' => false)); |
|
57 | 57 | } else { |
58 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
58 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
59 | 59 | } |
60 | 60 | |
61 | - if ( ! is_wp_error( $feed ) && ! empty( $feed ) ) { |
|
62 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
63 | - $cache = wp_remote_retrieve_body( $feed ); |
|
64 | - Give_Cache::set( 'give_add_ons_feed', $cache, HOUR_IN_SECONDS, true ); |
|
61 | + if ( ! is_wp_error($feed) && ! empty($feed)) { |
|
62 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
63 | + $cache = wp_remote_retrieve_body($feed); |
|
64 | + Give_Cache::set('give_add_ons_feed', $cache, HOUR_IN_SECONDS, true); |
|
65 | 65 | } |
66 | 66 | } else { |
67 | 67 | $cache = sprintf( |
68 | 68 | '<div class="error"><p>%s</p></div>', |
69 | - esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) |
|
69 | + esc_html__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give') |
|
70 | 70 | ); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - echo wp_kses_post( $cache ); |
|
74 | + echo wp_kses_post($cache); |
|
75 | 75 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.8.13 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -75,63 +75,63 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function init() { |
77 | 77 | // Bail early if screen cannot be detected. |
78 | - if ( empty( $this->screen ) ) { |
|
78 | + if (empty($this->screen)) { |
|
79 | 79 | return null; |
80 | 80 | } |
81 | 81 | |
82 | 82 | $content = array(); |
83 | 83 | |
84 | 84 | // Define content and hook into the appropriate action. |
85 | - switch ( $this->screen ) { |
|
85 | + switch ($this->screen) { |
|
86 | 86 | // Forms screen. |
87 | 87 | case 'edit-give_forms': |
88 | - $this->form = $this->post_exists( 'give_forms' ); |
|
88 | + $this->form = $this->post_exists('give_forms'); |
|
89 | 89 | |
90 | - if ( $this->form ) { |
|
90 | + if ($this->form) { |
|
91 | 91 | // Form exists. Bail out. |
92 | 92 | return false; |
93 | 93 | } else { |
94 | 94 | // No forms exist. |
95 | - $content = $this->get_content( 'no_forms' ); |
|
95 | + $content = $this->get_content('no_forms'); |
|
96 | 96 | } |
97 | 97 | |
98 | - add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) ); |
|
98 | + add_action('manage_posts_extra_tablenav', array($this, 'render')); |
|
99 | 99 | break; |
100 | 100 | // Donations screen. |
101 | 101 | case 'give_forms_page_give-payment-history': |
102 | - $this->form = $this->post_exists( 'give_forms' ); |
|
103 | - $this->donation = $this->post_exists( 'give_payment' ); |
|
102 | + $this->form = $this->post_exists('give_forms'); |
|
103 | + $this->donation = $this->post_exists('give_payment'); |
|
104 | 104 | |
105 | - if ( $this->donation ) { |
|
105 | + if ($this->donation) { |
|
106 | 106 | // Donation exists. Bail out. |
107 | 107 | return false; |
108 | - } elseif ( ! $this->form ) { |
|
108 | + } elseif ( ! $this->form) { |
|
109 | 109 | // No forms and no donations exist. |
110 | - $content = $this->get_content( 'no_donations_or_forms' ); |
|
110 | + $content = $this->get_content('no_donations_or_forms'); |
|
111 | 111 | } else { |
112 | 112 | // No donations exist but a form does exist. |
113 | - $content = $this->get_content( 'no_donations' ); |
|
113 | + $content = $this->get_content('no_donations'); |
|
114 | 114 | } |
115 | 115 | |
116 | - add_action( 'give_payments_page_bottom', array( $this, 'render' ) ); |
|
116 | + add_action('give_payments_page_bottom', array($this, 'render')); |
|
117 | 117 | break; |
118 | 118 | // Donors screen. |
119 | 119 | case 'give_forms_page_give-donors': |
120 | - $this->form = $this->post_exists( 'give_forms' ); |
|
120 | + $this->form = $this->post_exists('give_forms'); |
|
121 | 121 | $this->donor = $this->donor_exists(); |
122 | 122 | |
123 | - if ( $this->donor ) { |
|
123 | + if ($this->donor) { |
|
124 | 124 | // Donor exists. Bail out. |
125 | 125 | return false; |
126 | - } elseif ( ! $this->form ) { |
|
126 | + } elseif ( ! $this->form) { |
|
127 | 127 | // No forms and no donors exist. |
128 | - $content = $this->get_content( 'no_donors_or_forms' ); |
|
128 | + $content = $this->get_content('no_donors_or_forms'); |
|
129 | 129 | } else { |
130 | 130 | // No donors exist but a form does exist. |
131 | - $content = $this->get_content( 'no_donors' ); |
|
131 | + $content = $this->get_content('no_donors'); |
|
132 | 132 | } |
133 | 133 | |
134 | - add_action( 'give_donors_table_bottom', array( $this, 'render' ) ); |
|
134 | + add_action('give_donors_table_bottom', array($this, 'render')); |
|
135 | 135 | break; |
136 | 136 | default: |
137 | 137 | return null; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $this->content = $content; |
141 | 141 | |
142 | 142 | // Hide non-essential UI elements. |
143 | - add_action( 'admin_head', array( $this, 'hide_ui' ) ); |
|
143 | + add_action('admin_head', array($this, 'hide_ui')); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param string $which The location of the list table hook: 'top' or 'bottom'. |
152 | 152 | */ |
153 | - public function render( $which = 'bottom' ) { |
|
153 | + public function render($which = 'bottom') { |
|
154 | 154 | // Bail out to prevent content from rendering twice. |
155 | - if ( 'top' === $which ) { |
|
155 | + if ('top' === $which) { |
|
156 | 156 | return null; |
157 | 157 | } |
158 | 158 | |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @param string $screen The current screen ID. |
179 | 179 | */ |
180 | - $content = apply_filters( 'give_blank_slate_content', $this->content, $screen ); |
|
180 | + $content = apply_filters('give_blank_slate_content', $this->content, $screen); |
|
181 | 181 | |
182 | - $template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php'; |
|
182 | + $template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php'; |
|
183 | 183 | |
184 | 184 | include $template_path; |
185 | 185 | } |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | * @param string $post_type Post type used in the query. |
215 | 215 | * @return bool True if post exists, otherwise false. |
216 | 216 | */ |
217 | - private function post_exists( $post_type ) { |
|
217 | + private function post_exists($post_type) { |
|
218 | 218 | // Attempt to get a single post of the post type. |
219 | - $query = new WP_Query( array( |
|
219 | + $query = new WP_Query(array( |
|
220 | 220 | 'post_type' => $post_type, |
221 | 221 | 'posts_per_page' => 1, |
222 | 222 | 'no_found_rows' => false, |
223 | 223 | 'update_post_meta_cache' => false, |
224 | 224 | 'update_post_term_cache' => false, |
225 | 225 | 'fields' => 'ids', |
226 | - 'post_status' => array( 'any', 'trash' ), |
|
227 | - ) ); |
|
226 | + 'post_status' => array('any', 'trash'), |
|
227 | + )); |
|
228 | 228 | |
229 | 229 | return $query->have_posts(); |
230 | 230 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | * @return bool True if donor exists, otherwise false. |
238 | 238 | */ |
239 | 239 | private function donor_exists() { |
240 | - $donors = Give()->donors->get_donors( array( 'number' => 1 ) ); |
|
240 | + $donors = Give()->donors->get_donors(array('number' => 1)); |
|
241 | 241 | |
242 | - return ! empty( $donors ); |
|
242 | + return ! empty($donors); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -250,18 +250,18 @@ discard block |
||
250 | 250 | * @param string $context The key used to determine which content is returned. |
251 | 251 | * @return array Blank slate content. |
252 | 252 | */ |
253 | - private function get_content( $context ) { |
|
253 | + private function get_content($context) { |
|
254 | 254 | // Define default content. |
255 | 255 | $defaults = array( |
256 | - 'image_url' => GIVE_PLUGIN_URL . 'assets/dist/images/give-icon-full-circle.svg', |
|
257 | - 'image_alt' => __( 'Give Icon', 'give' ), |
|
258 | - 'heading' => __( 'No donation forms found.', 'give' ), |
|
259 | - 'message' => __( 'The first step towards accepting online donations is to create a form.', 'give' ), |
|
260 | - 'cta_text' => __( 'Create Donation Form', 'give' ), |
|
261 | - 'cta_link' => admin_url( 'post-new.php?post_type=give_forms' ), |
|
256 | + 'image_url' => GIVE_PLUGIN_URL.'assets/dist/images/give-icon-full-circle.svg', |
|
257 | + 'image_alt' => __('Give Icon', 'give'), |
|
258 | + 'heading' => __('No donation forms found.', 'give'), |
|
259 | + 'message' => __('The first step towards accepting online donations is to create a form.', 'give'), |
|
260 | + 'cta_text' => __('Create Donation Form', 'give'), |
|
261 | + 'cta_link' => admin_url('post-new.php?post_type=give_forms'), |
|
262 | 262 | 'help' => sprintf( |
263 | 263 | /* translators: 1: Opening anchor tag. 2: Closing anchor tag. */ |
264 | - __( 'Need help? Get started with %1$sGive 101%2$s.', 'give' ), |
|
264 | + __('Need help? Get started with %1$sGive 101%2$s.', 'give'), |
|
265 | 265 | '<a href="http://docs.givewp.com/give101/" target="_blank">', |
266 | 266 | '</a>' |
267 | 267 | ), |
@@ -270,42 +270,42 @@ discard block |
||
270 | 270 | // Define contextual content. |
271 | 271 | $content = array( |
272 | 272 | 'no_donations_or_forms' => array( |
273 | - 'heading' => __( 'No donations found.', 'give' ), |
|
274 | - 'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ), |
|
273 | + 'heading' => __('No donations found.', 'give'), |
|
274 | + 'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'), |
|
275 | 275 | ), |
276 | 276 | 'no_donations' => array( |
277 | - 'heading' => __( 'No donations found.', 'give' ), |
|
278 | - 'message' => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ), |
|
279 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
280 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
277 | + 'heading' => __('No donations found.', 'give'), |
|
278 | + 'message' => __('When your first donation arrives, a record of the donation will appear here.', 'give'), |
|
279 | + 'cta_text' => __('View All Forms', 'give'), |
|
280 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
281 | 281 | 'help' => sprintf( |
282 | 282 | /* translators: 1: Opening anchor tag. 2: Closing anchor tag. */ |
283 | - __( 'Need help? Learn more about %1$sDonations%2$s.', 'give' ), |
|
283 | + __('Need help? Learn more about %1$sDonations%2$s.', 'give'), |
|
284 | 284 | '<a href="http://docs.givewp.com/core-donations/">', |
285 | 285 | '</a>' |
286 | 286 | ), |
287 | 287 | ), |
288 | 288 | 'no_donors_or_forms' => array( |
289 | - 'heading' => __( 'No donors found.', 'give' ), |
|
290 | - 'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ), |
|
289 | + 'heading' => __('No donors found.', 'give'), |
|
290 | + 'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'), |
|
291 | 291 | ), |
292 | 292 | 'no_donors' => array( |
293 | - 'heading' => __( 'No donors found.', 'give' ), |
|
294 | - 'message' => __( 'When your first donation arrives, the donor will appear here.', 'give' ), |
|
295 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
296 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
293 | + 'heading' => __('No donors found.', 'give'), |
|
294 | + 'message' => __('When your first donation arrives, the donor will appear here.', 'give'), |
|
295 | + 'cta_text' => __('View All Forms', 'give'), |
|
296 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
297 | 297 | 'help' => sprintf( |
298 | 298 | /* translators: 1: Opening anchor tag. 2: Closing anchor tag. */ |
299 | - __( 'Need help? Learn more about %1$sDonors%2$s.', 'give' ), |
|
299 | + __('Need help? Learn more about %1$sDonors%2$s.', 'give'), |
|
300 | 300 | '<a href="http://docs.givewp.com/core-donors/">', |
301 | 301 | '</a>' |
302 | 302 | ), |
303 | 303 | ), |
304 | 304 | ); |
305 | 305 | |
306 | - if ( isset( $content[ $context ] ) ) { |
|
306 | + if (isset($content[$context])) { |
|
307 | 307 | // Merge contextual content with defaults. |
308 | - return wp_parse_args( $content[ $context ], $defaults ); |
|
308 | + return wp_parse_args($content[$context], $defaults); |
|
309 | 309 | } else { |
310 | 310 | // Return defaults if context is undefined. |
311 | 311 | return $defaults; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Constructor. |
55 | 55 | */ |
56 | - public function __construct( $_step = 1 ) { |
|
57 | - parent::__construct( $_step ); |
|
56 | + public function __construct($_step = 1) { |
|
57 | + parent::__construct($_step); |
|
58 | 58 | |
59 | 59 | $this->is_writable = true; |
60 | 60 | } |
@@ -69,43 +69,43 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get_data() { |
71 | 71 | |
72 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
72 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
73 | 73 | |
74 | - if ( $this->step == 1 ) { |
|
75 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
74 | + if ($this->step == 1) { |
|
75 | + $this->delete_data('give_temp_recount_form_stats'); |
|
76 | 76 | } |
77 | 77 | |
78 | - $totals = $this->get_stored_data( 'give_temp_recount_form_stats' ); |
|
78 | + $totals = $this->get_stored_data('give_temp_recount_form_stats'); |
|
79 | 79 | |
80 | - if ( false === $totals ) { |
|
80 | + if (false === $totals) { |
|
81 | 81 | $totals = array( |
82 | 82 | 'earnings' => (float) 0, |
83 | 83 | 'sales' => 0, |
84 | 84 | ); |
85 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
85 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
86 | 86 | } |
87 | 87 | |
88 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
88 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
89 | 89 | 'give_forms' => $this->form_id, |
90 | 90 | 'number' => $this->per_step, |
91 | 91 | 'status' => $accepted_statuses, |
92 | 92 | 'paged' => $this->step, |
93 | 93 | 'fields' => 'ids', |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | - $payments = new Give_Payments_Query( $args ); |
|
96 | + $payments = new Give_Payments_Query($args); |
|
97 | 97 | $payments = $payments->get_payments(); |
98 | 98 | |
99 | - if ( $payments ) { |
|
100 | - foreach ( $payments as $payment ) { |
|
99 | + if ($payments) { |
|
100 | + foreach ($payments as $payment) { |
|
101 | 101 | |
102 | 102 | // Ensure acceptable status only. |
103 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
103 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | 107 | // Ensure only payments for this form are counted. |
108 | - if ( $payment->form_id != $this->form_id ) { |
|
108 | + if ($payment->form_id != $this->form_id) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
@@ -116,25 +116,25 @@ discard block |
||
116 | 116 | */ |
117 | 117 | $earning_amount = apply_filters( |
118 | 118 | 'give_donation_amount', |
119 | - give_format_amount( $payment->total, array( 'donation_id' => $payment->ID ) ), |
|
119 | + give_format_amount($payment->total, array('donation_id' => $payment->ID)), |
|
120 | 120 | $payment->total, |
121 | 121 | $payment->ID, |
122 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
122 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
123 | 123 | ); |
124 | 124 | |
125 | - $totals['sales'] ++; |
|
126 | - $totals['earnings'] += (float) give_maybe_sanitize_amount( $earning_amount ); |
|
125 | + $totals['sales']++; |
|
126 | + $totals['earnings'] += (float) give_maybe_sanitize_amount($earning_amount); |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | - $this->store_data( 'give_temp_recount_form_stats', $totals ); |
|
130 | + $this->store_data('give_temp_recount_form_stats', $totals); |
|
131 | 131 | |
132 | 132 | return true; |
133 | 133 | } |
134 | 134 | |
135 | 135 | |
136 | - give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] ); |
|
137 | - give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
136 | + give_update_meta($this->form_id, '_give_form_sales', $totals['sales']); |
|
137 | + give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
138 | 138 | |
139 | 139 | return false; |
140 | 140 | } |
@@ -146,35 +146,35 @@ discard block |
||
146 | 146 | * @return int |
147 | 147 | */ |
148 | 148 | public function get_percentage_complete() { |
149 | - if ( $this->step == 1 ) { |
|
150 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
149 | + if ($this->step == 1) { |
|
150 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
151 | 151 | } |
152 | 152 | |
153 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
154 | - $total = $this->get_stored_data( 'give_recount_total_' . $this->form_id ); |
|
153 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
154 | + $total = $this->get_stored_data('give_recount_total_'.$this->form_id); |
|
155 | 155 | |
156 | - if ( false === $total ) { |
|
156 | + if (false === $total) { |
|
157 | 157 | $total = 0; |
158 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
158 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
159 | 159 | 'give_forms' => $this->form_id, |
160 | - 'number' => - 1, |
|
160 | + 'number' => -1, |
|
161 | 161 | 'status' => $accepted_statuses, |
162 | 162 | 'fields' => 'ids', |
163 | - ) ); |
|
163 | + )); |
|
164 | 164 | |
165 | - $payments = new Give_Payments_Query( $args ); |
|
166 | - $total = count( $payments->get_payments() ); |
|
167 | - $this->store_data( 'give_recount_total_' . $this->form_id, $total ); |
|
165 | + $payments = new Give_Payments_Query($args); |
|
166 | + $total = count($payments->get_payments()); |
|
167 | + $this->store_data('give_recount_total_'.$this->form_id, $total); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
171 | 171 | $percentage = 100; |
172 | 172 | |
173 | - if ( $total > 0 ) { |
|
174 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
173 | + if ($total > 0) { |
|
174 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
175 | 175 | } |
176 | 176 | |
177 | - if ( $percentage > 100 ) { |
|
177 | + if ($percentage > 100) { |
|
178 | 178 | $percentage = 100; |
179 | 179 | } |
180 | 180 | |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @param array $request The Form Data passed into the batch processing |
190 | 190 | */ |
191 | - public function set_properties( $request ) { |
|
192 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
191 | + public function set_properties($request) { |
|
192 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function process_step() { |
202 | 202 | |
203 | - if ( ! $this->can_export() ) { |
|
204 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
203 | + if ( ! $this->can_export()) { |
|
204 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | $had_data = $this->get_data(); |
208 | 208 | |
209 | - if ( $had_data ) { |
|
209 | + if ($had_data) { |
|
210 | 210 | $this->done = false; |
211 | 211 | |
212 | 212 | return true; |
213 | 213 | } else { |
214 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
215 | - $this->delete_data( 'give_temp_recount_form_stats' ); |
|
214 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
215 | + $this->delete_data('give_temp_recount_form_stats'); |
|
216 | 216 | $this->done = true; |
217 | - $this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) ); |
|
217 | + $this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id)); |
|
218 | 218 | |
219 | 219 | return false; |
220 | 220 | } |
@@ -248,17 +248,17 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return mixed Returns the data from the database |
250 | 250 | */ |
251 | - private function get_stored_data( $key ) { |
|
251 | + private function get_stored_data($key) { |
|
252 | 252 | global $wpdb; |
253 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
253 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
254 | 254 | |
255 | - if ( empty( $value ) ) { |
|
255 | + if (empty($value)) { |
|
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | |
259 | - $maybe_json = json_decode( $value ); |
|
260 | - if ( ! is_null( $maybe_json ) ) { |
|
261 | - $value = json_decode( $value, true ); |
|
259 | + $maybe_json = json_decode($value); |
|
260 | + if ( ! is_null($maybe_json)) { |
|
261 | + $value = json_decode($value, true); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | return $value; |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return void |
276 | 276 | */ |
277 | - private function store_data( $key, $value ) { |
|
277 | + private function store_data($key, $value) { |
|
278 | 278 | global $wpdb; |
279 | 279 | |
280 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
280 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
281 | 281 | |
282 | 282 | $data = array( |
283 | 283 | 'option_name' => $key, |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | '%s', |
292 | 292 | ); |
293 | 293 | |
294 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
294 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return void |
305 | 305 | */ |
306 | - private function delete_data( $key ) { |
|
306 | + private function delete_data($key) { |
|
307 | 307 | global $wpdb; |
308 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
308 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | } |
312 | 312 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Constructor. |
51 | 51 | */ |
52 | - public function __construct( $_step = 1 ) { |
|
53 | - parent::__construct( $_step ); |
|
52 | + public function __construct($_step = 1) { |
|
53 | + parent::__construct($_step); |
|
54 | 54 | |
55 | 55 | $this->is_writable = true; |
56 | 56 | } |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | public function get_data() { |
68 | 68 | global $wpdb; |
69 | 69 | |
70 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
70 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
71 | 71 | |
72 | - if ( ! is_array( $items ) ) { |
|
72 | + if ( ! is_array($items)) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | |
76 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
77 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
76 | + $offset = ($this->step - 1) * $this->per_step; |
|
77 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
78 | 78 | |
79 | - if ( $step_items ) { |
|
79 | + if ($step_items) { |
|
80 | 80 | |
81 | 81 | $step_ids = array( |
82 | 82 | 'customers' => array(), |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | 'other' => array(), |
85 | 85 | ); |
86 | 86 | |
87 | - foreach ( $step_items as $item ) { |
|
87 | + foreach ($step_items as $item) { |
|
88 | 88 | |
89 | - switch ( $item['type'] ) { |
|
89 | + switch ($item['type']) { |
|
90 | 90 | case 'customer': |
91 | 91 | $step_ids['customers'][] = $item['id']; |
92 | 92 | break; |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | $step_ids['give_forms'][] = $item['id']; |
95 | 95 | break; |
96 | 96 | default: |
97 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
98 | - $step_ids[ $item_type ][] = $item['id']; |
|
97 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
98 | + $step_ids[$item_type][] = $item['id']; |
|
99 | 99 | break; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | 103 | $sql = array(); |
104 | - $meta_table = __give_v20_bc_table_details('form' ); |
|
104 | + $meta_table = __give_v20_bc_table_details('form'); |
|
105 | 105 | |
106 | - foreach ( $step_ids as $type => $ids ) { |
|
106 | + foreach ($step_ids as $type => $ids) { |
|
107 | 107 | |
108 | - if ( empty( $ids ) ) { |
|
108 | + if (empty($ids)) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - $ids = implode( ',', $ids ); |
|
112 | + $ids = implode(',', $ids); |
|
113 | 113 | |
114 | - switch ( $type ) { |
|
114 | + switch ($type) { |
|
115 | 115 | case 'customers': |
116 | 116 | $sql[] = "DELETE FROM $wpdb->donors WHERE id IN ($ids)"; |
117 | 117 | $table_name = $wpdb->donors; |
@@ -131,16 +131,16 @@ discard block |
||
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
134 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
135 | 135 | // Allows other types of custom post types to filter on their own post_type |
136 | 136 | // and add items to the query list, for the IDs found in their post type. |
137 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
137 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - if ( ! empty( $sql ) ) { |
|
142 | - foreach ( $sql as $query ) { |
|
143 | - $wpdb->query( $query ); |
|
141 | + if ( ! empty($sql)) { |
|
142 | + foreach ($sql as $query) { |
|
143 | + $wpdb->query($query); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_percentage_complete() { |
162 | 162 | |
163 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
164 | - $total = count( $items ); |
|
163 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
164 | + $total = count($items); |
|
165 | 165 | |
166 | 166 | $percentage = 100; |
167 | 167 | |
168 | - if ( $total > 0 ) { |
|
169 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
168 | + if ($total > 0) { |
|
169 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( $percentage > 100 ) { |
|
172 | + if ($percentage > 100) { |
|
173 | 173 | $percentage = 100; |
174 | 174 | } |
175 | 175 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param array $request The Form Data passed into the batch processing. |
185 | 185 | */ |
186 | - public function set_properties( $request ) { |
|
186 | + public function set_properties($request) { |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -194,26 +194,26 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function process_step() { |
196 | 196 | |
197 | - if ( ! $this->can_export() ) { |
|
198 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
197 | + if ( ! $this->can_export()) { |
|
198 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array( |
|
199 | 199 | 'response' => 403, |
200 | - ) ); |
|
200 | + )); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $had_data = $this->get_data(); |
204 | 204 | |
205 | - if ( $had_data ) { |
|
205 | + if ($had_data) { |
|
206 | 206 | $this->done = false; |
207 | 207 | |
208 | 208 | return true; |
209 | 209 | } else { |
210 | - update_option( 'give_earnings_total', 0 ); |
|
211 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
210 | + update_option('give_earnings_total', 0); |
|
211 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
212 | 212 | |
213 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
213 | + $this->delete_data('give_temp_reset_ids'); |
|
214 | 214 | |
215 | 215 | $this->done = true; |
216 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
216 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
217 | 217 | |
218 | 218 | return false; |
219 | 219 | } |
@@ -246,26 +246,26 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function pre_fetch() { |
248 | 248 | |
249 | - if ( $this->step == 1 ) { |
|
250 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
249 | + if ($this->step == 1) { |
|
250 | + $this->delete_data('give_temp_reset_ids'); |
|
251 | 251 | } |
252 | 252 | |
253 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
253 | + $items = get_option('give_temp_reset_ids', false); |
|
254 | 254 | |
255 | - if ( false === $items ) { |
|
255 | + if (false === $items) { |
|
256 | 256 | $items = array(); |
257 | 257 | |
258 | - $give_types_for_reset = array( 'give_forms', 'give_payment' ); |
|
259 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
258 | + $give_types_for_reset = array('give_forms', 'give_payment'); |
|
259 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
260 | 260 | |
261 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
261 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
262 | 262 | 'post_type' => $give_types_for_reset, |
263 | 263 | 'post_status' => 'any', |
264 | - 'posts_per_page' => - 1, |
|
265 | - ) ); |
|
264 | + 'posts_per_page' => -1, |
|
265 | + )); |
|
266 | 266 | |
267 | - $posts = get_posts( $args ); |
|
268 | - foreach ( $posts as $post ) { |
|
267 | + $posts = get_posts($args); |
|
268 | + foreach ($posts as $post) { |
|
269 | 269 | $items[] = array( |
270 | 270 | 'id' => (int) $post->ID, |
271 | 271 | 'type' => $post->post_type, |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | $donor_args = array( |
276 | - 'number' => - 1, |
|
276 | + 'number' => -1, |
|
277 | 277 | ); |
278 | - $donors = Give()->donors->get_donors( $donor_args ); |
|
279 | - foreach ( $donors as $donor ) { |
|
278 | + $donors = Give()->donors->get_donors($donor_args); |
|
279 | + foreach ($donors as $donor) { |
|
280 | 280 | $items[] = array( |
281 | 281 | 'id' => (int) $donor->id, |
282 | 282 | 'type' => 'customer', |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | |
286 | 286 | // Allow filtering of items to remove with an unassociative array for each item |
287 | 287 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
288 | - $items = apply_filters( 'give_reset_items', $items ); |
|
288 | + $items = apply_filters('give_reset_items', $items); |
|
289 | 289 | |
290 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
290 | + $this->store_data('give_temp_reset_ids', $items); |
|
291 | 291 | }// End if(). |
292 | 292 | |
293 | 293 | } |
@@ -301,17 +301,17 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return mixed Returns the data from the database. |
303 | 303 | */ |
304 | - private function get_stored_data( $key ) { |
|
304 | + private function get_stored_data($key) { |
|
305 | 305 | global $wpdb; |
306 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
306 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
307 | 307 | |
308 | - if ( empty( $value ) ) { |
|
308 | + if (empty($value)) { |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | |
312 | - $maybe_json = json_decode( $value ); |
|
313 | - if ( ! is_null( $maybe_json ) ) { |
|
314 | - $value = json_decode( $value, true ); |
|
312 | + $maybe_json = json_decode($value); |
|
313 | + if ( ! is_null($maybe_json)) { |
|
314 | + $value = json_decode($value, true); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | return $value; |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - private function store_data( $key, $value ) { |
|
330 | + private function store_data($key, $value) { |
|
331 | 331 | global $wpdb; |
332 | 332 | |
333 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
333 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
334 | 334 | |
335 | 335 | $data = array( |
336 | 336 | 'option_name' => $key, |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | '%s', |
345 | 345 | ); |
346 | 346 | |
347 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
347 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return void |
358 | 358 | */ |
359 | - private function delete_data( $key ) { |
|
359 | + private function delete_data($key) { |
|
360 | 360 | global $wpdb; |
361 | - $wpdb->delete( $wpdb->options, array( |
|
361 | + $wpdb->delete($wpdb->options, array( |
|
362 | 362 | 'option_name' => $key, |
363 | - ) ); |
|
363 | + )); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Constructor. |
75 | 75 | */ |
76 | - public function __construct( $_step = 1 ) { |
|
77 | - parent::__construct( $_step ); |
|
76 | + public function __construct($_step = 1) { |
|
77 | + parent::__construct($_step); |
|
78 | 78 | |
79 | 79 | $this->is_writable = true; |
80 | 80 | } |
@@ -89,108 +89,106 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function get_data() { |
91 | 91 | |
92 | - $totals = $this->get_stored_data( 'give_temp_recount_all_stats' ); |
|
93 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
94 | - $processed_payments = $this->get_stored_data( 'give_temp_processed_payments' ); |
|
95 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
92 | + $totals = $this->get_stored_data('give_temp_recount_all_stats'); |
|
93 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
94 | + $processed_payments = $this->get_stored_data('give_temp_processed_payments'); |
|
95 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
96 | 96 | |
97 | - if ( false === $totals ) { |
|
97 | + if (false === $totals) { |
|
98 | 98 | $totals = array(); |
99 | 99 | } |
100 | 100 | |
101 | - if ( false === $payment_items ) { |
|
101 | + if (false === $payment_items) { |
|
102 | 102 | $payment_items = array(); |
103 | 103 | } |
104 | 104 | |
105 | - if ( false === $processed_payments ) { |
|
105 | + if (false === $processed_payments) { |
|
106 | 106 | $processed_payments = array(); |
107 | 107 | } |
108 | 108 | |
109 | - $all_forms = $this->get_stored_data( 'give_temp_form_ids' ); |
|
109 | + $all_forms = $this->get_stored_data('give_temp_form_ids'); |
|
110 | 110 | |
111 | - $payments = $this->get_stored_data( 'give_temp_all_payments_data' ); |
|
111 | + $payments = $this->get_stored_data('give_temp_all_payments_data'); |
|
112 | 112 | |
113 | - if ( empty( $payments ) ) { |
|
114 | - $args = apply_filters( 'give_recount_form_stats_args', array( |
|
113 | + if (empty($payments)) { |
|
114 | + $args = apply_filters('give_recount_form_stats_args', array( |
|
115 | 115 | 'give_forms' => $all_forms, |
116 | 116 | 'number' => $this->per_step, |
117 | 117 | 'status' => $accepted_statuses, |
118 | 118 | 'paged' => $this->step, |
119 | 119 | 'output' => 'give_payments', |
120 | - ) ); |
|
120 | + )); |
|
121 | 121 | |
122 | - $payments_query = new Give_Payments_Query( $args ); |
|
122 | + $payments_query = new Give_Payments_Query($args); |
|
123 | 123 | $payments = $payments_query->get_payments(); |
124 | 124 | } |
125 | 125 | |
126 | - if ( ! empty( $payments ) ) { |
|
126 | + if ( ! empty($payments)) { |
|
127 | 127 | |
128 | 128 | //Loop through payments |
129 | - foreach ( $payments as $payment ) { |
|
129 | + foreach ($payments as $payment) { |
|
130 | 130 | |
131 | - $payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) ); |
|
132 | - $payment = new Give_Payment( $payment_id ); |
|
131 | + $payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false)); |
|
132 | + $payment = new Give_Payment($payment_id); |
|
133 | 133 | |
134 | 134 | // Prevent payments that have all ready been retrieved from a previous sales log from counting again. |
135 | - if ( in_array( $payment->ID, $processed_payments ) ) { |
|
135 | + if (in_array($payment->ID, $processed_payments)) { |
|
136 | 136 | continue; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Verify accepted status. |
140 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
140 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
141 | 141 | $processed_payments[] = $payment->ID; |
142 | 142 | continue; |
143 | 143 | } |
144 | 144 | |
145 | - $payment_item = $payment_items[ $payment->ID ]; |
|
145 | + $payment_item = $payment_items[$payment->ID]; |
|
146 | 146 | |
147 | - $form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : ''; |
|
147 | + $form_id = isset($payment_item['id']) ? $payment_item['id'] : ''; |
|
148 | 148 | |
149 | 149 | // Must have a form ID. |
150 | - if ( empty( $form_id ) ) { |
|
150 | + if (empty($form_id)) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | |
154 | 154 | // Form ID must be within $all_forms array to be validated. |
155 | - if ( ! in_array( $form_id, $all_forms ) ) { |
|
155 | + if ( ! in_array($form_id, $all_forms)) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Set Sales count |
160 | - $totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ? |
|
161 | - ++ $totals[ $form_id ]['sales'] : |
|
162 | - 1; |
|
160 | + $totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ? |
|
161 | + ++$totals[$form_id]['sales'] : 1; |
|
163 | 162 | |
164 | 163 | // Set Total Earnings |
165 | - $totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ? |
|
166 | - ( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) : |
|
167 | - $payment_item['price']; |
|
164 | + $totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ? |
|
165 | + ($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price']; |
|
168 | 166 | |
169 | 167 | $processed_payments[] = $payment->ID; |
170 | 168 | } |
171 | 169 | |
172 | 170 | // Get the list of form ids which does not contain any payment record. |
173 | - $remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) ); |
|
174 | - foreach ( $remaining_form_ids as $form_id ) { |
|
171 | + $remaining_form_ids = array_diff($all_forms, array_keys($totals)); |
|
172 | + foreach ($remaining_form_ids as $form_id) { |
|
175 | 173 | //If array key doesn't exist, create it |
176 | - if ( ! array_key_exists( $form_id, $totals ) ) { |
|
177 | - $totals[ $form_id ] = array( |
|
174 | + if ( ! array_key_exists($form_id, $totals)) { |
|
175 | + $totals[$form_id] = array( |
|
178 | 176 | 'sales' => (int) 0, |
179 | 177 | 'earnings' => (float) 0, |
180 | 178 | ); |
181 | 179 | } |
182 | 180 | } |
183 | 181 | |
184 | - $this->store_data( 'give_temp_processed_payments', $processed_payments ); |
|
185 | - $this->store_data( 'give_temp_recount_all_stats', $totals ); |
|
182 | + $this->store_data('give_temp_processed_payments', $processed_payments); |
|
183 | + $this->store_data('give_temp_recount_all_stats', $totals); |
|
186 | 184 | |
187 | 185 | return true; |
188 | 186 | } |
189 | 187 | |
190 | 188 | |
191 | - foreach ( $totals as $key => $stats ) { |
|
192 | - give_update_meta( $key, '_give_form_sales', $stats['sales'] ); |
|
193 | - give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) ); |
|
189 | + foreach ($totals as $key => $stats) { |
|
190 | + give_update_meta($key, '_give_form_sales', $stats['sales']); |
|
191 | + give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings'])); |
|
194 | 192 | } |
195 | 193 | |
196 | 194 | return false; |
@@ -205,20 +203,20 @@ discard block |
||
205 | 203 | */ |
206 | 204 | public function get_percentage_complete() { |
207 | 205 | |
208 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
206 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
209 | 207 | |
210 | - if ( false === $total ) { |
|
208 | + if (false === $total) { |
|
211 | 209 | $this->pre_fetch(); |
212 | - $total = $this->get_stored_data( 'give_recount_all_total' ); |
|
210 | + $total = $this->get_stored_data('give_recount_all_total'); |
|
213 | 211 | } |
214 | 212 | |
215 | 213 | $percentage = 100; |
216 | 214 | |
217 | - if ( $total > 0 ) { |
|
218 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
215 | + if ($total > 0) { |
|
216 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
219 | 217 | } |
220 | 218 | |
221 | - if ( $percentage > 100 ) { |
|
219 | + if ($percentage > 100) { |
|
222 | 220 | $percentage = 100; |
223 | 221 | } |
224 | 222 | |
@@ -232,8 +230,8 @@ discard block |
||
232 | 230 | * |
233 | 231 | * @param array $request The Form Data passed into the batch processing |
234 | 232 | */ |
235 | - public function set_properties( $request ) { |
|
236 | - $this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false; |
|
233 | + public function set_properties($request) { |
|
234 | + $this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false; |
|
237 | 235 | } |
238 | 236 | |
239 | 237 | /** |
@@ -244,25 +242,25 @@ discard block |
||
244 | 242 | */ |
245 | 243 | public function process_step() { |
246 | 244 | |
247 | - if ( ! $this->can_export() ) { |
|
248 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
245 | + if ( ! $this->can_export()) { |
|
246 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
249 | 247 | } |
250 | 248 | |
251 | 249 | $had_data = $this->get_data(); |
252 | 250 | |
253 | - if ( $had_data ) { |
|
251 | + if ($had_data) { |
|
254 | 252 | $this->done = false; |
255 | 253 | |
256 | 254 | return true; |
257 | 255 | } else { |
258 | - $this->delete_data( 'give_recount_total_' . $this->form_id ); |
|
259 | - $this->delete_data( 'give_recount_all_total' ); |
|
260 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
261 | - $this->delete_data( 'give_temp_payment_items' ); |
|
262 | - $this->delete_data( 'give_temp_form_ids' ); |
|
263 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
256 | + $this->delete_data('give_recount_total_'.$this->form_id); |
|
257 | + $this->delete_data('give_recount_all_total'); |
|
258 | + $this->delete_data('give_temp_recount_all_stats'); |
|
259 | + $this->delete_data('give_temp_payment_items'); |
|
260 | + $this->delete_data('give_temp_form_ids'); |
|
261 | + $this->delete_data('give_temp_processed_payments'); |
|
264 | 262 | $this->done = true; |
265 | - $this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' ); |
|
263 | + $this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give'); |
|
266 | 264 | |
267 | 265 | return false; |
268 | 266 | } |
@@ -298,69 +296,69 @@ discard block |
||
298 | 296 | */ |
299 | 297 | public function pre_fetch() { |
300 | 298 | |
301 | - if ( 1 == $this->step ) { |
|
302 | - $this->delete_data( 'give_temp_recount_all_total' ); |
|
303 | - $this->delete_data( 'give_temp_recount_all_stats' ); |
|
304 | - $this->delete_data( 'give_temp_payment_items' ); |
|
305 | - $this->delete_data( 'give_temp_processed_payments' ); |
|
306 | - $this->delete_data( 'give_temp_all_payments_data' ); |
|
299 | + if (1 == $this->step) { |
|
300 | + $this->delete_data('give_temp_recount_all_total'); |
|
301 | + $this->delete_data('give_temp_recount_all_stats'); |
|
302 | + $this->delete_data('give_temp_payment_items'); |
|
303 | + $this->delete_data('give_temp_processed_payments'); |
|
304 | + $this->delete_data('give_temp_all_payments_data'); |
|
307 | 305 | } |
308 | 306 | |
309 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
310 | - $total = $this->get_stored_data( 'give_temp_recount_all_total' ); |
|
307 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
308 | + $total = $this->get_stored_data('give_temp_recount_all_total'); |
|
311 | 309 | |
312 | - if ( false === $total ) { |
|
310 | + if (false === $total) { |
|
313 | 311 | |
314 | - $payment_items = $this->get_stored_data( 'give_temp_payment_items' ); |
|
312 | + $payment_items = $this->get_stored_data('give_temp_payment_items'); |
|
315 | 313 | |
316 | - if ( false === $payment_items ) { |
|
314 | + if (false === $payment_items) { |
|
317 | 315 | $payment_items = array(); |
318 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
316 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
319 | 317 | } |
320 | 318 | |
321 | 319 | $args = array( |
322 | 320 | 'post_status' => 'publish', |
323 | 321 | 'post_type' => 'give_forms', |
324 | - 'posts_per_page' => - 1, |
|
322 | + 'posts_per_page' => -1, |
|
325 | 323 | 'fields' => 'ids', |
326 | 324 | ); |
327 | 325 | |
328 | - $all_forms = get_posts( $args ); |
|
326 | + $all_forms = get_posts($args); |
|
329 | 327 | |
330 | - $this->store_data( 'give_temp_form_ids', $all_forms ); |
|
328 | + $this->store_data('give_temp_form_ids', $all_forms); |
|
331 | 329 | |
332 | - $args = apply_filters( 'give_recount_form_stats_total_args', array( |
|
330 | + $args = apply_filters('give_recount_form_stats_total_args', array( |
|
333 | 331 | 'give_forms' => $all_forms, |
334 | 332 | 'number' => $this->per_step, |
335 | 333 | 'status' => $accepted_statuses, |
336 | 334 | 'page' => $this->step, |
337 | 335 | 'output' => 'payments', |
338 | - ) ); |
|
336 | + )); |
|
339 | 337 | |
340 | - $payments_query = new Give_Payments_Query( $args ); |
|
338 | + $payments_query = new Give_Payments_Query($args); |
|
341 | 339 | $payments = $payments_query->get_payments(); |
342 | 340 | |
343 | - $total = wp_count_posts( 'give_payment' )->publish; |
|
341 | + $total = wp_count_posts('give_payment')->publish; |
|
344 | 342 | |
345 | - $this->store_data( 'give_temp_all_payments_data', $payments ); |
|
343 | + $this->store_data('give_temp_all_payments_data', $payments); |
|
346 | 344 | |
347 | - if ( $payments ) { |
|
345 | + if ($payments) { |
|
348 | 346 | |
349 | - foreach ( $payments as $payment ) { |
|
347 | + foreach ($payments as $payment) { |
|
350 | 348 | |
351 | 349 | $form_id = $payment->form_id; |
352 | 350 | |
353 | 351 | //If for some reason somehow the form_ID isn't set check payment meta |
354 | - if ( empty( $payment->form_id ) ) { |
|
352 | + if (empty($payment->form_id)) { |
|
355 | 353 | $payment_meta = $payment->get_meta(); |
356 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
354 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
357 | 355 | } |
358 | 356 | |
359 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
357 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
360 | 358 | continue; |
361 | 359 | } |
362 | 360 | |
363 | - if ( ! array_key_exists( $payment->ID, $payment_items ) ) { |
|
361 | + if ( ! array_key_exists($payment->ID, $payment_items)) { |
|
364 | 362 | |
365 | 363 | /** |
366 | 364 | * Filter the payment amount. |
@@ -369,22 +367,22 @@ discard block |
||
369 | 367 | */ |
370 | 368 | $payment_total = apply_filters( |
371 | 369 | 'give_donation_amount', |
372 | - give_format_amount( $payment->total, array( 'donation_id' => $payment->ID ) ), |
|
370 | + give_format_amount($payment->total, array('donation_id' => $payment->ID)), |
|
373 | 371 | $payment->total, |
374 | 372 | $payment->ID, |
375 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
373 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
376 | 374 | ); |
377 | 375 | |
378 | - $payment_items[ $payment->ID ] = array( |
|
376 | + $payment_items[$payment->ID] = array( |
|
379 | 377 | 'id' => $form_id, |
380 | 378 | 'payment_id' => $payment->ID, |
381 | - 'price' => (float) give_maybe_sanitize_amount( $payment_total ), |
|
379 | + 'price' => (float) give_maybe_sanitize_amount($payment_total), |
|
382 | 380 | ); |
383 | 381 | } |
384 | 382 | } |
385 | 383 | } |
386 | - $this->store_data( 'give_temp_payment_items', $payment_items ); |
|
387 | - $this->store_data( 'give_recount_all_total', $total ); |
|
384 | + $this->store_data('give_temp_payment_items', $payment_items); |
|
385 | + $this->store_data('give_recount_all_total', $total); |
|
388 | 386 | } |
389 | 387 | |
390 | 388 | } |
@@ -398,17 +396,17 @@ discard block |
||
398 | 396 | * |
399 | 397 | * @return mixed Returns the data from the database |
400 | 398 | */ |
401 | - private function get_stored_data( $key ) { |
|
399 | + private function get_stored_data($key) { |
|
402 | 400 | global $wpdb; |
403 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
404 | - if ( empty( $value ) ) { |
|
401 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
402 | + if (empty($value)) { |
|
405 | 403 | return false; |
406 | 404 | } |
407 | 405 | |
408 | - $maybe_json = json_decode( $value ); |
|
406 | + $maybe_json = json_decode($value); |
|
409 | 407 | |
410 | - if ( ! is_null( $maybe_json ) ) { |
|
411 | - $value = json_decode( $value, true ); |
|
408 | + if ( ! is_null($maybe_json)) { |
|
409 | + $value = json_decode($value, true); |
|
412 | 410 | } |
413 | 411 | |
414 | 412 | return $value; |
@@ -424,10 +422,10 @@ discard block |
||
424 | 422 | * |
425 | 423 | * @return void |
426 | 424 | */ |
427 | - private function store_data( $key, $value ) { |
|
425 | + private function store_data($key, $value) { |
|
428 | 426 | global $wpdb; |
429 | 427 | |
430 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
428 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
431 | 429 | |
432 | 430 | $data = array( |
433 | 431 | 'option_name' => $key, |
@@ -441,7 +439,7 @@ discard block |
||
441 | 439 | '%s', |
442 | 440 | ); |
443 | 441 | |
444 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
442 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
445 | 443 | } |
446 | 444 | |
447 | 445 | /** |
@@ -453,9 +451,9 @@ discard block |
||
453 | 451 | * |
454 | 452 | * @return void |
455 | 453 | */ |
456 | - private function delete_data( $key ) { |
|
454 | + private function delete_data($key) { |
|
457 | 455 | global $wpdb; |
458 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
456 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
459 | 457 | } |
460 | 458 | |
461 | 459 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * Constructor. |
48 | 48 | */ |
49 | - public function __construct( $_step = 1 ) { |
|
50 | - parent::__construct( $_step ); |
|
49 | + public function __construct($_step = 1) { |
|
50 | + parent::__construct($_step); |
|
51 | 51 | |
52 | 52 | $this->is_writable = true; |
53 | 53 | } |
@@ -61,33 +61,33 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function get_data() { |
63 | 63 | |
64 | - if ( $this->step == 1 ) { |
|
65 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
64 | + if ($this->step == 1) { |
|
65 | + $this->delete_data('give_temp_recount_earnings'); |
|
66 | 66 | } |
67 | 67 | |
68 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
68 | + $total = get_option('give_temp_recount_earnings', false); |
|
69 | 69 | |
70 | - if ( false === $total ) { |
|
70 | + if (false === $total) { |
|
71 | 71 | $total = (float) 0; |
72 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
72 | + $this->store_data('give_temp_recount_earnings', $total); |
|
73 | 73 | } |
74 | 74 | |
75 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
75 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
76 | 76 | |
77 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
77 | + $args = apply_filters('give_recount_earnings_args', array( |
|
78 | 78 | 'number' => $this->per_step, |
79 | 79 | 'page' => $this->step, |
80 | 80 | 'status' => $accepted_statuses, |
81 | 81 | 'fields' => 'ids' |
82 | - ) ); |
|
82 | + )); |
|
83 | 83 | |
84 | - $payments = give_get_payments( $args ); |
|
84 | + $payments = give_get_payments($args); |
|
85 | 85 | |
86 | - if ( ! empty( $payments ) ) { |
|
86 | + if ( ! empty($payments)) { |
|
87 | 87 | |
88 | - foreach ( $payments as $payment ) { |
|
88 | + foreach ($payments as $payment) { |
|
89 | 89 | // Get the payment amount. |
90 | - $payment_amount = give_get_meta( $payment->ID, '_give_payment_total', true ); |
|
90 | + $payment_amount = give_get_meta($payment->ID, '_give_payment_total', true); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Filter the payment amount. |
@@ -96,28 +96,28 @@ discard block |
||
96 | 96 | */ |
97 | 97 | $donation_amount = apply_filters( |
98 | 98 | 'give_donation_amount', |
99 | - give_format_amount( $payment_amount, array( 'donation_id' => $payment->ID ) ), |
|
99 | + give_format_amount($payment_amount, array('donation_id' => $payment->ID)), |
|
100 | 100 | $payment->total, |
101 | 101 | $payment->ID, |
102 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
102 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
103 | 103 | ); |
104 | 104 | |
105 | - $total += (float) give_maybe_sanitize_amount( $donation_amount ); |
|
105 | + $total += (float) give_maybe_sanitize_amount($donation_amount); |
|
106 | 106 | } |
107 | 107 | |
108 | - if ( $total < 0 ) { |
|
108 | + if ($total < 0) { |
|
109 | 109 | $totals = 0; |
110 | 110 | } |
111 | 111 | |
112 | - $total = round( $total, give_get_price_decimals() ); |
|
112 | + $total = round($total, give_get_price_decimals()); |
|
113 | 113 | |
114 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
114 | + $this->store_data('give_temp_recount_earnings', $total); |
|
115 | 115 | |
116 | 116 | return true; |
117 | 117 | |
118 | 118 | } |
119 | 119 | |
120 | - update_option( 'give_earnings_total', $total ); |
|
120 | + update_option('give_earnings_total', $total); |
|
121 | 121 | |
122 | 122 | return false; |
123 | 123 | |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function get_percentage_complete() { |
133 | 133 | |
134 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
134 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
135 | 135 | |
136 | - if ( false === $total ) { |
|
137 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
136 | + if (false === $total) { |
|
137 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
138 | 138 | |
139 | - $counts = give_count_payments( $args ); |
|
140 | - $total = absint( $counts->publish ); |
|
141 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
139 | + $counts = give_count_payments($args); |
|
140 | + $total = absint($counts->publish); |
|
141 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
142 | 142 | |
143 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
143 | + $this->store_data('give_recount_earnings_total', $total); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $percentage = 100; |
147 | 147 | |
148 | - if ( $total > 0 ) { |
|
149 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
148 | + if ($total > 0) { |
|
149 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( $percentage > 100 ) { |
|
152 | + if ($percentage > 100) { |
|
153 | 153 | $percentage = 100; |
154 | 154 | } |
155 | 155 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param array $request The Form Data passed into the batch processing |
165 | 165 | */ |
166 | - public function set_properties( $request ) { |
|
166 | + public function set_properties($request) { |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,21 +174,21 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function process_step() { |
176 | 176 | |
177 | - if ( ! $this->can_export() ) { |
|
178 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
177 | + if ( ! $this->can_export()) { |
|
178 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | $had_data = $this->get_data(); |
182 | 182 | |
183 | - if ( $had_data ) { |
|
183 | + if ($had_data) { |
|
184 | 184 | $this->done = false; |
185 | 185 | |
186 | 186 | return true; |
187 | 187 | } else { |
188 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
189 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
188 | + $this->delete_data('give_recount_earnings_total'); |
|
189 | + $this->delete_data('give_temp_recount_earnings'); |
|
190 | 190 | $this->done = true; |
191 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
191 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
192 | 192 | |
193 | 193 | return false; |
194 | 194 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return mixed Returns the data from the database |
227 | 227 | */ |
228 | - private function get_stored_data( $key ) { |
|
228 | + private function get_stored_data($key) { |
|
229 | 229 | global $wpdb; |
230 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
230 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
231 | 231 | |
232 | - if ( empty( $value ) ) { |
|
232 | + if (empty($value)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - $maybe_json = json_decode( $value ); |
|
237 | - if ( ! is_null( $maybe_json ) ) { |
|
238 | - $value = json_decode( $value, true ); |
|
236 | + $maybe_json = json_decode($value); |
|
237 | + if ( ! is_null($maybe_json)) { |
|
238 | + $value = json_decode($value, true); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return $value; |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return void |
253 | 253 | */ |
254 | - private function store_data( $key, $value ) { |
|
254 | + private function store_data($key, $value) { |
|
255 | 255 | global $wpdb; |
256 | 256 | |
257 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
257 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
258 | 258 | |
259 | 259 | $data = array( |
260 | 260 | 'option_name' => $key, |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | '%s', |
269 | 269 | ); |
270 | 270 | |
271 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
271 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return void |
282 | 282 | */ |
283 | - private function delete_data( $key ) { |
|
283 | + private function delete_data($key) { |
|
284 | 284 | global $wpdb; |
285 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
285 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | } |