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

Posts Dashboard: Add a new experimental empty page #62406

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
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
43 changes: 43 additions & 0 deletions lib/experimental/posts/load.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Bootstraps the new posts dashboard page.
*
* @package Gutenberg
*/

add_action( 'admin_menu', 'gutenberg_replace_posts_dashboard' );

/**
* Renders the new posts dashboard page.
*/
function gutenberg_posts_dashboard() {
wp_register_style(
'wp-gutenberg-posts-dashboard',
gutenberg_url( 'build/edit-site/posts.css', __FILE__ ),
array()
);
wp_enqueue_style( 'wp-gutenberg-posts-dashboard' );
wp_add_inline_script( 'wp-edit-site', 'window.wp.editSite.initializePostsDashboard( "gutenberg-posts-dashboard" );', 'after' );
wp_enqueue_script( 'wp-edit-site' );

echo '<div id="gutenberg-posts-dashboard"></div>';
}

/**
* 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'
);
}
12 changes: 12 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 4 additions & 0 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
20 changes: 20 additions & 0 deletions packages/edit-site/src/posts.js
Original file line number Diff line number Diff line change
@@ -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( <StrictMode>Welcome To Posts</StrictMode> );

return root;
}
19 changes: 19 additions & 0 deletions packages/edit-site/src/posts.scss
Original file line number Diff line number Diff line change
@@ -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;
}
Loading