Yoast\WP\SEO\Routes

Indexables_Page_Route::update_ignored_indexables()publicYoast 1.0

Устарела с версии 20.4. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.

Adds an indexable id in the ignore list.

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

Хуков нет.

Возвращает

WP_REST_Response|WP_Error. The success or failure response.

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

$Indexables_Page_Route = new Indexables_Page_Route();
$Indexables_Page_Route->update_ignored_indexables( $request );
$request(WP_REST_Request) (обязательный)
The request object.

Список изменений

Устарела с 20.4

Код Indexables_Page_Route::update_ignored_indexables() Yoast 22.3

public function update_ignored_indexables( WP_REST_Request $request ) {
	\_deprecated_function( __METHOD__, 'Yoast SEO 20.4' );

	$params           = $request->get_json_params();
	$ignore_list_name = $params['type'] . '_ignore_list';

	$ignored_indexable_ids = \array_map(
		static function ( $ignored_indexable_id ) {
			return \intval( $ignored_indexable_id );
		},
		$params['list']
	);

	if ( $this->indexables_page_action->update_ignored_indexables( $ignore_list_name, $ignored_indexable_ids ) ) {
		return new WP_REST_Response(
			[
				'json' => (object) [ 'success' => true ],
			],
			200
		);
	}

	return new WP_Error(
		'ignore_failed',
		'Could not save the option in the database',
		[
			'status' => 500,
		]
	);
}