@@ -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' ) ); |
|
| 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 | 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 ); |
|
| 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 | } |
@@ -322,9 +320,9 @@ discard block |
||
| 322 | 320 | // Bailout. |
| 323 | 321 | if ( |
| 324 | 322 | wp_doing_ajax() || |
| 325 | - ! isset( $_GET['page'] ) || |
|
| 323 | + ! isset($_GET['page']) || |
|
| 326 | 324 | 'give-updates' !== $_GET['page'] || |
| 327 | - ! isset( $_GET['give-pause-db-upgrades'] ) || |
|
| 325 | + ! isset($_GET['give-pause-db-upgrades']) || |
|
| 328 | 326 | self::$background_updater->is_paused_process() |
| 329 | 327 | ) { |
| 330 | 328 | return false; |
@@ -332,20 +330,20 @@ discard block |
||
| 332 | 330 | |
| 333 | 331 | $batch = self::$background_updater->get_all_batch(); |
| 334 | 332 | |
| 335 | - if ( ! empty( $batch ) ) { |
|
| 336 | - update_option( 'give_paused_batches', $batch, 'no' ); |
|
| 337 | - delete_option( $batch->key ); |
|
| 338 | - delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' ); |
|
| 339 | - wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() ); |
|
| 333 | + if ( ! empty($batch)) { |
|
| 334 | + update_option('give_paused_batches', $batch, 'no'); |
|
| 335 | + delete_option($batch->key); |
|
| 336 | + delete_site_transient(self::$background_updater->get_identifier().'_process_lock'); |
|
| 337 | + wp_clear_scheduled_hook(self::$background_updater->get_cron_identifier()); |
|
| 340 | 338 | |
| 341 | - Give()->logs->add( 'Update Pause', print_r( $batch, true ), 0, 'update' ); |
|
| 339 | + Give()->logs->add('Update Pause', print_r($batch, true), 0, 'update'); |
|
| 342 | 340 | |
| 343 | 341 | /** |
| 344 | 342 | * Fire action when pause db updates |
| 345 | 343 | * |
| 346 | 344 | * @since 2.0.1 |
| 347 | 345 | */ |
| 348 | - do_action( 'give_pause_db_upgrade', $this ); |
|
| 346 | + do_action('give_pause_db_upgrade', $this); |
|
| 349 | 347 | } |
| 350 | 348 | |
| 351 | 349 | return true; |
@@ -363,28 +361,28 @@ discard block |
||
| 363 | 361 | // Bailout. |
| 364 | 362 | if ( |
| 365 | 363 | wp_doing_ajax() || |
| 366 | - ! isset( $_GET['page'] ) || |
|
| 364 | + ! isset($_GET['page']) || |
|
| 367 | 365 | 'give-updates' !== $_GET['page'] || |
| 368 | - ! isset( $_GET['give-restart-db-upgrades'] ) || |
|
| 366 | + ! isset($_GET['give-restart-db-upgrades']) || |
|
| 369 | 367 | ! self::$background_updater->is_paused_process() |
| 370 | 368 | ) { |
| 371 | 369 | return false; |
| 372 | 370 | } |
| 373 | 371 | |
| 374 | - $batch = get_option( 'give_paused_batches' ); |
|
| 372 | + $batch = get_option('give_paused_batches'); |
|
| 375 | 373 | |
| 376 | - if ( ! empty( $batch ) ) { |
|
| 377 | - update_option( $batch->key, $batch->data ); |
|
| 378 | - delete_option( 'give_paused_batches' ); |
|
| 374 | + if ( ! empty($batch)) { |
|
| 375 | + update_option($batch->key, $batch->data); |
|
| 376 | + delete_option('give_paused_batches'); |
|
| 379 | 377 | |
| 380 | - Give()->logs->add( 'Update Restart', print_r( $batch, true ), 0, 'update' ); |
|
| 378 | + Give()->logs->add('Update Restart', print_r($batch, true), 0, 'update'); |
|
| 381 | 379 | |
| 382 | 380 | |
| 383 | 381 | /** Fire action when restart db updates |
| 384 | 382 | * |
| 385 | 383 | * @since 2.0.1 |
| 386 | 384 | */ |
| 387 | - do_action( 'give_restart_db_upgrade', $this ); |
|
| 385 | + do_action('give_restart_db_upgrade', $this); |
|
| 388 | 386 | |
| 389 | 387 | self::$background_updater->dispatch(); |
| 390 | 388 | } |
@@ -400,77 +398,77 @@ discard block |
||
| 400 | 398 | * |
| 401 | 399 | * @param Give_Updates $give_updates |
| 402 | 400 | */ |
| 403 | - public function __health_background_update( $give_updates ) { |
|
| 404 | - if( ! $this->is_doing_updates() ) { |
|
| 401 | + public function __health_background_update($give_updates) { |
|
| 402 | + if ( ! $this->is_doing_updates()) { |
|
| 405 | 403 | return; |
| 406 | 404 | } |
| 407 | 405 | |
| 408 | 406 | $batch = Give_Updates::$background_updater->get_all_batch(); |
| 409 | - $batch_data_count = count( $batch->data ); |
|
| 410 | - $all_updates = $give_updates->get_updates( 'database', 'all' ); |
|
| 411 | - $all_update_ids = wp_list_pluck( $all_updates, 'id' ); |
|
| 412 | - $all_batch_update_ids = ! empty( $batch ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
| 407 | + $batch_data_count = count($batch->data); |
|
| 408 | + $all_updates = $give_updates->get_updates('database', 'all'); |
|
| 409 | + $all_update_ids = wp_list_pluck($all_updates, 'id'); |
|
| 410 | + $all_batch_update_ids = ! empty($batch) ? wp_list_pluck($batch->data, 'id') : array(); |
|
| 413 | 411 | $log_data = ''; |
| 414 | 412 | |
| 415 | - if ( ! empty( $batch ) ) { |
|
| 413 | + if ( ! empty($batch)) { |
|
| 416 | 414 | |
| 417 | - foreach ( $batch->data as $index => $update ) { |
|
| 418 | - $log_data = print_r( $update, true ) . "\n"; |
|
| 415 | + foreach ($batch->data as $index => $update) { |
|
| 416 | + $log_data = print_r($update, true)."\n"; |
|
| 419 | 417 | |
| 420 | - if ( ! is_callable( $update['callback'] ) ) { |
|
| 421 | - $log_data .= 'Removing missing callback update: ' . "{$update['id']}\n"; |
|
| 422 | - unset( $batch->data[ $index ] ); |
|
| 418 | + if ( ! is_callable($update['callback'])) { |
|
| 419 | + $log_data .= 'Removing missing callback update: '."{$update['id']}\n"; |
|
| 420 | + unset($batch->data[$index]); |
|
| 423 | 421 | } |
| 424 | 422 | |
| 425 | - if ( ! empty( $update['depend'] ) ) { |
|
| 423 | + if ( ! empty($update['depend'])) { |
|
| 426 | 424 | |
| 427 | - foreach ( $update['depend'] as $depend ) { |
|
| 428 | - if ( give_has_upgrade_completed( $depend ) ) { |
|
| 429 | - $log_data .= 'Completed update: ' . "{$depend}\n"; |
|
| 425 | + foreach ($update['depend'] as $depend) { |
|
| 426 | + if (give_has_upgrade_completed($depend)) { |
|
| 427 | + $log_data .= 'Completed update: '."{$depend}\n"; |
|
| 430 | 428 | continue; |
| 431 | 429 | } |
| 432 | 430 | |
| 433 | - if ( in_array( $depend, $all_update_ids ) && ! in_array( $depend, $all_batch_update_ids ) ) { |
|
| 434 | - $log_data .= 'Adding missing update: ' . "{$depend}\n"; |
|
| 435 | - array_unshift( $batch->data, $all_updates[ array_search( $depend, $all_update_ids ) ] ); |
|
| 431 | + if (in_array($depend, $all_update_ids) && ! in_array($depend, $all_batch_update_ids)) { |
|
| 432 | + $log_data .= 'Adding missing update: '."{$depend}\n"; |
|
| 433 | + array_unshift($batch->data, $all_updates[array_search($depend, $all_update_ids)]); |
|
| 436 | 434 | } |
| 437 | 435 | } |
| 438 | 436 | } |
| 439 | 437 | } |
| 440 | 438 | } |
| 441 | 439 | |
| 442 | - if( $new_updates = $this->get_updates( 'database', 'new' ) ){ |
|
| 443 | - $all_batch_update_ids = ! empty( $batch ) ? wp_list_pluck( $batch->data, 'id' ) : array(); |
|
| 440 | + if ($new_updates = $this->get_updates('database', 'new')) { |
|
| 441 | + $all_batch_update_ids = ! empty($batch) ? wp_list_pluck($batch->data, 'id') : array(); |
|
| 444 | 442 | |
| 445 | - foreach ( $new_updates as $index => $new_update ) { |
|
| 446 | - if( give_has_upgrade_completed( $new_update['id'] ) || in_array( $new_update['id'], $all_batch_update_ids ) ) { |
|
| 447 | - unset( $new_updates[$index] ); |
|
| 443 | + foreach ($new_updates as $index => $new_update) { |
|
| 444 | + if (give_has_upgrade_completed($new_update['id']) || in_array($new_update['id'], $all_batch_update_ids)) { |
|
| 445 | + unset($new_updates[$index]); |
|
| 448 | 446 | } |
| 449 | 447 | } |
| 450 | 448 | |
| 451 | - if( ! empty( $new_updates ) ) { |
|
| 452 | - $log_data .= 'Adding new update: ' . "\n"; |
|
| 453 | - $log_data .= print_r( $new_updates, true ) . "\n"; |
|
| 449 | + if ( ! empty($new_updates)) { |
|
| 450 | + $log_data .= 'Adding new update: '."\n"; |
|
| 451 | + $log_data .= print_r($new_updates, true)."\n"; |
|
| 454 | 452 | |
| 455 | - $batch->data = array_merge( $batch->data, $new_updates ); |
|
| 456 | - update_option( 'give_db_update_count', ( absint( get_option( 'give_db_update_count' ) ) + count( $new_updates ) ) ); |
|
| 453 | + $batch->data = array_merge($batch->data, $new_updates); |
|
| 454 | + update_option('give_db_update_count', (absint(get_option('give_db_update_count')) + count($new_updates))); |
|
| 457 | 455 | } |
| 458 | 456 | } |
| 459 | 457 | |
| 460 | - if ( $batch_data_count !== count( $batch->data ) ) { |
|
| 461 | - $log_data .= 'Updating batch' . "\n"; |
|
| 462 | - $log_data .= print_r( $batch, true ); |
|
| 458 | + if ($batch_data_count !== count($batch->data)) { |
|
| 459 | + $log_data .= 'Updating batch'."\n"; |
|
| 460 | + $log_data .= print_r($batch, true); |
|
| 463 | 461 | |
| 464 | - update_option( $batch->key, $batch->data ); |
|
| 462 | + update_option($batch->key, $batch->data); |
|
| 465 | 463 | |
| 466 | 464 | // Reset update info. |
| 467 | - $doing_upgrade_args = get_option( 'give_doing_upgrade' ); |
|
| 465 | + $doing_upgrade_args = get_option('give_doing_upgrade'); |
|
| 468 | 466 | // $doing_upgrade_args['update'] = $give_updates->update; |
| 469 | - $doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) ); |
|
| 467 | + $doing_upgrade_args['heading'] = sprintf('Update %s of %s', $doing_upgrade_args['update'], get_option('give_db_update_count')); |
|
| 470 | 468 | $doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage(); |
| 471 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
| 469 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
| 472 | 470 | |
| 473 | - Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' ); |
|
| 471 | + Give()->logs->add('Update Health Check', $log_data, 0, 'update'); |
|
| 474 | 472 | } |
| 475 | 473 | } |
| 476 | 474 | |
@@ -483,63 +481,63 @@ discard block |
||
| 483 | 481 | */ |
| 484 | 482 | public function __show_notice() { |
| 485 | 483 | // Bailout. |
| 486 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 484 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 487 | 485 | return; |
| 488 | 486 | } |
| 489 | 487 | |
| 490 | 488 | // Run DB updates. |
| 491 | - if ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
| 489 | + if ( ! empty($_GET['give-run-db-update'])) { |
|
| 492 | 490 | $this->run_db_update(); |
| 493 | 491 | } |
| 494 | 492 | |
| 495 | 493 | |
| 496 | 494 | // Bailout. |
| 497 | - if ( isset( $_GET['page'] ) && 'give-updates' === $_GET['page'] ) { |
|
| 495 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
| 498 | 496 | return; |
| 499 | 497 | } |
| 500 | 498 | |
| 501 | 499 | // Show notice if upgrade paused. |
| 502 | - if ( self::$background_updater->is_paused_process() ) { |
|
| 500 | + if (self::$background_updater->is_paused_process()) { |
|
| 503 | 501 | ob_start(); |
| 504 | 502 | ?> |
| 505 | 503 | <p> |
| 506 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 507 | - – <?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' ); ?> |
|
| 504 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 505 | + – <?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'); ?> |
|
| 508 | 506 | </p> |
| 509 | 507 | <p class="submit"> |
| 510 | - <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"> |
|
| 511 | - <?php _e( 'Restart the updater', 'give' ); ?> |
|
| 508 | + <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"> |
|
| 509 | + <?php _e('Restart the updater', 'give'); ?> |
|
| 512 | 510 | </a> |
| 513 | 511 | </p> |
| 514 | 512 | <script type="text/javascript"> |
| 515 | 513 | jQuery('.give-restart-updater-btn').click('click', function () { |
| 516 | - 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 |
|
| 514 | + 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 |
|
| 517 | 515 | }); |
| 518 | 516 | </script> |
| 519 | 517 | <?php |
| 520 | 518 | $desc_html = ob_get_clean(); |
| 521 | 519 | |
| 522 | 520 | |
| 523 | - Give()->notices->register_notice( array( |
|
| 521 | + Give()->notices->register_notice(array( |
|
| 524 | 522 | 'id' => 'give_upgrade_db', |
| 525 | 523 | 'type' => 'error', |
| 526 | 524 | 'dismissible' => false, |
| 527 | 525 | 'description' => $desc_html, |
| 528 | - ) ); |
|
| 526 | + )); |
|
| 529 | 527 | } |
| 530 | 528 | |
| 531 | 529 | // Bailout if doing upgrades. |
| 532 | - if( $this->is_doing_updates() ) { |
|
| 530 | + if ($this->is_doing_updates()) { |
|
| 533 | 531 | return; |
| 534 | 532 | } |
| 535 | 533 | |
| 536 | 534 | // Show notice if ajax is not working. |
| 537 | - if ( ! give_test_ajax_works() ) { |
|
| 535 | + if ( ! give_test_ajax_works()) { |
|
| 538 | 536 | Give()->notices->register_notice( |
| 539 | 537 | array( |
| 540 | 538 | 'id' => 'give_db_upgrade_ajax_inaccessible', |
| 541 | 539 | 'type' => 'error', |
| 542 | - 'description' => sprintf( '%1$s <a href="%2$s">%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' ) . ' »' ), |
|
| 540 | + 'description' => sprintf('%1$s <a href="%2$s">%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').' »'), |
|
| 543 | 541 | 'show' => true, |
| 544 | 542 | ) |
| 545 | 543 | ); |
@@ -548,46 +546,46 @@ discard block |
||
| 548 | 546 | } |
| 549 | 547 | |
| 550 | 548 | // Show db upgrade completed notice. |
| 551 | - if ( ! empty( $_GET['give-db-update-completed'] ) ) { |
|
| 552 | - Give()->notices->register_notice( array( |
|
| 549 | + if ( ! empty($_GET['give-db-update-completed'])) { |
|
| 550 | + Give()->notices->register_notice(array( |
|
| 553 | 551 | 'id' => 'give_db_upgrade_completed', |
| 554 | 552 | 'type' => 'updated', |
| 555 | - 'description' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
| 553 | + 'description' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
| 556 | 554 | 'show' => true, |
| 557 | - ) ); |
|
| 555 | + )); |
|
| 558 | 556 | |
| 559 | 557 | // Start update. |
| 560 | - } elseif ( ! empty( $_GET['give-run-db-update'] ) ) { |
|
| 558 | + } elseif ( ! empty($_GET['give-run-db-update'])) { |
|
| 561 | 559 | $this->run_db_update(); |
| 562 | 560 | |
| 563 | 561 | // Show run the update notice. |
| 564 | - } elseif ( $this->get_total_new_db_update_count() ) { |
|
| 562 | + } elseif ($this->get_total_new_db_update_count()) { |
|
| 565 | 563 | ob_start(); |
| 566 | 564 | ?> |
| 567 | 565 | <p> |
| 568 | - <strong><?php _e( 'Database Update', 'give' ); ?></strong> |
|
| 569 | - – <?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' ); ?> |
|
| 566 | + <strong><?php _e('Database Update', 'give'); ?></strong> |
|
| 567 | + – <?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'); ?> |
|
| 570 | 568 | </p> |
| 571 | 569 | <p class="submit"> |
| 572 | - <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"> |
|
| 573 | - <?php _e( 'Run the updater', 'give' ); ?> |
|
| 570 | + <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"> |
|
| 571 | + <?php _e('Run the updater', 'give'); ?> |
|
| 574 | 572 | </a> |
| 575 | 573 | </p> |
| 576 | 574 | <script type="text/javascript"> |
| 577 | 575 | jQuery('.give-run-update-now').click('click', function () { |
| 578 | - 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 |
|
| 576 | + 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 |
|
| 579 | 577 | }); |
| 580 | 578 | </script> |
| 581 | 579 | <?php |
| 582 | 580 | $desc_html = ob_get_clean(); |
| 583 | 581 | |
| 584 | 582 | |
| 585 | - Give()->notices->register_notice( array( |
|
| 583 | + Give()->notices->register_notice(array( |
|
| 586 | 584 | 'id' => 'give_upgrade_db', |
| 587 | 585 | 'type' => 'updated', |
| 588 | 586 | 'dismissible' => false, |
| 589 | 587 | 'description' => $desc_html, |
| 590 | - ) ); |
|
| 588 | + )); |
|
| 591 | 589 | } |
| 592 | 590 | } |
| 593 | 591 | |
@@ -598,7 +596,7 @@ discard block |
||
| 598 | 596 | * @access public |
| 599 | 597 | */ |
| 600 | 598 | public function render_complete_page() { |
| 601 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
| 599 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
| 602 | 600 | } |
| 603 | 601 | |
| 604 | 602 | /** |
@@ -608,7 +606,7 @@ discard block |
||
| 608 | 606 | * @access public |
| 609 | 607 | */ |
| 610 | 608 | public function render_page() { |
| 611 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
| 609 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
| 612 | 610 | } |
| 613 | 611 | |
| 614 | 612 | /** |
@@ -619,26 +617,26 @@ discard block |
||
| 619 | 617 | */ |
| 620 | 618 | private function run_db_update() { |
| 621 | 619 | // Bailout. |
| 622 | - if ( $this->is_doing_updates() || ! $this->get_total_new_db_update_count() ) { |
|
| 620 | + if ($this->is_doing_updates() || ! $this->get_total_new_db_update_count()) { |
|
| 623 | 621 | return; |
| 624 | 622 | } |
| 625 | 623 | |
| 626 | - $updates = $this->get_updates( 'database', 'new' ); |
|
| 624 | + $updates = $this->get_updates('database', 'new'); |
|
| 627 | 625 | |
| 628 | - foreach ( $updates as $update ) { |
|
| 629 | - self::$background_updater->push_to_queue( $update ); |
|
| 626 | + foreach ($updates as $update) { |
|
| 627 | + self::$background_updater->push_to_queue($update); |
|
| 630 | 628 | } |
| 631 | 629 | |
| 632 | - add_option( 'give_db_update_count', count( $updates ), '', 'no' ); |
|
| 630 | + add_option('give_db_update_count', count($updates), '', 'no'); |
|
| 633 | 631 | |
| 634 | - add_option( 'give_doing_upgrade', array( |
|
| 632 | + add_option('give_doing_upgrade', array( |
|
| 635 | 633 | 'update_info' => $updates[0], |
| 636 | 634 | 'step' => 1, |
| 637 | 635 | 'update' => 1, |
| 638 | - 'heading' => sprintf( 'Update %s of %s', 1, count( $updates ) ), |
|
| 636 | + 'heading' => sprintf('Update %s of %s', 1, count($updates)), |
|
| 639 | 637 | 'percentage' => 0, |
| 640 | 638 | 'total_percentage' => 0, |
| 641 | - ), '', 'no' ); |
|
| 639 | + ), '', 'no'); |
|
| 642 | 640 | |
| 643 | 641 | self::$background_updater->save()->dispatch(); |
| 644 | 642 | } |
@@ -652,11 +650,11 @@ discard block |
||
| 652 | 650 | */ |
| 653 | 651 | public function __flush_resume_updates() { |
| 654 | 652 | //delete_option( 'give_doing_upgrade' ); |
| 655 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
| 653 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
| 656 | 654 | |
| 657 | 655 | // Reset counter. |
| 658 | 656 | $this->step = $this->percentage = 0; |
| 659 | - ++ $this->update; |
|
| 657 | + ++$this->update; |
|
| 660 | 658 | } |
| 661 | 659 | |
| 662 | 660 | |
@@ -671,7 +669,7 @@ discard block |
||
| 671 | 669 | public function __give_start_updating() { |
| 672 | 670 | // Check permission. |
| 673 | 671 | if ( |
| 674 | - ! current_user_can( 'manage_give_settings' ) || |
|
| 672 | + ! current_user_can('manage_give_settings') || |
|
| 675 | 673 | $this->is_doing_updates() |
| 676 | 674 | ) { |
| 677 | 675 | wp_send_json_error(); |
@@ -679,7 +677,7 @@ discard block |
||
| 679 | 677 | |
| 680 | 678 | // @todo: validate nonce |
| 681 | 679 | // @todo: set http method to post |
| 682 | - if ( empty( $_POST['run_db_update'] ) ) { |
|
| 680 | + if (empty($_POST['run_db_update'])) { |
|
| 683 | 681 | wp_send_json_error(); |
| 684 | 682 | } |
| 685 | 683 | |
@@ -698,21 +696,21 @@ discard block |
||
| 698 | 696 | * @return string |
| 699 | 697 | */ |
| 700 | 698 | public function __give_db_updates_info() { |
| 701 | - $update_info = get_option( 'give_doing_upgrade' ); |
|
| 699 | + $update_info = get_option('give_doing_upgrade'); |
|
| 702 | 700 | $response_type = ''; |
| 703 | 701 | |
| 704 | - if ( empty( $update_info ) ) { |
|
| 705 | - $update_info = array( |
|
| 706 | - 'message' => __( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ), |
|
| 707 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
| 702 | + if (empty($update_info)) { |
|
| 703 | + $update_info = array( |
|
| 704 | + 'message' => __('Give database updates completed successfully. Thank you for updating to the latest version!', 'give'), |
|
| 705 | + 'heading' => __('Updates Completed.', 'give'), |
|
| 708 | 706 | 'percentage' => 0, |
| 709 | 707 | ); |
| 710 | 708 | $response_type = 'success'; |
| 711 | 709 | |
| 712 | - delete_option( 'give_show_db_upgrade_complete_notice' ); |
|
| 710 | + delete_option('give_show_db_upgrade_complete_notice'); |
|
| 713 | 711 | } |
| 714 | 712 | |
| 715 | - $this->send_ajax_response( $update_info, $response_type ); |
|
| 713 | + $this->send_ajax_response($update_info, $response_type); |
|
| 716 | 714 | } |
| 717 | 715 | |
| 718 | 716 | /** |
@@ -724,7 +722,7 @@ discard block |
||
| 724 | 722 | * @param $data |
| 725 | 723 | * @param string $type |
| 726 | 724 | */ |
| 727 | - public function send_ajax_response( $data, $type = '' ) { |
|
| 725 | + public function send_ajax_response($data, $type = '') { |
|
| 728 | 726 | $default = array( |
| 729 | 727 | 'message' => '', |
| 730 | 728 | 'heading' => '', |
@@ -734,24 +732,24 @@ discard block |
||
| 734 | 732 | ); |
| 735 | 733 | |
| 736 | 734 | // Set data. |
| 737 | - $data = wp_parse_args( $data, $default ); |
|
| 735 | + $data = wp_parse_args($data, $default); |
|
| 738 | 736 | |
| 739 | 737 | // Enable cache. |
| 740 | 738 | Give_Cache::enable(); |
| 741 | 739 | |
| 742 | - switch ( $type ) { |
|
| 740 | + switch ($type) { |
|
| 743 | 741 | case 'success': |
| 744 | - wp_send_json_success( $data ); |
|
| 742 | + wp_send_json_success($data); |
|
| 745 | 743 | break; |
| 746 | 744 | |
| 747 | 745 | case 'error': |
| 748 | - wp_send_json_error( $data ); |
|
| 746 | + wp_send_json_error($data); |
|
| 749 | 747 | break; |
| 750 | 748 | |
| 751 | 749 | default: |
| 752 | - wp_send_json( array( |
|
| 750 | + wp_send_json(array( |
|
| 753 | 751 | 'data' => $data, |
| 754 | - ) ); |
|
| 752 | + )); |
|
| 755 | 753 | break; |
| 756 | 754 | } |
| 757 | 755 | } |
@@ -765,12 +763,12 @@ discard block |
||
| 765 | 763 | * @param $total |
| 766 | 764 | * @param $current_total |
| 767 | 765 | */ |
| 768 | - public function set_percentage( $total, $current_total ) { |
|
| 766 | + public function set_percentage($total, $current_total) { |
|
| 769 | 767 | // Set percentage. |
| 770 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
| 768 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
| 771 | 769 | |
| 772 | 770 | // Verify percentage. |
| 773 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
| 771 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
| 774 | 772 | } |
| 775 | 773 | |
| 776 | 774 | /** |
@@ -783,22 +781,22 @@ discard block |
||
| 783 | 781 | * |
| 784 | 782 | * @return bool|null |
| 785 | 783 | */ |
| 786 | - public function is_parent_updates_completed( $update ) { |
|
| 784 | + public function is_parent_updates_completed($update) { |
|
| 787 | 785 | // Bailout. |
| 788 | - if ( empty( $update['depend'] ) ) { |
|
| 786 | + if (empty($update['depend'])) { |
|
| 789 | 787 | return true; |
| 790 | 788 | } |
| 791 | 789 | |
| 792 | 790 | // Check if dependency is valid or not. |
| 793 | - if ( ! $this->has_valid_dependency( $update ) ) { |
|
| 791 | + if ( ! $this->has_valid_dependency($update)) { |
|
| 794 | 792 | return null; |
| 795 | 793 | } |
| 796 | 794 | |
| 797 | 795 | $is_dependency_completed = true; |
| 798 | 796 | |
| 799 | - foreach ( $update['depend'] as $depend ) { |
|
| 797 | + foreach ($update['depend'] as $depend) { |
|
| 800 | 798 | |
| 801 | - if ( ! give_has_upgrade_completed( $depend ) ) { |
|
| 799 | + if ( ! give_has_upgrade_completed($depend)) { |
|
| 802 | 800 | $is_dependency_completed = false; |
| 803 | 801 | break; |
| 804 | 802 | } |
@@ -815,7 +813,7 @@ discard block |
||
| 815 | 813 | * @return bool |
| 816 | 814 | */ |
| 817 | 815 | public function is_doing_updates() { |
| 818 | - return (bool) get_option( 'give_doing_upgrade' ); |
|
| 816 | + return (bool) get_option('give_doing_upgrade'); |
|
| 819 | 817 | } |
| 820 | 818 | |
| 821 | 819 | |
@@ -829,7 +827,7 @@ discard block |
||
| 829 | 827 | * |
| 830 | 828 | * @return bool |
| 831 | 829 | */ |
| 832 | - public function has_valid_dependency( $update ) { |
|
| 830 | + public function has_valid_dependency($update) { |
|
| 833 | 831 | $is_valid_dependency = true; |
| 834 | 832 | // $update_ids = wp_list_pluck( $this->get_updates( 'database', 'all' ), 'id' ); |
| 835 | 833 | // |
@@ -855,32 +853,32 @@ discard block |
||
| 855 | 853 | * |
| 856 | 854 | * @return array |
| 857 | 855 | */ |
| 858 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
| 856 | + public function get_updates($update_type = '', $status = 'all') { |
|
| 859 | 857 | // return all updates. |
| 860 | - if ( empty( $update_type ) ) { |
|
| 858 | + if (empty($update_type)) { |
|
| 861 | 859 | return $this->updates; |
| 862 | 860 | } |
| 863 | 861 | |
| 864 | 862 | // Get specific update. |
| 865 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
| 863 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
| 866 | 864 | |
| 867 | 865 | // Bailout. |
| 868 | - if ( empty( $updates ) ) { |
|
| 866 | + if (empty($updates)) { |
|
| 869 | 867 | return $updates; |
| 870 | 868 | } |
| 871 | 869 | |
| 872 | - switch ( $status ) { |
|
| 870 | + switch ($status) { |
|
| 873 | 871 | case 'new': |
| 874 | 872 | // Remove already completed updates. |
| 875 | 873 | $completed_updates = give_get_completed_upgrades(); |
| 876 | 874 | |
| 877 | - if ( ! empty( $completed_updates ) ) { |
|
| 878 | - foreach ( $updates as $index => $update ) { |
|
| 879 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
| 880 | - unset( $updates[ $index ] ); |
|
| 875 | + if ( ! empty($completed_updates)) { |
|
| 876 | + foreach ($updates as $index => $update) { |
|
| 877 | + if (in_array($update['id'], $completed_updates)) { |
|
| 878 | + unset($updates[$index]); |
|
| 881 | 879 | } |
| 882 | 880 | } |
| 883 | - $updates = array_values( $updates ); |
|
| 881 | + $updates = array_values($updates); |
|
| 884 | 882 | } |
| 885 | 883 | |
| 886 | 884 | break; |
@@ -897,7 +895,7 @@ discard block |
||
| 897 | 895 | * @return int |
| 898 | 896 | */ |
| 899 | 897 | public function get_total_plugin_update_count() { |
| 900 | - return count( $this->get_updates( 'plugin' ) ); |
|
| 898 | + return count($this->get_updates('plugin')); |
|
| 901 | 899 | } |
| 902 | 900 | |
| 903 | 901 | /** |
@@ -912,7 +910,7 @@ discard block |
||
| 912 | 910 | $db_update_count = $this->get_pending_db_update_count(); |
| 913 | 911 | $plugin_update_count = $this->get_total_plugin_update_count(); |
| 914 | 912 | |
| 915 | - return ( $db_update_count + $plugin_update_count ); |
|
| 913 | + return ($db_update_count + $plugin_update_count); |
|
| 916 | 914 | } |
| 917 | 915 | |
| 918 | 916 | /** |
@@ -924,7 +922,7 @@ discard block |
||
| 924 | 922 | * @return int |
| 925 | 923 | */ |
| 926 | 924 | public function get_pending_db_update_count() { |
| 927 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
| 925 | + return count($this->get_updates('database', 'new')); |
|
| 928 | 926 | } |
| 929 | 927 | |
| 930 | 928 | /** |
@@ -936,7 +934,7 @@ discard block |
||
| 936 | 934 | * @return int |
| 937 | 935 | */ |
| 938 | 936 | public function get_total_db_update_count() { |
| 939 | - return count( $this->get_updates( 'database', 'all' ) ); |
|
| 937 | + return count($this->get_updates('database', 'all')); |
|
| 940 | 938 | } |
| 941 | 939 | |
| 942 | 940 | /** |
@@ -949,8 +947,7 @@ discard block |
||
| 949 | 947 | */ |
| 950 | 948 | public function get_total_new_db_update_count() { |
| 951 | 949 | return $this->is_doing_updates() ? |
| 952 | - get_option( 'give_db_update_count' ) : |
|
| 953 | - $this->get_pending_db_update_count(); |
|
| 950 | + get_option('give_db_update_count') : $this->get_pending_db_update_count(); |
|
| 954 | 951 | } |
| 955 | 952 | |
| 956 | 953 | /** |
@@ -962,11 +959,10 @@ discard block |
||
| 962 | 959 | * @return int |
| 963 | 960 | */ |
| 964 | 961 | public function get_running_db_update() { |
| 965 | - $current_update = get_option( 'give_doing_upgrade' ); |
|
| 962 | + $current_update = get_option('give_doing_upgrade'); |
|
| 966 | 963 | |
| 967 | 964 | return $this->is_doing_updates() ? |
| 968 | - $current_update['update'] : |
|
| 969 | - 1; |
|
| 965 | + $current_update['update'] : 1; |
|
| 970 | 966 | } |
| 971 | 967 | |
| 972 | 968 | /** |
@@ -978,23 +974,21 @@ discard block |
||
| 978 | 974 | */ |
| 979 | 975 | public function get_db_update_processing_percentage() { |
| 980 | 976 | // Bailout. |
| 981 | - if ( ! $this->get_total_new_db_update_count() ) { |
|
| 977 | + if ( ! $this->get_total_new_db_update_count()) { |
|
| 982 | 978 | return 0; |
| 983 | 979 | } |
| 984 | 980 | |
| 985 | - $resume_update = get_option( 'give_doing_upgrade' ); |
|
| 986 | - $update_count_percentages = ( ( $this->get_running_db_update() - 1 ) / $this->get_total_new_db_update_count() ) * 100; |
|
| 987 | - $update_percentage_share = ( 1 / $this->get_total_new_db_update_count() ) * 100; |
|
| 988 | - $upgrade_percentage = ( ( $resume_update['percentage'] * $update_percentage_share ) / 100 ); |
|
| 981 | + $resume_update = get_option('give_doing_upgrade'); |
|
| 982 | + $update_count_percentages = (($this->get_running_db_update() - 1) / $this->get_total_new_db_update_count()) * 100; |
|
| 983 | + $update_percentage_share = (1 / $this->get_total_new_db_update_count()) * 100; |
|
| 984 | + $upgrade_percentage = (($resume_update['percentage'] * $update_percentage_share) / 100); |
|
| 989 | 985 | |
| 990 | 986 | $final_percentage = $update_count_percentages + $upgrade_percentage; |
| 991 | 987 | |
| 992 | 988 | return $this->is_doing_updates() ? |
| 993 | - ( absint( $final_percentage ) ? |
|
| 994 | - absint( $final_percentage ) : |
|
| 995 | - round( $final_percentage, 2 ) |
|
| 996 | - ) : |
|
| 997 | - 0; |
|
| 989 | + (absint($final_percentage) ? |
|
| 990 | + absint($final_percentage) : round($final_percentage, 2) |
|
| 991 | + ) : 0; |
|
| 998 | 992 | } |
| 999 | 993 | } |
| 1000 | 994 | |