-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Tie zoom out availability to content post supports #66600
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,27 @@ function gutenberg_menu() { | |
); | ||
} | ||
add_action( 'admin_menu', 'gutenberg_menu', 9 ); | ||
|
||
|
||
/** | ||
* This should be implemented in core as a default | ||
* post type feature. | ||
* | ||
*/ | ||
if ( ! function_exists( 'add_content_support' ) ) { | ||
/** | ||
* Add the 'content' support to core content post types. | ||
* | ||
* @since 6.8.0 | ||
*/ | ||
function add_content_support() { | ||
global $wp_post_types; | ||
|
||
foreach ( array_keys( $wp_post_types ) as $post_type ) { | ||
if ( in_array( $post_type, array( 'post', 'page', 'wp_template' ), true ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of this in general. But it seems odd that In all the other places where we differentiate between wether something is content or now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the support type name is debatable b/c of this. It's also still unclear what is content and what is not ... Let's see what other reviewers think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What should the default be for custom post types that plugins might be creating? I.e. is the intention that we're gating the zoom out feature so that plugins will need to opt-in in order to support it? (I don't have an opinion either way, just a thought as I looked over the PR 🙂) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some kinds of post types where it doesn't make sense. We can make all post types support this by default and opt out only when a custom supports list is provided. |
||
add_post_type_support( $post_type, 'content' ); | ||
} | ||
} | ||
} | ||
add_action( 'init', 'add_content_support' ); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1814,6 +1814,21 @@ export const getPostTypeLabel = createRegistrySelector( | |
} | ||
); | ||
|
||
/** | ||
* Returns a post type support object on the current post | ||
* | ||
* @param {Object} state Global application state. | ||
* | ||
* @return {Object} The post type supports object. | ||
*/ | ||
export const getPostTypeSupports = createRegistrySelector( | ||
( select ) => ( state ) => { | ||
const currentPostType = getCurrentPostType( state ); | ||
const postType = select( coreStore ).getPostType( currentPostType ); | ||
return postType?.supports ?? {}; | ||
} | ||
); | ||
Comment on lines
+1817
to
+1830
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to introduce a new public registry selector for the value the editor has been deriving forever? 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand we should not add this selector, but what does "the editor has been deriving forever" mean? Do we have this data selectable already? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see you mean maybe derrive it from the entity call
Well we do have a selector above for post title ... IDK! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Components like P.S. I didn't meant this as snarky remark, sorry if it came out that way 🙇 |
||
|
||
/** | ||
* Returns true if the publish sidebar is opened. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a selector in the editor package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not thought about putting it here on purpose, it just came naturally after the
getPostTypeLabel
selector 🤷🏻There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I was not aware of
getPostTypeLabel
. I agree that it's similar but it seems to me that neither should exist to be honest (especially in the editor package).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why tho? From the editor package readme:
Since it knows of WordPress posts what is wrong with sugar selectors like these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should avoid "convenient" selectors or shortcuts like that. There's more detailed reasoning here https://make.wordpress.org/core/2024/09/12/gutenberg-development-practices-and-common-pitfalls/
If we allow that, we'll never stop adding shortcuts and APIs everywhere. We just use core-data for these directly.