Skip to content

Commit

Permalink
Remove function_exist wrap from Gutenberg init function.
Browse files Browse the repository at this point in the history
This function will only exists in Gutenberg, thus it does
not the guard to protect it from the same function in Core
(that is once the Fonts Library is merged into Core).
  • Loading branch information
hellofromtonya committed Aug 10, 2023
1 parent 5453579 commit 82968c9
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions lib/experimental/fonts-library/fonts-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,29 @@
* @since 6.4.0
*/

if ( ! function_exists( 'gutenberg_init_fonts_library' ) ) {
/**
* Registers the routes for the objects of the controller.
*
* This function will not be merged into Core. However, the
* code in the function will be. @core-merge annotation
* provides instructions on where the could needs to go
* in Core.
*
* @since 6.4.0
*/
function gutenberg_init_fonts_library() {
// @core-merge: This code will go into Core's `create_initial_post_types()`.
$args = array(
'public' => true,
'label' => 'Font Library',
'show_in_rest' => true,
);
register_post_type( 'wp_font_family', $args );

// @core-merge: This code will go into Core's `create_initial_rest_routes()`.
$fonts_library_controller = new WP_REST_Fonts_Library_Controller();
$fonts_library_controller->register_routes();
}
/**
* Registers the routes for the objects of the controller.
*
* This function will not be merged into Core. However, the
* code in the function will be. @core-merge annotation
* provides instructions on where the could needs to go
* in Core.
*
* @since 6.4.0
*/
function gutenberg_init_fonts_library() {
// @core-merge: This code will go into Core's `create_initial_post_types()`.
$args = array(
'public' => true,
'label' => 'Font Library',
'show_in_rest' => true,
);
register_post_type( 'wp_font_family', $args );

add_action( 'rest_api_init', 'gutenberg_init_fonts_library' );
// @core-merge: This code will go into Core's `create_initial_rest_routes()`.
$fonts_library_controller = new WP_REST_Fonts_Library_Controller();
$fonts_library_controller->register_routes();
}

add_action( 'rest_api_init', 'gutenberg_init_fonts_library' );

0 comments on commit 82968c9

Please sign in to comment.