-
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
Boilerplate for classic stylebook #66851
Draft
tellthemachines
wants to merge
17
commits into
trunk
Choose a base branch
from
try/classic-stylebook
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+244
−36
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fe4e7e9
Boilerplate for classic stylebook
tellthemachines 2aa8b7a
Add provider and settings
tellthemachines 1e211ff
Fix link to dashboard
tellthemachines 69ada87
Add customizer styles to the editor.
tellthemachines a900d99
Integrate overview section.
tellthemachines a77ab0a
Make items non-clickable
tellthemachines 62c2e1f
Display classic theme color and gradient palettes
tellthemachines edae5f6
Remove aria label if area isn't clickable
tellthemachines 1a53be3
Update to use site editor layout with new route
tellthemachines 1e34450
Make style book default mobile view
tellthemachines 2581276
Rename things to be more future proof
tellthemachines 8e617ec
update name
tellthemachines 218a025
Canvas shouldn't go into edit mode when resizing
tellthemachines 8379831
Add core PR
tellthemachines a6a3575
lint PHP
tellthemachines 9f55b77
Use site editor URL
tellthemachines db6e3b1
remove whitespace
tellthemachines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/7865 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/66851 |
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,42 @@ | ||
<?php | ||
/** | ||
* Set up a screen to show stylebook for classic themes. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Add a Styles submenu under the Appearance menu | ||
* for Classic themes. | ||
* | ||
* @global array $submenu | ||
*/ | ||
function gutenberg_add_styles_submenu_item() { | ||
if ( ! wp_is_block_theme() ) { | ||
global $submenu; | ||
|
||
$styles_menu_item = array( | ||
__( 'Styles', 'gutenberg' ), | ||
'edit_theme_options', | ||
'site-editor.php?path=/style-book', | ||
); | ||
// Insert the Styles submenu item at position 2. | ||
array_splice( $submenu['themes.php'], 2, 0, array( $styles_menu_item ) ); | ||
} | ||
} | ||
add_action( 'admin_init', 'gutenberg_add_styles_submenu_item' ); | ||
|
||
/** | ||
* Filter the `wp_die_handler` to allow access to the Site Editor's Styles page | ||
* for Classic themes. | ||
* | ||
* @param callable $default_handler The default handler. | ||
* @return callable The default handler or a custom handler. | ||
*/ | ||
function gutenberg_styles_wp_die_handler( $default_handler ) { | ||
if ( ! wp_is_block_theme() && str_contains( $_SERVER['REQUEST_URI'], 'site-editor.php' ) && isset( $_GET['path'] ) && 'style-book' === sanitize_key( $_GET['path'] ) ) { | ||
return '__return_false'; | ||
} | ||
return $default_handler; | ||
} | ||
add_filter( 'wp_die_handler', 'gutenberg_styles_wp_die_handler' ); | ||
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
35 changes: 35 additions & 0 deletions
35
packages/edit-site/src/components/site-editor-routes/static-stylebook.js
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,35 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import SidebarNavigationScreen from '../sidebar-navigation-screen'; | ||
import { StyleBookPreview } from '../style-book'; | ||
|
||
export const staticStylebookRoute = { | ||
name: 'static-stylebook', | ||
match: ( params ) => { | ||
return ( | ||
params.path && | ||
params.path.startsWith( '/style-book' ) && | ||
params.canvas !== 'edit' | ||
); | ||
}, | ||
areas: { | ||
sidebar: ( | ||
<SidebarNavigationScreen | ||
title={ __( 'Styles' ) } | ||
description={ __( 'Overview of styled blocks.' ) } | ||
isRoot | ||
/> | ||
), | ||
preview: <StyleBookPreview />, | ||
mobile: <StyleBookPreview />, | ||
}, | ||
widths: { | ||
content: 380, | ||
}, | ||
}; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 feel the url check that is done in Core should be removed entirely. We should just allow access to the full site editor in classic themes and let the frontend code handle the routing.
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.
(nothing to be done here but maybe something for the backport PR)