WP_REST_Font_Faces_Controller::prepare_item_for_database()protectedWP 6.5.0

Prepares a single font face post for creation.

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

Хуков нет.

Возвращает

stdClass. Post object.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_item_for_database( $request );
$request(WP_REST_Request) (обязательный)
Request object.

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

С версии 6.5.0 Введена.

Код WP_REST_Font_Faces_Controller::prepare_item_for_database() WP 6.7.1

protected function prepare_item_for_database( $request ) {
	$prepared_post = new stdClass();

	// Settings have already been decoded by ::sanitize_font_face_settings().
	$settings = $request->get_param( 'font_face_settings' );

	// Store this "slug" as the post_title rather than post_name, since it uses the fontFamily setting,
	// which may contain multibyte characters.
	$title = WP_Font_Utils::get_font_face_slug( $settings );

	$prepared_post->post_type    = $this->post_type;
	$prepared_post->post_parent  = $request['font_family_id'];
	$prepared_post->post_status  = 'publish';
	$prepared_post->post_title   = $title;
	$prepared_post->post_name    = sanitize_title( $title );
	$prepared_post->post_content = wp_json_encode( $settings );

	return $prepared_post;
}