-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Experiment: Content types single route and package #78059
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
Changes from 1 commit
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 |
|---|---|---|
| @@ -1,37 +1,26 @@ | ||
| <?php | ||
| /** | ||
| * Bootstraps the Content Types pages (Taxonomies, Post Types) in wp-admin | ||
| * under Settings. | ||
| * Bootstraps the Content Types page in wp-admin under Settings. | ||
| * | ||
| * @package gutenberg | ||
| */ | ||
|
|
||
| add_action( 'admin_menu', '_gutenberg_content_types_add_settings_menu_items', 11 ); | ||
|
|
||
| /** | ||
| * Registers "Taxonomies" and "Post Types" submenu items under Settings. | ||
| * Registers the "Content Types" submenu item under Settings. | ||
| * | ||
| * @access private | ||
| */ | ||
| function _gutenberg_content_types_add_settings_menu_items() { | ||
| if ( function_exists( 'gutenberg_taxonomies_wp_admin_render_page' ) ) { | ||
| if ( function_exists( 'gutenberg_content_types_wp_admin_render_page' ) ) { | ||
| add_submenu_page( | ||
| 'options-general.php', | ||
| __( 'Taxonomies', 'gutenberg' ), | ||
| __( 'Taxonomies', 'gutenberg' ), | ||
| __( 'Content Types', 'gutenberg' ), | ||
| __( 'Content Types', 'gutenberg' ), | ||
| 'manage_options', | ||
| 'taxonomies-wp-admin', | ||
| 'gutenberg_taxonomies_wp_admin_render_page' | ||
| ); | ||
| } | ||
| if ( function_exists( 'gutenberg_post_types_wp_admin_render_page' ) ) { | ||
| add_submenu_page( | ||
| 'options-general.php', | ||
| __( 'Post Types', 'gutenberg' ), | ||
| __( 'Post Types', 'gutenberg' ), | ||
| 'manage_options', | ||
| 'post-types-wp-admin', | ||
| 'gutenberg_post_types_wp_admin_render_page' | ||
| 'content-types-wp-admin', | ||
| 'gutenberg_content_types_wp_admin_render_page' | ||
| ); | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { Page } from '@wordpress/admin-ui'; | ||
| import { privateApis as componentsPrivateApis } from '@wordpress/components'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { useNavigate } from '@wordpress/route'; | ||
| import type { ReactNode } from 'react'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { unlock } from '../../lock-unlock'; | ||
|
|
||
| const { Tabs } = unlock( componentsPrivateApis ); | ||
|
|
||
| interface LayoutProps { | ||
| activeTab: 'post-types' | 'taxonomies'; | ||
| children: ReactNode; | ||
| } | ||
|
|
||
| export function Layout( { activeTab, children }: LayoutProps ) { | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <Page | ||
| ariaLabel={ __( 'Content Types' ) } | ||
| className="content-types-page" | ||
| > | ||
| <Tabs | ||
| selectedTabId={ activeTab } | ||
| onSelect={ ( tabId: string ) => | ||
| navigate( { to: `/${ tabId }` } ) | ||
| } | ||
| > | ||
| <div className="content-types-tabs-wrapper"> | ||
| <Tabs.TabList> | ||
| <Tabs.Tab tabId="post-types"> | ||
| { __( 'Post Types' ) } | ||
| </Tabs.Tab> | ||
| <Tabs.Tab tabId="taxonomies"> | ||
| { __( 'Taxonomies' ) } | ||
| </Tabs.Tab> | ||
| </Tabs.TabList> | ||
| </div> | ||
|
Comment on lines
+36
to
+45
Member
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. One of the issues we have here now is that if you make a relationship between a post type and taxonomy (say you do it in the taxonomy edit page), and you navigate to the post types tab, you don't see the relationship immediately. Looks like we need a |
||
| </Tabs> | ||
| { children } | ||
| </Page> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| @use "@wordpress/base-styles/colors" as *; | ||
|
|
||
|
ntsekouras marked this conversation as resolved.
|
||
| .content-types-page { | ||
| padding: var(--wpds-dimension-padding-lg); | ||
| } | ||
|
|
||
| .content-types-tabs-wrapper { | ||
| border-bottom: 1px solid $gray-100; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // URL path segments for the top-level tabs / list pages. | ||
| export const POST_TYPES_PATH = '/post-types'; | ||
| export const TAXONOMIES_PATH = '/taxonomies'; | ||
|
|
||
| // Core-data postType names that store the user-defined records. | ||
| export const POST_TYPE_ENTITY = 'wp_user_post_type'; | ||
| export const TAXONOMY_ENTITY = 'wp_user_taxonomy'; | ||
|
|
||
| // Sentinel for the edit-route param when creating a new record. | ||
| export const NEW_ID = 'new'; |
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.
Is this necessary? Looks like it could theoretically be
nullorundefined