Yoast\WP\SEO\Routes

Indexables_Page_Route::update_ignored_indexables()publicYoast 1.0

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.

Код Indexables_Page_Route::update_ignored_indexables() Yoast 19.11

public function update_ignored_indexables( WP_REST_Request $request ) {
	$params           = $request->get_json_params();
	$ignore_list_name = $params['type'] . '_ignore_list';

	$ignored_indexable_ids = \array_map(
		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,
		]
	);
}