diff --git a/lib/experimental/posts/load.php b/lib/experimental/posts/load.php new file mode 100644 index 00000000000000..56a600ab97c05d --- /dev/null +++ b/lib/experimental/posts/load.php @@ -0,0 +1,43 @@ +'; +} + +/** + * Replaces the default posts menu item with the new posts dashboard. + */ +function gutenberg_replace_posts_dashboard() { + $gutenberg_experiments = get_option( 'gutenberg-experiments' ); + if ( ! $gutenberg_experiments || ! array_key_exists( 'gutenberg-new-posts-dashboard', $gutenberg_experiments ) || ! $gutenberg_experiments['gutenberg-new-posts-dashboard'] ) { + return; + } + $ptype_obj = get_post_type_object( 'post' ); + add_submenu_page( + 'gutenberg', + $ptype_obj->labels->name, + $ptype_obj->labels->name, + 'edit_posts', + 'gutenberg-posts-dashboard', + 'gutenberg_posts_dashboard' + ); +} diff --git a/lib/experiments-page.php b/lib/experiments-page.php index 5147edda0deec5..ca5c87eec737be 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -139,6 +139,18 @@ function gutenberg_initialize_experiments_settings() { ) ); + add_settings_field( + 'gutenberg-new-posts-dashboard', + __( 'Redesigned posts dashboard', 'gutenberg' ), + 'gutenberg_display_experiment_field', + 'gutenberg-experiments', + 'gutenberg_experiments_section', + array( + 'label' => __( 'Enable a redesigned posts dashboard.', 'gutenberg' ), + 'id' => 'gutenberg-new-posts-dashboard', + ) + ); + register_setting( 'gutenberg-experiments', 'gutenberg-experiments' diff --git a/lib/load.php b/lib/load.php index 45b8f1a1ceb3b0..201bfe1967d5b9 100644 --- a/lib/load.php +++ b/lib/load.php @@ -149,6 +149,7 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/experimental/l10n.php'; require __DIR__ . '/experimental/synchronization.php'; require __DIR__ . '/experimental/script-modules.php'; +require __DIR__ . '/experimental/posts/load.php'; if ( gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ) { require __DIR__ . '/experimental/disable-tinymce.php'; diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js index f7ef09f81ce7e7..3e8c637a493de8 100644 --- a/packages/edit-site/src/index.js +++ b/packages/edit-site/src/index.js @@ -104,3 +104,7 @@ export function reinitializeEditor() { export { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel'; export { store } from './store'; export * from './deprecated'; + +// Temporary: While the posts dashboard is being iterated on +// it's being built in the same package as the site editor. +export { initializePostsDashboard } from './posts'; diff --git a/packages/edit-site/src/posts.js b/packages/edit-site/src/posts.js new file mode 100644 index 00000000000000..ceee039806c9e7 --- /dev/null +++ b/packages/edit-site/src/posts.js @@ -0,0 +1,20 @@ +/** + * WordPress dependencies + */ +import { createRoot, StrictMode } from '@wordpress/element'; + +/** + * Initializes the "Posts Dashboard" + * @param {string} id DOM element id. + */ +export function initializePostsDashboard( id ) { + if ( ! globalThis.IS_GUTENBERG_PLUGIN ) { + return; + } + const target = document.getElementById( id ); + const root = createRoot( target ); + + root.render( Welcome To Posts ); + + return root; +} diff --git a/packages/edit-site/src/posts.scss b/packages/edit-site/src/posts.scss new file mode 100644 index 00000000000000..777ee3fa3412d5 --- /dev/null +++ b/packages/edit-site/src/posts.scss @@ -0,0 +1,19 @@ +@include wordpress-admin-schemes(); + +#wpadminbar, +#adminmenumain { + display: none; +} +#wpcontent { + margin-left: 0; +} +body { + @include wp-admin-reset("#gutenberg-posts-dashboard"); + @include reset; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + min-height: 100vh; +}