WC_Background_Updater::task()protectedWC 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.

Метод класса: WC_Background_Updater{}

Хуков нет.

Возвращает

Строку|true|false.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->task( $callback );
$callback(строка) (обязательный)
Update callback function.

Код WC_Background_Updater::task() WC 8.7.0

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;
}