Yoast\WP\SEO\Routes

Indexing_Route::run_indexation_action │ protected │ Yoast 1.0

Runs an indexing action and returns the response.

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

Хуков нет.

Возвращает

WP_REST_Response|WP_Error. The response, or an error when running the indexing action failed.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->run_indexation_action( $indexation_action, $url );
$indexation_action(Indexation_Action_Interface) (обязательный)
The indexing action.
$url(строка) (обязательный)
The url of the indexing route.

Код Indexing_Route::run_indexation_action() Yoast 28.9

protected function run_indexation_action( Indexation_Action_Interface $indexation_action, $url ) {
	try {
		return parent::run_indexation_action( $indexation_action, $url );
	} catch ( Indexing_Failed_Exception $exception ) {
		$this->indexing_helper->indexing_failed();

		$previous = $exception->getPrevious();

		return new WP_Error(
			'wpseo_error_indexing',
			$exception->getMessage(),
			[
				'stackTrace'  => ( $previous !== null ) ? $previous->getTraceAsString() : $exception->getTraceAsString(),
				'object_id'   => $exception->get_object_id(),
				'object_type' => $exception->get_object_type(),
			],
		);
	} catch ( Exception $exception ) {
		$this->indexing_helper->indexing_failed();

		return new WP_Error(
			'wpseo_error_indexing',
			$exception->getMessage(),
			[ 'stackTrace' => $exception->getTraceAsString() ],
		);
	}
}