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

Conversation

creativecoder
Copy link
Contributor

What?

Register font post types for all requests.

Why?

To ensure the post types are available to inspect or customize.

Found while working on #59294. $post_type = get_post_type_object( 'wp_font_face' ); did not work outside of REST API routes.

How?

Register wp_font_family and wp_font_face post types on the init hook.

Testing Instructions

Test with WP 6.4: ensure font library continues to work as expected

@creativecoder creativecoder added [Type] Bug An existing feature does not function as intended Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) [Feature] Font Library labels Feb 24, 2024
@creativecoder creativecoder self-assigned this Feb 24, 2024
Copy link

github-actions bot commented Feb 24, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: creativecoder <grantmkin@git.wordpress.org>
Co-authored-by: mikachan <mikachan@git.wordpress.org>
Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/compat/wordpress-6.5/fonts/fonts.php

Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me and the Font Library still works as expected 👍

Copy link
Contributor

@matiasbenedetto matiasbenedetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An accurate way of testing this could be running get_post_types function and check if the wp_font_family and wp_font_face posts types are listed.

get_post_types();

Returns in trunk:

[
  "post" => "post",
  "page" => "page",
  "attachment" => "attachment",
  "revision" => "revision",
  "nav_menu_item" => "nav_menu_item",
  "custom_css" => "custom_css",
  "customize_changeset" => "customize_changeset",
  "oembed_cache" => "oembed_cache",
  "user_request" => "user_request",
  "wp_block" => "wp_block",
  "wp_template" => "wp_template",
  "wp_template_part" => "wp_template_part",
  "wp_global_styles" => "wp_global_styles",
  "wp_navigation" => "wp_navigation",
]

Returns in this branch:

[
  "post" => "post",
  "page" => "page",
  "attachment" => "attachment",
  "revision" => "revision",
  "nav_menu_item" => "nav_menu_item",
  "custom_css" => "custom_css",
  "customize_changeset" => "customize_changeset",
  "oembed_cache" => "oembed_cache",
  "user_request" => "user_request",
  "wp_block" => "wp_block",
  "wp_template" => "wp_template",
  "wp_template_part" => "wp_template_part",
  "wp_global_styles" => "wp_global_styles",
  "wp_navigation" => "wp_navigation",
  "wp_font_family" => "wp_font_family",
  "wp_font_face" => "wp_font_face",
]

I see that wp_font_family and wp_font_face posts types are listed so it look that the PR is working as advertised.
LGTM

@matiasbenedetto matiasbenedetto added the Backport to WP Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Feb 27, 2024
@mikachan mikachan merged commit d60f525 into trunk Feb 27, 2024
68 checks passed
@mikachan mikachan deleted the fix/font-post-type-registration branch February 27, 2024 11:32
@github-actions github-actions bot added this to the Gutenberg 17.9 milestone Feb 27, 2024
@getdave
Copy link
Contributor

getdave commented Feb 27, 2024

I just cherry-picked this PR to the cherry-pick-wp-6-5-beta-3 branch to get it included in the next release: eba2b3c6d6

@getdave getdave added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Feb 27, 2024
@getdave
Copy link
Contributor

getdave commented Feb 27, 2024

@mikachan I don't think these changes are required in trunk. Post type registration is handled in it's own way in WP Core and so porting this PR's changes to Core "as is" won't work.

@getdave getdave removed the Backported to WP Core Pull request that has been successfully merged into WP Core label Feb 27, 2024
@getdave
Copy link
Contributor

getdave commented Feb 27, 2024

I just cherry-picked this PR to the cherry-pick-wp-6-5-beta-3 branch to get it included in the next release: eba2b3c

I spoke to @matiasbenedetto and he confirmed that this PR does not need to be backported and is already handled in WP Core.

Therefore I will drop it from #59394

@creativecoder
Copy link
Contributor Author

I just cherry-picked this PR to the release/17.8 branch to get it included in the next release: 1b5ae3c

@creativecoder creativecoder removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Font Library [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants