Show error when cannot dispatch updater

This commit is contained in:
Mike Jolley 2016-06-02 23:41:19 +01:00
parent 12c582762a
commit 21db8d4824
2 changed files with 23 additions and 3 deletions

View File

@ -29,11 +29,31 @@ class WC_Background_Updater extends WP_Background_Process {
protected $action = 'wc_updater';
/**
* Dispatch
* @var string
*/
protected $error = '';
/**
* Dispatch updater.
*
* Updater will still run via cron job if this fails for any reason.
*/
public function dispatch() {
WC_Admin_Notices::add_notice( 'updating' );
parent::dispatch();
$dispatched = parent::dispatch();
if ( is_wp_error( $dispatched ) ) {
$this->error = $dispatched->get_error_message();
add_action( 'admin_notices', array( $this, 'dispatch_error' ) );
}
}
/**
* Error shown when the updater cannot dispatch.
*/
public function dispatch_error() {
echo '<div class="error"><p>' . __( 'Unable to dispatch WooCommerce updater:', 'woocommerce' ) . ' ' . esc_html( $this->error ) . '</p></div>';
}
/**

View File

@ -48,7 +48,7 @@ if ( ! class_exists( 'WP_Background_Process' ) ) {
$this->schedule_event();
// Perform remote post
parent::dispatch();
return parent::dispatch();
}
/**