1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104:
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once( 'libraries/wp-async-request.php' );
require_once( 'libraries/gf-background-process.php' );
class GF_Background_Upgrader extends GF_Background_Process {
protected $action = 'gf_upgrader';
public function get_data() {
return $this->data;
}
public function is_queue_empty() {
return parent::is_queue_empty();
}
public function is_updating() {
return false === $this->is_queue_empty();
}
protected function task( $callback ) {
if ( ! defined( 'GF_UPGRADING' ) ) {
define( 'GF_UPGRADING', true );
}
if ( is_callable( $callback ) ) {
GFCommon::log_debug( sprintf( '%s(): Running callback: %s', __METHOD__, print_r( $callback, 1 ) ) );
$needs_more_time = call_user_func( $callback );
if ( $needs_more_time ) {
GFCommon::log_debug( sprintf( '%s(): Callback needs another run: %s', __METHOD__, print_r( $callback, 1 ) ) );
return $callback;
} else {
GFCommon::log_debug( sprintf( '%s(): Finished callback: %s', __METHOD__, print_r( $callback, 1 ) ) );
}
} else {
GFCommon::log_debug( sprintf( '%s(): Could not find callback: %s', __METHOD__, print_r( $callback, 1 ) ) );
}
return false;
}
protected function complete() {
parent::complete();
}
}