Yoast\WP\SEO\Commands

Index_Command::run_indexation_actions()protectedYoast 1.0

Runs all indexation actions.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->run_indexation_actions( $assoc_args );
$assoc_args(массив) (обязательный)
The associative arguments.

Код Index_Command::run_indexation_actions() Yoast 22.4

protected function run_indexation_actions( $assoc_args ) {
	// See if we need to clear all indexables before repopulating.
	if ( isset( $assoc_args['reindex'] ) ) {

		// Argument --skip-confirmation to prevent confirmation (for automated systems).
		if ( ! isset( $assoc_args['skip-confirmation'] ) ) {
			WP_CLI::confirm( 'This will clear all previously indexed objects. Are you certain you wish to proceed?' );
		}

		// Truncate the tables.
		$this->clear();

		// Delete the transients to make sure re-indexing runs every time.
		\delete_transient( Indexable_Post_Indexation_Action::UNINDEXED_COUNT_TRANSIENT );
		\delete_transient( Indexable_Post_Type_Archive_Indexation_Action::UNINDEXED_COUNT_TRANSIENT );
		\delete_transient( Indexable_Term_Indexation_Action::UNINDEXED_COUNT_TRANSIENT );
	}

	$indexation_actions = [
		'posts'              => $this->post_indexation_action,
		'terms'              => $this->term_indexation_action,
		'post type archives' => $this->post_type_archive_indexation_action,
		'general objects'    => $this->general_indexation_action,
		'post links'         => $this->post_link_indexing_action,
		'term links'         => $this->term_link_indexing_action,
	];

	$this->prepare_indexing_action->prepare();

	$interval = (int) $assoc_args['interval'];
	foreach ( $indexation_actions as $name => $indexation_action ) {
		$this->run_indexation_action( $name, $indexation_action, $interval );
	}

	$this->complete_indexation_action->complete();
}