Yoast\WP\SEO\Routes

Indexables_Page_Route::set_reading_list()publicYoast 1.0

Sets the state of the reading list.

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

Хуков нет.

Возвращает

WP_REST_Response|WP_Error. The success or failure response.

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

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

Код Indexables_Page_Route::set_reading_list() Yoast 19.11

public function set_reading_list( WP_REST_Request $request ) {
	$params             = $request->get_json_params();
	$reading_list_state = \array_map(
		function ( $article ) {
			return boolval( $article );
		},
		$params['state']
	);

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

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