Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Library: create post types on init hook #59333

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/compat/wordpress-6.5/fonts/fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,32 @@ function gutenberg_create_initial_post_types() {

/**
* Initializes REST routes.
*
* @since 6.5
*/
function gutenberg_create_initial_rest_routes() {
$font_collections_controller = new WP_REST_Font_Collections_Controller();
$font_collections_controller->register_routes();
global $wp_version;

// Runs only if the Font Library is not available in core ( i.e. in core < 6.5-alpha ).
if ( version_compare( $wp_version, '6.5-alpha', '<' ) ) {
$font_collections_controller = new WP_REST_Font_Collections_Controller();
$font_collections_controller->register_routes();
}
}

add_action( 'rest_api_init', 'gutenberg_create_initial_rest_routes' );

/**
* Initializes REST routes and post types.
*
* @since 6.5
*/
function gutenberg_init_font_library() {
global $wp_version;

// Runs only if the Font Library is not available in core ( i.e. in core < 6.5-alpha ).
if ( version_compare( $wp_version, '6.5-alpha', '<' ) ) {
gutenberg_create_initial_post_types();
gutenberg_create_initial_rest_routes();
}
}

add_action( 'rest_api_init', 'gutenberg_init_font_library' );
add_action( 'init', 'gutenberg_init_font_library' );


if ( ! function_exists( 'wp_register_font_collection' ) ) {
Expand Down
Loading