@@ -80,34 +80,34 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param array $args |
82 | 82 | */ |
83 | - public function register( $args ) { |
|
83 | + public function register($args) { |
|
84 | 84 | $args_default = array( |
85 | 85 | 'id' => '', |
86 | 86 | 'version' => '', |
87 | 87 | 'callback' => '', |
88 | 88 | ); |
89 | 89 | |
90 | - $args = wp_parse_args( $args, $args_default ); |
|
90 | + $args = wp_parse_args($args, $args_default); |
|
91 | 91 | |
92 | 92 | // You can only register database upgrade. |
93 | 93 | $args['type'] = 'database'; |
94 | 94 | |
95 | 95 | // Bailout. |
96 | 96 | if ( |
97 | - empty( $args['id'] ) || |
|
98 | - empty( $args['version'] ) || |
|
99 | - empty( $args['callback'] ) || |
|
100 | - ! is_callable( $args['callback'] ) |
|
97 | + empty($args['id']) || |
|
98 | + empty($args['version']) || |
|
99 | + empty($args['callback']) || |
|
100 | + ! is_callable($args['callback']) |
|
101 | 101 | ) { |
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // Change depend param to array. |
106 | - if ( isset( $args['depend'] ) && is_string( $args['depend'] ) ) { |
|
107 | - $args['depend'] = array( $args['depend'] ); |
|
106 | + if (isset($args['depend']) && is_string($args['depend'])) { |
|
107 | + $args['depend'] = array($args['depend']); |
|
108 | 108 | } |
109 | 109 | |
110 | - $this->updates[ $args['type'] ][] = $args; |
|
110 | + $this->updates[$args['type']][] = $args; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return static |
119 | 119 | */ |
120 | 120 | static function get_instance() { |
121 | - if ( is_null( self::$instance ) ) { |
|
121 | + if (is_null(self::$instance)) { |
|
122 | 122 | self::$instance = new self(); |
123 | 123 | } |
124 | 124 | |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * Load file |
138 | 138 | */ |
139 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-background-updater.php'; |
|
140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
139 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-background-updater.php'; |
|
140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
141 | 141 | |
142 | 142 | self::$background_updater = new Give_Background_Updater(); |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Setup hooks. |
146 | 146 | */ |
147 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
148 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
149 | - add_action( 'wp_ajax_give_db_updates_info', array( $this, '__give_db_updates_info' ) ); |
|
150 | - add_action( 'wp_ajax_give_run_db_updates', array( $this, '__give_start_updating' ) ); |
|
151 | - add_action( 'admin_init', array( $this, '__redirect_admin' ) ); |
|
152 | - add_action( 'admin_init', array( $this, '__pause_db_update' ), - 1 ); |
|
153 | - add_action( 'admin_init', array( $this, '__restart_db_update' ), - 1 ); |
|
154 | - add_action( 'admin_notices', array( $this, '__show_notice' ) ); |
|
155 | - add_action( 'give_restart_db_upgrade', array( $this, '__health_background_update' ) ); |
|
156 | - |
|
157 | - if ( is_admin() ) { |
|
158 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
159 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
147 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
148 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
149 | + add_action('wp_ajax_give_db_updates_info', array($this, '__give_db_updates_info')); |
|
150 | + add_action('wp_ajax_give_run_db_updates', array($this, '__give_start_updating')); |
|
151 | + add_action('admin_init', array($this, '__redirect_admin')); |
|
152 | + add_action('admin_init', array($this, '__pause_db_update'), - 1); |
|
153 | + add_action('admin_init', array($this, '__restart_db_update'), - 1); |
|
154 | + add_action('admin_notices', array($this, '__show_notice')); |
|
155 | + add_action('give_restart_db_upgrade', array($this, '__health_background_update')); |
|
156 | + |
|
157 | + if (is_admin()) { |
|
158 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
159 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $addons = give_get_plugins(); |
171 | 171 | $plugin_updates = get_plugin_updates(); |
172 | 172 | |
173 | - foreach ( $addons as $key => $info ) { |
|
174 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
173 | + foreach ($addons as $key => $info) { |
|
174 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | |
178 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
178 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | */ |
189 | 189 | public function __register_upgrade() { |
190 | - if ( ! is_admin() ) { |
|
190 | + if ( ! is_admin()) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @since 1.8.12 |
198 | 198 | */ |
199 | - do_action( 'give_register_updates', $this ); |
|
199 | + do_action('give_register_updates', $this); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -209,23 +209,22 @@ discard block |
||
209 | 209 | global $menu; |
210 | 210 | |
211 | 211 | // Bailout. |
212 | - if ( empty( $menu ) || ! $this->get_total_update_count() ) { |
|
212 | + if (empty($menu) || ! $this->get_total_update_count()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
216 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
217 | 217 | |
218 | - foreach ( $menu as $index => $menu_item ) { |
|
219 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
218 | + foreach ($menu as $index => $menu_item) { |
|
219 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | - $menu[ $index ][0] = sprintf( |
|
223 | + $menu[$index][0] = sprintf( |
|
224 | 224 | '%1$s <span class="update-plugins"><span class="plugin-count give-update-progress-count">%2$s%3$s</span></span>', |
225 | - __( 'Donations', 'give' ), |
|
225 | + __('Donations', 'give'), |
|
226 | 226 | $is_update ? |
227 | - $this->get_db_update_processing_percentage() : |
|
228 | - $this->get_total_update_count(), |
|
227 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
229 | 228 | $is_update ? '%' : '' |
230 | 229 | ); |
231 | 230 | |
@@ -241,7 +240,7 @@ discard block |
||
241 | 240 | */ |
242 | 241 | public function __register_menu() { |
243 | 242 | // Bailout. |
244 | - if ( ! give_test_ajax_works() ) { |
|
243 | + if ( ! give_test_ajax_works()) { |
|
245 | 244 | return; |
246 | 245 | } |
247 | 246 | |
@@ -249,41 +248,40 @@ discard block |
||
249 | 248 | $this->__register_plugin_addon_updates(); |
250 | 249 | |
251 | 250 | // Bailout. |
252 | - if ( ! $this->get_total_update_count() ) { |
|
251 | + if ( ! $this->get_total_update_count()) { |
|
253 | 252 | // Show complete update message if still on update setting page. |
254 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
253 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
255 | 254 | // Upgrades |
256 | 255 | add_submenu_page( |
257 | 256 | 'edit.php?post_type=give_forms', |
258 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
259 | - __( 'Updates', 'give' ), |
|
257 | + esc_html__('Give Updates Complete', 'give'), |
|
258 | + __('Updates', 'give'), |
|
260 | 259 | 'manage_give_settings', |
261 | 260 | 'give-updates', |
262 | - array( $this, 'render_complete_page' ) |
|
261 | + array($this, 'render_complete_page') |
|
263 | 262 | ); |
264 | 263 | } |
265 | 264 | |
266 | 265 | return; |
267 | 266 | } |
268 | 267 | |
269 | - $is_update = ( $this->is_doing_updates() && ! self::$background_updater->is_paused_process() ); |
|
268 | + $is_update = ($this->is_doing_updates() && ! self::$background_updater->is_paused_process()); |
|
270 | 269 | |
271 | 270 | // Upgrades |
272 | 271 | add_submenu_page( |
273 | 272 | 'edit.php?post_type=give_forms', |
274 | - esc_html__( 'Give Updates', 'give' ), |
|
273 | + esc_html__('Give Updates', 'give'), |
|
275 | 274 | sprintf( |
276 | 275 | '%1$s <span class="update-plugins"%2$s><span class="plugin-count give-update-progress-count">%3$s%4$s</span></span>', |
277 | - __( 'Updates', 'give' ), |
|
278 | - isset( $_GET['give-pause-db-upgrades'] ) ? ' style="display:none;"' : '', |
|
276 | + __('Updates', 'give'), |
|
277 | + isset($_GET['give-pause-db-upgrades']) ? ' style="display:none;"' : '', |
|
279 | 278 | $is_update ? |
280 | - $this->get_db_update_processing_percentage() : |
|
281 | - $this->get_total_update_count(), |
|
279 | + $this->get_db_update_processing_percentage() : $this->get_total_update_count(), |
|
282 | 280 | $is_update ? '%' : '' |
283 | 281 | ), |
284 | 282 | 'manage_give_settings', |
285 | 283 | 'give-updates', |
286 | - array( $this, 'render_page' ) |
|
284 | + array($this, 'render_page') |
|
287 | 285 | ); |
288 | 286 | } |
289 | 287 | |
@@ -298,13 +296,13 @@ discard block |
||
298 | 296 | // Show db upgrade completed notice. |
299 | 297 | if ( |
300 | 298 | ! wp_doing_ajax() && |
301 | - current_user_can( 'manage_give_settings' ) && |
|
302 | - get_option( 'give_show_db_upgrade_complete_notice' ) && |
|
303 | - ! isset( $_GET['give-db-update-completed'] ) |
|
299 | + current_user_can('manage_give_settings') && |
|
300 | + get_option('give_show_db_upgrade_complete_notice') && |
|
301 | + ! isset($_GET['give-db-update-completed']) |
|
304 | 302 | ) { |
305 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
303 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
306 | 304 | |
307 | - wp_redirect( add_query_arg( array( 'give-db-update-completed' => 'give_db_upgrade_completed' ) ) ); |
|
305 | + wp_redirect(add_query_arg(array('give-db-update-completed' => 'give_db_upgrade_completed'))); |
|
308 | 306 | exit(); |
309 | 307 | } |
310 | 308 | } |
@@ -320,15 +318,15 @@ discard block |
||
320 | 318 | * |
321 | 319 | * @return bool |
322 | 320 | */ |
323 | - public function __pause_db_update( $force = false ) { |
|
321 | + public function __pause_db_update($force = false) { |
|
324 | 322 | // Bailout. |
325 | 323 | if ( |
326 | 324 | ! $force && |
327 | 325 | ( |
328 | 326 | wp_doing_ajax() || |
329 | - ! isset( $_GET['page'] ) || |
|
327 | + ! isset($_GET['page']) || |
|
330 | 328 | 'give-updates' !== $_GET['page'] || |
331 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
329 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
332 | 330 | self::$background_updater->is_paused_process() || |
333 | 331 | ! self::$background_updater->has_queue() |
334 | 332 | ) |
@@ -337,13 +335,13 @@ discard block |
||
337 | 335 | return false; |
338 | 336 | } |
339 | 337 | |
340 | - delete_option( 'give_upgrade_error' ); |
|
338 | + delete_option('give_upgrade_error'); |
|
341 | 339 | |
342 | - $this->__health_background_update( $this ); |
|
340 | + $this->__health_background_update($this); |
|
343 | 341 | $batch = self::$background_updater->get_all_batch(); |
344 | 342 | |
345 | 343 | // Bailout: if batch is empty |
346 | - if ( empty( $batch->data ) ) { |
|
344 | + if (empty($batch->data)) { |
|
347 | 345 | return false; |
348 | 346 | } |
349 | 347 | |
@@ -352,25 +350,25 @@ discard block |
||
352 | 350 | |
353 | 351 | // Do not stop background process immediately if task running. |
354 | 352 | // @see Give_Background_Updater::lock_process |
355 | - if ( ! $force && self::$background_updater->is_process_running() ) { |
|
356 | - update_option( 'give_pause_upgrade', 1 ); |
|
353 | + if ( ! $force && self::$background_updater->is_process_running()) { |
|
354 | + update_option('give_pause_upgrade', 1); |
|
357 | 355 | |
358 | 356 | return true; |
359 | 357 | } |
360 | 358 | |
361 | - update_option( 'give_paused_batches', $batch, 'no' ); |
|
362 | - delete_option( $batch->key ); |
|
363 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
364 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
359 | + update_option('give_paused_batches', $batch, 'no'); |
|
360 | + delete_option($batch->key); |
|
361 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
362 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
365 | 363 | |
366 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
364 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
367 | 365 | |
368 | 366 | /** |
369 | 367 | * Fire action when pause db updates |
370 | 368 | * |
371 | 369 | * @since 2.0.1 |
372 | 370 | */ |
373 | - do_action( 'give_pause_db_upgrade', $this ); |
|
371 | + do_action('give_pause_db_upgrade', $this); |
|
374 | 372 | |
375 | 373 | return true; |
376 | 374 | } |
@@ -387,31 +385,31 @@ discard block |
||
387 | 385 | // Bailout. |
388 | 386 | if ( |
389 | 387 | wp_doing_ajax() || |
390 | - ! isset( $_GET['page'] ) || |
|
388 | + ! isset($_GET['page']) || |
|
391 | 389 | 'give-updates' !== $_GET['page'] || |
392 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
390 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
393 | 391 | ! self::$background_updater->is_paused_process() |
394 | 392 | ) { |
395 | 393 | return false; |
396 | 394 | } |
397 | 395 | |
398 | 396 | Give_Background_Updater::flush_cache(); |
399 | - $batch = get_option( 'give_paused_batches' ); |
|
397 | + $batch = get_option('give_paused_batches'); |
|
400 | 398 | |
401 | - if ( ! empty( $batch ) ) { |
|
402 | - wp_cache_delete( $batch->key, 'options' ); |
|
403 | - update_option( $batch->key, $batch->data ); |
|
399 | + if ( ! empty($batch)) { |
|
400 | + wp_cache_delete($batch->key, 'options'); |
|
401 | + update_option($batch->key, $batch->data); |
|
404 | 402 | |
405 | - delete_option( 'give_paused_batches' ); |
|
403 | + delete_option('give_paused_batches'); |
|
406 | 404 | |
407 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
405 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
408 | 406 | |
409 | 407 | |
410 | 408 | /** Fire action when restart db updates |
411 | 409 | * |
412 | 410 | * @since 2.0.1 |
413 | 411 | */ |
414 | - do_action( 'give_restart_db_upgrade', $this ); |
|
412 | + do_action('give_restart_db_upgrade', $this); |
|
415 | 413 | |
416 | 414 | self::$background_updater->dispatch(); |
417 | 415 | } |
@@ -427,53 +425,53 @@ discard block |
||
427 | 425 | * |
428 | 426 | * @param Give_Updates $give_updates |
429 | 427 | */ |
430 | - public function __health_background_update( $give_updates ) { |
|
431 | - if ( ! $this->is_doing_updates() ) { |
|
428 | + public function __health_background_update($give_updates) { |
|
429 | + if ( ! $this->is_doing_updates()) { |
|
432 | 430 | return; |
433 | 431 | } |
434 | 432 | |
435 | 433 | Give_Background_Updater::flush_cache(); |
436 | 434 | |
437 | 435 | $batch = Give_Updates::$background_updater->get_all_batch(); |
438 | - $batch_data_count = count( $batch->data ); |
|
439 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
440 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
441 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
436 | + $batch_data_count = count($batch->data); |
|
437 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
438 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
439 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
442 | 440 | $log_data = ''; |
443 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
441 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
444 | 442 | |
445 | - if ( ! empty( $doing_upgrade_args ) ) { |
|
446 | - $log_data .= 'Doing update:' . "\n"; |
|
447 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
443 | + if ( ! empty($doing_upgrade_args)) { |
|
444 | + $log_data .= 'Doing update:'."\n"; |
|
445 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
448 | 446 | } |
449 | 447 | |
450 | 448 | /** |
451 | 449 | * Add remove upgrade from batch |
452 | 450 | */ |
453 | - if ( ! empty( $batch->data ) ) { |
|
451 | + if ( ! empty($batch->data)) { |
|
454 | 452 | |
455 | - foreach ( $batch->data as $index => $update ) { |
|
456 | - $log_data = print_r( $update, true ) . "\n"; |
|
453 | + foreach ($batch->data as $index => $update) { |
|
454 | + $log_data = print_r($update, true)."\n"; |
|
457 | 455 | |
458 | - if ( ! is_callable( $update['callback'] ) ) { |
|
459 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
460 | - unset( $batch->data[ $index ] ); |
|
461 | - } elseif ( give_has_upgrade_completed( $update['id'] ) ) { |
|
462 | - $log_data .= 'Removing already completed update: ' . "{$update['id']}\n"; |
|
463 | - unset( $batch->data[ $index ] ); |
|
456 | + if ( ! is_callable($update['callback'])) { |
|
457 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
458 | + unset($batch->data[$index]); |
|
459 | + } elseif (give_has_upgrade_completed($update['id'])) { |
|
460 | + $log_data .= 'Removing already completed update: '."{$update['id']}\n"; |
|
461 | + unset($batch->data[$index]); |
|
464 | 462 | } |
465 | 463 | |
466 | - if ( ! empty( $update['depend'] ) ) { |
|
464 | + if ( ! empty($update['depend'])) { |
|
467 | 465 | |
468 | - foreach ( $update['depend'] as $depend ) { |
|
469 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
470 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
466 | + foreach ($update['depend'] as $depend) { |
|
467 | + if (give_has_upgrade_completed($depend)) { |
|
468 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
471 | 469 | continue; |
472 | 470 | } |
473 | 471 | |
474 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
475 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
476 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
472 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
473 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
474 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
477 | 475 | } |
478 | 476 | } |
479 | 477 | } |
@@ -483,60 +481,60 @@ discard block |
||
483 | 481 | /** |
484 | 482 | * Add new upgrade to batch |
485 | 483 | */ |
486 | - if ( $new_updates = $this->get_updates( 'database', 'new' ) ) { |
|
487 | - $all_batch_update_ids = ! empty( $batch->data ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
484 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
485 | + $all_batch_update_ids = ! empty($batch->data) ? wp_list_pluck($batch->data, 'id') : array(); |
|
488 | 486 | |
489 | - foreach ( $new_updates as $index => $new_update ) { |
|
490 | - if ( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
491 | - unset( $new_updates[ $index ] ); |
|
487 | + foreach ($new_updates as $index => $new_update) { |
|
488 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
489 | + unset($new_updates[$index]); |
|
492 | 490 | } |
493 | 491 | } |
494 | 492 | |
495 | - if ( ! empty( $new_updates ) ) { |
|
496 | - $log_data .= 'Adding new update: ' . "\n"; |
|
497 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
493 | + if ( ! empty($new_updates)) { |
|
494 | + $log_data .= 'Adding new update: '."\n"; |
|
495 | + $log_data .= print_r($new_updates, true)."\n"; |
|
498 | 496 | |
499 | - $batch->data = array_merge( (array) $batch->data, $new_updates ); |
|
500 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) ); |
|
497 | + $batch->data = array_merge((array) $batch->data, $new_updates); |
|
498 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates))); |
|
501 | 499 | } |
502 | 500 | } |
503 | 501 | |
504 | 502 | /** |
505 | 503 | * Fix batch |
506 | 504 | */ |
507 | - if ( empty( $batch->data ) ) { |
|
505 | + if (empty($batch->data)) { |
|
508 | 506 | // Complete batch if do not have any data to process. |
509 | - self::$background_updater->delete( $batch->key ); |
|
507 | + self::$background_updater->delete($batch->key); |
|
510 | 508 | |
511 | - if ( self::$background_updater->has_queue() ) { |
|
512 | - $this->__health_background_update( $this ); |
|
509 | + if (self::$background_updater->has_queue()) { |
|
510 | + $this->__health_background_update($this); |
|
513 | 511 | } else { |
514 | 512 | self::$background_updater->complete(); |
515 | 513 | } |
516 | 514 | |
517 | - } elseif ( $batch_data_count !== count( $batch->data ) ) { |
|
515 | + } elseif ($batch_data_count !== count($batch->data)) { |
|
518 | 516 | |
519 | - $log_data .= 'Updating batch' . "\n"; |
|
520 | - $log_data .= print_r( $batch, true ); |
|
517 | + $log_data .= 'Updating batch'."\n"; |
|
518 | + $log_data .= print_r($batch, true); |
|
521 | 519 | |
522 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) ); |
|
520 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', $doing_upgrade_args['update'], get_option('give_db_update_count')); |
|
523 | 521 | $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(); |
524 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
522 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
525 | 523 | |
526 | - if ( ! empty( $batch->key ) ) { |
|
527 | - wp_cache_delete( $batch->key, 'options' ); |
|
528 | - update_option( $batch->key, $batch->data ); |
|
524 | + if ( ! empty($batch->key)) { |
|
525 | + wp_cache_delete($batch->key, 'options'); |
|
526 | + update_option($batch->key, $batch->data); |
|
529 | 527 | } else { |
530 | 528 | |
531 | - update_option( 'give_db_update_count', count( $batch->data ) ); |
|
529 | + update_option('give_db_update_count', count($batch->data)); |
|
532 | 530 | |
533 | 531 | $doing_upgrade_args['update'] = $give_updates->update; |
534 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, count( $batch->data ) ); |
|
532 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, count($batch->data)); |
|
535 | 533 | |
536 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
534 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
537 | 535 | |
538 | - foreach ( $batch->data as $data ) { |
|
539 | - Give_Updates::$background_updater->push_to_queue( $data ); |
|
536 | + foreach ($batch->data as $data) { |
|
537 | + Give_Updates::$background_updater->push_to_queue($data); |
|
540 | 538 | } |
541 | 539 | |
542 | 540 | Give_Updates::$background_updater->save(); |
@@ -548,27 +546,27 @@ discard block |
||
548 | 546 | * Fix give_doing_upgrade option |
549 | 547 | */ |
550 | 548 | $update_option = false; |
551 | - $fresh_new_db_count = $this->get_total_new_db_update_count( true ); |
|
552 | - if ( $fresh_new_db_count < $doing_upgrade_args['update'] ) { |
|
553 | - update_option( 'give_db_update_count', $fresh_new_db_count ); |
|
549 | + $fresh_new_db_count = $this->get_total_new_db_update_count(true); |
|
550 | + if ($fresh_new_db_count < $doing_upgrade_args['update']) { |
|
551 | + update_option('give_db_update_count', $fresh_new_db_count); |
|
554 | 552 | $doing_upgrade_args['update'] = 1; |
555 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count ); |
|
553 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', 1, $fresh_new_db_count); |
|
556 | 554 | $update_option = true; |
557 | 555 | } |
558 | 556 | |
559 | - if ( 101 < $doing_upgrade_args['total_percentage'] ) { |
|
560 | - $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true ); |
|
557 | + if (101 < $doing_upgrade_args['total_percentage']) { |
|
558 | + $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(true); |
|
561 | 559 | $update_option = true; |
562 | 560 | } |
563 | 561 | |
564 | - if ( $update_option ) { |
|
565 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
562 | + if ($update_option) { |
|
563 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
566 | 564 | |
567 | - $log_data .= 'Updated doing update:' . "\n"; |
|
568 | - $log_data .= print_r( $doing_upgrade_args, true ) . "\n"; |
|
565 | + $log_data .= 'Updated doing update:'."\n"; |
|
566 | + $log_data .= print_r($doing_upgrade_args, true)."\n"; |
|
569 | 567 | } |
570 | 568 | |
571 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
569 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
572 | 570 | } |
573 | 571 | |
574 | 572 | |
@@ -580,66 +578,66 @@ discard block |
||
580 | 578 | */ |
581 | 579 | public function __show_notice() { |
582 | 580 | // Bailout. |
583 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
581 | + if ( ! current_user_can('manage_give_settings')) { |
|
584 | 582 | return; |
585 | 583 | } |
586 | 584 | |
587 | 585 | // Run DB updates. |
588 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
586 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
589 | 587 | $this->run_db_update(); |
590 | 588 | } |
591 | 589 | |
592 | 590 | |
593 | 591 | // Bailout. |
594 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
592 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
595 | 593 | return; |
596 | 594 | } |
597 | 595 | |
598 | 596 | // Show notice if upgrade paused. |
599 | - if ( self::$background_updater->is_paused_process() ) { |
|
597 | + if (self::$background_updater->is_paused_process()) { |
|
600 | 598 | ob_start(); |
601 | 599 | |
602 | - $upgrade_error = get_option( 'give_upgrade_error' ); |
|
603 | - if ( ! $upgrade_error ) : ?> |
|
604 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
605 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give' ); ?> |
|
600 | + $upgrade_error = get_option('give_upgrade_error'); |
|
601 | + if ( ! $upgrade_error) : ?> |
|
602 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
603 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a backup before proceeding.', 'give'); ?> |
|
606 | 604 | <br> |
607 | 605 | <br> |
608 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-restart-db-upgrades' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-restart-updater-btn"> |
|
609 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
606 | + <a href="<?php echo esc_url(add_query_arg(array('give-restart-db-upgrades' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-restart-updater-btn"> |
|
607 | + <?php _e('Restart the updater', 'give'); ?> |
|
610 | 608 | </a> |
611 | 609 | <script type="text/javascript"> |
612 | 610 | jQuery('.give-restart-updater-btn').click('click', function () { |
613 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
611 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
614 | 612 | }); |
615 | 613 | </script> |
616 | 614 | <?php else: ?> |
617 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
618 | - – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
615 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
616 | + – <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
619 | 617 | <?php |
620 | 618 | endif; |
621 | 619 | $desc_html = ob_get_clean(); |
622 | 620 | |
623 | - Give()->notices->register_notice( array( |
|
621 | + Give()->notices->register_notice(array( |
|
624 | 622 | 'id' => 'give_upgrade_db', |
625 | 623 | 'type' => 'error', |
626 | 624 | 'dismissible' => false, |
627 | 625 | 'description' => $desc_html, |
628 | - ) ); |
|
626 | + )); |
|
629 | 627 | } |
630 | 628 | |
631 | 629 | // Bailout if doing upgrades. |
632 | - if ( $this->is_doing_updates() ) { |
|
630 | + if ($this->is_doing_updates()) { |
|
633 | 631 | return; |
634 | 632 | } |
635 | 633 | |
636 | 634 | // Show notice if ajax is not working. |
637 | - if ( ! give_test_ajax_works() ) { |
|
635 | + if ( ! give_test_ajax_works()) { |
|
638 | 636 | Give()->notices->register_notice( |
639 | 637 | array( |
640 | 638 | 'id' => 'give_db_upgrade_ajax_inaccessible', |
641 | 639 | 'type' => 'error', |
642 | - 'description' => sprintf( '%1$s <a href="%2$s" target="_blank">%3$s</a>', __( 'Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give' ), 'http://docs.givewp.com/admin-ajax-error', __( 'Read More', 'give' ) . ' »' ), |
|
640 | + 'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a>', __('Give needs to upgrade the database but cannot because AJAX does not appear accessible. This could be because your website is password protected, in maintenance mode, or has a specific hosting configuration or plugin active that is preventing access.', 'give'), 'http://docs.givewp.com/admin-ajax-error', __('Read More', 'give').' »'), |
|
643 | 641 | 'show' => true, |
644 | 642 | ) |
645 | 643 | ); |
@@ -648,45 +646,45 @@ discard block |
||
648 | 646 | } |
649 | 647 | |
650 | 648 | // Show db upgrade completed notice. |
651 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
652 | - Give()->notices->register_notice( array( |
|
649 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
650 | + Give()->notices->register_notice(array( |
|
653 | 651 | 'id' => 'give_db_upgrade_completed', |
654 | 652 | 'type' => 'updated', |
655 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
653 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
656 | 654 | 'show' => true, |
657 | - ) ); |
|
655 | + )); |
|
658 | 656 | |
659 | 657 | // Start update. |
660 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
658 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
661 | 659 | $this->run_db_update(); |
662 | 660 | |
663 | 661 | // Show run the update notice. |
664 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
662 | + } elseif ($this->get_total_new_db_update_count()) { |
|
665 | 663 | ob_start(); |
666 | 664 | ?> |
667 | 665 | <p> |
668 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
669 | - – <?php _e( 'GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give' ); ?> |
|
666 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
667 | + – <?php _e('GiveWP needs to update your database to the latest version. The following process will make updates to your site\'s database. Please create a complete backup before proceeding.', 'give'); ?> |
|
670 | 668 | </p> |
671 | 669 | <p class="submit"> |
672 | - <a href="<?php echo esc_url( add_query_arg( array( 'give-run-db-update' => 1 ), admin_url( 'edit.php?post_type=give_forms&page=give-updates' ) ) ); ?>" class="button button-primary give-run-update-now"> |
|
673 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
670 | + <a href="<?php echo esc_url(add_query_arg(array('give-run-db-update' => 1), admin_url('edit.php?post_type=give_forms&page=give-updates'))); ?>" class="button button-primary give-run-update-now"> |
|
671 | + <?php _e('Run the updater', 'give'); ?> |
|
674 | 672 | </a> |
675 | 673 | </p> |
676 | 674 | <script type="text/javascript"> |
677 | 675 | jQuery('.give-run-update-now').click('click', function () { |
678 | - return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
|
676 | + return window.confirm('<?php echo esc_js(__('It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give')); ?>'); // jshint ignore:line |
|
679 | 677 | }); |
680 | 678 | </script> |
681 | 679 | <?php |
682 | 680 | $desc_html = ob_get_clean(); |
683 | 681 | |
684 | - Give()->notices->register_notice( array( |
|
682 | + Give()->notices->register_notice(array( |
|
685 | 683 | 'id' => 'give_upgrade_db', |
686 | 684 | 'type' => 'updated', |
687 | 685 | 'dismissible' => false, |
688 | 686 | 'description' => $desc_html, |
689 | - ) ); |
|
687 | + )); |
|
690 | 688 | } |
691 | 689 | } |
692 | 690 | |
@@ -697,7 +695,7 @@ discard block |
||
697 | 695 | * @access public |
698 | 696 | */ |
699 | 697 | public function render_complete_page() { |
700 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
698 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
701 | 699 | } |
702 | 700 | |
703 | 701 | /** |
@@ -707,7 +705,7 @@ discard block |
||
707 | 705 | * @access public |
708 | 706 | */ |
709 | 707 | public function render_page() { |
710 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
708 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
711 | 709 | } |
712 | 710 | |
713 | 711 | /** |
@@ -718,26 +716,26 @@ discard block |
||
718 | 716 | */ |
719 | 717 | private function run_db_update() { |
720 | 718 | // Bailout. |
721 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
719 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
722 | 720 | return; |
723 | 721 | } |
724 | 722 | |
725 | - $updates = $this->get_updates( 'database', 'new' ); |
|
723 | + $updates = $this->get_updates('database', 'new'); |
|
726 | 724 | |
727 | - foreach ( $updates as $update ) { |
|
728 | - self::$background_updater->push_to_queue( $update ); |
|
725 | + foreach ($updates as $update) { |
|
726 | + self::$background_updater->push_to_queue($update); |
|
729 | 727 | } |
730 | 728 | |
731 | - add_option( 'give_db_update_count', count( $updates ), '', 'no' ); |
|
729 | + add_option('give_db_update_count', count($updates), '', 'no'); |
|
732 | 730 | |
733 | - add_option( 'give_doing_upgrade', array( |
|
731 | + add_option('give_doing_upgrade', array( |
|
734 | 732 | 'update_info' => $updates[0], |
735 | 733 | 'step' => 1, |
736 | 734 | 'update' => 1, |
737 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
735 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
738 | 736 | 'percentage' => 0, |
739 | 737 | 'total_percentage' => 0, |
740 | - ), '', 'no' ); |
|
738 | + ), '', 'no'); |
|
741 | 739 | |
742 | 740 | self::$background_updater->save()->dispatch(); |
743 | 741 | } |
@@ -751,14 +749,13 @@ discard block |
||
751 | 749 | */ |
752 | 750 | public function __flush_resume_updates() { |
753 | 751 | //delete_option( 'give_doing_upgrade' ); |
754 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
752 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
755 | 753 | |
756 | 754 | // Reset counter. |
757 | 755 | $this->step = $this->percentage = 0; |
758 | 756 | |
759 | - $this->update = ( $this->get_total_db_update_count() > $this->update ) ? |
|
760 | - ( $this->update + 1 ) : |
|
761 | - $this->update; |
|
757 | + $this->update = ($this->get_total_db_update_count() > $this->update) ? |
|
758 | + ($this->update + 1) : $this->update; |
|
762 | 759 | } |
763 | 760 | |
764 | 761 | |
@@ -773,7 +770,7 @@ discard block |
||
773 | 770 | public function __give_start_updating() { |
774 | 771 | // Check permission. |
775 | 772 | if ( |
776 | - ! current_user_can( 'manage_give_settings' ) || |
|
773 | + ! current_user_can('manage_give_settings') || |
|
777 | 774 | $this->is_doing_updates() |
778 | 775 | ) { |
779 | 776 | wp_send_json_error(); |
@@ -781,7 +778,7 @@ discard block |
||
781 | 778 | |
782 | 779 | // @todo: validate nonce |
783 | 780 | // @todo: set http method to post |
784 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
781 | + if (empty($_POST['run_db_update'])) { |
|
785 | 782 | wp_send_json_error(); |
786 | 783 | } |
787 | 784 | |
@@ -800,34 +797,34 @@ discard block |
||
800 | 797 | * @return string |
801 | 798 | */ |
802 | 799 | public function __give_db_updates_info() { |
803 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
800 | + $update_info = get_option('give_doing_upgrade'); |
|
804 | 801 | $response_type = ''; |
805 | 802 | |
806 | - if ( self::$background_updater->is_paused_process() ) { |
|
803 | + if (self::$background_updater->is_paused_process()) { |
|
807 | 804 | $update_info = array( |
808 | - 'message' => __( 'The updates have been paused.', 'give' ), |
|
809 | - 'heading' => __( '', 'give' ), |
|
805 | + 'message' => __('The updates have been paused.', 'give'), |
|
806 | + 'heading' => __('', 'give'), |
|
810 | 807 | 'percentage' => 0, |
811 | 808 | ); |
812 | 809 | |
813 | - if ( get_option( 'give_upgrade_error' ) ) { |
|
814 | - $update_info['message'] = __( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); |
|
810 | + if (get_option('give_upgrade_error')) { |
|
811 | + $update_info['message'] = __('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); |
|
815 | 812 | } |
816 | 813 | |
817 | 814 | $response_type = 'error'; |
818 | 815 | |
819 | - } elseif ( empty( $update_info ) ) { |
|
816 | + } elseif (empty($update_info)) { |
|
820 | 817 | $update_info = array( |
821 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
822 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
818 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
819 | + 'heading' => __('Updates Completed.', 'give'), |
|
823 | 820 | 'percentage' => 0, |
824 | 821 | ); |
825 | 822 | $response_type = 'success'; |
826 | 823 | |
827 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
824 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
828 | 825 | } |
829 | 826 | |
830 | - $this->send_ajax_response( $update_info, $response_type ); |
|
827 | + $this->send_ajax_response($update_info, $response_type); |
|
831 | 828 | } |
832 | 829 | |
833 | 830 | /** |
@@ -839,7 +836,7 @@ discard block |
||
839 | 836 | * @param $data |
840 | 837 | * @param string $type |
841 | 838 | */ |
842 | - public function send_ajax_response( $data, $type = '' ) { |
|
839 | + public function send_ajax_response($data, $type = '') { |
|
843 | 840 | $default = array( |
844 | 841 | 'message' => '', |
845 | 842 | 'heading' => '', |
@@ -849,24 +846,24 @@ discard block |
||
849 | 846 | ); |
850 | 847 | |
851 | 848 | // Set data. |
852 | - $data = wp_parse_args( $data, $default ); |
|
849 | + $data = wp_parse_args($data, $default); |
|
853 | 850 | |
854 | 851 | // Enable cache. |
855 | 852 | Give_Cache::enable(); |
856 | 853 | |
857 | - switch ( $type ) { |
|
854 | + switch ($type) { |
|
858 | 855 | case 'success': |
859 | - wp_send_json_success( $data ); |
|
856 | + wp_send_json_success($data); |
|
860 | 857 | break; |
861 | 858 | |
862 | 859 | case 'error': |
863 | - wp_send_json_error( $data ); |
|
860 | + wp_send_json_error($data); |
|
864 | 861 | break; |
865 | 862 | |
866 | 863 | default: |
867 | - wp_send_json( array( |
|
864 | + wp_send_json(array( |
|
868 | 865 | 'data' => $data, |
869 | - ) ); |
|
866 | + )); |
|
870 | 867 | break; |
871 | 868 | } |
872 | 869 | } |
@@ -880,12 +877,12 @@ discard block |
||
880 | 877 | * @param $total |
881 | 878 | * @param $current_total |
882 | 879 | */ |
883 | - public function set_percentage( $total, $current_total ) { |
|
880 | + public function set_percentage($total, $current_total) { |
|
884 | 881 | // Set percentage. |
885 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
882 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
886 | 883 | |
887 | 884 | // Verify percentage. |
888 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
885 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
889 | 886 | } |
890 | 887 | |
891 | 888 | /** |
@@ -898,22 +895,22 @@ discard block |
||
898 | 895 | * |
899 | 896 | * @return bool|null |
900 | 897 | */ |
901 | - public function is_parent_updates_completed( $update ) { |
|
898 | + public function is_parent_updates_completed($update) { |
|
902 | 899 | // Bailout. |
903 | - if ( empty( $update['depend'] ) ) { |
|
900 | + if (empty($update['depend'])) { |
|
904 | 901 | return true; |
905 | 902 | } |
906 | 903 | |
907 | 904 | // Check if dependency is valid or not. |
908 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
905 | + if ( ! $this->has_valid_dependency($update)) { |
|
909 | 906 | return null; |
910 | 907 | } |
911 | 908 | |
912 | 909 | $is_dependency_completed = true; |
913 | 910 | |
914 | - foreach ( $update['depend'] as $depend ) { |
|
911 | + foreach ($update['depend'] as $depend) { |
|
915 | 912 | |
916 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
913 | + if ( ! give_has_upgrade_completed($depend)) { |
|
917 | 914 | $is_dependency_completed = false; |
918 | 915 | break; |
919 | 916 | } |
@@ -930,7 +927,7 @@ discard block |
||
930 | 927 | * @return bool |
931 | 928 | */ |
932 | 929 | public function is_doing_updates() { |
933 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
930 | + return (bool) get_option('give_doing_upgrade'); |
|
934 | 931 | } |
935 | 932 | |
936 | 933 | |
@@ -944,7 +941,7 @@ discard block |
||
944 | 941 | * |
945 | 942 | * @return bool |
946 | 943 | */ |
947 | - public function has_valid_dependency( $update ) { |
|
944 | + public function has_valid_dependency($update) { |
|
948 | 945 | $is_valid_dependency = true; |
949 | 946 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
950 | 947 | // |
@@ -970,33 +967,33 @@ discard block |
||
970 | 967 | * |
971 | 968 | * @return array |
972 | 969 | */ |
973 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
970 | + public function get_updates($update_type = '', $status = 'all') { |
|
974 | 971 | // return all updates. |
975 | - if ( empty( $update_type ) ) { |
|
972 | + if (empty($update_type)) { |
|
976 | 973 | return $this->updates; |
977 | 974 | } |
978 | 975 | |
979 | 976 | // Get specific update. |
980 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
977 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
981 | 978 | |
982 | 979 | // Bailout. |
983 | - if ( empty( $updates ) ) { |
|
980 | + if (empty($updates)) { |
|
984 | 981 | return $updates; |
985 | 982 | } |
986 | 983 | |
987 | - switch ( $status ) { |
|
984 | + switch ($status) { |
|
988 | 985 | case 'new': |
989 | 986 | // Remove already completed updates. |
990 | - wp_cache_delete( 'give_completed_upgrades', 'options' ); |
|
987 | + wp_cache_delete('give_completed_upgrades', 'options'); |
|
991 | 988 | $completed_updates = give_get_completed_upgrades(); |
992 | 989 | |
993 | - if ( ! empty( $completed_updates ) ) { |
|
994 | - foreach ( $updates as $index => $update ) { |
|
995 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
996 | - unset( $updates[ $index ] ); |
|
990 | + if ( ! empty($completed_updates)) { |
|
991 | + foreach ($updates as $index => $update) { |
|
992 | + if (in_array($update['id'], $completed_updates)) { |
|
993 | + unset($updates[$index]); |
|
997 | 994 | } |
998 | 995 | } |
999 | - $updates = array_values( $updates ); |
|
996 | + $updates = array_values($updates); |
|
1000 | 997 | } |
1001 | 998 | |
1002 | 999 | break; |
@@ -1013,7 +1010,7 @@ discard block |
||
1013 | 1010 | * @return int |
1014 | 1011 | */ |
1015 | 1012 | public function get_total_plugin_update_count() { |
1016 | - return count( $this->get_updates( 'plugin' ) ); |
|
1013 | + return count($this->get_updates('plugin')); |
|
1017 | 1014 | } |
1018 | 1015 | |
1019 | 1016 | /** |
@@ -1028,7 +1025,7 @@ discard block |
||
1028 | 1025 | $db_update_count = $this->get_pending_db_update_count(); |
1029 | 1026 | $plugin_update_count = $this->get_total_plugin_update_count(); |
1030 | 1027 | |
1031 | - return ( $db_update_count + $plugin_update_count ); |
|
1028 | + return ($db_update_count + $plugin_update_count); |
|
1032 | 1029 | } |
1033 | 1030 | |
1034 | 1031 | /** |
@@ -1040,7 +1037,7 @@ discard block |
||
1040 | 1037 | * @return int |
1041 | 1038 | */ |
1042 | 1039 | public function get_pending_db_update_count() { |
1043 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
1040 | + return count($this->get_updates('database', 'new')); |
|
1044 | 1041 | } |
1045 | 1042 | |
1046 | 1043 | /** |
@@ -1052,7 +1049,7 @@ discard block |
||
1052 | 1049 | * @return int |
1053 | 1050 | */ |
1054 | 1051 | public function get_total_db_update_count() { |
1055 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
1052 | + return count($this->get_updates('database', 'all')); |
|
1056 | 1053 | } |
1057 | 1054 | |
1058 | 1055 | /** |
@@ -1065,10 +1062,9 @@ discard block |
||
1065 | 1062 | * |
1066 | 1063 | * @return int |
1067 | 1064 | */ |
1068 | - public function get_total_new_db_update_count( $refresh = false ) { |
|
1065 | + public function get_total_new_db_update_count($refresh = false) { |
|
1069 | 1066 | $update_count = $this->is_doing_updates() && ! $refresh ? |
1070 | - get_option( 'give_db_update_count' ) : |
|
1071 | - $this->get_pending_db_update_count(); |
|
1067 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
1072 | 1068 | |
1073 | 1069 | return $update_count; |
1074 | 1070 | } |
@@ -1083,11 +1079,11 @@ discard block |
||
1083 | 1079 | * |
1084 | 1080 | * @return int |
1085 | 1081 | */ |
1086 | - public function get_running_db_update( $refresh = false ) { |
|
1082 | + public function get_running_db_update($refresh = false) { |
|
1087 | 1083 | $current_update = 1; |
1088 | 1084 | |
1089 | - if ( $this->is_doing_updates() && ! $refresh ) { |
|
1090 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
1085 | + if ($this->is_doing_updates() && ! $refresh) { |
|
1086 | + $current_update = get_option('give_doing_upgrade'); |
|
1091 | 1087 | $current_update = $current_update['update']; |
1092 | 1088 | } |
1093 | 1089 | |
@@ -1104,25 +1100,23 @@ discard block |
||
1104 | 1100 | * |
1105 | 1101 | * @return float|int |
1106 | 1102 | */ |
1107 | - public function get_db_update_processing_percentage( $refresh = false ) { |
|
1103 | + public function get_db_update_processing_percentage($refresh = false) { |
|
1108 | 1104 | // Bailout. |
1109 | - if ( ! $this->get_total_new_db_update_count( $refresh ) ) { |
|
1105 | + if ( ! $this->get_total_new_db_update_count($refresh)) { |
|
1110 | 1106 | return 0; |
1111 | 1107 | } |
1112 | 1108 | |
1113 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
1114 | - $update_count_percentages = ( ( $this->get_running_db_update( $refresh ) - 1 ) / $this->get_total_new_db_update_count( $refresh ) ) * 100; |
|
1115 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
1116 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
1109 | + $resume_update = get_option('give_doing_upgrade'); |
|
1110 | + $update_count_percentages = (($this->get_running_db_update($refresh) - 1) / $this->get_total_new_db_update_count($refresh)) * 100; |
|
1111 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
1112 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
1117 | 1113 | |
1118 | 1114 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
1119 | 1115 | |
1120 | 1116 | return $this->is_doing_updates() ? |
1121 | - ( absint( $final_percentage ) ? |
|
1122 | - absint( $final_percentage ) : |
|
1123 | - round( $final_percentage, 2 ) |
|
1124 | - ) : |
|
1125 | - 0; |
|
1117 | + (absint($final_percentage) ? |
|
1118 | + absint($final_percentage) : round($final_percentage, 2) |
|
1119 | + ) : 0; |
|
1126 | 1120 | } |
1127 | 1121 | |
1128 | 1122 | |
@@ -1134,8 +1128,8 @@ discard block |
||
1134 | 1128 | * @return array |
1135 | 1129 | */ |
1136 | 1130 | public function get_update_ids() { |
1137 | - $all_updates = $this->get_updates( 'database', 'all' ); |
|
1138 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
1131 | + $all_updates = $this->get_updates('database', 'all'); |
|
1132 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
1139 | 1133 | |
1140 | 1134 | return $all_update_ids; |
1141 | 1135 | } |
@@ -613,8 +613,11 @@ |
||
613 | 613 | return window.confirm('<?php echo esc_js( __( 'It is recommended that you backup your database before proceeding. Do you want to run the update now?', 'give' ) ); ?>'); // jshint ignore:line |
614 | 614 | }); |
615 | 615 | </script> |
616 | - <?php else: ?> |
|
617 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
616 | + <?php else { |
|
617 | + : ?> |
|
618 | + <strong><?php _e( 'Database Update', 'give' ); |
|
619 | +} |
|
620 | +?></strong> |
|
618 | 621 | – <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
619 | 622 | <?php |
620 | 623 | endif; |
@@ -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 | |
@@ -18,56 +18,55 @@ discard block |
||
18 | 18 | ?> |
19 | 19 | <div class="wrap" id="poststuff"> |
20 | 20 | <div id="give-updates"> |
21 | - <h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1> |
|
21 | + <h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1> |
|
22 | 22 | <hr class="wp-header-end"> |
23 | 23 | |
24 | 24 | <div class="give-update-panel-content"> |
25 | - <p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p> |
|
25 | + <p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons. Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p> |
|
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <?php $db_updates = $give_updates->get_pending_db_update_count(); ?> |
29 | - <?php if ( ! empty( $db_updates ) ) : ?> |
|
29 | + <?php if ( ! empty($db_updates)) : ?> |
|
30 | 30 | <?php |
31 | 31 | $is_doing_updates = $give_updates->is_doing_updates(); |
32 | - $db_update_url = add_query_arg( array( 'type' => 'database', ) ); |
|
33 | - $resume_updates = get_option( 'give_doing_upgrade' ); |
|
34 | - $width = ! empty( $resume_updates ) ? $resume_updates['percentage'] : 0; |
|
32 | + $db_update_url = add_query_arg(array('type' => 'database',)); |
|
33 | + $resume_updates = get_option('give_doing_upgrade'); |
|
34 | + $width = ! empty($resume_updates) ? $resume_updates['percentage'] : 0; |
|
35 | 35 | ?> |
36 | - <div id="give-db-updates" data-resume-update="<?php echo absint( $give_updates->is_doing_updates() ); ?>"> |
|
36 | + <div id="give-db-updates" data-resume-update="<?php echo absint($give_updates->is_doing_updates()); ?>"> |
|
37 | 37 | <div class="postbox-container"> |
38 | 38 | <div class="postbox"> |
39 | - <h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2> |
|
39 | + <h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2> |
|
40 | 40 | <div class="inside"> |
41 | 41 | <div class="panel-content"> |
42 | 42 | <p class="give-update-button"> |
43 | - <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
43 | + <span class="give-doing-update-text-p" <?php echo Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
44 | 44 | <?php echo sprintf( |
45 | - __( '%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give' ), |
|
45 | + __('%1$s <a href="%2$s" class="give-update-now %3$s">%4$s</a>', 'give'), |
|
46 | 46 | $is_doing_updates ? |
47 | - __( 'Give is currently updating the database in the background.', 'give' ) : |
|
48 | - __( 'Give needs to update the database.', 'give' ), |
|
47 | + __('Give is currently updating the database in the background.', 'give') : __('Give needs to update the database.', 'give'), |
|
49 | 48 | $db_update_url, |
50 | - ( $is_doing_updates ? 'give-hidden' : '' ), |
|
51 | - __( 'Update now', 'give' ) |
|
49 | + ($is_doing_updates ? 'give-hidden' : ''), |
|
50 | + __('Update now', 'give') |
|
52 | 51 | ); |
53 | 52 | ?> |
54 | 53 | </span> |
55 | - <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
56 | - <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
|
57 | - <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
|
54 | + <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
|
55 | + <?php if (get_option('give_upgrade_error')) : ?> |
|
56 | + <?php _e('An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give'); ?> |
|
58 | 57 | <?php else : ?> |
59 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
58 | + <?php _e('The updates have been paused.', 'give'); ?> |
|
60 | 59 | |
61 | 60 | <?php endif; ?> |
62 | 61 | </span> |
63 | 62 | |
64 | - <?php if ( Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
65 | - <?php $is_disabled = isset( $_GET['give-restart-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
66 | - <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>><?php _e( 'Restart Upgrades', 'give' ); ?></button> |
|
67 | - <?php elseif( $give_updates->is_doing_updates() ): ?> |
|
68 | - <?php $is_disabled = isset( $_GET['give-pause-db-upgrades'] ) ? ' disabled' : ''; ?> |
|
69 | - <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url( admin_url( '/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1' ) ); ?>"<?php echo $is_disabled; ?>> |
|
70 | - <?php _e( 'Pause Upgrades', 'give' ); ?> |
|
63 | + <?php if (Give_Updates::$background_updater->is_paused_process()) : ?> |
|
64 | + <?php $is_disabled = isset($_GET['give-restart-db-upgrades']) ? ' disabled' : ''; ?> |
|
65 | + <button id="give-restart-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-restart-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>><?php _e('Restart Upgrades', 'give'); ?></button> |
|
66 | + <?php elseif ($give_updates->is_doing_updates()): ?> |
|
67 | + <?php $is_disabled = isset($_GET['give-pause-db-upgrades']) ? ' disabled' : ''; ?> |
|
68 | + <button id="give-pause-upgrades" class="button button-primary alignright" data-redirect-url="<?php echo esc_url(admin_url('/edit.php?post_type=give_forms&page=give-updates&give-pause-db-upgrades=1')); ?>"<?php echo $is_disabled; ?>> |
|
69 | + <?php _e('Pause Upgrades', 'give'); ?> |
|
71 | 70 | </button> |
72 | 71 | <?php endif; ?> |
73 | 72 | |
@@ -76,7 +75,7 @@ discard block |
||
76 | 75 | e.preventDefault(); |
77 | 76 | jQuery('.give-doing-update-text-p').hide(); |
78 | 77 | jQuery('.give-update-paused-text-p').show(); |
79 | - if (window.confirm('<?php echo esc_js( __( 'Do you want to stop the update process now?', 'give' ) ); ?>')) { |
|
78 | + if (window.confirm('<?php echo esc_js(__('Do you want to stop the update process now?', 'give')); ?>')) { |
|
80 | 79 | window.location.assign(jQuery(this).data('redirect-url')); |
81 | 80 | } |
82 | 81 | }); |
@@ -84,7 +83,7 @@ discard block |
||
84 | 83 | e.preventDefault(); |
85 | 84 | jQuery('.give-doing-update-text-p').show(); |
86 | 85 | jQuery('.give-update-paused-text-p').hide(); |
87 | - if (window.confirm('<?php echo esc_js( __( 'Do you want to restart the update process?', 'give' ) ); ?>')) { |
|
86 | + if (window.confirm('<?php echo esc_js(__('Do you want to restart the update process?', 'give')); ?>')) { |
|
88 | 87 | window.location.assign(jQuery(this).data('redirect-url')); |
89 | 88 | } |
90 | 89 | }); |
@@ -96,7 +95,7 @@ discard block |
||
96 | 95 | <strong> |
97 | 96 | <?php |
98 | 97 | echo sprintf( |
99 | - __( 'Update %s of %s', 'give' ), |
|
98 | + __('Update %s of %s', 'give'), |
|
100 | 99 | $give_updates->get_running_db_update(), |
101 | 100 | $give_updates->get_total_new_db_update_count() |
102 | 101 | ); |
@@ -104,10 +103,10 @@ discard block |
||
104 | 103 | </strong> |
105 | 104 | </p> |
106 | 105 | <div class="progress-content"> |
107 | - <?php if ( $is_doing_updates ) : ?> |
|
106 | + <?php if ($is_doing_updates) : ?> |
|
108 | 107 | <div class="notice-wrap give-clearfix"> |
109 | 108 | |
110 | - <?php if ( ! Give_Updates::$background_updater->is_paused_process() ) : ?> |
|
109 | + <?php if ( ! Give_Updates::$background_updater->is_paused_process()) : ?> |
|
111 | 110 | <span class="spinner is-active"></span> |
112 | 111 | <?php endif; ?> |
113 | 112 | |
@@ -119,7 +118,7 @@ discard block |
||
119 | 118 | </div> |
120 | 119 | </div> |
121 | 120 | |
122 | - <?php if ( ! $is_doing_updates ) : ?> |
|
121 | + <?php if ( ! $is_doing_updates) : ?> |
|
123 | 122 | <div class="give-run-database-update"></div> |
124 | 123 | <?php endif; ?> |
125 | 124 | </div> |
@@ -130,17 +129,17 @@ discard block |
||
130 | 129 | <?php endif; ?> |
131 | 130 | |
132 | 131 | <?php $plugin_updates = $give_updates->get_total_plugin_update_count(); ?> |
133 | - <?php if ( ! empty( $plugin_updates ) ) : ?> |
|
134 | - <?php $plugin_update_url = add_query_arg( array( |
|
132 | + <?php if ( ! empty($plugin_updates)) : ?> |
|
133 | + <?php $plugin_update_url = add_query_arg(array( |
|
135 | 134 | 's' => 'Give', |
136 | - ), admin_url( '/plugins.php' ) ); ?> |
|
135 | + ), admin_url('/plugins.php')); ?> |
|
137 | 136 | <div id="give-plugin-updates"> |
138 | 137 | <div class="postbox-container"> |
139 | 138 | <div class="postbox"> |
140 | - <h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2> |
|
139 | + <h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2> |
|
141 | 140 | <div class="inside"> |
142 | 141 | <div class="panel-content"> |
143 | - <p><?php echo sprintf( __( 'There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give' ), _n( 'is', 'are', $plugin_updates, 'give' ), $plugin_updates, _n( 'add-on', 'add-ons', $plugin_updates, 'give' ), _n( 'needs', 'need', $plugin_updates, 'give' ), $plugin_update_url ); ?></p> |
|
142 | + <p><?php echo sprintf(__('There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give'), _n('is', 'are', $plugin_updates, 'give'), $plugin_updates, _n('add-on', 'add-ons', $plugin_updates, 'give'), _n('needs', 'need', $plugin_updates, 'give'), $plugin_update_url); ?></p> |
|
144 | 143 | <?php include_once 'plugins-update-section.php'; ?> |
145 | 144 | </div> |
146 | 145 | </div> |
@@ -55,8 +55,11 @@ |
||
55 | 55 | <span class="give-update-paused-text-p" <?php echo ! Give_Updates::$background_updater->is_paused_process() ? 'style="display:none;"' : ''; ?>> |
56 | 56 | <?php if ( get_option( 'give_upgrade_error' ) ) : ?> |
57 | 57 | <?php _e( 'An unexpected issue occurred during the database update which caused it to stop automatically. Please contact support for assistance.', 'give' ); ?> |
58 | - <?php else : ?> |
|
59 | - <?php _e( 'The updates have been paused.', 'give' ); ?> |
|
58 | + <?php else { |
|
59 | + : ?> |
|
60 | + <?php _e( 'The updates have been paused.', 'give' ); |
|
61 | +} |
|
62 | +?> |
|
60 | 63 | |
61 | 64 | <?php endif; ?> |
62 | 65 | </span> |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly. |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_General' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_General')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_General. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'general'; |
30 | - $this->label = __( 'General', 'give' ); |
|
30 | + $this->label = __('General', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'general-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'access-control': |
49 | 49 | $settings = array( |
50 | 50 | // Section 3: Access control. |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | ), |
55 | 55 | array( |
56 | 56 | 'id' => 'session_lifetime', |
57 | - 'name' => __( 'Session Lifetime', 'give' ), |
|
58 | - 'desc' => __( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ), |
|
57 | + 'name' => __('Session Lifetime', 'give'), |
|
58 | + 'desc' => __('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'), |
|
59 | 59 | 'type' => 'select', |
60 | 60 | 'options' => array( |
61 | - '86400' => __( '24 Hours', 'give' ), |
|
62 | - '172800' => __( '48 Hours', 'give' ), |
|
63 | - '259200' => __( '72 Hours', 'give' ), |
|
64 | - '604800' => __( '1 Week', 'give' ), |
|
61 | + '86400' => __('24 Hours', 'give'), |
|
62 | + '172800' => __('48 Hours', 'give'), |
|
63 | + '259200' => __('72 Hours', 'give'), |
|
64 | + '604800' => __('1 Week', 'give'), |
|
65 | 65 | ), |
66 | 66 | ), |
67 | 67 | array( |
68 | 68 | 'id' => 'limit_display_donations', |
69 | - 'name' => __( 'Limit Donations Displayed', 'give' ), |
|
70 | - 'desc' => __( 'Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give' ), |
|
69 | + 'name' => __('Limit Donations Displayed', 'give'), |
|
70 | + 'desc' => __('Adjusts the number of donations displayed to a non logged-in user when they attempt to access the Donation History page without an active session. For security reasons, it\'s best to leave this at 1-3 donations.', 'give'), |
|
71 | 71 | 'default' => '1', |
72 | 72 | 'type' => 'number', |
73 | 73 | 'css' => 'width:50px;', |
@@ -77,47 +77,47 @@ discard block |
||
77 | 77 | ), |
78 | 78 | ), |
79 | 79 | array( |
80 | - 'name' => __( 'Email Access', 'give' ), |
|
81 | - 'desc' => __( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ), |
|
80 | + 'name' => __('Email Access', 'give'), |
|
81 | + 'desc' => __('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'), |
|
82 | 82 | 'id' => 'email_access', |
83 | 83 | 'type' => 'radio_inline', |
84 | 84 | 'default' => 'disabled', |
85 | 85 | 'options' => array( |
86 | - 'enabled' => __( 'Enabled', 'give' ), |
|
87 | - 'disabled' => __( 'Disabled', 'give' ), |
|
86 | + 'enabled' => __('Enabled', 'give'), |
|
87 | + 'disabled' => __('Disabled', 'give'), |
|
88 | 88 | ), |
89 | 89 | ), |
90 | 90 | array( |
91 | - 'name' => __( 'Enable reCAPTCHA', 'give' ), |
|
92 | - 'desc' => __( 'Would you like to enable the reCAPTCHA feature?', 'give' ), |
|
91 | + 'name' => __('Enable reCAPTCHA', 'give'), |
|
92 | + 'desc' => __('Would you like to enable the reCAPTCHA feature?', 'give'), |
|
93 | 93 | 'id' => 'enable_recaptcha', |
94 | 94 | 'type' => 'radio_inline', |
95 | 95 | 'default' => 'disabled', |
96 | 96 | 'options' => array( |
97 | - 'enabled' => __( 'Enabled', 'give' ), |
|
98 | - 'disabled' => __( 'Disabled', 'give' ), |
|
97 | + 'enabled' => __('Enabled', 'give'), |
|
98 | + 'disabled' => __('Disabled', 'give'), |
|
99 | 99 | ), |
100 | 100 | ), |
101 | 101 | array( |
102 | 102 | 'id' => 'recaptcha_key', |
103 | - 'name' => __( 'reCAPTCHA Site Key', 'give' ), |
|
103 | + 'name' => __('reCAPTCHA Site Key', 'give'), |
|
104 | 104 | /* translators: %s: https://www.google.com/recaptcha/ */ |
105 | - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'http://docs.givewp.com/recaptcha' ) ), |
|
105 | + 'desc' => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key and paste your reCAPTCHA site key here. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('http://docs.givewp.com/recaptcha')), |
|
106 | 106 | 'default' => '', |
107 | 107 | 'type' => 'text', |
108 | 108 | ), |
109 | 109 | array( |
110 | 110 | 'id' => 'recaptcha_secret', |
111 | - 'name' => __( 'reCAPTCHA Secret Key', 'give' ), |
|
112 | - 'desc' => __( 'Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give' ), |
|
111 | + 'name' => __('reCAPTCHA Secret Key', 'give'), |
|
112 | + 'desc' => __('Please paste the reCAPTCHA secret key here from your reCAPTCHA API Keys panel.', 'give'), |
|
113 | 113 | 'default' => '', |
114 | 114 | 'type' => 'text', |
115 | 115 | ), |
116 | 116 | array( |
117 | - 'name' => __( 'Access Control Docs Link', 'give' ), |
|
117 | + 'name' => __('Access Control Docs Link', 'give'), |
|
118 | 118 | 'id' => 'access_control_docs_link', |
119 | - 'url' => esc_url( 'http://docs.givewp.com/settings-access-control' ), |
|
120 | - 'title' => __( 'Access Control', 'give' ), |
|
119 | + 'url' => esc_url('http://docs.givewp.com/settings-access-control'), |
|
120 | + 'title' => __('Access Control', 'give'), |
|
121 | 121 | 'type' => 'give_docs_link', |
122 | 122 | ), |
123 | 123 | array( |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | break; |
129 | 129 | |
130 | 130 | case 'currency-settings' : |
131 | - $currency_position_before = __( 'Before - %s‎10', 'give' ); |
|
132 | - $currency_position_after = __( 'After - 10%s‏', 'give' ); |
|
131 | + $currency_position_before = __('Before - %s‎10', 'give'); |
|
132 | + $currency_position_after = __('After - 10%s‏', 'give'); |
|
133 | 133 | |
134 | 134 | $settings = array( |
135 | 135 | // Section 2: Currency |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | 'id' => 'give_title_general_settings_2', |
139 | 139 | ), |
140 | 140 | array( |
141 | - 'name' => __( 'Currency Settings', 'give' ), |
|
141 | + 'name' => __('Currency Settings', 'give'), |
|
142 | 142 | 'desc' => '', |
143 | 143 | 'type' => 'give_title', |
144 | 144 | 'id' => 'give_title_general_settings_2', |
145 | 145 | ), |
146 | 146 | array( |
147 | - 'name' => __( 'Currency', 'give' ), |
|
148 | - 'desc' => __( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ), |
|
147 | + 'name' => __('Currency', 'give'), |
|
148 | + 'desc' => __('The donation currency. Note that some payment gateways have currency restrictions.', 'give'), |
|
149 | 149 | 'id' => 'currency', |
150 | 150 | 'class' => 'give-select-chosen', |
151 | 151 | 'type' => 'select', |
@@ -153,51 +153,51 @@ discard block |
||
153 | 153 | 'default' => 'USD', |
154 | 154 | ), |
155 | 155 | array( |
156 | - 'name' => __( 'Currency Position', 'give' ), |
|
157 | - 'desc' => __( 'The position of the currency symbol.', 'give' ), |
|
156 | + 'name' => __('Currency Position', 'give'), |
|
157 | + 'desc' => __('The position of the currency symbol.', 'give'), |
|
158 | 158 | 'id' => 'currency_position', |
159 | 159 | 'type' => 'select', |
160 | 160 | 'options' => array( |
161 | 161 | /* translators: %s: currency symbol */ |
162 | - 'before' => sprintf( $currency_position_before, give_currency_symbol( give_get_currency() ) ), |
|
162 | + 'before' => sprintf($currency_position_before, give_currency_symbol(give_get_currency())), |
|
163 | 163 | /* translators: %s: currency symbol */ |
164 | - 'after' => sprintf( $currency_position_after, give_currency_symbol( give_get_currency() ) ), |
|
164 | + 'after' => sprintf($currency_position_after, give_currency_symbol(give_get_currency())), |
|
165 | 165 | ), |
166 | 166 | 'default' => 'before', |
167 | 167 | 'attributes' => array( |
168 | - 'data-before-template' => sprintf( $currency_position_before, '{currency_pos}' ), |
|
169 | - 'data-after-template' => sprintf( $currency_position_after, '{currency_pos}' ), |
|
168 | + 'data-before-template' => sprintf($currency_position_before, '{currency_pos}'), |
|
169 | + 'data-after-template' => sprintf($currency_position_after, '{currency_pos}'), |
|
170 | 170 | ), |
171 | 171 | ), |
172 | 172 | array( |
173 | - 'name' => __( 'Thousands Separator', 'give' ), |
|
174 | - 'desc' => __( 'The symbol (typically , or .) to separate thousands.', 'give' ), |
|
173 | + 'name' => __('Thousands Separator', 'give'), |
|
174 | + 'desc' => __('The symbol (typically , or .) to separate thousands.', 'give'), |
|
175 | 175 | 'id' => 'thousands_separator', |
176 | 176 | 'type' => 'text', |
177 | 177 | 'default' => ',', |
178 | 178 | 'css' => 'width:12em;', |
179 | 179 | ), |
180 | 180 | array( |
181 | - 'name' => __( 'Decimal Separator', 'give' ), |
|
182 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points.', 'give' ), |
|
181 | + 'name' => __('Decimal Separator', 'give'), |
|
182 | + 'desc' => __('The symbol (usually , or .) to separate decimal points.', 'give'), |
|
183 | 183 | 'id' => 'decimal_separator', |
184 | 184 | 'type' => 'text', |
185 | 185 | 'default' => '.', |
186 | 186 | 'css' => 'width:12em;', |
187 | 187 | ), |
188 | 188 | array( |
189 | - 'name' => __( 'Number of Decimals', 'give' ), |
|
190 | - 'desc' => __( 'The number of decimal points displayed in amounts.', 'give' ), |
|
189 | + 'name' => __('Number of Decimals', 'give'), |
|
190 | + 'desc' => __('The number of decimal points displayed in amounts.', 'give'), |
|
191 | 191 | 'id' => 'number_decimals', |
192 | 192 | 'type' => 'text', |
193 | 193 | 'default' => 2, |
194 | 194 | 'css' => 'width:12em;', |
195 | 195 | ), |
196 | 196 | array( |
197 | - 'name' => __( 'Currency Options Docs Link', 'give' ), |
|
197 | + 'name' => __('Currency Options Docs Link', 'give'), |
|
198 | 198 | 'id' => 'currency_settings_docs_link', |
199 | - 'url' => esc_url( 'http://docs.givewp.com/settings-currency' ), |
|
200 | - 'title' => __( 'Currency Settings', 'give' ), |
|
199 | + 'url' => esc_url('http://docs.givewp.com/settings-currency'), |
|
200 | + 'title' => __('Currency Settings', 'give'), |
|
201 | 201 | 'type' => 'give_docs_link', |
202 | 202 | ), |
203 | 203 | array( |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $country = give_get_country(); |
214 | 214 | |
215 | 215 | // get the list of the states of which default country is selected. |
216 | - $states = give_get_states( $country ); |
|
216 | + $states = give_get_states($country); |
|
217 | 217 | |
218 | 218 | // Get the country list that does not have any states init. |
219 | 219 | $no_states_country = give_no_states_country_list(); |
@@ -225,46 +225,46 @@ discard block |
||
225 | 225 | 'id' => 'give_title_general_settings_1', |
226 | 226 | ), |
227 | 227 | array( |
228 | - 'name' => __( 'General Settings', 'give' ), |
|
228 | + 'name' => __('General Settings', 'give'), |
|
229 | 229 | 'desc' => '', |
230 | 230 | 'type' => 'give_title', |
231 | 231 | 'id' => 'give_title_general_settings_1', |
232 | 232 | ), |
233 | 233 | array( |
234 | - 'name' => __( 'Success Page', 'give' ), |
|
234 | + 'name' => __('Success Page', 'give'), |
|
235 | 235 | /* translators: %s: [give_receipt] */ |
236 | - 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ), |
|
236 | + 'desc' => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'), |
|
237 | 237 | 'id' => 'success_page', |
238 | 238 | 'type' => 'select', |
239 | - 'options' => give_cmb2_get_post_options( array( |
|
239 | + 'options' => give_cmb2_get_post_options(array( |
|
240 | 240 | 'post_type' => 'page', |
241 | 241 | 'numberposts' => 999, |
242 | - ) ), |
|
242 | + )), |
|
243 | 243 | ), |
244 | 244 | array( |
245 | - 'name' => __( 'Failed Donation Page', 'give' ), |
|
246 | - 'desc' => __( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ), |
|
245 | + 'name' => __('Failed Donation Page', 'give'), |
|
246 | + 'desc' => __('The page donors are sent to if their donation is cancelled or fails.', 'give'), |
|
247 | 247 | 'id' => 'failure_page', |
248 | 248 | 'type' => 'select', |
249 | - 'options' => give_cmb2_get_post_options( array( |
|
249 | + 'options' => give_cmb2_get_post_options(array( |
|
250 | 250 | 'post_type' => 'page', |
251 | 251 | 'numberposts' => 999, |
252 | - ) ), |
|
252 | + )), |
|
253 | 253 | ), |
254 | 254 | array( |
255 | - 'name' => __( 'Donation History Page', 'give' ), |
|
255 | + 'name' => __('Donation History Page', 'give'), |
|
256 | 256 | /* translators: %s: [donation_history] */ |
257 | - 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ), |
|
257 | + 'desc' => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'), |
|
258 | 258 | 'id' => 'history_page', |
259 | 259 | 'type' => 'select', |
260 | - 'options' => give_cmb2_get_post_options( array( |
|
260 | + 'options' => give_cmb2_get_post_options(array( |
|
261 | 261 | 'post_type' => 'page', |
262 | 262 | 'numberposts' => 999, |
263 | - ) ), |
|
263 | + )), |
|
264 | 264 | ), |
265 | 265 | array( |
266 | - 'name' => __( 'Base Country', 'give' ), |
|
267 | - 'desc' => __( 'The country your site operates from.', 'give' ), |
|
266 | + 'name' => __('Base Country', 'give'), |
|
267 | + 'desc' => __('The country your site operates from.', 'give'), |
|
268 | 268 | 'id' => 'base_country', |
269 | 269 | 'type' => 'select', |
270 | 270 | 'options' => give_get_country_list(), |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | * @since 1.8.14 |
276 | 276 | */ |
277 | 277 | array( |
278 | - 'wrapper_class' => ( array_key_exists( $country, $no_states_country ) ? 'give-hidden' : '' ), |
|
279 | - 'name' => __( 'Base State/Province', 'give' ), |
|
280 | - 'desc' => __( 'The state/province your site operates from.', 'give' ), |
|
278 | + 'wrapper_class' => (array_key_exists($country, $no_states_country) ? 'give-hidden' : ''), |
|
279 | + 'name' => __('Base State/Province', 'give'), |
|
280 | + 'desc' => __('The state/province your site operates from.', 'give'), |
|
281 | 281 | 'id' => 'base_state', |
282 | - 'type' => ( empty( $states ) ? 'text' : 'select' ), |
|
282 | + 'type' => (empty($states) ? 'text' : 'select'), |
|
283 | 283 | 'options' => $states, |
284 | 284 | ), |
285 | 285 | array( |
286 | - 'name' => __( 'General Options Docs Link', 'give' ), |
|
286 | + 'name' => __('General Options Docs Link', 'give'), |
|
287 | 287 | 'id' => 'general_options_docs_link', |
288 | - 'url' => esc_url( 'http://docs.givewp.com/settings-general' ), |
|
289 | - 'title' => __( 'General Options', 'give' ), |
|
288 | + 'url' => esc_url('http://docs.givewp.com/settings-general'), |
|
289 | + 'title' => __('General Options', 'give'), |
|
290 | 290 | 'type' => 'give_docs_link', |
291 | 291 | ), |
292 | 292 | array( |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * Filter the general settings. |
302 | 302 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
303 | 303 | */ |
304 | - $settings = apply_filters( 'give_settings_general', $settings ); |
|
304 | + $settings = apply_filters('give_settings_general', $settings); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Filter the settings. |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @param array $settings |
312 | 312 | */ |
313 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
313 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
314 | 314 | |
315 | 315 | // Output. |
316 | 316 | return $settings; |
@@ -324,12 +324,12 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function get_sections() { |
326 | 326 | $sections = array( |
327 | - 'general-settings' => __( 'General', 'give' ), |
|
328 | - 'currency-settings' => __( 'Currency', 'give' ), |
|
329 | - 'access-control' => __( 'Access Control', 'give' ), |
|
327 | + 'general-settings' => __('General', 'give'), |
|
328 | + 'currency-settings' => __('Currency', 'give'), |
|
329 | + 'access-control' => __('Access Control', 'give'), |
|
330 | 330 | ); |
331 | 331 | |
332 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
332 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 |
@@ -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 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | // Set parent defaults. |
137 | 137 | parent::__construct( |
138 | 138 | array( |
139 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
140 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
141 | - 'ajax' => false, // Does this table support ajax? |
|
139 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
140 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
141 | + 'ajax' => false, // Does this table support ajax? |
|
142 | 142 | ) |
143 | 143 | ); |
144 | 144 | |
145 | 145 | $this->process_bulk_action(); |
146 | 146 | $this->get_payment_counts(); |
147 | - $this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
147 | + $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -153,31 +153,31 @@ discard block |
||
153 | 153 | * @return void |
154 | 154 | */ |
155 | 155 | public function advanced_filters() { |
156 | - $start_date = isset( $_GET['start-date'] ) ? give_clean( $_GET['start-date'] ) : null; |
|
157 | - $end_date = isset( $_GET['end-date'] ) ? give_clean( $_GET['end-date'] ) : null; |
|
158 | - $status = isset( $_GET['status'] ) ? give_clean( $_GET['status'] ) : ''; |
|
159 | - $donor = isset( $_GET['donor'] ) ? absint( $_GET['donor'] ) : ''; |
|
160 | - $search = isset( $_GET['s'] ) ? give_clean( $_GET['s'] ) : ''; |
|
161 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0; |
|
156 | + $start_date = isset($_GET['start-date']) ? give_clean($_GET['start-date']) : null; |
|
157 | + $end_date = isset($_GET['end-date']) ? give_clean($_GET['end-date']) : null; |
|
158 | + $status = isset($_GET['status']) ? give_clean($_GET['status']) : ''; |
|
159 | + $donor = isset($_GET['donor']) ? absint($_GET['donor']) : ''; |
|
160 | + $search = isset($_GET['s']) ? give_clean($_GET['s']) : ''; |
|
161 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0; |
|
162 | 162 | ?> |
163 | 163 | <div id="give-payment-filters" class="give-filters"> |
164 | - <?php $this->search_box( __( 'Search', 'give' ), 'give-payments' ); ?> |
|
164 | + <?php $this->search_box(__('Search', 'give'), 'give-payments'); ?> |
|
165 | 165 | <div id="give-payment-date-filters"> |
166 | 166 | <div class="give-filter give-filter-half"> |
167 | 167 | <label for="start-date" |
168 | - class="give-start-date-label"><?php _e( 'Start Date', 'give' ); ?></label> |
|
168 | + class="give-start-date-label"><?php _e('Start Date', 'give'); ?></label> |
|
169 | 169 | <input type="text" id="start-date" name="start-date" class="give_datepicker" |
170 | 170 | value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/> |
171 | 171 | </div> |
172 | 172 | <div class="give-filter give-filter-half"> |
173 | - <label for="end-date" class="give-end-date-label"><?php _e( 'End Date', 'give' ); ?></label> |
|
173 | + <label for="end-date" class="give-end-date-label"><?php _e('End Date', 'give'); ?></label> |
|
174 | 174 | <input type="text" id="end-date" name="end-date" class="give_datepicker" |
175 | 175 | value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/> |
176 | 176 | </div> |
177 | 177 | </div> |
178 | 178 | <div id="give-payment-form-filter" class="give-filter"> |
179 | 179 | <label for="give-donation-forms-filter" |
180 | - class="give-donation-forms-filter-label"><?php _e( 'Form', 'give' ); ?></label> |
|
180 | + class="give-donation-forms-filter-label"><?php _e('Form', 'give'); ?></label> |
|
181 | 181 | <?php |
182 | 182 | // Filter Donations by Donation Forms. |
183 | 183 | echo Give()->html->forms_dropdown( |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'class' => 'give-donation-forms-filter', |
188 | 188 | 'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection. |
189 | 189 | 'chosen' => true, |
190 | - 'number' => - 1, |
|
190 | + 'number' => -1, |
|
191 | 191 | ) |
192 | 192 | ); |
193 | 193 | ?> |
@@ -199,26 +199,26 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @since 1.8.18 |
201 | 201 | */ |
202 | - do_action( 'give_payment_table_advanced_filters' ); |
|
202 | + do_action('give_payment_table_advanced_filters'); |
|
203 | 203 | |
204 | 204 | |
205 | - if ( ! empty( $status ) ) { |
|
206 | - echo sprintf( '<input type="hidden" name="status" value="%s"/>', esc_attr( $status ) ); |
|
205 | + if ( ! empty($status)) { |
|
206 | + echo sprintf('<input type="hidden" name="status" value="%s"/>', esc_attr($status)); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( ! empty( $donor ) ) { |
|
210 | - echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $donor ) ); |
|
209 | + if ( ! empty($donor)) { |
|
210 | + echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($donor)); |
|
211 | 211 | } |
212 | 212 | ?> |
213 | 213 | |
214 | 214 | <div class="give-filter"> |
215 | - <?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?> |
|
215 | + <?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?> |
|
216 | 216 | <?php |
217 | 217 | // Clear active filters button. |
218 | - if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) : |
|
218 | + if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) : |
|
219 | 219 | ?> |
220 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" |
|
221 | - class="button give-clear-filters-button"><?php _e( 'Clear Filters', 'give' ); ?></a> |
|
220 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" |
|
221 | + class="button give-clear-filters-button"><?php _e('Clear Filters', 'give'); ?></a> |
|
222 | 222 | <?php endif; ?> |
223 | 223 | </div> |
224 | 224 | </div> |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - public function search_box( $text, $input_id ) { |
|
241 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
240 | + public function search_box($text, $input_id) { |
|
241 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
245 | - $input_id = $input_id . '-search-input'; |
|
245 | + $input_id = $input_id.'-search-input'; |
|
246 | 246 | |
247 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
248 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
247 | + if ( ! empty($_REQUEST['orderby'])) { |
|
248 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
249 | 249 | } |
250 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
251 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
250 | + if ( ! empty($_REQUEST['order'])) { |
|
251 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
252 | 252 | } |
253 | 253 | ?> |
254 | 254 | <div class="give-filter give-filter-search" role="search"> |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @since 1.7 |
262 | 262 | */ |
263 | - do_action( 'give_payment_history_search' ); |
|
263 | + do_action('give_payment_history_search'); |
|
264 | 264 | ?> |
265 | 265 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
266 | 266 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
267 | - <?php submit_button( $text, 'button', false, false, array( |
|
267 | + <?php submit_button($text, 'button', false, false, array( |
|
268 | 268 | 'ID' => 'search-submit', |
269 | - ) ); ?><br/> |
|
269 | + )); ?><br/> |
|
270 | 270 | </div> |
271 | 271 | <?php |
272 | 272 | } |
@@ -281,48 +281,48 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function get_views() { |
283 | 283 | |
284 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
284 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
285 | 285 | $views = array(); |
286 | 286 | $tabs = array( |
287 | 287 | 'all' => array( |
288 | 288 | 'total_count', |
289 | - __( 'All', 'give' ), |
|
289 | + __('All', 'give'), |
|
290 | 290 | ), |
291 | 291 | 'publish' => array( |
292 | 292 | 'complete_count', |
293 | - __( 'Completed', 'give' ), |
|
293 | + __('Completed', 'give'), |
|
294 | 294 | ), |
295 | 295 | 'pending' => array( |
296 | 296 | 'pending_count', |
297 | - __( 'Pending', 'give' ), |
|
297 | + __('Pending', 'give'), |
|
298 | 298 | ), |
299 | 299 | 'processing' => array( |
300 | 300 | 'processing_count', |
301 | - __( 'Processing', 'give' ), |
|
301 | + __('Processing', 'give'), |
|
302 | 302 | ), |
303 | 303 | 'refunded' => array( |
304 | 304 | 'refunded_count', |
305 | - __( 'Refunded', 'give' ), |
|
305 | + __('Refunded', 'give'), |
|
306 | 306 | ), |
307 | 307 | 'revoked' => array( |
308 | 308 | 'revoked_count', |
309 | - __( 'Revoked', 'give' ), |
|
309 | + __('Revoked', 'give'), |
|
310 | 310 | ), |
311 | 311 | 'failed' => array( |
312 | 312 | 'failed_count', |
313 | - __( 'Failed', 'give' ), |
|
313 | + __('Failed', 'give'), |
|
314 | 314 | ), |
315 | 315 | 'cancelled' => array( |
316 | 316 | 'cancelled_count', |
317 | - __( 'Cancelled', 'give' ), |
|
317 | + __('Cancelled', 'give'), |
|
318 | 318 | ), |
319 | 319 | 'abandoned' => array( |
320 | 320 | 'abandoned_count', |
321 | - __( 'Abandoned', 'give' ), |
|
321 | + __('Abandoned', 'give'), |
|
322 | 322 | ), |
323 | 323 | 'preapproval' => array( |
324 | 324 | 'preapproval_count', |
325 | - __( 'Preapproval Pending', 'give' ), |
|
325 | + __('Preapproval Pending', 'give'), |
|
326 | 326 | ), |
327 | 327 | ); |
328 | 328 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @since 1.8.18 |
333 | 333 | */ |
334 | - $args = (array) apply_filters( 'give_payments_table_status_remove_query_arg', array( 'paged', '_wpnonce', '_wp_http_referer' ) ); |
|
334 | + $args = (array) apply_filters('give_payments_table_status_remove_query_arg', array('paged', '_wpnonce', '_wp_http_referer')); |
|
335 | 335 | |
336 | 336 | // Build URL. |
337 | - $staus_url = remove_query_arg( $args ); |
|
337 | + $staus_url = remove_query_arg($args); |
|
338 | 338 | |
339 | - foreach ( $tabs as $key => $tab ) { |
|
339 | + foreach ($tabs as $key => $tab) { |
|
340 | 340 | $count_key = $tab[0]; |
341 | 341 | $name = $tab[1]; |
342 | 342 | $count = $this->$count_key; |
@@ -351,16 +351,15 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @since 1.8.12 |
353 | 353 | */ |
354 | - if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) { |
|
354 | + if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) { |
|
355 | 355 | |
356 | 356 | $staus_url = 'all' === $key ? |
357 | - add_query_arg( array( 'status' => false ), $staus_url ) : |
|
358 | - add_query_arg( array( 'status' => $key ), $staus_url ); |
|
357 | + add_query_arg(array('status' => false), $staus_url) : add_query_arg(array('status' => $key), $staus_url); |
|
359 | 358 | |
360 | - $views[ $key ] = sprintf( |
|
359 | + $views[$key] = sprintf( |
|
361 | 360 | '<a href="%s"%s>%s <span class="count">(%s)</span></a>', |
362 | - esc_url( $staus_url ), |
|
363 | - ( ( 'all' === $key && empty( $current ) ) ) ? ' class="current"' : ( $current == $key ? 'class="current"' : '' ), |
|
361 | + esc_url($staus_url), |
|
362 | + (('all' === $key && empty($current))) ? ' class="current"' : ($current == $key ? 'class="current"' : ''), |
|
364 | 363 | $name, |
365 | 364 | $count |
366 | 365 | ); |
@@ -375,7 +374,7 @@ discard block |
||
375 | 374 | * @param array $views |
376 | 375 | * @param Give_Payment_History_Table |
377 | 376 | */ |
378 | - return apply_filters( 'give_payments_table_views', $views, $this ); |
|
377 | + return apply_filters('give_payments_table_views', $views, $this); |
|
379 | 378 | } |
380 | 379 | |
381 | 380 | /** |
@@ -389,18 +388,18 @@ discard block |
||
389 | 388 | public function get_columns() { |
390 | 389 | $columns = array( |
391 | 390 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
392 | - 'donation' => __( 'Donation', 'give' ), |
|
393 | - 'donation_form' => __( 'Donation Form', 'give' ), |
|
394 | - 'status' => __( 'Status', 'give' ), |
|
395 | - 'date' => __( 'Date', 'give' ), |
|
396 | - 'amount' => __( 'Amount', 'give' ), |
|
391 | + 'donation' => __('Donation', 'give'), |
|
392 | + 'donation_form' => __('Donation Form', 'give'), |
|
393 | + 'status' => __('Status', 'give'), |
|
394 | + 'date' => __('Date', 'give'), |
|
395 | + 'amount' => __('Amount', 'give'), |
|
397 | 396 | ); |
398 | 397 | |
399 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
400 | - $columns['details'] = __( 'Details', 'give' ); |
|
398 | + if (current_user_can('view_give_payments')) { |
|
399 | + $columns['details'] = __('Details', 'give'); |
|
401 | 400 | } |
402 | 401 | |
403 | - return apply_filters( 'give_payments_table_columns', $columns ); |
|
402 | + return apply_filters('give_payments_table_columns', $columns); |
|
404 | 403 | } |
405 | 404 | |
406 | 405 | /** |
@@ -413,14 +412,14 @@ discard block |
||
413 | 412 | */ |
414 | 413 | public function get_sortable_columns() { |
415 | 414 | $columns = array( |
416 | - 'donation' => array( 'ID', true ), |
|
417 | - 'donation_form' => array( 'donation_form', false ), |
|
418 | - 'status' => array( 'status', false ), |
|
419 | - 'amount' => array( 'amount', false ), |
|
420 | - 'date' => array( 'date', false ), |
|
415 | + 'donation' => array('ID', true), |
|
416 | + 'donation_form' => array('donation_form', false), |
|
417 | + 'status' => array('status', false), |
|
418 | + 'amount' => array('amount', false), |
|
419 | + 'date' => array('date', false), |
|
421 | 420 | ); |
422 | 421 | |
423 | - return apply_filters( 'give_payments_table_sortable_columns', $columns ); |
|
422 | + return apply_filters('give_payments_table_sortable_columns', $columns); |
|
424 | 423 | } |
425 | 424 | |
426 | 425 | /** |
@@ -446,43 +445,43 @@ discard block |
||
446 | 445 | * |
447 | 446 | * @return string Column Name |
448 | 447 | */ |
449 | - public function column_default( $payment, $column_name ) { |
|
448 | + public function column_default($payment, $column_name) { |
|
450 | 449 | |
451 | - $single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) ); |
|
452 | - $row_actions = $this->get_row_actions( $payment ); |
|
450 | + $single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details'))); |
|
451 | + $row_actions = $this->get_row_actions($payment); |
|
453 | 452 | $value = ''; |
454 | 453 | |
455 | - switch ( $column_name ) { |
|
454 | + switch ($column_name) { |
|
456 | 455 | case 'donation' : |
457 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
458 | - $value = Give()->tooltips->render_link( array( |
|
459 | - 'label' => sprintf( __( 'View Donation #%s', 'give' ), $payment->ID ), |
|
456 | + if (current_user_can('view_give_payments')) { |
|
457 | + $value = Give()->tooltips->render_link(array( |
|
458 | + 'label' => sprintf(__('View Donation #%s', 'give'), $payment->ID), |
|
460 | 459 | 'tag_content' => "#$payment->ID", |
461 | 460 | 'link' => $single_donation_url, |
462 | - ) ); |
|
461 | + )); |
|
463 | 462 | } else { |
464 | 463 | $value = "#{$payment->ID}"; |
465 | 464 | } |
466 | 465 | |
467 | 466 | $value .= sprintf( |
468 | 467 | ' %1$s %2$s<br>', |
469 | - __( 'by', 'give' ), |
|
470 | - $this->get_donor( $payment ) |
|
468 | + __('by', 'give'), |
|
469 | + $this->get_donor($payment) |
|
471 | 470 | ); |
472 | 471 | |
473 | - $value .= $this->get_donor_email( $payment ); |
|
474 | - $value .= $this->row_actions( $row_actions ); |
|
472 | + $value .= $this->get_donor_email($payment); |
|
473 | + $value .= $this->row_actions($row_actions); |
|
475 | 474 | break; |
476 | 475 | |
477 | 476 | case 'amount': |
478 | - $amount = ! empty( $payment->total ) ? $payment->total : 0; |
|
479 | - $value = give_donation_amount( $payment, true ); |
|
480 | - $value .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) ); |
|
477 | + $amount = ! empty($payment->total) ? $payment->total : 0; |
|
478 | + $value = give_donation_amount($payment, true); |
|
479 | + $value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway)); |
|
481 | 480 | break; |
482 | 481 | |
483 | 482 | case 'donation_form': |
484 | - $form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title; |
|
485 | - $value = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>'; |
|
483 | + $form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title; |
|
484 | + $value = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>'; |
|
486 | 485 | $level = give_get_donation_form_title( |
487 | 486 | $payment, |
488 | 487 | array( |
@@ -490,44 +489,44 @@ discard block |
||
490 | 489 | ) |
491 | 490 | ); |
492 | 491 | |
493 | - if ( ! empty( $level ) ) { |
|
492 | + if ( ! empty($level)) { |
|
494 | 493 | $value .= $level; |
495 | 494 | } |
496 | 495 | |
497 | 496 | break; |
498 | 497 | |
499 | 498 | case 'date': |
500 | - $date = strtotime( $payment->date ); |
|
501 | - $value = date_i18n( give_date_format(), $date ); |
|
499 | + $date = strtotime($payment->date); |
|
500 | + $value = date_i18n(give_date_format(), $date); |
|
502 | 501 | break; |
503 | 502 | |
504 | 503 | case 'status': |
505 | - $value = $this->get_payment_status( $payment ); |
|
504 | + $value = $this->get_payment_status($payment); |
|
506 | 505 | break; |
507 | 506 | |
508 | 507 | |
509 | 508 | case 'details' : |
510 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
511 | - $value = Give()->tooltips->render_link( array( |
|
512 | - 'label' => sprintf( __( 'View Donation #%s', 'give' ), $payment->ID ), |
|
509 | + if (current_user_can('view_give_payments')) { |
|
510 | + $value = Give()->tooltips->render_link(array( |
|
511 | + 'label' => sprintf(__('View Donation #%s', 'give'), $payment->ID), |
|
513 | 512 | 'tag_content' => '<span class="dashicons dashicons-visibility"></span>', |
514 | 513 | 'link' => $single_donation_url, |
515 | 514 | 'attributes' => array( |
516 | 515 | 'class' => 'give-payment-details-link button button-small', |
517 | 516 | ), |
518 | - ) ); |
|
517 | + )); |
|
519 | 518 | |
520 | 519 | $value = "<div class=\"give-payment-details-link-wrap\">{$value}</div>"; |
521 | 520 | } |
522 | 521 | break; |
523 | 522 | |
524 | 523 | default: |
525 | - $value = isset( $payment->$column_name ) ? $payment->$column_name : ''; |
|
524 | + $value = isset($payment->$column_name) ? $payment->$column_name : ''; |
|
526 | 525 | break; |
527 | 526 | |
528 | 527 | }// End switch(). |
529 | 528 | |
530 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name ); |
|
529 | + return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name); |
|
531 | 530 | } |
532 | 531 | |
533 | 532 | /** |
@@ -540,22 +539,22 @@ discard block |
||
540 | 539 | * |
541 | 540 | * @return string Data shown in the Email column |
542 | 541 | */ |
543 | - public function get_donor_email( $payment ) { |
|
542 | + public function get_donor_email($payment) { |
|
544 | 543 | |
545 | - $email = give_get_payment_user_email( $payment->ID ); |
|
544 | + $email = give_get_payment_user_email($payment->ID); |
|
546 | 545 | |
547 | - if ( empty( $email ) ) { |
|
548 | - $email = __( '(unknown)', 'give' ); |
|
546 | + if (empty($email)) { |
|
547 | + $email = __('(unknown)', 'give'); |
|
549 | 548 | } |
550 | 549 | |
551 | 550 | |
552 | - $value = Give()->tooltips->render_link( array( |
|
551 | + $value = Give()->tooltips->render_link(array( |
|
553 | 552 | 'link' => "mailto:{$email}", |
554 | - 'label' => __( 'Email donor', 'give' ), |
|
553 | + 'label' => __('Email donor', 'give'), |
|
555 | 554 | 'tag_content' => $email, |
556 | - ) ); |
|
555 | + )); |
|
557 | 556 | |
558 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' ); |
|
557 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'email'); |
|
559 | 558 | } |
560 | 559 | |
561 | 560 | /** |
@@ -567,18 +566,18 @@ discard block |
||
567 | 566 | * |
568 | 567 | * @return array $actions |
569 | 568 | */ |
570 | - function get_row_actions( $payment ) { |
|
569 | + function get_row_actions($payment) { |
|
571 | 570 | |
572 | 571 | $actions = array(); |
573 | - $email = give_get_payment_user_email( $payment->ID ); |
|
572 | + $email = give_get_payment_user_email($payment->ID); |
|
574 | 573 | |
575 | 574 | // Add search term string back to base URL. |
576 | - $search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' ); |
|
577 | - if ( ! empty( $search_terms ) ) { |
|
578 | - $this->base_url = add_query_arg( 's', $search_terms, $this->base_url ); |
|
575 | + $search_terms = (isset($_GET['s']) ? trim($_GET['s']) : ''); |
|
576 | + if ( ! empty($search_terms)) { |
|
577 | + $this->base_url = add_query_arg('s', $search_terms, $this->base_url); |
|
579 | 578 | } |
580 | 579 | |
581 | - if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) { |
|
580 | + if (give_is_payment_complete($payment->ID) && ! empty($email)) { |
|
582 | 581 | |
583 | 582 | $actions['email_links'] = sprintf( |
584 | 583 | '<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( |
@@ -588,12 +587,12 @@ discard block |
||
588 | 587 | 'purchase_id' => $payment->ID, |
589 | 588 | ), $this->base_url |
590 | 589 | ), 'give_payment_nonce' |
591 | - ), sprintf( __( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), __( 'Resend Receipt', 'give' ) |
|
590 | + ), sprintf(__('Resend Donation %s Receipt', 'give'), $payment->ID), __('Resend Receipt', 'give') |
|
592 | 591 | ); |
593 | 592 | |
594 | 593 | } |
595 | 594 | |
596 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
595 | + if (current_user_can('view_give_payments')) { |
|
597 | 596 | $actions['delete'] = sprintf( |
598 | 597 | '<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', |
599 | 598 | wp_nonce_url( |
@@ -603,11 +602,11 @@ discard block |
||
603 | 602 | 'purchase_id' => $payment->ID, |
604 | 603 | ), $this->base_url |
605 | 604 | ), 'give_donation_nonce' |
606 | - ), sprintf( __( 'Delete Donation %s', 'give' ), $payment->ID ), __( 'Delete', 'give' ) |
|
605 | + ), sprintf(__('Delete Donation %s', 'give'), $payment->ID), __('Delete', 'give') |
|
607 | 606 | ); |
608 | 607 | } |
609 | 608 | |
610 | - return apply_filters( 'give_payment_row_actions', $actions, $payment ); |
|
609 | + return apply_filters('give_payment_row_actions', $actions, $payment); |
|
611 | 610 | } |
612 | 611 | |
613 | 612 | |
@@ -621,30 +620,30 @@ discard block |
||
621 | 620 | * |
622 | 621 | * @return string Data shown in the Email column |
623 | 622 | */ |
624 | - function get_payment_status( $payment ) { |
|
623 | + function get_payment_status($payment) { |
|
625 | 624 | $value = sprintf( |
626 | 625 | '<div class="give-donation-status status-%1$s"><span class="give-donation-status-icon"></span> %2$s</div>', |
627 | 626 | $payment->status, |
628 | - give_get_payment_status( $payment, true ) |
|
627 | + give_get_payment_status($payment, true) |
|
629 | 628 | ); |
630 | 629 | |
631 | - if ( $payment->mode == 'test' ) { |
|
632 | - $value .= Give()->tooltips->render_span( array( |
|
633 | - 'label' => __( 'This donation was made in test mode.', 'give' ), |
|
634 | - 'tag_content' => __( 'Test', 'give' ), |
|
630 | + if ($payment->mode == 'test') { |
|
631 | + $value .= Give()->tooltips->render_span(array( |
|
632 | + 'label' => __('This donation was made in test mode.', 'give'), |
|
633 | + 'tag_content' => __('Test', 'give'), |
|
635 | 634 | 'attributes' => array( |
636 | 635 | 'class' => 'give-item-label give-item-label-orange give-test-mode-transactions-label', |
637 | 636 | ), |
638 | 637 | |
639 | 638 | |
640 | - ) ); |
|
639 | + )); |
|
641 | 640 | } |
642 | 641 | |
643 | - if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) { |
|
642 | + if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) { |
|
644 | 643 | $value .= sprintf( |
645 | 644 | ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="%1$s">%2$s</span>', |
646 | - __( 'This donation was imported.', 'give' ), |
|
647 | - __( 'Import', 'give' ) |
|
645 | + __('This donation was imported.', 'give'), |
|
646 | + __('Import', 'give') |
|
648 | 647 | ); |
649 | 648 | } |
650 | 649 | |
@@ -661,8 +660,8 @@ discard block |
||
661 | 660 | * |
662 | 661 | * @return string Displays a checkbox. |
663 | 662 | */ |
664 | - public function column_cb( $payment ) { |
|
665 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID ); |
|
663 | + public function column_cb($payment) { |
|
664 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID); |
|
666 | 665 | } |
667 | 666 | |
668 | 667 | /** |
@@ -675,8 +674,8 @@ discard block |
||
675 | 674 | * |
676 | 675 | * @return string Displays a checkbox. |
677 | 676 | */ |
678 | - public function get_payment_id( $payment ) { |
|
679 | - return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>'; |
|
677 | + public function get_payment_id($payment) { |
|
678 | + return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>'; |
|
680 | 679 | } |
681 | 680 | |
682 | 681 | /** |
@@ -689,32 +688,32 @@ discard block |
||
689 | 688 | * |
690 | 689 | * @return string Data shown in the User column |
691 | 690 | */ |
692 | - public function get_donor( $payment ) { |
|
691 | + public function get_donor($payment) { |
|
693 | 692 | |
694 | - $donor_id = give_get_payment_donor_id( $payment->ID ); |
|
695 | - $donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' ); |
|
696 | - $donor_name = give_get_donor_name_by( $donor_id, 'donor' ); |
|
693 | + $donor_id = give_get_payment_donor_id($payment->ID); |
|
694 | + $donor_billing_name = give_get_donor_name_by($payment->ID, 'donation'); |
|
695 | + $donor_name = give_get_donor_name_by($donor_id, 'donor'); |
|
697 | 696 | |
698 | 697 | $value = ''; |
699 | - if ( ! empty( $donor_id ) ) { |
|
698 | + if ( ! empty($donor_id)) { |
|
700 | 699 | |
701 | 700 | // Check whether the donor name and WP_User name is same or not. |
702 | - if ( sanitize_title( $donor_billing_name ) !== sanitize_title( $donor_name ) ) { |
|
703 | - $value .= $donor_billing_name . ' ('; |
|
701 | + if (sanitize_title($donor_billing_name) !== sanitize_title($donor_name)) { |
|
702 | + $value .= $donor_billing_name.' ('; |
|
704 | 703 | } |
705 | 704 | |
706 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>'; |
|
705 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>'; |
|
707 | 706 | |
708 | 707 | // Check whether the donor name and WP_User name is same or not. |
709 | - if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) { |
|
708 | + if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) { |
|
710 | 709 | $value .= ')'; |
711 | 710 | } |
712 | 711 | } else { |
713 | - $email = give_get_payment_user_email( $payment->ID ); |
|
714 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . __( '(donor missing)', 'give' ) . '</a>'; |
|
712 | + $email = give_get_payment_user_email($payment->ID); |
|
713 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.__('(donor missing)', 'give').'</a>'; |
|
715 | 714 | } |
716 | 715 | |
717 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' ); |
|
716 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor'); |
|
718 | 717 | } |
719 | 718 | |
720 | 719 | /** |
@@ -727,20 +726,20 @@ discard block |
||
727 | 726 | */ |
728 | 727 | public function get_bulk_actions() { |
729 | 728 | $actions = array( |
730 | - 'delete' => __( 'Delete', 'give' ), |
|
731 | - 'set-status-publish' => __( 'Set To Completed', 'give' ), |
|
732 | - 'set-status-pending' => __( 'Set To Pending', 'give' ), |
|
733 | - 'set-status-processing' => __( 'Set To Processing', 'give' ), |
|
734 | - 'set-status-refunded' => __( 'Set To Refunded', 'give' ), |
|
735 | - 'set-status-revoked' => __( 'Set To Revoked', 'give' ), |
|
736 | - 'set-status-failed' => __( 'Set To Failed', 'give' ), |
|
737 | - 'set-status-cancelled' => __( 'Set To Cancelled', 'give' ), |
|
738 | - 'set-status-abandoned' => __( 'Set To Abandoned', 'give' ), |
|
739 | - 'set-status-preapproval' => __( 'Set To Preapproval', 'give' ), |
|
740 | - 'resend-receipt' => __( 'Resend Email Receipts', 'give' ), |
|
729 | + 'delete' => __('Delete', 'give'), |
|
730 | + 'set-status-publish' => __('Set To Completed', 'give'), |
|
731 | + 'set-status-pending' => __('Set To Pending', 'give'), |
|
732 | + 'set-status-processing' => __('Set To Processing', 'give'), |
|
733 | + 'set-status-refunded' => __('Set To Refunded', 'give'), |
|
734 | + 'set-status-revoked' => __('Set To Revoked', 'give'), |
|
735 | + 'set-status-failed' => __('Set To Failed', 'give'), |
|
736 | + 'set-status-cancelled' => __('Set To Cancelled', 'give'), |
|
737 | + 'set-status-abandoned' => __('Set To Abandoned', 'give'), |
|
738 | + 'set-status-preapproval' => __('Set To Preapproval', 'give'), |
|
739 | + 'resend-receipt' => __('Resend Email Receipts', 'give'), |
|
741 | 740 | ); |
742 | 741 | |
743 | - return apply_filters( 'give_payments_table_bulk_actions', $actions ); |
|
742 | + return apply_filters('give_payments_table_bulk_actions', $actions); |
|
744 | 743 | } |
745 | 744 | |
746 | 745 | /** |
@@ -752,59 +751,59 @@ discard block |
||
752 | 751 | * @return void |
753 | 752 | */ |
754 | 753 | public function process_bulk_action() { |
755 | - $ids = isset( $_GET['payment'] ) ? $_GET['payment'] : false; |
|
754 | + $ids = isset($_GET['payment']) ? $_GET['payment'] : false; |
|
756 | 755 | $action = $this->current_action(); |
757 | 756 | |
758 | - if ( ! is_array( $ids ) ) { |
|
759 | - $ids = array( $ids ); |
|
757 | + if ( ! is_array($ids)) { |
|
758 | + $ids = array($ids); |
|
760 | 759 | } |
761 | 760 | |
762 | - if ( empty( $action ) ) { |
|
761 | + if (empty($action)) { |
|
763 | 762 | return; |
764 | 763 | } |
765 | 764 | |
766 | - foreach ( $ids as $id ) { |
|
765 | + foreach ($ids as $id) { |
|
767 | 766 | |
768 | 767 | // Detect when a bulk action is being triggered. |
769 | - switch ( $this->current_action() ) { |
|
768 | + switch ($this->current_action()) { |
|
770 | 769 | |
771 | 770 | case 'delete': |
772 | - give_delete_donation( $id ); |
|
771 | + give_delete_donation($id); |
|
773 | 772 | break; |
774 | 773 | |
775 | 774 | case 'set-status-publish': |
776 | - give_update_payment_status( $id, 'publish' ); |
|
775 | + give_update_payment_status($id, 'publish'); |
|
777 | 776 | break; |
778 | 777 | |
779 | 778 | case 'set-status-pending': |
780 | - give_update_payment_status( $id, 'pending' ); |
|
779 | + give_update_payment_status($id, 'pending'); |
|
781 | 780 | break; |
782 | 781 | |
783 | 782 | case 'set-status-processing': |
784 | - give_update_payment_status( $id, 'processing' ); |
|
783 | + give_update_payment_status($id, 'processing'); |
|
785 | 784 | break; |
786 | 785 | |
787 | 786 | case 'set-status-refunded': |
788 | - give_update_payment_status( $id, 'refunded' ); |
|
787 | + give_update_payment_status($id, 'refunded'); |
|
789 | 788 | break; |
790 | 789 | case 'set-status-revoked': |
791 | - give_update_payment_status( $id, 'revoked' ); |
|
790 | + give_update_payment_status($id, 'revoked'); |
|
792 | 791 | break; |
793 | 792 | |
794 | 793 | case 'set-status-failed': |
795 | - give_update_payment_status( $id, 'failed' ); |
|
794 | + give_update_payment_status($id, 'failed'); |
|
796 | 795 | break; |
797 | 796 | |
798 | 797 | case 'set-status-cancelled': |
799 | - give_update_payment_status( $id, 'cancelled' ); |
|
798 | + give_update_payment_status($id, 'cancelled'); |
|
800 | 799 | break; |
801 | 800 | |
802 | 801 | case 'set-status-abandoned': |
803 | - give_update_payment_status( $id, 'abandoned' ); |
|
802 | + give_update_payment_status($id, 'abandoned'); |
|
804 | 803 | break; |
805 | 804 | |
806 | 805 | case 'set-status-preapproval': |
807 | - give_update_payment_status( $id, 'preapproval' ); |
|
806 | + give_update_payment_status($id, 'preapproval'); |
|
808 | 807 | break; |
809 | 808 | |
810 | 809 | case 'resend-receipt': |
@@ -813,7 +812,7 @@ discard block |
||
813 | 812 | * |
814 | 813 | * @since 2.0 |
815 | 814 | */ |
816 | - do_action( 'give_donation-receipt_email_notification', $id ); |
|
815 | + do_action('give_donation-receipt_email_notification', $id); |
|
817 | 816 | break; |
818 | 817 | }// End switch(). |
819 | 818 | |
@@ -825,7 +824,7 @@ discard block |
||
825 | 824 | * |
826 | 825 | * @since 1.7 |
827 | 826 | */ |
828 | - do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() ); |
|
827 | + do_action('give_payments_table_do_bulk_action', $id, $this->current_action()); |
|
829 | 828 | }// End foreach(). |
830 | 829 | |
831 | 830 | } |
@@ -842,32 +841,32 @@ discard block |
||
842 | 841 | |
843 | 842 | $args = array(); |
844 | 843 | |
845 | - if ( isset( $_GET['user'] ) ) { |
|
846 | - $args['user'] = urldecode( $_GET['user'] ); |
|
847 | - } elseif ( isset( $_GET['donor'] ) ) { |
|
848 | - $args['donor'] = absint( $_GET['donor'] ); |
|
849 | - } elseif ( isset( $_GET['s'] ) ) { |
|
850 | - $is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false; |
|
851 | - if ( $is_user ) { |
|
852 | - $args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) ); |
|
853 | - unset( $args['s'] ); |
|
844 | + if (isset($_GET['user'])) { |
|
845 | + $args['user'] = urldecode($_GET['user']); |
|
846 | + } elseif (isset($_GET['donor'])) { |
|
847 | + $args['donor'] = absint($_GET['donor']); |
|
848 | + } elseif (isset($_GET['s'])) { |
|
849 | + $is_user = strpos($_GET['s'], strtolower('user:')) !== false; |
|
850 | + if ($is_user) { |
|
851 | + $args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s'])))); |
|
852 | + unset($args['s']); |
|
854 | 853 | } else { |
855 | - $args['s'] = sanitize_text_field( $_GET['s'] ); |
|
854 | + $args['s'] = sanitize_text_field($_GET['s']); |
|
856 | 855 | } |
857 | 856 | } |
858 | 857 | |
859 | - if ( ! empty( $_GET['start-date'] ) ) { |
|
860 | - $args['start-date'] = urldecode( $_GET['start-date'] ); |
|
858 | + if ( ! empty($_GET['start-date'])) { |
|
859 | + $args['start-date'] = urldecode($_GET['start-date']); |
|
861 | 860 | } |
862 | 861 | |
863 | - if ( ! empty( $_GET['end-date'] ) ) { |
|
864 | - $args['end-date'] = urldecode( $_GET['end-date'] ); |
|
862 | + if ( ! empty($_GET['end-date'])) { |
|
863 | + $args['end-date'] = urldecode($_GET['end-date']); |
|
865 | 864 | } |
866 | 865 | |
867 | - $args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
868 | - $args['gateway'] = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null; |
|
866 | + $args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
867 | + $args['gateway'] = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null; |
|
869 | 868 | |
870 | - $payment_count = give_count_payments( $args ); |
|
869 | + $payment_count = give_count_payments($args); |
|
871 | 870 | $this->complete_count = $payment_count->publish; |
872 | 871 | $this->pending_count = $payment_count->pending; |
873 | 872 | $this->processing_count = $payment_count->processing; |
@@ -878,7 +877,7 @@ discard block |
||
878 | 877 | $this->abandoned_count = $payment_count->abandoned; |
879 | 878 | $this->preapproval_count = $payment_count->preapproval; |
880 | 879 | |
881 | - foreach ( $payment_count as $count ) { |
|
880 | + foreach ($payment_count as $count) { |
|
882 | 881 | $this->total_count += $count; |
883 | 882 | } |
884 | 883 | |
@@ -896,25 +895,25 @@ discard block |
||
896 | 895 | public function payments_data() { |
897 | 896 | |
898 | 897 | $per_page = $this->per_page; |
899 | - $orderby = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID'; |
|
900 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
901 | - $user = isset( $_GET['user'] ) ? $_GET['user'] : null; |
|
902 | - $donor = isset( $_GET['donor'] ) ? $_GET['donor'] : null; |
|
903 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys(); |
|
904 | - $meta_key = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null; |
|
905 | - $year = isset( $_GET['year'] ) ? $_GET['year'] : null; |
|
906 | - $month = isset( $_GET['m'] ) ? $_GET['m'] : null; |
|
907 | - $day = isset( $_GET['day'] ) ? $_GET['day'] : null; |
|
908 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; |
|
909 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
910 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date; |
|
911 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
912 | - $gateway = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null; |
|
898 | + $orderby = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID'; |
|
899 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
900 | + $user = isset($_GET['user']) ? $_GET['user'] : null; |
|
901 | + $donor = isset($_GET['donor']) ? $_GET['donor'] : null; |
|
902 | + $status = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys(); |
|
903 | + $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; |
|
904 | + $year = isset($_GET['year']) ? $_GET['year'] : null; |
|
905 | + $month = isset($_GET['m']) ? $_GET['m'] : null; |
|
906 | + $day = isset($_GET['day']) ? $_GET['day'] : null; |
|
907 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null; |
|
908 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
909 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date; |
|
910 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
911 | + $gateway = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null; |
|
913 | 912 | |
914 | 913 | $args = array( |
915 | 914 | 'output' => 'payments', |
916 | 915 | 'number' => $per_page, |
917 | - 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null, |
|
916 | + 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, |
|
918 | 917 | 'orderby' => $orderby, |
919 | 918 | 'order' => $order, |
920 | 919 | 'user' => $user, |
@@ -931,9 +930,9 @@ discard block |
||
931 | 930 | 'give_forms' => $form_id, |
932 | 931 | ); |
933 | 932 | |
934 | - if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) { |
|
933 | + if (is_string($search) && false !== strpos($search, 'txn:')) { |
|
935 | 934 | $args['search_in_notes'] = true; |
936 | - $args['s'] = trim( str_replace( 'txn:', '', $args['s'] ) ); |
|
935 | + $args['s'] = trim(str_replace('txn:', '', $args['s'])); |
|
937 | 936 | } |
938 | 937 | |
939 | 938 | /** |
@@ -941,9 +940,9 @@ discard block |
||
941 | 940 | * |
942 | 941 | * @since 1.8.18 |
943 | 942 | */ |
944 | - $args = (array) apply_filters( 'give_payment_table_payments_query', $args ); |
|
943 | + $args = (array) apply_filters('give_payment_table_payments_query', $args); |
|
945 | 944 | |
946 | - $p_query = new Give_Payments_Query( $args ); |
|
945 | + $p_query = new Give_Payments_Query($args); |
|
947 | 946 | |
948 | 947 | return $p_query->get_payments(); |
949 | 948 | |
@@ -964,17 +963,17 @@ discard block |
||
964 | 963 | */ |
965 | 964 | public function prepare_items() { |
966 | 965 | |
967 | - wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) ); |
|
966 | + wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's')); |
|
968 | 967 | |
969 | 968 | $columns = $this->get_columns(); |
970 | 969 | $hidden = array(); // No hidden columns. |
971 | 970 | $sortable = $this->get_sortable_columns(); |
972 | 971 | $data = $this->payments_data(); |
973 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
972 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
974 | 973 | |
975 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
974 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
976 | 975 | |
977 | - switch ( $status ) { |
|
976 | + switch ($status) { |
|
978 | 977 | case 'publish': |
979 | 978 | $total_items = $this->complete_count; |
980 | 979 | break; |
@@ -1007,8 +1006,8 @@ discard block |
||
1007 | 1006 | break; |
1008 | 1007 | default: |
1009 | 1008 | // Retrieve the count of the non-default-Give status. |
1010 | - $count = wp_count_posts( 'give_payment' ); |
|
1011 | - $total_items = isset( $count->{$status} ) ? $count->{$status} : 0; |
|
1009 | + $count = wp_count_posts('give_payment'); |
|
1010 | + $total_items = isset($count->{$status} ) ? $count->{$status} : 0; |
|
1012 | 1011 | break; |
1013 | 1012 | } |
1014 | 1013 | |
@@ -1019,7 +1018,7 @@ discard block |
||
1019 | 1018 | * |
1020 | 1019 | * @since 1.8.19 |
1021 | 1020 | */ |
1022 | - $total_items = (int) apply_filters( 'give_payment_table_pagination_total_count', $total_items, $this ); |
|
1021 | + $total_items = (int) apply_filters('give_payment_table_pagination_total_count', $total_items, $this); |
|
1023 | 1022 | |
1024 | 1023 | $this->set_pagination_args( |
1025 | 1024 | array( |
@@ -1027,7 +1026,7 @@ discard block |
||
1027 | 1026 | // We have to calculate the total number of items. |
1028 | 1027 | 'per_page' => $this->per_page, |
1029 | 1028 | // We have to determine how many items to show on a page. |
1030 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
1029 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
1031 | 1030 | // We have to calculate the total number of pages. |
1032 | 1031 | ) |
1033 | 1032 | ); |
@@ -21,33 +21,33 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return array |
23 | 23 | */ |
24 | - public static function get_setting_fields( Give_Email_Notification $email, $form_id = null ) { |
|
25 | - $setting_fields = self::get_default_setting_fields( $email, $form_id ); |
|
24 | + public static function get_setting_fields(Give_Email_Notification $email, $form_id = null) { |
|
25 | + $setting_fields = self::get_default_setting_fields($email, $form_id); |
|
26 | 26 | |
27 | 27 | // Recipient field. |
28 | - if ( Give_Email_Notification_Util::has_recipient_field( $email ) ) { |
|
29 | - $setting_fields[] = self::get_recipient_setting_field( $email, $form_id ); |
|
28 | + if (Give_Email_Notification_Util::has_recipient_field($email)) { |
|
29 | + $setting_fields[] = self::get_recipient_setting_field($email, $form_id); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | // Add extra setting field. |
34 | - if ( $extra_setting_field = $email->get_extra_setting_fields( $form_id ) ) { |
|
35 | - $setting_fields = array_merge( $setting_fields, $extra_setting_field ); |
|
34 | + if ($extra_setting_field = $email->get_extra_setting_fields($form_id)) { |
|
35 | + $setting_fields = array_merge($setting_fields, $extra_setting_field); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Preview field. |
39 | - if ( Give_Email_Notification_Util::has_preview( $email ) ) { |
|
40 | - $setting_fields[] = self::get_preview_setting_field( $email, $form_id ); |
|
39 | + if (Give_Email_Notification_Util::has_preview($email)) { |
|
40 | + $setting_fields[] = self::get_preview_setting_field($email, $form_id); |
|
41 | 41 | } |
42 | 42 | |
43 | - $setting_fields = self::add_section_end( $email, $setting_fields ); |
|
43 | + $setting_fields = self::add_section_end($email, $setting_fields); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Filter the email notification settings. |
47 | 47 | * |
48 | 48 | * @since 2.0 |
49 | 49 | */ |
50 | - return apply_filters( 'give_email_notification_setting_fields', $setting_fields, $email, $form_id ); |
|
50 | + return apply_filters('give_email_notification_setting_fields', $setting_fields, $email, $form_id); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return bool |
63 | 63 | */ |
64 | - public static function has_section_end( $setting ) { |
|
65 | - $last_field = end( $setting ); |
|
64 | + public static function has_section_end($setting) { |
|
65 | + $last_field = end($setting); |
|
66 | 66 | $has_section_end = false; |
67 | 67 | |
68 | - if ( 'sectionend' === $last_field['type'] ) { |
|
68 | + if ('sectionend' === $last_field['type']) { |
|
69 | 69 | $has_section_end = true; |
70 | 70 | } |
71 | 71 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - public static function get_section_start( Give_Email_Notification $email, $form_id = null ) { |
|
86 | + public static function get_section_start(Give_Email_Notification $email, $form_id = null) { |
|
87 | 87 | // Add section end field. |
88 | 88 | $setting = array( |
89 | 89 | 'id' => "give_title_email_settings_{$email->config['id']}", |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public static function add_section_end( Give_Email_Notification $email, $setting ) { |
|
109 | - if ( ! self::has_section_end( $setting ) ) { |
|
108 | + public static function add_section_end(Give_Email_Notification $email, $setting) { |
|
109 | + if ( ! self::has_section_end($setting)) { |
|
110 | 110 | // Add section end field. |
111 | 111 | $setting[] = array( |
112 | 112 | 'id' => "give_title_email_settings_{$email->config['id']}", |
@@ -128,25 +128,25 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - public static function get_default_setting_fields( Give_Email_Notification $email, $form_id = null ) { |
|
132 | - $settings[] = self::get_section_start( $email, $form_id ); |
|
133 | - $settings[] = self::get_notification_status_field( $email, $form_id ); |
|
131 | + public static function get_default_setting_fields(Give_Email_Notification $email, $form_id = null) { |
|
132 | + $settings[] = self::get_section_start($email, $form_id); |
|
133 | + $settings[] = self::get_notification_status_field($email, $form_id); |
|
134 | 134 | |
135 | - if ( ! Give_Email_Notification_Util::is_notification_status_editable( $email ) ) { |
|
136 | - if( $form_id || give_is_add_new_form_page() ){ |
|
135 | + if ( ! Give_Email_Notification_Util::is_notification_status_editable($email)) { |
|
136 | + if ($form_id || give_is_add_new_form_page()) { |
|
137 | 137 | // Do not allow admin to disable notification on perform basis. |
138 | - unset( $settings[1]['options']['disabled'] ); |
|
139 | - } else{ |
|
138 | + unset($settings[1]['options']['disabled']); |
|
139 | + } else { |
|
140 | 140 | // Do not allow admin to edit notification status globally. |
141 | - unset( $settings[1] ); |
|
141 | + unset($settings[1]); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - $settings[] = self::get_email_subject_field( $email, $form_id ); |
|
146 | - $settings[] = self::get_email_message_field( $email, $form_id ); |
|
145 | + $settings[] = self::get_email_subject_field($email, $form_id); |
|
146 | + $settings[] = self::get_email_message_field($email, $form_id); |
|
147 | 147 | |
148 | - if( Give_Email_Notification_Util::is_content_type_editable( $email ) ) { |
|
149 | - $settings[] = self::get_email_content_type_field( $email, $form_id ); |
|
148 | + if (Give_Email_Notification_Util::is_content_type_editable($email)) { |
|
149 | + $settings[] = self::get_email_content_type_field($email, $form_id); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $settings; |
@@ -163,31 +163,31 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - public static function get_notification_status_field( Give_Email_Notification $email, $form_id = null ) { |
|
166 | + public static function get_notification_status_field(Give_Email_Notification $email, $form_id = null) { |
|
167 | 167 | $option = array( |
168 | - 'enabled' => __( 'Enabled', 'give' ), |
|
169 | - 'disabled' => __( 'Disabled', 'give' ), |
|
168 | + 'enabled' => __('Enabled', 'give'), |
|
169 | + 'disabled' => __('Disabled', 'give'), |
|
170 | 170 | ); |
171 | 171 | |
172 | 172 | $default_value = $email->get_notification_status(); |
173 | 173 | |
174 | 174 | // Add global options. |
175 | - if ( $form_id || give_is_add_new_form_page() ) { |
|
175 | + if ($form_id || give_is_add_new_form_page()) { |
|
176 | 176 | $option = array( |
177 | - 'global' => __( 'Global Options' ), |
|
178 | - 'enabled' => __( 'Customize', 'give' ), |
|
179 | - 'disabled' => __( 'Disabled', 'give' ), |
|
177 | + 'global' => __('Global Options'), |
|
178 | + 'enabled' => __('Customize', 'give'), |
|
179 | + 'disabled' => __('Disabled', 'give'), |
|
180 | 180 | ); |
181 | 181 | |
182 | 182 | $default_value = 'global'; |
183 | 183 | } |
184 | 184 | |
185 | - $description = isset($_GET['page']) && 'give-settings' === $_GET['page'] ? __('Choose whether you want this email enabled or not.', 'give') : sprintf( __( 'Global Options are set <a href="%s">in Give settings</a>. You may override them for this form here.', 'give' ), admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=emails' ) ); |
|
185 | + $description = isset($_GET['page']) && 'give-settings' === $_GET['page'] ? __('Choose whether you want this email enabled or not.', 'give') : sprintf(__('Global Options are set <a href="%s">in Give settings</a>. You may override them for this form here.', 'give'), admin_url('edit.php?post_type=give_forms&page=give-settings&tab=emails')); |
|
186 | 186 | |
187 | 187 | return array( |
188 | - 'name' => esc_html__( 'Notification', 'give' ), |
|
188 | + 'name' => esc_html__('Notification', 'give'), |
|
189 | 189 | 'desc' => $description, |
190 | - 'id' => self::get_prefix( $email, $form_id ) . 'notification', |
|
190 | + 'id' => self::get_prefix($email, $form_id).'notification', |
|
191 | 191 | 'type' => 'radio_inline', |
192 | 192 | 'default' => $default_value, |
193 | 193 | 'options' => $option, |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return array |
208 | 208 | */ |
209 | - public static function get_email_subject_field( Give_Email_Notification $email, $form_id = null ) { |
|
209 | + public static function get_email_subject_field(Give_Email_Notification $email, $form_id = null) { |
|
210 | 210 | return array( |
211 | - 'id' => self::get_prefix( $email, $form_id ) . 'email_subject', |
|
212 | - 'name' => esc_html__( 'Email Subject', 'give' ), |
|
213 | - 'desc' => esc_html__( 'Enter the email subject line.', 'give' ), |
|
211 | + 'id' => self::get_prefix($email, $form_id).'email_subject', |
|
212 | + 'name' => esc_html__('Email Subject', 'give'), |
|
213 | + 'desc' => esc_html__('Enter the email subject line.', 'give'), |
|
214 | 214 | 'default' => $email->config['default_email_subject'], |
215 | 215 | 'type' => 'text', |
216 | 216 | ); |
@@ -227,28 +227,28 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return array |
229 | 229 | */ |
230 | - public static function get_email_message_field( Give_Email_Notification $email, $form_id = null ) { |
|
231 | - $desc = esc_html__( 'Enter the email message.', 'give' ); |
|
230 | + public static function get_email_message_field(Give_Email_Notification $email, $form_id = null) { |
|
231 | + $desc = esc_html__('Enter the email message.', 'give'); |
|
232 | 232 | |
233 | - if ( $email_tag_list = $email->get_allowed_email_tags( true ) ) { |
|
233 | + if ($email_tag_list = $email->get_allowed_email_tags(true)) { |
|
234 | 234 | $desc = sprintf( |
235 | 235 | '%1$s <br> %2$s: %3$s %4$s', |
236 | - __( 'The email that is sent to users after completing a successful donation. HTML is accepted.', 'give' ), |
|
237 | - __( 'Available template tags', 'give' ), |
|
236 | + __('The email that is sent to users after completing a successful donation. HTML is accepted.', 'give'), |
|
237 | + __('Available template tags', 'give'), |
|
238 | 238 | $email_tag_list, |
239 | 239 | sprintf( |
240 | 240 | '<br><a href="%1$s" target="_blank">%2$s</a> %3$s', |
241 | 241 | esc_url('http://docs.givewp.com/meta-email-tags'), |
242 | - __( 'See our documentation', 'give' ), |
|
243 | - __( 'for examples of how to use custom meta email tags to output additional donor or donation information in your Give emails.', 'give' ) |
|
242 | + __('See our documentation', 'give'), |
|
243 | + __('for examples of how to use custom meta email tags to output additional donor or donation information in your Give emails.', 'give') |
|
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | 249 | return array( |
250 | - 'id' => self::get_prefix( $email, $form_id ) . 'email_message', |
|
251 | - 'name' => esc_html__( 'Email message', 'give' ), |
|
250 | + 'id' => self::get_prefix($email, $form_id).'email_message', |
|
251 | + 'name' => esc_html__('Email message', 'give'), |
|
252 | 252 | 'desc' => $desc, |
253 | 253 | 'type' => 'wysiwyg', |
254 | 254 | 'default' => $email->config['default_email_message'], |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @return array |
268 | 268 | */ |
269 | - public static function get_email_content_type_field( Give_Email_Notification $email, $form_id = null ) { |
|
269 | + public static function get_email_content_type_field(Give_Email_Notification $email, $form_id = null) { |
|
270 | 270 | return array( |
271 | - 'id' => self::get_prefix( $email, $form_id ) . 'email_content_type', |
|
272 | - 'name' => esc_html__( 'Email Content Type', 'give' ), |
|
273 | - 'desc' => __( 'Choose email type.', 'give' ), |
|
271 | + 'id' => self::get_prefix($email, $form_id).'email_content_type', |
|
272 | + 'name' => esc_html__('Email Content Type', 'give'), |
|
273 | + 'desc' => __('Choose email type.', 'give'), |
|
274 | 274 | 'type' => 'select', |
275 | 275 | 'options' => array( |
276 | - 'text/html' => Give_Email_Notification_Util::get_formatted_email_type( 'text/html' ), |
|
277 | - 'text/plain' => Give_Email_Notification_Util::get_formatted_email_type( 'text/plain' ), |
|
276 | + 'text/html' => Give_Email_Notification_Util::get_formatted_email_type('text/html'), |
|
277 | + 'text/plain' => Give_Email_Notification_Util::get_formatted_email_type('text/plain'), |
|
278 | 278 | ), |
279 | 279 | 'default' => $email->config['content_type'], |
280 | 280 | ); |
@@ -293,29 +293,29 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return array |
295 | 295 | */ |
296 | - public static function get_recipient_setting_field( Give_Email_Notification $email, $form_id = null ) { |
|
297 | - $recipient = array( |
|
298 | - 'id' => self::get_prefix( $email, $form_id ) . 'recipient', |
|
299 | - 'name' => esc_html__( 'Email Recipients', 'give' ), |
|
300 | - 'desc' => __( 'Enter the email address(es) that should receive a notification.', 'give' ), |
|
296 | + public static function get_recipient_setting_field(Give_Email_Notification $email, $form_id = null) { |
|
297 | + $recipient = array( |
|
298 | + 'id' => self::get_prefix($email, $form_id).'recipient', |
|
299 | + 'name' => esc_html__('Email Recipients', 'give'), |
|
300 | + 'desc' => __('Enter the email address(es) that should receive a notification.', 'give'), |
|
301 | 301 | 'type' => 'email', |
302 | - 'default' => get_bloginfo( 'admin_email' ), |
|
302 | + 'default' => get_bloginfo('admin_email'), |
|
303 | 303 | 'repeat' => true, |
304 | - 'repeat_btn_title' => esc_html__( 'Add Recipient', 'give' ), |
|
304 | + 'repeat_btn_title' => esc_html__('Add Recipient', 'give'), |
|
305 | 305 | ); |
306 | 306 | |
307 | - if ( $form_id || give_is_add_new_form_page() ) { |
|
308 | - $recipient['name'] = __( 'Email', 'give' ); |
|
307 | + if ($form_id || give_is_add_new_form_page()) { |
|
308 | + $recipient['name'] = __('Email', 'give'); |
|
309 | 309 | $recipient['default'] = ''; |
310 | 310 | $recipient['id'] = 'email'; |
311 | - $recipient['desc'] = __( 'Enter the email address that should receive a notification.', 'give' ); |
|
311 | + $recipient['desc'] = __('Enter the email address that should receive a notification.', 'give'); |
|
312 | 312 | |
313 | 313 | $recipient = array( |
314 | - 'id' => self::get_prefix( $email, $form_id ) . 'recipient', |
|
314 | + 'id' => self::get_prefix($email, $form_id).'recipient', |
|
315 | 315 | 'type' => 'group', |
316 | 316 | 'options' => array( |
317 | - 'add_button' => __( 'Add Email', 'give' ), |
|
318 | - 'header_title' => __( 'Email Recipient', 'give' ), |
|
317 | + 'add_button' => __('Add Email', 'give'), |
|
318 | + 'header_title' => __('Email Recipient', 'give'), |
|
319 | 319 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
320 | 320 | ), |
321 | 321 | 'fields' => array( |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @return array |
340 | 340 | */ |
341 | - public static function get_preview_setting_field( Give_Email_Notification $email, $form_id = null ) { |
|
341 | + public static function get_preview_setting_field(Give_Email_Notification $email, $form_id = null) { |
|
342 | 342 | return array( |
343 | - 'name' => __( 'Preview Email', 'give' ), |
|
344 | - 'desc' => __( 'Click the "Preview Email" button to preview the email in your browser. Click the "Send Test Email" button to send a test email directly to your inbox.', |
|
345 | - 'give' ), |
|
346 | - 'id' => self::get_prefix( $email, $form_id ) . 'preview_buttons', |
|
343 | + 'name' => __('Preview Email', 'give'), |
|
344 | + 'desc' => __('Click the "Preview Email" button to preview the email in your browser. Click the "Send Test Email" button to send a test email directly to your inbox.', |
|
345 | + 'give'), |
|
346 | + 'id' => self::get_prefix($email, $form_id).'preview_buttons', |
|
347 | 347 | 'type' => 'email_preview_buttons', |
348 | 348 | ); |
349 | 349 | } |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return string |
362 | 362 | */ |
363 | - public static function get_prefix( Give_Email_Notification $email, $form_id = null ) { |
|
363 | + public static function get_prefix(Give_Email_Notification $email, $form_id = null) { |
|
364 | 364 | $meta_key = "{$email->config['id']}_"; |
365 | 365 | |
366 | - if( $form_id || give_is_add_new_form_page() ) { |
|
366 | + if ($form_id || give_is_add_new_form_page()) { |
|
367 | 367 | $meta_key = "_give_{$email->config['id']}_"; |
368 | 368 | } |
369 | 369 |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | -if ( ! class_exists( 'Give_Email_Notification' ) ) : |
|
19 | +if ( ! class_exists('Give_Email_Notification')) : |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Give_Email_Notification |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return Give_Email_Notification |
95 | 95 | */ |
96 | - public static function get_instance( $email_notification_id = '' ) { |
|
96 | + public static function get_instance($email_notification_id = '') { |
|
97 | 97 | $class = ''; |
98 | 98 | |
99 | - if ( ! empty( $email_notification_id ) ) { |
|
99 | + if ( ! empty($email_notification_id)) { |
|
100 | 100 | /* @var Give_Email_Notification $class */ |
101 | - foreach ( self::$singleton as $class ) { |
|
102 | - if ( $email_notification_id === $class->config['id'] ) { |
|
103 | - $class = get_class( $class ); |
|
101 | + foreach (self::$singleton as $class) { |
|
102 | + if ($email_notification_id === $class->config['id']) { |
|
103 | + $class = get_class($class); |
|
104 | 104 | break; |
105 | 105 | } |
106 | 106 | } |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | $class = get_called_class(); |
109 | 109 | } |
110 | 110 | |
111 | - if ( ! empty( $class ) && ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) ) { |
|
112 | - self::$singleton[ $class ] = new $class(); |
|
111 | + if ( ! empty($class) && ( ! array_key_exists($class, self::$singleton) || is_null(self::$singleton[$class]))) { |
|
112 | + self::$singleton[$class] = new $class(); |
|
113 | 113 | } |
114 | 114 | |
115 | - return ( isset( self::$singleton[ $class ] ) ? self::$singleton[ $class ] : null ); |
|
115 | + return (isset(self::$singleton[$class]) ? self::$singleton[$class] : null); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -123,35 +123,35 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param array $config |
125 | 125 | */ |
126 | - public function load( $config ) { |
|
126 | + public function load($config) { |
|
127 | 127 | // Set notification configuration. |
128 | - $this->config = wp_parse_args( $config, $this->config ); |
|
128 | + $this->config = wp_parse_args($config, $this->config); |
|
129 | 129 | |
130 | 130 | // Set email preview header status. |
131 | 131 | $this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false; |
132 | 132 | |
133 | 133 | // Set email content type |
134 | - $this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array( |
|
134 | + $this->config['content_type'] = empty($this->config['content_type']) || ! in_array($this->config['content_type'], array( |
|
135 | 135 | 'text/html', |
136 | 136 | 'text/plain', |
137 | - ) ) |
|
137 | + )) |
|
138 | 138 | ? Give()->emails->get_content_type() |
139 | 139 | : $this->config['content_type']; |
140 | - $this->config['content_type'] = give_get_option( Give_Email_Setting_Field::get_prefix( $this ) . 'email_content_type', $this->config['content_type'] ); |
|
140 | + $this->config['content_type'] = give_get_option(Give_Email_Setting_Field::get_prefix($this).'email_content_type', $this->config['content_type']); |
|
141 | 141 | |
142 | 142 | // Set email template type. |
143 | - $this->config['email_template'] = empty( $this->config['email_template'] ) |
|
144 | - ? give_get_option( 'email_template' ) |
|
143 | + $this->config['email_template'] = empty($this->config['email_template']) |
|
144 | + ? give_get_option('email_template') |
|
145 | 145 | : $this->config['email_template']; |
146 | 146 | |
147 | 147 | // Set recipient group name. |
148 | - $this->config['recipient_group_name'] = empty( $this->config['recipient_group_name'] ) |
|
149 | - ? ( ! Give_Email_Notification_Util::has_recipient_field( $this ) ? __( 'Donor', 'give' ) : '' ) |
|
148 | + $this->config['recipient_group_name'] = empty($this->config['recipient_group_name']) |
|
149 | + ? ( ! Give_Email_Notification_Util::has_recipient_field($this) ? __('Donor', 'give') : '') |
|
150 | 150 | : $this->config['recipient_group_name']; |
151 | 151 | |
152 | 152 | // Non notification status editable notice. |
153 | - $this->config['notices']['non-notification-status-editable'] = empty( $this->config['notices']['non-notification-status-editable'] ) |
|
154 | - ? __( 'You can not edit notification status from here.', 'give' ) |
|
153 | + $this->config['notices']['non-notification-status-editable'] = empty($this->config['notices']['non-notification-status-editable']) |
|
154 | + ? __('You can not edit notification status from here.', 'give') |
|
155 | 155 | : $this->config['notices']['non-notification-status-editable']; |
156 | 156 | |
157 | 157 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param array Give_Email_Notification::config |
163 | 163 | * @param Give_Email_Notification $this |
164 | 164 | */ |
165 | - $this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this ); |
|
165 | + $this->config = apply_filters('give_email_api_notification_config', $this->config, $this); |
|
166 | 166 | |
167 | 167 | // Setup filters. |
168 | 168 | $this->setup_filters(); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | private function setup_filters() { |
179 | 179 | // Apply filter only for current email notification section. |
180 | - if ( give_get_current_setting_section() === $this->config['id'] ) { |
|
180 | + if (give_get_current_setting_section() === $this->config['id']) { |
|
181 | 181 | // Initialize email context for email notification. |
182 | 182 | $this->config['email_tag_context'] = apply_filters( |
183 | 183 | "give_{$this->config['id']}_email_tag_context", |
@@ -187,23 +187,23 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | // Setup setting fields. |
190 | - if( $this->config['show_on_emails_setting_page'] ) { |
|
191 | - add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 ); |
|
190 | + if ($this->config['show_on_emails_setting_page']) { |
|
191 | + add_filter('give_get_settings_emails', array($this, 'add_setting_fields'), 10, 2); |
|
192 | 192 | } |
193 | 193 | |
194 | - if ( $this->config['form_metabox_setting'] ) { |
|
194 | + if ($this->config['form_metabox_setting']) { |
|
195 | 195 | add_filter( |
196 | 196 | 'give_email_notification_options_metabox_fields', |
197 | - array( $this, 'add_metabox_setting_field' ), |
|
197 | + array($this, 'add_metabox_setting_field'), |
|
198 | 198 | 10, |
199 | 199 | 2 |
200 | 200 | ); |
201 | 201 | } |
202 | 202 | |
203 | - if( $this->config['has_recipient_field'] ) { |
|
203 | + if ($this->config['has_recipient_field']) { |
|
204 | 204 | add_action( |
205 | 205 | "give_save__give_{$this->config['id']}_recipient", |
206 | - array( $this, 'validate_form_recipient_field_value' ), |
|
206 | + array($this, 'validate_form_recipient_field_value'), |
|
207 | 207 | 10, |
208 | 208 | 3 |
209 | 209 | ); |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - public function add_section( $sections ) { |
|
245 | - $sections[ $this->config['id'] ] = $this->config['label']; |
|
244 | + public function add_section($sections) { |
|
245 | + $sections[$this->config['id']] = $this->config['label']; |
|
246 | 246 | |
247 | 247 | return $sections; |
248 | 248 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return bool |
258 | 258 | */ |
259 | - public function hide_section( $hide_section ) { |
|
259 | + public function hide_section($hide_section) { |
|
260 | 260 | $hide_section = true; |
261 | 261 | |
262 | 262 | return $hide_section; |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return array |
274 | 274 | */ |
275 | - public function add_setting_fields( $settings ) { |
|
276 | - if ( $this->config['id'] === give_get_current_setting_section() ) { |
|
275 | + public function add_setting_fields($settings) { |
|
276 | + if ($this->config['id'] === give_get_current_setting_section()) { |
|
277 | 277 | $settings = $this->get_setting_fields(); |
278 | 278 | } |
279 | 279 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - public function get_setting_fields( $form_id = null ) { |
|
295 | - return Give_Email_Setting_Field::get_setting_fields( $this, $form_id ); |
|
294 | + public function get_setting_fields($form_id = null) { |
|
295 | + return Give_Email_Setting_Field::get_setting_fields($this, $form_id); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -307,13 +307,13 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return array |
309 | 309 | */ |
310 | - public function add_metabox_setting_field( $settings, $form_id ) { |
|
310 | + public function add_metabox_setting_field($settings, $form_id) { |
|
311 | 311 | |
312 | - if( Give_Email_Notification_Util::is_email_notification_active( $this ) ) { |
|
312 | + if (Give_Email_Notification_Util::is_email_notification_active($this)) { |
|
313 | 313 | $settings[] = array( |
314 | 314 | 'id' => $this->config['id'], |
315 | 315 | 'title' => $this->config['label'], |
316 | - 'fields' => $this->get_setting_fields( $form_id ), |
|
316 | + 'fields' => $this->get_setting_fields($form_id), |
|
317 | 317 | ); |
318 | 318 | } |
319 | 319 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return array |
333 | 333 | */ |
334 | - public function get_extra_setting_fields( $form_id = null ) { |
|
334 | + public function get_extra_setting_fields($form_id = null) { |
|
335 | 335 | return array(); |
336 | 336 | } |
337 | 337 | |
@@ -348,11 +348,11 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return string|array |
350 | 350 | */ |
351 | - public function get_recipient( $form_id = null ) { |
|
352 | - if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) { |
|
351 | + public function get_recipient($form_id = null) { |
|
352 | + if (empty($this->recipient_email) && $this->config['has_recipient_field']) { |
|
353 | 353 | $this->recipient_email = Give_Email_Notification_Util::get_value( |
354 | 354 | $this, |
355 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'recipient', |
|
355 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'recipient', |
|
356 | 356 | $form_id |
357 | 357 | ); |
358 | 358 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @since 1.0 |
364 | 364 | * @deprecated 2.0 |
365 | 365 | */ |
366 | - $this->recipient_email = apply_filters( 'give_admin_notice_emails', $this->recipient_email, $this, $form_id ); |
|
366 | + $this->recipient_email = apply_filters('give_admin_notice_emails', $this->recipient_email, $this, $form_id); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return bool |
395 | 395 | */ |
396 | - public function get_notification_status( $form_id = null ) { |
|
397 | - $notification_status = empty( $form_id ) |
|
398 | - ? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] ) |
|
399 | - : give_get_meta( $form_id, Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'notification', true, 'global' ); |
|
396 | + public function get_notification_status($form_id = null) { |
|
397 | + $notification_status = empty($form_id) |
|
398 | + ? give_get_option("{$this->config['id']}_notification", $this->config['notification_status']) |
|
399 | + : give_get_meta($form_id, Give_Email_Setting_Field::get_prefix($this, $form_id).'notification', true, 'global'); |
|
400 | 400 | |
401 | 401 | /** |
402 | 402 | * Filter the notification status. |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string |
423 | 423 | */ |
424 | - function get_email_subject( $form_id = null ) { |
|
424 | + function get_email_subject($form_id = null) { |
|
425 | 425 | $subject = wp_strip_all_tags( |
426 | 426 | Give_Email_Notification_Util::get_value( |
427 | 427 | $this, |
428 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
428 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
429 | 429 | $form_id, |
430 | 430 | $this->config['default_email_subject'] |
431 | 431 | ) |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public function get_email_message( $form_id = null ) { |
|
457 | + public function get_email_message($form_id = null) { |
|
458 | 458 | $message = Give_Email_Notification_Util::get_value( |
459 | 459 | $this, |
460 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
460 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
461 | 461 | $form_id, |
462 | 462 | $this->config['default_email_message'] |
463 | 463 | ); |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @return string |
488 | 488 | */ |
489 | - public function get_email_content_type( $form_id ) { |
|
489 | + public function get_email_content_type($form_id) { |
|
490 | 490 | $content_type = Give_Email_Notification_Util::get_value( |
491 | 491 | $this, |
492 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_content_type', |
|
492 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_content_type', |
|
493 | 493 | $form_id, |
494 | 494 | $this->config['content_type'] |
495 | 495 | ); |
@@ -517,15 +517,14 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - public function get_email_template( $form_id ) { |
|
521 | - $email_template = give_get_meta( $form_id, '_give_email_template', true ); |
|
520 | + public function get_email_template($form_id) { |
|
521 | + $email_template = give_get_meta($form_id, '_give_email_template', true); |
|
522 | 522 | $email_template = Give_Email_Notification_Util::get_value( |
523 | 523 | $this, |
524 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) .'email_template', |
|
524 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_template', |
|
525 | 525 | $form_id, |
526 | - ! empty( $email_template ) && Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ? |
|
527 | - $email_template : |
|
528 | - $this->config['email_template'] |
|
526 | + ! empty($email_template) && Give_Email_Notification_Util::can_use_form_email_options($this, $form_id) ? |
|
527 | + $email_template : $this->config['email_template'] |
|
529 | 528 | ); |
530 | 529 | |
531 | 530 | /** |
@@ -552,34 +551,34 @@ discard block |
||
552 | 551 | * |
553 | 552 | * @return array |
554 | 553 | */ |
555 | - public function get_allowed_email_tags( $formatted = false ) { |
|
554 | + public function get_allowed_email_tags($formatted = false) { |
|
556 | 555 | // Get all email tags. |
557 | 556 | $email_tags = Give()->email_tags->get_tags(); |
558 | 557 | |
559 | 558 | // Skip if all email template tags context setup exit. |
560 | - if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) { |
|
561 | - if ( is_array( $this->config['email_tag_context'] ) ) { |
|
562 | - foreach ( $email_tags as $index => $email_tag ) { |
|
563 | - if ( in_array( $email_tag['context'], $this->config['email_tag_context'] ) ) { |
|
559 | + if ($this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context']) { |
|
560 | + if (is_array($this->config['email_tag_context'])) { |
|
561 | + foreach ($email_tags as $index => $email_tag) { |
|
562 | + if (in_array($email_tag['context'], $this->config['email_tag_context'])) { |
|
564 | 563 | continue; |
565 | 564 | } |
566 | 565 | |
567 | - unset( $email_tags[ $index ] ); |
|
566 | + unset($email_tags[$index]); |
|
568 | 567 | } |
569 | 568 | } else { |
570 | - foreach ( $email_tags as $index => $email_tag ) { |
|
571 | - if ( $this->config['email_tag_context'] === $email_tag['context'] ) { |
|
569 | + foreach ($email_tags as $index => $email_tag) { |
|
570 | + if ($this->config['email_tag_context'] === $email_tag['context']) { |
|
572 | 571 | continue; |
573 | 572 | } |
574 | 573 | |
575 | - unset( $email_tags[ $index ] ); |
|
574 | + unset($email_tags[$index]); |
|
576 | 575 | } |
577 | 576 | } |
578 | 577 | } |
579 | 578 | |
580 | - if ( count( $email_tags ) && $formatted ) : ob_start() ?> |
|
579 | + if (count($email_tags) && $formatted) : ob_start() ?> |
|
581 | 580 | <ul class="give-email-tags-wrap"> |
582 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
581 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
583 | 582 | <li class="give_<?php echo $email_tag['tag']; ?>_tag"> |
584 | 583 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
585 | 584 | </li> |
@@ -602,8 +601,8 @@ discard block |
||
602 | 601 | * |
603 | 602 | * @return array|string |
604 | 603 | */ |
605 | - public function get_preview_email_recipient( $form_id = null ) { |
|
606 | - $recipients = $this->get_recipient( $form_id ); |
|
604 | + public function get_preview_email_recipient($form_id = null) { |
|
605 | + $recipients = $this->get_recipient($form_id); |
|
607 | 606 | |
608 | 607 | /** |
609 | 608 | * Filter the preview email recipients. |
@@ -613,7 +612,7 @@ discard block |
||
613 | 612 | * @param string|array $recipients List of recipients. |
614 | 613 | * @param Give_Email_Notification $this |
615 | 614 | */ |
616 | - $recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id ); |
|
615 | + $recipients = apply_filters('give_get_preview_email_recipient', $recipients, $this, $form_id); |
|
617 | 616 | |
618 | 617 | return $recipients; |
619 | 618 | } |
@@ -628,13 +627,13 @@ discard block |
||
628 | 627 | * |
629 | 628 | * @return array |
630 | 629 | */ |
631 | - public function get_email_attachments( $form_id = null ) { |
|
630 | + public function get_email_attachments($form_id = null) { |
|
632 | 631 | /** |
633 | 632 | * Filter the attachment. |
634 | 633 | * |
635 | 634 | * @since 2.0 |
636 | 635 | */ |
637 | - return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id ); |
|
636 | + return apply_filters("give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id); |
|
638 | 637 | } |
639 | 638 | |
640 | 639 | |
@@ -646,37 +645,37 @@ discard block |
||
646 | 645 | */ |
647 | 646 | public function send_preview_email() { |
648 | 647 | // Get form id |
649 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
648 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
650 | 649 | |
651 | 650 | // setup email data. |
652 | 651 | $this->setup_email_data(); |
653 | 652 | |
654 | 653 | $attachments = $this->get_email_attachments(); |
655 | - $message = $this->preview_email_template_tags( $this->get_email_message( $form_id ) ); |
|
656 | - $subject = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) ); |
|
657 | - $content_type = $this->get_email_content_type( $form_id ); |
|
654 | + $message = $this->preview_email_template_tags($this->get_email_message($form_id)); |
|
655 | + $subject = $this->preview_email_template_tags($this->get_email_subject($form_id)); |
|
656 | + $content_type = $this->get_email_content_type($form_id); |
|
658 | 657 | |
659 | 658 | // Setup email content type. |
660 | - Give()->emails->__set( 'content_type', $content_type ); |
|
661 | - Give()->emails->__set( 'html', true ); |
|
659 | + Give()->emails->__set('content_type', $content_type); |
|
660 | + Give()->emails->__set('html', true); |
|
662 | 661 | |
663 | 662 | // Setup email template |
664 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
663 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
665 | 664 | |
666 | 665 | // Format plain content type email. |
667 | - if ( 'text/plain' === $content_type ) { |
|
668 | - Give()->emails->__set( 'html', false ); |
|
669 | - Give()->emails->__set( 'template', 'none' ); |
|
670 | - $message = strip_tags( $message ); |
|
666 | + if ('text/plain' === $content_type) { |
|
667 | + Give()->emails->__set('html', false); |
|
668 | + Give()->emails->__set('template', 'none'); |
|
669 | + $message = strip_tags($message); |
|
671 | 670 | } |
672 | 671 | |
673 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
672 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
674 | 673 | Give()->emails->form_id = $form_id; |
675 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
676 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
674 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
675 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
677 | 676 | } |
678 | 677 | |
679 | - return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments ); |
|
678 | + return Give()->emails->send($this->get_preview_email_recipient($form_id), $subject, $message, $attachments); |
|
680 | 679 | } |
681 | 680 | |
682 | 681 | |
@@ -697,7 +696,7 @@ discard block |
||
697 | 696 | * |
698 | 697 | * @return bool |
699 | 698 | */ |
700 | - public function send_email_notification( $email_tag_args = array() ) { |
|
699 | + public function send_email_notification($email_tag_args = array()) { |
|
701 | 700 | // Add email content type email tags. |
702 | 701 | $email_tag_args['email_content_type'] = $this->config['content_type']; |
703 | 702 | |
@@ -706,16 +705,16 @@ discard block |
||
706 | 705 | * |
707 | 706 | * @since 2.0 |
708 | 707 | */ |
709 | - $email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this ); |
|
708 | + $email_tag_args = apply_filters("give_{$this->config['id']}_email_tag_args", $email_tag_args, $this); |
|
710 | 709 | |
711 | 710 | // Get form id. |
712 | - $form_id = ! empty( $email_tag_args['form_id'] ) |
|
713 | - ? absint( $email_tag_args['form_id'] ) |
|
714 | - : ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null ); |
|
711 | + $form_id = ! empty($email_tag_args['form_id']) |
|
712 | + ? absint($email_tag_args['form_id']) |
|
713 | + : ( ! empty($email_tag_args['payment_id']) ? give_get_payment_form_id($email_tag_args['payment_id']) : null); |
|
715 | 714 | |
716 | 715 | |
717 | 716 | // Do not send email if notification is disable. |
718 | - if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) { |
|
717 | + if ( ! Give_Email_Notification_Util::is_email_notification_active($this, $form_id)) { |
|
719 | 718 | return false; |
720 | 719 | } |
721 | 720 | |
@@ -724,41 +723,41 @@ discard block |
||
724 | 723 | * |
725 | 724 | * @since 2.0 |
726 | 725 | */ |
727 | - do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id ); |
|
726 | + do_action("give_{$this->config['id']}_email_send_before", $this, $form_id); |
|
728 | 727 | |
729 | 728 | $attachments = $this->get_email_attachments(); |
730 | - $message = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args ); |
|
731 | - $subject = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args ); |
|
732 | - $content_type = $this->get_email_content_type( $form_id ); |
|
729 | + $message = give_do_email_tags($this->get_email_message($form_id), $email_tag_args); |
|
730 | + $subject = give_do_email_tags($this->get_email_subject($form_id), $email_tag_args); |
|
731 | + $content_type = $this->get_email_content_type($form_id); |
|
733 | 732 | |
734 | 733 | // Setup email content type. |
735 | - Give()->emails->__set( 'content_type', $content_type ); |
|
736 | - Give()->emails->__set( 'html', true ); |
|
734 | + Give()->emails->__set('content_type', $content_type); |
|
735 | + Give()->emails->__set('html', true); |
|
737 | 736 | |
738 | 737 | // Set email template. |
739 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
738 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
740 | 739 | |
741 | - if ( 'text/plain' === $content_type ) { |
|
742 | - Give()->emails->__set( 'html', false ); |
|
743 | - Give()->emails->__set( 'template', 'none' ); |
|
744 | - $message = strip_tags( $message ); |
|
740 | + if ('text/plain' === $content_type) { |
|
741 | + Give()->emails->__set('html', false); |
|
742 | + Give()->emails->__set('template', 'none'); |
|
743 | + $message = strip_tags($message); |
|
745 | 744 | } |
746 | 745 | |
747 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
746 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
748 | 747 | Give()->emails->form_id = $form_id; |
749 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
750 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
748 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
749 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
751 | 750 | } |
752 | 751 | |
753 | 752 | // Send email. |
754 | - $email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments ); |
|
753 | + $email_status = Give()->emails->send($this->get_recipient($form_id), $subject, $message, $attachments); |
|
755 | 754 | |
756 | 755 | /** |
757 | 756 | * Fire action after after email send. |
758 | 757 | * |
759 | 758 | * @since 2.0 |
760 | 759 | */ |
761 | - do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id ); |
|
760 | + do_action("give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id); |
|
762 | 761 | |
763 | 762 | return $email_status; |
764 | 763 | } |
@@ -773,67 +772,67 @@ discard block |
||
773 | 772 | * |
774 | 773 | * @return string |
775 | 774 | */ |
776 | - public function preview_email_template_tags( $message ) { |
|
775 | + public function preview_email_template_tags($message) { |
|
777 | 776 | // Set Payment. |
778 | - $payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' ); |
|
779 | - $payment = $payment_id ? new Give_Payment( $payment_id ) : new stdClass(); |
|
777 | + $payment_id = give_check_variable(give_clean($_GET), 'isset_empty', 0, 'preview_id'); |
|
778 | + $payment = $payment_id ? new Give_Payment($payment_id) : new stdClass(); |
|
780 | 779 | |
781 | 780 | // Set donor. |
782 | 781 | $user_id = $payment_id |
783 | 782 | ? $payment->user_id |
784 | - : give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' ); |
|
783 | + : give_check_variable(give_clean($_GET), 'isset_empty', 0, 'user_id'); |
|
785 | 784 | $user_id = $user_id ? $user_id : wp_get_current_user()->ID; |
786 | 785 | |
787 | 786 | // Set receipt. |
788 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
787 | + $receipt_id = strtolower(md5(uniqid())); |
|
789 | 788 | |
790 | - $receipt_link_url = esc_url( add_query_arg( array( |
|
789 | + $receipt_link_url = esc_url(add_query_arg(array( |
|
791 | 790 | 'payment_key' => $receipt_id, |
792 | - ), give_get_history_page_uri() ) ); |
|
791 | + ), give_get_history_page_uri())); |
|
793 | 792 | |
794 | 793 | $receipt_link = sprintf( |
795 | 794 | '<a href="%1$s">%2$s</a>', |
796 | 795 | $receipt_link_url, |
797 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
796 | + esc_html__('View the receipt in your browser »', 'give') |
|
798 | 797 | ); |
799 | 798 | |
800 | 799 | // Set default values for tags. |
801 | 800 | $this->config['preview_email_tags_values'] = wp_parse_args( |
802 | 801 | $this->config['preview_email_tags_values'], |
803 | 802 | array( |
804 | - 'name' => give_email_tag_first_name( array( |
|
803 | + 'name' => give_email_tag_first_name(array( |
|
805 | 804 | 'payment_id' => $payment_id, |
806 | 805 | 'user_id' => $user_id, |
807 | - ) ), |
|
808 | - 'fullname' => give_email_tag_fullname( array( |
|
806 | + )), |
|
807 | + 'fullname' => give_email_tag_fullname(array( |
|
809 | 808 | 'payment_id' => $payment_id, |
810 | 809 | 'user_id' => $user_id, |
811 | - ) ), |
|
812 | - 'username' => give_email_tag_username( array( |
|
810 | + )), |
|
811 | + 'username' => give_email_tag_username(array( |
|
813 | 812 | 'payment_id' => $payment_id, |
814 | 813 | 'user_id' => $user_id, |
815 | - ) ), |
|
816 | - 'user_email' => give_email_tag_user_email( array( |
|
814 | + )), |
|
815 | + 'user_email' => give_email_tag_user_email(array( |
|
817 | 816 | 'payment_id' => $payment_id, |
818 | 817 | 'user_id' => $user_id, |
819 | - ) ), |
|
820 | - 'payment_total' => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
821 | - 'amount' => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
822 | - 'price' => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
823 | - 'payment_method' => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ), |
|
818 | + )), |
|
819 | + 'payment_total' => $payment_id ? give_email_tag_payment_total(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
820 | + 'amount' => $payment_id ? give_email_tag_amount(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
821 | + 'price' => $payment_id ? give_email_tag_price(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
822 | + 'payment_method' => $payment_id ? give_email_tag_payment_method(array('payment_id' => $payment_id)) : __('PayPal', 'give'), |
|
824 | 823 | 'receipt_id' => $receipt_id, |
825 | - 'payment_id' => $payment_id ? $payment_id : rand( 2000, 2050 ), |
|
824 | + 'payment_id' => $payment_id ? $payment_id : rand(2000, 2050), |
|
826 | 825 | 'receipt_link_url' => $receipt_link_url, |
827 | 826 | 'receipt_link' => $receipt_link, |
828 | - 'date' => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ), |
|
829 | - 'donation' => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ), |
|
830 | - 'form_title' => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), |
|
831 | - 'sitename' => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ), |
|
827 | + 'date' => $payment_id ? date(give_date_format(), strtotime($payment->date)) : date(give_date_format(), current_time('timestamp')), |
|
828 | + 'donation' => $payment_id ? give_email_tag_donation(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title', 'give'), |
|
829 | + 'form_title' => $payment_id ? give_email_tag_form_title(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), |
|
830 | + 'sitename' => $payment_id ? give_email_tag_sitename(array('payment_id' => $payment_id)) : get_bloginfo('name'), |
|
832 | 831 | 'pdf_receipt' => sprintf( |
833 | 832 | '<a href="#">%s</a>', |
834 | - __( 'Download Receipt', 'give' ) |
|
833 | + __('Download Receipt', 'give') |
|
835 | 834 | ), |
836 | - 'billing_address' => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '', |
|
835 | + 'billing_address' => $payment_id ? give_email_tag_billing_address(array('payment_id' => $payment_id)) : '', |
|
837 | 836 | 'email_access_link' => sprintf( |
838 | 837 | '<a href="%1$s">%2$s</a>', |
839 | 838 | add_query_arg( |
@@ -842,20 +841,20 @@ discard block |
||
842 | 841 | ), |
843 | 842 | give_get_history_page_uri() |
844 | 843 | ), |
845 | - __( 'View your donation history »', 'give' ) |
|
844 | + __('View your donation history »', 'give') |
|
846 | 845 | ), |
847 | - 'reset_password_link' => $user_id ? give_email_tag_reset_password_link( array( 'user_id' => $user_id ), $payment_id ) : '', |
|
846 | + 'reset_password_link' => $user_id ? give_email_tag_reset_password_link(array('user_id' => $user_id), $payment_id) : '', |
|
848 | 847 | ) |
849 | 848 | ); |
850 | 849 | |
851 | 850 | // Decode tags. |
852 | - foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) { |
|
853 | - if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) { |
|
854 | - $message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message ); |
|
851 | + foreach ($this->config['preview_email_tags_values'] as $preview_tag => $value) { |
|
852 | + if (isset($this->config['preview_email_tags_values'][$preview_tag])) { |
|
853 | + $message = str_replace("{{$preview_tag}}", $this->config['preview_email_tags_values'][$preview_tag], $message); |
|
855 | 854 | } |
856 | 855 | } |
857 | 856 | |
858 | - return apply_filters( 'give_email_preview_template_tags', $message ); |
|
857 | + return apply_filters('give_email_preview_template_tags', $message); |
|
859 | 858 | } |
860 | 859 | |
861 | 860 | /** |
@@ -880,17 +879,17 @@ discard block |
||
880 | 879 | * @param $post_id |
881 | 880 | * |
882 | 881 | */ |
883 | - public function validate_form_recipient_field_value( $form_meta_key, $form_meta_value, $post_id ) { |
|
882 | + public function validate_form_recipient_field_value($form_meta_key, $form_meta_value, $post_id) { |
|
884 | 883 | // Get valid emails. |
885 | - $new_form_meta_value = array_filter( $form_meta_value, function ( $value ) { |
|
886 | - return ! empty( $value['email'] ) && is_email( $value['email'] ); |
|
884 | + $new_form_meta_value = array_filter($form_meta_value, function($value) { |
|
885 | + return ! empty($value['email']) && is_email($value['email']); |
|
887 | 886 | } ); |
888 | 887 | |
889 | 888 | // Remove duplicate emails from array. |
890 | 889 | $email_arr = array(); |
891 | - foreach ( $new_form_meta_value as $index => $email ) { |
|
892 | - if( in_array( $email['email'], $email_arr ) ) { |
|
893 | - unset( $new_form_meta_value[$index] ); |
|
890 | + foreach ($new_form_meta_value as $index => $email) { |
|
891 | + if (in_array($email['email'], $email_arr)) { |
|
892 | + unset($new_form_meta_value[$index]); |
|
894 | 893 | continue; |
895 | 894 | } |
896 | 895 | |
@@ -899,25 +898,25 @@ discard block |
||
899 | 898 | |
900 | 899 | $update = false; |
901 | 900 | |
902 | - if ( empty( $new_form_meta_value ) ) { |
|
901 | + if (empty($new_form_meta_value)) { |
|
903 | 902 | // Set default recipient. |
904 | 903 | $form_meta_value = array( |
905 | 904 | array( |
906 | - 'email' => get_bloginfo( 'admin_email' ) |
|
905 | + 'email' => get_bloginfo('admin_email') |
|
907 | 906 | ), |
908 | 907 | ); |
909 | 908 | |
910 | 909 | $update = true; |
911 | 910 | |
912 | - } elseif ( count( $new_form_meta_value ) !== count( $form_meta_value ) ) { |
|
911 | + } elseif (count($new_form_meta_value) !== count($form_meta_value)) { |
|
913 | 912 | // Filter recipient emails. |
914 | 913 | $form_meta_value = $new_form_meta_value; |
915 | 914 | |
916 | 915 | $update = true; |
917 | 916 | } |
918 | 917 | |
919 | - if( $update ) { |
|
920 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
918 | + if ($update) { |
|
919 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
921 | 920 | } |
922 | 921 | } |
923 | 922 | } |
@@ -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 | |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @since 1.0 |
64 | 64 | */ |
65 | - public function __construct( $shortcode ) { |
|
65 | + public function __construct($shortcode) { |
|
66 | 66 | |
67 | 67 | $this->shortcode_tag = $shortcode; |
68 | 68 | |
69 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
69 | + add_action('admin_init', array($this, 'init')); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function init() { |
79 | 79 | |
80 | - if ( $this->shortcode_tag ) { |
|
80 | + if ($this->shortcode_tag) { |
|
81 | 81 | |
82 | - $this->self = get_class( $this ); |
|
82 | + $this->self = get_class($this); |
|
83 | 83 | |
84 | 84 | $this->errors = array(); |
85 | 85 | $this->required = array(); |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | $fields = $this->get_fields(); |
89 | 89 | |
90 | 90 | $defaults = array( |
91 | - 'btn_close' => esc_html__( 'Close', 'give' ), |
|
92 | - 'btn_okay' => esc_html__( 'Insert Shortcode', 'give' ), |
|
91 | + 'btn_close' => esc_html__('Close', 'give'), |
|
92 | + 'btn_okay' => esc_html__('Insert Shortcode', 'give'), |
|
93 | 93 | 'errors' => $this->errors, |
94 | 94 | 'fields' => $fields, |
95 | - 'label' => '[' . $this->shortcode_tag . ']', |
|
95 | + 'label' => '['.$this->shortcode_tag.']', |
|
96 | 96 | 'required' => $this->required, |
97 | - 'title' => esc_html__( 'Insert Shortcode', 'give' ), |
|
97 | + 'title' => esc_html__('Insert Shortcode', 'give'), |
|
98 | 98 | ); |
99 | 99 | |
100 | - if ( user_can_richedit() ) { |
|
100 | + if (user_can_richedit()) { |
|
101 | 101 | |
102 | - Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults ); |
|
102 | + Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults); |
|
103 | 103 | |
104 | 104 | } |
105 | 105 | } |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | - protected function generate_fields( $defined_fields ) { |
|
131 | + protected function generate_fields($defined_fields) { |
|
132 | 132 | |
133 | 133 | $fields = array(); |
134 | 134 | |
135 | - if ( is_array( $defined_fields ) ) { |
|
135 | + if (is_array($defined_fields)) { |
|
136 | 136 | |
137 | - foreach ( $defined_fields as $field ) { |
|
137 | + foreach ($defined_fields as $field) { |
|
138 | 138 | |
139 | 139 | $defaults = array( |
140 | 140 | 'label' => false, |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | 'type' => '', |
146 | 146 | ); |
147 | 147 | |
148 | - $field = wp_parse_args( (array) $field, $defaults ); |
|
149 | - $method = 'generate_' . strtolower( $field['type'] ); |
|
148 | + $field = wp_parse_args((array) $field, $defaults); |
|
149 | + $method = 'generate_'.strtolower($field['type']); |
|
150 | 150 | |
151 | - if ( method_exists( $this, $method ) ) { |
|
151 | + if (method_exists($this, $method)) { |
|
152 | 152 | |
153 | - $field = call_user_func( array( $this, $method ), $field ); |
|
153 | + $field = call_user_func(array($this, $method), $field); |
|
154 | 154 | |
155 | - if ( $field ) { |
|
155 | + if ($field) { |
|
156 | 156 | $fields[] = $field; |
157 | 157 | } |
158 | 158 | } |
@@ -172,23 +172,23 @@ discard block |
||
172 | 172 | protected function get_fields() { |
173 | 173 | |
174 | 174 | $defined_fields = $this->define_fields(); |
175 | - $generated_fields = $this->generate_fields( $defined_fields ); |
|
175 | + $generated_fields = $this->generate_fields($defined_fields); |
|
176 | 176 | |
177 | 177 | $errors = array(); |
178 | 178 | |
179 | - if ( ! empty( $this->errors ) ) { |
|
180 | - foreach ( $this->required as $name => $alert ) { |
|
179 | + if ( ! empty($this->errors)) { |
|
180 | + foreach ($this->required as $name => $alert) { |
|
181 | 181 | // Using WordPress function in place of array_column wp_list_pluck as it support older version as well. |
182 | - if ( false === array_search( $name, give_list_pluck( $generated_fields, 'name' ) ) ) { |
|
182 | + if (false === array_search($name, give_list_pluck($generated_fields, 'name'))) { |
|
183 | 183 | |
184 | - $errors[] = $this->errors[ $name ]; |
|
184 | + $errors[] = $this->errors[$name]; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | $this->errors = $errors; |
189 | 189 | } |
190 | 190 | |
191 | - if ( ! empty( $errors ) ) { |
|
191 | + if ( ! empty($errors)) { |
|
192 | 192 | |
193 | 193 | return $errors; |
194 | 194 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - protected function generate_container( $field ) { |
|
208 | + protected function generate_container($field) { |
|
209 | 209 | |
210 | - if ( array_key_exists( 'html', $field ) ) { |
|
210 | + if (array_key_exists('html', $field)) { |
|
211 | 211 | |
212 | 212 | return array( |
213 | 213 | 'type' => $field['type'], |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0 |
229 | 229 | */ |
230 | - protected function generate_listbox( $field ) { |
|
230 | + protected function generate_listbox($field) { |
|
231 | 231 | |
232 | - $listbox = shortcode_atts( array( |
|
232 | + $listbox = shortcode_atts(array( |
|
233 | 233 | 'label' => '', |
234 | 234 | 'minWidth' => '', |
235 | 235 | 'name' => false, |
@@ -237,27 +237,27 @@ discard block |
||
237 | 237 | 'type' => '', |
238 | 238 | 'value' => '', |
239 | 239 | 'classes' => '' |
240 | - ), $field ); |
|
240 | + ), $field); |
|
241 | 241 | |
242 | - if ( $this->validate( $field ) ) { |
|
242 | + if ($this->validate($field)) { |
|
243 | 243 | |
244 | 244 | $new_listbox = array(); |
245 | 245 | |
246 | - foreach ( $listbox as $key => $value ) { |
|
246 | + foreach ($listbox as $key => $value) { |
|
247 | 247 | |
248 | - if ( $key == 'value' && empty( $value ) ) { |
|
249 | - $new_listbox[ $key ] = $listbox['name']; |
|
250 | - } else if ( $value ) { |
|
251 | - $new_listbox[ $key ] = $value; |
|
248 | + if ($key == 'value' && empty($value)) { |
|
249 | + $new_listbox[$key] = $listbox['name']; |
|
250 | + } else if ($value) { |
|
251 | + $new_listbox[$key] = $value; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | // do not reindex array! |
256 | 256 | $field['options'] = array( |
257 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
257 | + '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')), |
|
258 | 258 | ) + $field['options']; |
259 | 259 | |
260 | - foreach ( $field['options'] as $value => $text ) { |
|
260 | + foreach ($field['options'] as $value => $text) { |
|
261 | 261 | $new_listbox['values'][] = array( |
262 | 262 | 'text' => $text, |
263 | 263 | 'value' => $value, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @since 1.0 |
281 | 281 | */ |
282 | - protected function generate_post( $field ) { |
|
282 | + protected function generate_post($field) { |
|
283 | 283 | |
284 | 284 | $args = array( |
285 | 285 | 'post_type' => 'post', |
@@ -289,26 +289,26 @@ discard block |
||
289 | 289 | 'posts_per_page' => 500, |
290 | 290 | ); |
291 | 291 | |
292 | - $args = wp_parse_args( (array) $field['query_args'], $args ); |
|
293 | - $posts = new WP_Query( $args ); |
|
292 | + $args = wp_parse_args((array) $field['query_args'], $args); |
|
293 | + $posts = new WP_Query($args); |
|
294 | 294 | $options = array(); |
295 | 295 | |
296 | - if ( $posts->have_posts() ) { |
|
297 | - while ( $posts->have_posts() ) { |
|
296 | + if ($posts->have_posts()) { |
|
297 | + while ($posts->have_posts()) { |
|
298 | 298 | $posts->the_post(); |
299 | 299 | $post_title = get_the_title(); |
300 | 300 | $post_id = get_the_ID(); |
301 | - $options[ absint( $post_id ) ] = ( empty( $post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $post_id ) : $post_title ); |
|
301 | + $options[absint($post_id)] = (empty($post_title) ? sprintf(__('Untitled (#%s)', 'give'), $post_id) : $post_title); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | $field['type'] = 'listbox'; |
305 | 305 | $field['options'] = $options; |
306 | 306 | |
307 | - return $this->generate_listbox( $field ); |
|
307 | + return $this->generate_listbox($field); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // perform validation here before returning false |
311 | - $this->validate( $field ); |
|
311 | + $this->validate($field); |
|
312 | 312 | |
313 | 313 | return false; |
314 | 314 | } |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @since 1.0 |
324 | 324 | */ |
325 | - protected function generate_textbox( $field ) { |
|
325 | + protected function generate_textbox($field) { |
|
326 | 326 | |
327 | - $textbox = shortcode_atts( array( |
|
327 | + $textbox = shortcode_atts(array( |
|
328 | 328 | 'label' => '', |
329 | 329 | 'maxLength' => '', |
330 | 330 | 'minHeight' => '', |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | 'type' => '', |
336 | 336 | 'value' => '', |
337 | 337 | 'classes' => '' |
338 | - ), $field ); |
|
338 | + ), $field); |
|
339 | 339 | |
340 | - if ( $this->validate( $field ) ) { |
|
341 | - return array_filter( $textbox, array( $this, 'return_textbox_value' ) ); |
|
340 | + if ($this->validate($field)) { |
|
341 | + return array_filter($textbox, array($this, 'return_textbox_value')); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return false; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return bool |
353 | 353 | */ |
354 | - function return_textbox_value( $value ) { |
|
354 | + function return_textbox_value($value) { |
|
355 | 355 | return $value !== ''; |
356 | 356 | } |
357 | 357 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @since 1.0 |
369 | 369 | */ |
370 | - protected function validate( $field ) { |
|
370 | + protected function validate($field) { |
|
371 | 371 | |
372 | - extract( shortcode_atts( |
|
372 | + extract(shortcode_atts( |
|
373 | 373 | array( |
374 | 374 | 'name' => false, |
375 | 375 | 'required' => false, |
@@ -377,36 +377,36 @@ discard block |
||
377 | 377 | ), $field ) |
378 | 378 | ); |
379 | 379 | |
380 | - if ( $name ) { |
|
380 | + if ($name) { |
|
381 | 381 | |
382 | - if ( isset( $required['error'] ) ) { |
|
382 | + if (isset($required['error'])) { |
|
383 | 383 | |
384 | 384 | $error = array( |
385 | 385 | 'type' => 'container', |
386 | 386 | 'html' => $required['error'], |
387 | 387 | ); |
388 | 388 | |
389 | - $this->errors[ $name ] = $this->generate_container( $error ); |
|
389 | + $this->errors[$name] = $this->generate_container($error); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( ! ! $required || is_array( $required ) ) { |
|
392 | + if ( ! ! $required || is_array($required)) { |
|
393 | 393 | |
394 | - $alert = esc_html__( 'Some of the shortcode options are required.', 'give' ); |
|
394 | + $alert = esc_html__('Some of the shortcode options are required.', 'give'); |
|
395 | 395 | |
396 | - if ( isset( $required['alert'] ) ) { |
|
396 | + if (isset($required['alert'])) { |
|
397 | 397 | |
398 | 398 | $alert = $required['alert']; |
399 | 399 | |
400 | - } else if ( ! empty( $label ) ) { |
|
400 | + } else if ( ! empty($label)) { |
|
401 | 401 | |
402 | 402 | $alert = sprintf( |
403 | 403 | /* translators: %s: option label */ |
404 | - esc_html__( 'The "%s" option is required.', 'give' ), |
|
405 | - str_replace( ':', '', $label ) |
|
404 | + esc_html__('The "%s" option is required.', 'give'), |
|
405 | + str_replace(':', '', $label) |
|
406 | 406 | ); |
407 | 407 | } |
408 | 408 | |
409 | - $this->required[ $name ] = $alert; |
|
409 | + $this->required[$name] = $alert; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | return true; |
@@ -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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', __( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', __('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats(); ?> |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date_i18n( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date_i18n(_x('F j, Y', 'dashboard widget', 'give')); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - __( 'Happy %s!', 'give' ), |
|
55 | - date_i18n( 'l', current_time( 'timestamp' ) ) |
|
54 | + __('Happy %s!', 'give'), |
|
55 | + date_i18n('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | 59 | <p class="give-dashboard-today-earnings"><?php |
60 | - $earnings_today = $stats->get_earnings( 0, 'today', false ); |
|
61 | - echo give_currency_filter( give_format_amount( $earnings_today, array( 'sanitize' => false ) ) ); |
|
60 | + $earnings_today = $stats->get_earnings(0, 'today', false); |
|
61 | + echo give_currency_filter(give_format_amount($earnings_today, array('sanitize' => false))); |
|
62 | 62 | ?></p> |
63 | 63 | |
64 | 64 | <p class="give-donations-today"><?php |
65 | - $donations_today = $stats->get_sales( 0, 'today', false ); |
|
65 | + $donations_today = $stats->get_sales(0, 'today', false); |
|
66 | 66 | printf( |
67 | 67 | /* translators: %s: daily donation count */ |
68 | - __( '%s donations today', 'give' ), |
|
69 | - give_format_amount( $donations_today, array( 'decimal' => false, 'sanitize' => false ) ) |
|
68 | + __('%s donations today', 'give'), |
|
69 | + give_format_amount($donations_today, array('decimal' => false, 'sanitize' => false)) |
|
70 | 70 | ); |
71 | 71 | ?></p> |
72 | 72 | |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | <table class="give-table-stats"> |
77 | 77 | <thead style="display: none;"> |
78 | 78 | <tr> |
79 | - <th><?php _e( 'This Week', 'give' ); ?></th> |
|
80 | - <th><?php _e( 'This Month', 'give' ); ?></th> |
|
81 | - <th><?php _e( 'Past 30 Days', 'give' ); ?></th> |
|
79 | + <th><?php _e('This Week', 'give'); ?></th> |
|
80 | + <th><?php _e('This Month', 'give'); ?></th> |
|
81 | + <th><?php _e('Past 30 Days', 'give'); ?></th> |
|
82 | 82 | </tr> |
83 | 83 | </thead> |
84 | 84 | <tbody> |
85 | 85 | <tr id="give-table-stats-tr-1"> |
86 | 86 | <td> |
87 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ), array( 'sanitize' => false ) ) ); ?></p> |
|
87 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'), array('sanitize' => false))); ?></p> |
|
88 | 88 | |
89 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Week', 'give' ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total-label"><?php _e('This Week', 'give'); ?></p> |
|
90 | 90 | </td> |
91 | 91 | <td> |
92 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ), array( 'sanitize' => false ) ) ); ?></p> |
|
92 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'), array('sanitize' => false))); ?></p> |
|
93 | 93 | |
94 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Month', 'give' ); ?></p> |
|
94 | + <p class="give-dashboard-stat-total-label"><?php _e('This Month', 'give'); ?></p> |
|
95 | 95 | </td> |
96 | 96 | </tr> |
97 | 97 | <tr id="give-table-stats-tr-2"> |
98 | 98 | <td> |
99 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) ) ?></p> |
|
99 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'), array('sanitize' => false))) ?></p> |
|
100 | 100 | |
101 | - <p class="give-dashboard-stat-total-label"><?php _e( 'Last Month', 'give' ); ?></p> |
|
101 | + <p class="give-dashboard-stat-total-label"><?php _e('Last Month', 'give'); ?></p> |
|
102 | 102 | </td> |
103 | 103 | <td> |
104 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( give_get_total_earnings(), array( 'sanitize' => false ) ) ) ?></p> |
|
104 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount(give_get_total_earnings(), array('sanitize' => false))) ?></p> |
|
105 | 105 | |
106 | - <p class="give-dashboard-stat-total-label"><?php _e( 'This Year', 'give' ); ?></p> |
|
106 | + <p class="give-dashboard-stat-total-label"><?php _e('This Year', 'give'); ?></p> |
|
107 | 107 | </td> |
108 | 108 | </tr> |
109 | 109 | </tbody> |
@@ -123,24 +123,24 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
126 | +function give_dashboard_at_a_glance_widget($items) { |
|
127 | 127 | |
128 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
128 | + $num_posts = wp_count_posts('give_forms'); |
|
129 | 129 | |
130 | - if ( $num_posts && $num_posts->publish ) { |
|
130 | + if ($num_posts && $num_posts->publish) { |
|
131 | 131 | |
132 | 132 | $text = sprintf( |
133 | 133 | /* translators: %s: number of posts published */ |
134 | - _n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ), |
|
134 | + _n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'), |
|
135 | 135 | $num_posts->publish |
136 | 136 | ); |
137 | 137 | |
138 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
138 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
139 | 139 | |
140 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
140 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
141 | 141 | $text = sprintf( |
142 | 142 | '<a class="give-forms-count" href="%1$s">%2$s</a>', |
143 | - admin_url( 'edit.php?post_type=give_forms' ), |
|
143 | + admin_url('edit.php?post_type=give_forms'), |
|
144 | 144 | $text |
145 | 145 | ); |
146 | 146 | } else { |
@@ -156,4 +156,4 @@ discard block |
||
156 | 156 | return $items; |
157 | 157 | } |
158 | 158 | |
159 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
159 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1); |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | * @since 1.8.14 |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; // Exit if accessed directly |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Give_Import_Donations' ) ) { |
|
18 | +if ( ! class_exists('Give_Import_Donations')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Give_Import_Donations. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @access private |
58 | 58 | */ |
59 | 59 | private function __construct() { |
60 | - self::$per_page = ! empty( $_GET['per_page'] ) ? absint( $_GET['per_page'] ) : self::$per_page; |
|
60 | + self::$per_page = ! empty($_GET['per_page']) ? absint($_GET['per_page']) : self::$per_page; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return static |
70 | 70 | */ |
71 | 71 | public static function get_instance() { |
72 | - if ( null === static::$instance ) { |
|
72 | + if (null === static::$instance) { |
|
73 | 73 | self::$instance = new static(); |
74 | 74 | } |
75 | 75 | |
@@ -96,27 +96,27 @@ discard block |
||
96 | 96 | * @return void |
97 | 97 | */ |
98 | 98 | private function setup_hooks() { |
99 | - if ( ! $this->is_donations_import_page() ) { |
|
99 | + if ( ! $this->is_donations_import_page()) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Do not render main import tools page. |
104 | - remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) ); |
|
104 | + remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',)); |
|
105 | 105 | |
106 | 106 | |
107 | 107 | // Render donation import page |
108 | - add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) ); |
|
108 | + add_action('give_admin_field_tools_import', array($this, 'render_page')); |
|
109 | 109 | |
110 | 110 | // Print the HTML. |
111 | - add_action( 'give_tools_import_donations_form_start', array( $this, 'html' ), 10 ); |
|
111 | + add_action('give_tools_import_donations_form_start', array($this, 'html'), 10); |
|
112 | 112 | |
113 | 113 | // Run when form submit. |
114 | - add_action( 'give-tools_save_import', array( $this, 'save' ) ); |
|
114 | + add_action('give-tools_save_import', array($this, 'save')); |
|
115 | 115 | |
116 | - add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 ); |
|
116 | + add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1); |
|
117 | 117 | |
118 | 118 | // Used to add submit button. |
119 | - add_action( 'give_tools_import_donations_form_end', array( $this, 'submit' ), 10 ); |
|
119 | + add_action('give_tools_import_donations_form_end', array($this, 'submit'), 10); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return mixed |
130 | 130 | */ |
131 | - public function update_notices( $messages ) { |
|
132 | - if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) { |
|
133 | - unset( $messages['give-setting-updated'] ); |
|
131 | + public function update_notices($messages) { |
|
132 | + if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) { |
|
133 | + unset($messages['give-setting-updated']); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return $messages; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @since 1.8.14 |
143 | 143 | */ |
144 | 144 | public function submit() { |
145 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
145 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
146 | 146 | ?> |
147 | 147 | <input type="hidden" class="import-step" id="import-step" name="step" value="<?php echo $this->get_step(); ?>"/> |
148 | 148 | <input type="hidden" class="importer-type" value="<?php echo $this->importer_type; ?>"/> |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | <table class="widefat export-options-table give-table <?php echo "step-{$step}"; ?>" id="<?php echo "step-{$step}"; ?>"> |
165 | 165 | <tbody> |
166 | 166 | <?php |
167 | - switch ( $this->get_step() ) { |
|
167 | + switch ($this->get_step()) { |
|
168 | 168 | case 1: |
169 | 169 | $this->render_media_csv(); |
170 | 170 | break; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $this->import_success(); |
182 | 182 | } |
183 | 183 | |
184 | - if ( false === $this->check_for_dropdown_or_import() ) { |
|
184 | + if (false === $this->check_for_dropdown_or_import()) { |
|
185 | 185 | ?> |
186 | 186 | <tr valign="top"> |
187 | 187 | <th></th> |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | <input type="submit" |
190 | 190 | class=" button button-primary button-large button-secondary <?php echo "step-{$step}"; ?>" |
191 | 191 | id="recount-stats-submit" |
192 | - <?php echo ( 2 === $step ) ? 'disabled' : ''; ?> |
|
193 | - value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/> |
|
192 | + <?php echo (2 === $step) ? 'disabled' : ''; ?> |
|
193 | + value="<?php esc_attr_e('Submit', 'give'); ?>"/> |
|
194 | 194 | </th> |
195 | 195 | </tr> |
196 | 196 | <?php |
@@ -209,57 +209,57 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function import_success() { |
211 | 211 | |
212 | - $delete_csv = ( ! empty( $_GET['delete_csv'] ) ? absint( $_GET['delete_csv'] ) : false ); |
|
213 | - $csv = ( ! empty( $_GET['csv'] ) ? absint( $_GET['csv'] ) : false ); |
|
214 | - if ( ! empty( $delete_csv ) && ! empty( $csv ) ) { |
|
215 | - wp_delete_attachment( $csv, true ); |
|
212 | + $delete_csv = ( ! empty($_GET['delete_csv']) ? absint($_GET['delete_csv']) : false); |
|
213 | + $csv = ( ! empty($_GET['csv']) ? absint($_GET['csv']) : false); |
|
214 | + if ( ! empty($delete_csv) && ! empty($csv)) { |
|
215 | + wp_delete_attachment($csv, true); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | $report = give_import_donation_report(); |
219 | 219 | |
220 | 220 | $report_html = array( |
221 | 221 | 'duplicate_donor' => array( |
222 | - __( '%s duplicate %s detected', 'give' ), |
|
223 | - __( 'donor', 'give' ), |
|
224 | - __( 'donors', 'give' ), |
|
222 | + __('%s duplicate %s detected', 'give'), |
|
223 | + __('donor', 'give'), |
|
224 | + __('donors', 'give'), |
|
225 | 225 | ), |
226 | 226 | 'create_donor' => array( |
227 | - __( '%s %s created', 'give' ), |
|
228 | - __( 'donor', 'give' ), |
|
229 | - __( 'donors', 'give' ), |
|
227 | + __('%s %s created', 'give'), |
|
228 | + __('donor', 'give'), |
|
229 | + __('donors', 'give'), |
|
230 | 230 | ), |
231 | 231 | 'create_form' => array( |
232 | - __( '%s donation %s created', 'give' ), |
|
233 | - __( 'form', 'give' ), |
|
234 | - __( 'forms', 'give' ), |
|
232 | + __('%s donation %s created', 'give'), |
|
233 | + __('form', 'give'), |
|
234 | + __('forms', 'give'), |
|
235 | 235 | ), |
236 | 236 | 'duplicate_donation' => array( |
237 | - __( '%s duplicate %s detected', 'give' ), |
|
238 | - __( 'donation', 'give' ), |
|
239 | - __( 'donations', 'give' ), |
|
237 | + __('%s duplicate %s detected', 'give'), |
|
238 | + __('donation', 'give'), |
|
239 | + __('donations', 'give'), |
|
240 | 240 | ), |
241 | 241 | 'create_donation' => array( |
242 | - __( '%s %s imported', 'give' ), |
|
243 | - __( 'donation', 'give' ), |
|
244 | - __( 'donations', 'give' ), |
|
242 | + __('%s %s imported', 'give'), |
|
243 | + __('donation', 'give'), |
|
244 | + __('donations', 'give'), |
|
245 | 245 | ), |
246 | 246 | ); |
247 | - $total = (int) $_GET['total']; |
|
248 | - -- $total; |
|
247 | + $total = (int) $_GET['total']; |
|
248 | + --$total; |
|
249 | 249 | $success = (bool) $_GET['success']; |
250 | 250 | ?> |
251 | 251 | <tr valign="top" class="give-import-dropdown"> |
252 | 252 | <th colspan="2"> |
253 | 253 | <h2> |
254 | 254 | <?php |
255 | - if ( $success ) { |
|
255 | + if ($success) { |
|
256 | 256 | printf( |
257 | - _n( 'Import complete! %s donation processed', 'Import complete! %s donations processed', $total, 'give' ), |
|
257 | + _n('Import complete! %s donation processed', 'Import complete! %s donations processed', $total, 'give'), |
|
258 | 258 | "<strong>{$total}</strong>" |
259 | 259 | ); |
260 | 260 | } else { |
261 | 261 | printf( |
262 | - _n( 'Failed to import %s donation', 'Failed to import %s donations', $total, 'give' ), |
|
262 | + _n('Failed to import %s donation', 'Failed to import %s donations', $total, 'give'), |
|
263 | 263 | "<strong>{$total}</strong>" |
264 | 264 | ); |
265 | 265 | } |
@@ -267,25 +267,25 @@ discard block |
||
267 | 267 | </h2> |
268 | 268 | |
269 | 269 | <?php |
270 | - $text = __( 'Import Donation', 'give' ); |
|
270 | + $text = __('Import Donation', 'give'); |
|
271 | 271 | $query_arg = array( |
272 | 272 | 'post_type' => 'give_forms', |
273 | 273 | 'page' => 'give-tools', |
274 | 274 | 'tab' => 'import', |
275 | 275 | ); |
276 | - if ( $success ) { |
|
276 | + if ($success) { |
|
277 | 277 | $query_arg = array( |
278 | 278 | 'post_type' => 'give_forms', |
279 | 279 | 'page' => 'give-payment-history', |
280 | 280 | ); |
281 | - $text = __( 'View Donations', 'give' ); |
|
281 | + $text = __('View Donations', 'give'); |
|
282 | 282 | } |
283 | 283 | |
284 | - foreach ( $report as $key => $value ) { |
|
285 | - if ( array_key_exists( $key, $report_html ) && ! empty( $value ) ) { |
|
284 | + foreach ($report as $key => $value) { |
|
285 | + if (array_key_exists($key, $report_html) && ! empty($value)) { |
|
286 | 286 | ?> |
287 | 287 | <p> |
288 | - <?php echo esc_html( wp_sprintf( $report_html[ $key ][0], $value, _n( $report_html[ $key ][1], $report_html[ $key ][2], $value, 'give' ) ) ); ?> |
|
288 | + <?php echo esc_html(wp_sprintf($report_html[$key][0], $value, _n($report_html[$key][1], $report_html[$key][2], $value, 'give'))); ?> |
|
289 | 289 | </p> |
290 | 290 | <?php |
291 | 291 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | ?> |
294 | 294 | |
295 | 295 | <p> |
296 | - <a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a> |
|
296 | + <a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg, admin_url('edit.php')); ?>"><?php echo $text; ?></a> |
|
297 | 297 | </p> |
298 | 298 | </th> |
299 | 299 | </tr> |
@@ -310,26 +310,26 @@ discard block |
||
310 | 310 | give_import_donation_report_reset(); |
311 | 311 | |
312 | 312 | $csv = (int) $_REQUEST['csv']; |
313 | - $delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' ); |
|
313 | + $delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv'); |
|
314 | 314 | $index_start = 1; |
315 | 315 | $index_end = 1; |
316 | 316 | $next = true; |
317 | - $total = self::get_csv_total( $csv ); |
|
318 | - if ( self::$per_page < $total ) { |
|
319 | - $total_ajax = ceil( $total / self::$per_page ); |
|
317 | + $total = self::get_csv_total($csv); |
|
318 | + if (self::$per_page < $total) { |
|
319 | + $total_ajax = ceil($total / self::$per_page); |
|
320 | 320 | $index_end = self::$per_page; |
321 | 321 | } else { |
322 | 322 | $total_ajax = 1; |
323 | 323 | $index_end = $total; |
324 | 324 | $next = false; |
325 | 325 | } |
326 | - $current_percentage = 100 / ( $total_ajax + 1 ); |
|
326 | + $current_percentage = 100 / ($total_ajax + 1); |
|
327 | 327 | |
328 | 328 | ?> |
329 | 329 | <tr valign="top" class="give-import-dropdown"> |
330 | 330 | <th colspan="2"> |
331 | - <h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2> |
|
332 | - <p class="give-field-description"><?php esc_html_e( 'Your donations are now being imported...', 'give' ) ?></p> |
|
331 | + <h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2> |
|
332 | + <p class="give-field-description"><?php esc_html_e('Your donations are now being imported...', 'give') ?></p> |
|
333 | 333 | </th> |
334 | 334 | </tr> |
335 | 335 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | <div style="width: <?php echo $current_percentage; ?>%"></div> |
349 | 349 | </div> |
350 | 350 | <input type="hidden" value="3" name="step"> |
351 | - <input type="hidden" value='<?php echo maybe_serialize( $_REQUEST['mapto'] ); ?>' name="mapto" |
|
351 | + <input type="hidden" value='<?php echo maybe_serialize($_REQUEST['mapto']); ?>' name="mapto" |
|
352 | 352 | class="mapto"> |
353 | 353 | <input type="hidden" value="<?php echo $_REQUEST['csv']; ?>" name="csv" class="csv"> |
354 | 354 | <input type="hidden" value="<?php echo $_REQUEST['mode']; ?>" name="mode" class="mode"> |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | <input type="hidden" value="<?php echo $_REQUEST['delete_csv']; ?>" name="delete_csv" |
358 | 358 | class="delete_csv"> |
359 | 359 | <input type="hidden" value="<?php echo $delimiter; ?>" name="delimiter"> |
360 | - <input type="hidden" value='<?php echo maybe_serialize( self::get_importer( $csv, 0, $delimiter ) ); ?>' |
|
360 | + <input type="hidden" value='<?php echo maybe_serialize(self::get_importer($csv, 0, $delimiter)); ?>' |
|
361 | 361 | name="main_key" |
362 | 362 | class="main_key"> |
363 | 363 | </th> |
@@ -378,20 +378,20 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function check_for_dropdown_or_import() { |
380 | 380 | $return = true; |
381 | - if ( isset( $_REQUEST['mapto'] ) ) { |
|
381 | + if (isset($_REQUEST['mapto'])) { |
|
382 | 382 | $mapto = (array) $_REQUEST['mapto']; |
383 | - if ( false === in_array( 'form_title', $mapto ) && false === in_array( 'form_id', $mapto ) ) { |
|
384 | - Give_Admin_Settings::add_error( 'give-import-csv-form', __( 'In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give' ) ); |
|
383 | + if (false === in_array('form_title', $mapto) && false === in_array('form_id', $mapto)) { |
|
384 | + Give_Admin_Settings::add_error('give-import-csv-form', __('In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give')); |
|
385 | 385 | $return = false; |
386 | 386 | } |
387 | 387 | |
388 | - if ( false === in_array( 'amount', $mapto ) ) { |
|
389 | - Give_Admin_Settings::add_error( 'give-import-csv-amount', __( 'In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give' ) ); |
|
388 | + if (false === in_array('amount', $mapto)) { |
|
389 | + Give_Admin_Settings::add_error('give-import-csv-amount', __('In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give')); |
|
390 | 390 | $return = false; |
391 | 391 | } |
392 | 392 | |
393 | - if ( false === in_array( 'email', $mapto ) && false === in_array( 'donor_id', $mapto ) ) { |
|
394 | - Give_Admin_Settings::add_error( 'give-import-csv-donor', __( 'In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give' ) ); |
|
393 | + if (false === in_array('email', $mapto) && false === in_array('donor_id', $mapto)) { |
|
394 | + Give_Admin_Settings::add_error('give-import-csv-donor', __('In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give')); |
|
395 | 395 | $return = false; |
396 | 396 | } |
397 | 397 | } else { |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | */ |
409 | 409 | public function render_dropdown() { |
410 | 410 | $csv = (int) $_GET['csv']; |
411 | - $delimiter = ( ! empty( $_GET['delimiter'] ) ? give_clean( $_GET['delimiter'] ) : 'csv' ); |
|
411 | + $delimiter = ( ! empty($_GET['delimiter']) ? give_clean($_GET['delimiter']) : 'csv'); |
|
412 | 412 | |
413 | 413 | // TO check if the CSV files that is being add is valid or not if not then redirect to first step again |
414 | - if ( ! $this->is_valid_csv( $csv ) ) { |
|
414 | + if ( ! $this->is_valid_csv($csv)) { |
|
415 | 415 | $url = give_import_page_url(); |
416 | 416 | ?> |
417 | 417 | <script type="text/javascript"> |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | ?> |
423 | 423 | <tr valign="top" class="give-import-dropdown"> |
424 | 424 | <th colspan="2"> |
425 | - <h2 id="give-import-title"><?php esc_html_e( 'Map CSV fields to donations', 'give' ) ?></h2> |
|
425 | + <h2 id="give-import-title"><?php esc_html_e('Map CSV fields to donations', 'give') ?></h2> |
|
426 | 426 | |
427 | - <p class="give-import-donation-required-fields-title"><?php _e( 'Required Fields' ); ?></p> |
|
427 | + <p class="give-import-donation-required-fields-title"><?php _e('Required Fields'); ?></p> |
|
428 | 428 | |
429 | - <p class="give-field-description"><?php _e( 'These fields are required for the import to submitted' ); ?></p> |
|
429 | + <p class="give-field-description"><?php _e('These fields are required for the import to submitted'); ?></p> |
|
430 | 430 | |
431 | 431 | <ul class="give-import-donation-required-fields"> |
432 | 432 | <li class="give-import-donation-required-email" title="Please configure all required fields to start the import process."> |
433 | 433 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
434 | 434 | <span class="give-import-donation-required-text"> |
435 | 435 | <?php |
436 | - _e( 'Email Access', 'give' ); |
|
436 | + _e('Email Access', 'give'); |
|
437 | 437 | ?> |
438 | 438 | </span> |
439 | 439 | </li> |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
443 | 443 | <span class="give-import-donation-required-text"> |
444 | 444 | <?php |
445 | - _e( 'First Name', 'give' ); |
|
445 | + _e('First Name', 'give'); |
|
446 | 446 | ?> |
447 | 447 | </span> |
448 | 448 | </li> |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
452 | 452 | <span class="give-import-donation-required-text"> |
453 | 453 | <?php |
454 | - _e( 'Donation Amount', 'give' ); |
|
454 | + _e('Donation Amount', 'give'); |
|
455 | 455 | ?> |
456 | 456 | </span> |
457 | 457 | </li> |
@@ -460,32 +460,32 @@ discard block |
||
460 | 460 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
461 | 461 | <span class="give-import-donation-required-text"> |
462 | 462 | <?php |
463 | - _e( 'Form Title or ID', 'give' ); |
|
463 | + _e('Form Title or ID', 'give'); |
|
464 | 464 | ?> |
465 | 465 | </span> |
466 | 466 | </li> |
467 | 467 | </ul> |
468 | 468 | |
469 | - <p class="give-field-description"><?php esc_html_e( 'Select fields from your CSV file to map against donations fields or to ignore during import.', 'give' ) ?></p> |
|
469 | + <p class="give-field-description"><?php esc_html_e('Select fields from your CSV file to map against donations fields or to ignore during import.', 'give') ?></p> |
|
470 | 470 | </th> |
471 | 471 | </tr> |
472 | 472 | |
473 | 473 | <tr valign="top" class="give-import-dropdown"> |
474 | - <th><b><?php esc_html_e( 'Column name', 'give' ); ?></b></th> |
|
475 | - <th><b><?php esc_html_e( 'Map to field', 'give' ); ?></b></th> |
|
474 | + <th><b><?php esc_html_e('Column name', 'give'); ?></b></th> |
|
475 | + <th><b><?php esc_html_e('Map to field', 'give'); ?></b></th> |
|
476 | 476 | </tr> |
477 | 477 | |
478 | 478 | <?php |
479 | - $raw_key = $this->get_importer( $csv, 0, $delimiter ); |
|
480 | - $mapto = (array) ( isset( $_REQUEST['mapto'] ) ? $_REQUEST['mapto'] : array() ); |
|
479 | + $raw_key = $this->get_importer($csv, 0, $delimiter); |
|
480 | + $mapto = (array) (isset($_REQUEST['mapto']) ? $_REQUEST['mapto'] : array()); |
|
481 | 481 | |
482 | - foreach ( $raw_key as $index => $value ) { |
|
482 | + foreach ($raw_key as $index => $value) { |
|
483 | 483 | ?> |
484 | 484 | <tr valign="top" class="give-import-option"> |
485 | 485 | <th><?php echo $value; ?></th> |
486 | 486 | <th> |
487 | 487 | <?php |
488 | - $this->get_columns( $index, $value, $mapto ); |
|
488 | + $this->get_columns($index, $value, $mapto); |
|
489 | 489 | ?> |
490 | 490 | </th> |
491 | 491 | </tr> |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public function selected( $option_value, $value ) { |
|
504 | - $option_value = strtolower( $option_value ); |
|
505 | - $value = strtolower( $value ); |
|
503 | + public function selected($option_value, $value) { |
|
504 | + $option_value = strtolower($option_value); |
|
505 | + $value = strtolower($value); |
|
506 | 506 | |
507 | 507 | $selected = ''; |
508 | - if ( stristr( $value, $option_value ) ) { |
|
508 | + if (stristr($value, $option_value)) { |
|
509 | 509 | $selected = 'selected'; |
510 | - } elseif ( strrpos( $value, '_' ) && stristr( $option_value, __( 'Import as Meta', 'give' ) ) ) { |
|
510 | + } elseif (strrpos($value, '_') && stristr($option_value, __('Import as Meta', 'give'))) { |
|
511 | 511 | $selected = 'selected'; |
512 | 512 | } |
513 | 513 | |
@@ -526,28 +526,28 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return void |
528 | 528 | */ |
529 | - private function get_columns( $index, $value = false, $mapto = array() ) { |
|
529 | + private function get_columns($index, $value = false, $mapto = array()) { |
|
530 | 530 | $default = give_import_default_options(); |
531 | - $current_mapto = (string) ( ! empty( $mapto[ $index ] ) ? $mapto[ $index ] : '' ); |
|
531 | + $current_mapto = (string) ( ! empty($mapto[$index]) ? $mapto[$index] : ''); |
|
532 | 532 | ?> |
533 | 533 | <select name="mapto[<?php echo $index; ?>]"> |
534 | - <?php $this->get_dropdown_option_html( $default, $current_mapto, $value ); ?> |
|
534 | + <?php $this->get_dropdown_option_html($default, $current_mapto, $value); ?> |
|
535 | 535 | |
536 | - <optgroup label="<?php _e( 'Donations', 'give' ); ?>"> |
|
536 | + <optgroup label="<?php _e('Donations', 'give'); ?>"> |
|
537 | 537 | <?php |
538 | - $this->get_dropdown_option_html( give_import_donations_options(), $current_mapto, $value ); |
|
538 | + $this->get_dropdown_option_html(give_import_donations_options(), $current_mapto, $value); |
|
539 | 539 | ?> |
540 | 540 | </optgroup> |
541 | 541 | |
542 | - <optgroup label="<?php _e( 'Donors', 'give' ); ?>"> |
|
542 | + <optgroup label="<?php _e('Donors', 'give'); ?>"> |
|
543 | 543 | <?php |
544 | - $this->get_dropdown_option_html( give_import_donor_options(), $current_mapto, $value ); |
|
544 | + $this->get_dropdown_option_html(give_import_donor_options(), $current_mapto, $value); |
|
545 | 545 | ?> |
546 | 546 | </optgroup> |
547 | 547 | |
548 | - <optgroup label="<?php _e( 'Forms', 'give' ); ?>"> |
|
548 | + <optgroup label="<?php _e('Forms', 'give'); ?>"> |
|
549 | 549 | <?php |
550 | - $this->get_dropdown_option_html( give_import_donation_form_options(), $current_mapto, $value ); |
|
550 | + $this->get_dropdown_option_html(give_import_donation_form_options(), $current_mapto, $value); |
|
551 | 551 | ?> |
552 | 552 | </optgroup> |
553 | 553 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @since 1.8.15 |
560 | 560 | */ |
561 | - do_action( 'give_import_dropdown_option', $index, $value, $mapto, $current_mapto ); |
|
561 | + do_action('give_import_dropdown_option', $index, $value, $mapto, $current_mapto); |
|
562 | 562 | ?> |
563 | 563 | </select> |
564 | 564 | <?php |
@@ -576,16 +576,16 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return void |
578 | 578 | */ |
579 | - public function get_dropdown_option_html( $options, $current_mapto, $value = false ) { |
|
580 | - foreach ( $options as $option => $option_value ) { |
|
579 | + public function get_dropdown_option_html($options, $current_mapto, $value = false) { |
|
580 | + foreach ($options as $option => $option_value) { |
|
581 | 581 | $option_value_texts = (array) $option_value; |
582 | 582 | $option_text = $option_value_texts[0]; |
583 | 583 | |
584 | - $checked = ( ( $current_mapto === $option ) ? 'selected' : false ); |
|
585 | - if ( empty( $checked ) ) { |
|
586 | - foreach ( $option_value_texts as $option_value_text ) { |
|
587 | - $checked = $this->selected( $option_value_text, $value ); |
|
588 | - if ( $checked ) { |
|
584 | + $checked = (($current_mapto === $option) ? 'selected' : false); |
|
585 | + if (empty($checked)) { |
|
586 | + foreach ($option_value_texts as $option_value_text) { |
|
587 | + $checked = $this->selected($option_value_text, $value); |
|
588 | + if ($checked) { |
|
589 | 589 | break; |
590 | 590 | } |
591 | 591 | } |
@@ -609,13 +609,13 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @return bool|int |
611 | 611 | */ |
612 | - public function get_csv_total( $file_id ) { |
|
612 | + public function get_csv_total($file_id) { |
|
613 | 613 | $total = false; |
614 | - if ( $file_id ) { |
|
615 | - $file_dir = get_attached_file( $file_id ); |
|
616 | - if ( $file_dir ) { |
|
617 | - $file = new SplFileObject( $file_dir, 'r' ); |
|
618 | - $file->seek( PHP_INT_MAX ); |
|
614 | + if ($file_id) { |
|
615 | + $file_dir = get_attached_file($file_id); |
|
616 | + if ($file_dir) { |
|
617 | + $file = new SplFileObject($file_dir, 'r'); |
|
618 | + $file->seek(PHP_INT_MAX); |
|
619 | 619 | $total = $file->key() + 1; |
620 | 620 | } |
621 | 621 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return array|bool $raw_data title of the CSV file fields |
636 | 636 | */ |
637 | - public function get_importer( $file_id, $index = 0, $delimiter = 'csv' ) { |
|
637 | + public function get_importer($file_id, $index = 0, $delimiter = 'csv') { |
|
638 | 638 | /** |
639 | 639 | * Filter to modify delimiter of Import. |
640 | 640 | * |
@@ -642,16 +642,16 @@ discard block |
||
642 | 642 | * |
643 | 643 | * Return string $delimiter. |
644 | 644 | */ |
645 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
645 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
646 | 646 | |
647 | 647 | $raw_data = false; |
648 | - $file_dir = get_attached_file( $file_id ); |
|
649 | - if ( $file_dir ) { |
|
650 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
651 | - $raw_data = fgetcsv( $handle, $index, $delimiter ); |
|
648 | + $file_dir = get_attached_file($file_id); |
|
649 | + if ($file_dir) { |
|
650 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
651 | + $raw_data = fgetcsv($handle, $index, $delimiter); |
|
652 | 652 | // Remove BOM signature from the first item. |
653 | - if ( isset( $raw_data[0] ) ) { |
|
654 | - $raw_data[0] = $this->remove_utf8_bom( $raw_data[0] ); |
|
653 | + if (isset($raw_data[0])) { |
|
654 | + $raw_data[0] = $this->remove_utf8_bom($raw_data[0]); |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | } |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | * |
669 | 669 | * @return string |
670 | 670 | */ |
671 | - public function remove_utf8_bom( $string ) { |
|
672 | - if ( 'efbbbf' === substr( bin2hex( $string ), 0, 6 ) ) { |
|
673 | - $string = substr( $string, 3 ); |
|
671 | + public function remove_utf8_bom($string) { |
|
672 | + if ('efbbbf' === substr(bin2hex($string), 0, 6)) { |
|
673 | + $string = substr($string, 3); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | return $string; |
@@ -686,17 +686,17 @@ discard block |
||
686 | 686 | $step = $this->get_step(); |
687 | 687 | ?> |
688 | 688 | <ol class="give-progress-steps"> |
689 | - <li class="<?php echo( 1 === $step ? 'active' : '' ); ?>"> |
|
690 | - <?php esc_html_e( 'Upload CSV file', 'give' ); ?> |
|
689 | + <li class="<?php echo(1 === $step ? 'active' : ''); ?>"> |
|
690 | + <?php esc_html_e('Upload CSV file', 'give'); ?> |
|
691 | 691 | </li> |
692 | - <li class="<?php echo( 2 === $step ? 'active' : '' ); ?>"> |
|
693 | - <?php esc_html_e( 'Column mapping', 'give' ); ?> |
|
692 | + <li class="<?php echo(2 === $step ? 'active' : ''); ?>"> |
|
693 | + <?php esc_html_e('Column mapping', 'give'); ?> |
|
694 | 694 | </li> |
695 | - <li class="<?php echo( 3 === $step ? 'active' : '' ); ?>"> |
|
696 | - <?php esc_html_e( 'Import', 'give' ); ?> |
|
695 | + <li class="<?php echo(3 === $step ? 'active' : ''); ?>"> |
|
696 | + <?php esc_html_e('Import', 'give'); ?> |
|
697 | 697 | </li> |
698 | - <li class="<?php echo( 4 === $step ? 'active' : '' ); ?>"> |
|
699 | - <?php esc_html_e( 'Done!', 'give' ); ?> |
|
698 | + <li class="<?php echo(4 === $step ? 'active' : ''); ?>"> |
|
699 | + <?php esc_html_e('Done!', 'give'); ?> |
|
700 | 700 | </li> |
701 | 701 | </ol> |
702 | 702 | <?php |
@@ -710,16 +710,16 @@ discard block |
||
710 | 710 | * @return int $step on which step doest the import is on. |
711 | 711 | */ |
712 | 712 | public function get_step() { |
713 | - $step = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 ); |
|
713 | + $step = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0); |
|
714 | 714 | $on_step = 1; |
715 | 715 | |
716 | - if ( empty( $step ) || 1 === $step ) { |
|
716 | + if (empty($step) || 1 === $step) { |
|
717 | 717 | $on_step = 1; |
718 | - } elseif ( $this->check_for_dropdown_or_import() ) { |
|
718 | + } elseif ($this->check_for_dropdown_or_import()) { |
|
719 | 719 | $on_step = 3; |
720 | - } elseif ( 2 === $step ) { |
|
720 | + } elseif (2 === $step) { |
|
721 | 721 | $on_step = 2; |
722 | - } elseif ( 4 === $step ) { |
|
722 | + } elseif (4 === $step) { |
|
723 | 723 | $on_step = 4; |
724 | 724 | } |
725 | 725 | |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * @since 1.8.14 |
733 | 733 | */ |
734 | 734 | public function render_page() { |
735 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-donations.php'; |
|
735 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-donations.php'; |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
@@ -747,37 +747,34 @@ discard block |
||
747 | 747 | ?> |
748 | 748 | <tr valign="top"> |
749 | 749 | <th colspan="2"> |
750 | - <h2 id="give-import-title"><?php esc_html_e( 'Import donations from a CSV file', 'give' ) ?></h2> |
|
751 | - <p class="give-field-description"><?php esc_html_e( 'This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give' ) ?></p> |
|
750 | + <h2 id="give-import-title"><?php esc_html_e('Import donations from a CSV file', 'give') ?></h2> |
|
751 | + <p class="give-field-description"><?php esc_html_e('This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give') ?></p> |
|
752 | 752 | </th> |
753 | 753 | </tr> |
754 | 754 | <?php |
755 | - $csv = ( isset( $_POST['csv'] ) ? give_clean( $_POST['csv'] ) : '' ); |
|
756 | - $csv_id = ( isset( $_POST['csv_id'] ) ? give_clean( $_POST['csv_id'] ) : '' ); |
|
757 | - $delimiter = ( isset( $_POST['delimiter'] ) ? give_clean( $_POST['delimiter'] ) : 'csv' ); |
|
758 | - $mode = empty( $_POST['mode'] ) ? |
|
759 | - 'disabled' : |
|
760 | - ( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? 'enabled' : 'disabled' ); |
|
761 | - $create_user = empty( $_POST['create_user'] ) ? |
|
762 | - 'enabled' : |
|
763 | - ( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? 'enabled' : 'disabled' ); |
|
764 | - $delete_csv = empty( $_POST['delete_csv'] ) ? |
|
765 | - 'enabled' : |
|
766 | - ( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? 'enabled' : 'disabled' ); |
|
755 | + $csv = (isset($_POST['csv']) ? give_clean($_POST['csv']) : ''); |
|
756 | + $csv_id = (isset($_POST['csv_id']) ? give_clean($_POST['csv_id']) : ''); |
|
757 | + $delimiter = (isset($_POST['delimiter']) ? give_clean($_POST['delimiter']) : 'csv'); |
|
758 | + $mode = empty($_POST['mode']) ? |
|
759 | + 'disabled' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? 'enabled' : 'disabled'); |
|
760 | + $create_user = empty($_POST['create_user']) ? |
|
761 | + 'enabled' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? 'enabled' : 'disabled'); |
|
762 | + $delete_csv = empty($_POST['delete_csv']) ? |
|
763 | + 'enabled' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? 'enabled' : 'disabled'); |
|
767 | 764 | |
768 | 765 | // Reset csv and csv_id if csv |
769 | - if ( empty( $csv_id ) || ! $this->is_valid_csv( $csv_id, $csv ) ) { |
|
766 | + if (empty($csv_id) || ! $this->is_valid_csv($csv_id, $csv)) { |
|
770 | 767 | $csv_id = $csv = ''; |
771 | 768 | } |
772 | - $per_page = isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page; |
|
769 | + $per_page = isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page; |
|
773 | 770 | |
774 | 771 | $settings = array( |
775 | 772 | array( |
776 | 773 | 'id' => 'csv', |
777 | - 'name' => __( 'Choose a CSV file:', 'give' ), |
|
774 | + 'name' => __('Choose a CSV file:', 'give'), |
|
778 | 775 | 'type' => 'file', |
779 | - 'attributes' => array( 'editing' => 'false', 'library' => 'text' ), |
|
780 | - 'description' => __( 'The file must be a Comma Seperated Version (CSV) file type only.', 'give' ), |
|
776 | + 'attributes' => array('editing' => 'false', 'library' => 'text'), |
|
777 | + 'description' => __('The file must be a Comma Seperated Version (CSV) file type only.', 'give'), |
|
781 | 778 | 'fvalue' => 'url', |
782 | 779 | 'default' => $csv, |
783 | 780 | ), |
@@ -788,61 +785,61 @@ discard block |
||
788 | 785 | ), |
789 | 786 | array( |
790 | 787 | 'id' => 'delimiter', |
791 | - 'name' => __( 'CSV Delimiter:', 'give' ), |
|
792 | - 'description' => __( 'In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give' ), |
|
788 | + 'name' => __('CSV Delimiter:', 'give'), |
|
789 | + 'description' => __('In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give'), |
|
793 | 790 | 'default' => $delimiter, |
794 | 791 | 'type' => 'select', |
795 | 792 | 'options' => array( |
796 | - 'csv' => esc_html__( 'Comma', 'give' ), |
|
797 | - 'tab-separated-values' => esc_html__( 'Tab', 'give' ), |
|
793 | + 'csv' => esc_html__('Comma', 'give'), |
|
794 | + 'tab-separated-values' => esc_html__('Tab', 'give'), |
|
798 | 795 | ), |
799 | 796 | ), |
800 | 797 | array( |
801 | 798 | 'id' => 'mode', |
802 | - 'name' => __( 'Test Mode:', 'give' ), |
|
803 | - 'description' => __( 'Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give' ), |
|
799 | + 'name' => __('Test Mode:', 'give'), |
|
800 | + 'description' => __('Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give'), |
|
804 | 801 | 'default' => $mode, |
805 | 802 | 'type' => 'radio_inline', |
806 | 803 | 'options' => array( |
807 | - 'enabled' => __( 'Enabled', 'give' ), |
|
808 | - 'disabled' => __( 'Disabled', 'give' ), |
|
804 | + 'enabled' => __('Enabled', 'give'), |
|
805 | + 'disabled' => __('Disabled', 'give'), |
|
809 | 806 | ), |
810 | 807 | ), |
811 | 808 | array( |
812 | 809 | 'id' => 'create_user', |
813 | - 'name' => __( 'Create WP users for new donors:', 'give' ), |
|
814 | - 'description' => __( 'The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give' ), |
|
810 | + 'name' => __('Create WP users for new donors:', 'give'), |
|
811 | + 'description' => __('The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give'), |
|
815 | 812 | 'default' => $create_user, |
816 | 813 | 'type' => 'radio_inline', |
817 | 814 | 'options' => array( |
818 | - 'enabled' => __( 'Enabled', 'give' ), |
|
819 | - 'disabled' => __( 'Disabled', 'give' ), |
|
815 | + 'enabled' => __('Enabled', 'give'), |
|
816 | + 'disabled' => __('Disabled', 'give'), |
|
820 | 817 | ), |
821 | 818 | ), |
822 | 819 | array( |
823 | 820 | 'id' => 'delete_csv', |
824 | - 'name' => __( 'Delete CSV after import:', 'give' ), |
|
825 | - 'description' => __( 'Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give' ), |
|
821 | + 'name' => __('Delete CSV after import:', 'give'), |
|
822 | + 'description' => __('Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give'), |
|
826 | 823 | 'default' => $delete_csv, |
827 | 824 | 'type' => 'radio_inline', |
828 | 825 | 'options' => array( |
829 | - 'enabled' => __( 'Enabled', 'give' ), |
|
830 | - 'disabled' => __( 'Disabled', 'give' ), |
|
826 | + 'enabled' => __('Enabled', 'give'), |
|
827 | + 'disabled' => __('Disabled', 'give'), |
|
831 | 828 | ), |
832 | 829 | ), |
833 | 830 | array( |
834 | 831 | 'id' => 'per_page', |
835 | - 'name' => __( 'Process Rows Per Batch:', 'give' ), |
|
832 | + 'name' => __('Process Rows Per Batch:', 'give'), |
|
836 | 833 | 'type' => 'number', |
837 | - 'description' => __( 'Determine how many rows you would like to import per cycle.', 'give' ), |
|
834 | + 'description' => __('Determine how many rows you would like to import per cycle.', 'give'), |
|
838 | 835 | 'default' => $per_page, |
839 | 836 | 'class' => 'give-text-small', |
840 | 837 | ), |
841 | 838 | ); |
842 | 839 | |
843 | - $settings = apply_filters( 'give_import_file_upload_html', $settings ); |
|
840 | + $settings = apply_filters('give_import_file_upload_html', $settings); |
|
844 | 841 | |
845 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
842 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
846 | 843 | } |
847 | 844 | |
848 | 845 | /** |
@@ -855,27 +852,24 @@ discard block |
||
855 | 852 | $step = $this->get_step(); |
856 | 853 | |
857 | 854 | // Validation for first step. |
858 | - if ( 1 === $step ) { |
|
859 | - $csv_id = absint( $_POST['csv_id'] ); |
|
855 | + if (1 === $step) { |
|
856 | + $csv_id = absint($_POST['csv_id']); |
|
860 | 857 | |
861 | - if ( $this->is_valid_csv( $csv_id, esc_url( $_POST['csv'] ) ) ) { |
|
858 | + if ($this->is_valid_csv($csv_id, esc_url($_POST['csv']))) { |
|
862 | 859 | |
863 | - $url = give_import_page_url( (array) apply_filters( 'give_import_step_two_url', array( |
|
860 | + $url = give_import_page_url((array) apply_filters('give_import_step_two_url', array( |
|
864 | 861 | 'step' => '2', |
865 | 862 | 'importer-type' => $this->importer_type, |
866 | 863 | 'csv' => $csv_id, |
867 | - 'delimiter' => isset( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv', |
|
868 | - 'mode' => empty( $_POST['mode'] ) ? |
|
869 | - '0' : |
|
870 | - ( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? '1' : '0' ), |
|
871 | - 'create_user' => empty( $_POST['create_user'] ) ? |
|
872 | - '0' : |
|
873 | - ( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? '1' : '0' ), |
|
874 | - 'delete_csv' => empty( $_POST['delete_csv'] ) ? |
|
875 | - '1' : |
|
876 | - ( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? '1' : '0' ), |
|
877 | - 'per_page' => isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page, |
|
878 | - ) ) ); |
|
864 | + 'delimiter' => isset($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv', |
|
865 | + 'mode' => empty($_POST['mode']) ? |
|
866 | + '0' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? '1' : '0'), |
|
867 | + 'create_user' => empty($_POST['create_user']) ? |
|
868 | + '0' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? '1' : '0'), |
|
869 | + 'delete_csv' => empty($_POST['delete_csv']) ? |
|
870 | + '1' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? '1' : '0'), |
|
871 | + 'per_page' => isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page, |
|
872 | + ))); |
|
879 | 873 | ?> |
880 | 874 | <script type="text/javascript"> |
881 | 875 | window.location = "<?php echo $url; ?>" |
@@ -896,25 +890,25 @@ discard block |
||
896 | 890 | * |
897 | 891 | * @return bool $has_error CSV is valid or not. |
898 | 892 | */ |
899 | - private function is_valid_csv( $csv = false, $match_url = '' ) { |
|
893 | + private function is_valid_csv($csv = false, $match_url = '') { |
|
900 | 894 | $is_valid_csv = true; |
901 | 895 | |
902 | - if ( $csv ) { |
|
903 | - $csv_url = wp_get_attachment_url( $csv ); |
|
896 | + if ($csv) { |
|
897 | + $csv_url = wp_get_attachment_url($csv); |
|
904 | 898 | |
905 | - $delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' ); |
|
899 | + $delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv'); |
|
906 | 900 | |
907 | 901 | if ( |
908 | 902 | ! $csv_url || |
909 | - ( ! empty( $match_url ) && ( $csv_url !== $match_url ) ) || |
|
910 | - ( ( $mime_type = get_post_mime_type( $csv ) ) && ! strpos( $mime_type, $delimiter ) ) |
|
903 | + ( ! empty($match_url) && ($csv_url !== $match_url)) || |
|
904 | + (($mime_type = get_post_mime_type($csv)) && ! strpos($mime_type, $delimiter)) |
|
911 | 905 | ) { |
912 | 906 | $is_valid_csv = false; |
913 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) ); |
|
907 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give')); |
|
914 | 908 | } |
915 | 909 | } else { |
916 | 910 | $is_valid_csv = false; |
917 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) ); |
|
911 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give')); |
|
918 | 912 | } |
919 | 913 | |
920 | 914 | return $is_valid_csv; |
@@ -930,8 +924,8 @@ discard block |
||
930 | 924 | * @param $field |
931 | 925 | * @param $option_value |
932 | 926 | */ |
933 | - public function render_import_field( $field, $option_value ) { |
|
934 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php'; |
|
927 | + public function render_import_field($field, $option_value) { |
|
928 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-imports.php'; |
|
935 | 929 | } |
936 | 930 | |
937 | 931 | /** |
@@ -942,8 +936,8 @@ discard block |
||
942 | 936 | */ |
943 | 937 | private function is_donations_import_page() { |
944 | 938 | return 'import' === give_get_current_setting_tab() && |
945 | - isset( $_GET['importer-type'] ) && |
|
946 | - $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
939 | + isset($_GET['importer-type']) && |
|
940 | + $this->importer_type === give_clean($_GET['importer-type']); |
|
947 | 941 | } |
948 | 942 | } |
949 | 943 |