Creates a single font family.
Parameters
$request
WP_REST_Requestrequired- Full details about the request.
Source
public function create_item( $request ) {
$settings = $request->get_param( 'font_family_settings' );
// Check that the font family slug is unique.
$query = new WP_Query(
array(
'post_type' => $this->post_type,
'posts_per_page' => 1,
'name' => $settings['slug'],
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
)
);
if ( ! empty( $query->posts ) ) {
return new WP_Error(
'rest_duplicate_font_family',
/* translators: %s: Font family slug. */
sprintf( __( 'A font family with slug "%s" already exists.' ), $settings['slug'] ),
array( 'status' => 400 )
);
}
return parent::create_item( $request );
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.