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

Detecting pages/posts authored via Gutenberg #2235

Closed
WPDevHQ opened this issue Aug 4, 2017 · 4 comments
Closed

Detecting pages/posts authored via Gutenberg #2235

WPDevHQ opened this issue Aug 4, 2017 · 4 comments

Comments

@WPDevHQ
Copy link

WPDevHQ commented Aug 4, 2017

Is there a way to detect if a page/post is authored via Gutenberg?

Styling older themes when the editor is finally release may prove to be a little bit of a nighmare for some authors. Perhaps a body class of gutenberg could be filtered in?

Right now I've had to create a custom template in order to allow for alignwide/alignfull to take up the full defined width instead of being contrained in the predefined content area width!
`

@westonruter
Copy link
Member

There is a a gutenberg_post_has_blocks function proposed in #1797 which could be used in a theme to add a body class, and even without it you could do it manually in a theme via:

function mytheme_add_gutenberg_body_class( $body_classes ) {
	if ( is_singular() && false !== strpos( get_queried_object()->post_content, '<!-- wp:' ) ) {
		$body_classes[] = 'gutenberg';
	}
	return $body_classes;
}
add_filter( 'body_class', 'mytheme_add_gutenberg_body_class' );

@WPDevHQ
Copy link
Author

WPDevHQ commented Aug 5, 2017

That worked perfectly, thank you @westonruter

@paaljoachim
Copy link
Contributor

That is a very good idea Zulfikar.
Having an auto detect if a post/page is created in Gutenberg or the standard editor and giving a message or auto direct to open in the editor it has been created in seems like a very good idea.

@karmatosed
Copy link
Member

As the solution for a theme has been given, I think for now closing this. I'm not sure the core Gutenberg needs to display a message at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants