WC_Background_Updater::taskprotectedWC 1.0

Task

Override this method to perform any actions required on each queue item. Return the modified item for further processing in the next pass through. Or, return false to remove the item from the queue.

Method of the class: WC_Background_Updater{}

No Hooks.

Returns

String|true|false.

Usage

// protected - for code of main (parent) or child class
$result = $this->task( $callback );
$callback(string) (required)
Update callback function.

WC_Background_Updater::task() code WC 10.8.1

protected function task( $callback ) {
	wc_maybe_define_constant( 'WC_UPDATING', true );

	$logger = wc_get_logger();

	include_once dirname( __FILE__ ) . '/wc-update-functions.php';

	$result = false;

	if ( is_callable( $callback ) ) {
		$logger->info( sprintf( 'Running %s callback', $callback ), array( 'source' => 'wc_db_updates' ) );
		$result = (bool) call_user_func( $callback, $this );

		if ( $result ) {
			$logger->info( sprintf( '%s callback needs to run again', $callback ), array( 'source' => 'wc_db_updates' ) );
		} else {
			$logger->info( sprintf( 'Finished running %s callback', $callback ), array( 'source' => 'wc_db_updates' ) );
		}
	} else {
		$logger->notice( sprintf( 'Could not find %s callback', $callback ), array( 'source' => 'wc_db_updates' ) );
	}

	return $result ? $callback : false;
}