forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Posts Dashboard: Add a new experimental empty page (WordPress#62406)
Co-authored-by: youknowriad <[email protected]> Co-authored-by: fabiankaegy <[email protected]>
- Loading branch information
1 parent
7c854bb
commit 5d12b39
Showing
6 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |