Skip to content

Instantly share code, notes, and snippets.

@billerickson billerickson/functions.php Secret
Last active May 13, 2019

Embed
What would you like to do?
<?php
/**
* Gutenberg layout class
* @see https://www.billerickson.net/change-gutenberg-content-width-to-match-layout/
*
* @param string $classes
* @return string
*/
function ea_gutenberg_layout_class( $classes ) {
$screen = get_current_screen();
if( ! $screen->is_block_editor() )
return $classes;
$layout = false;
$post_id = isset( $_GET['post'] ) ? intval( $_GET['post'] ) : false;
// Get post-specific layout
if( $post_id )
$layout = genesis_get_custom_field( '_genesis_layout', $post_id );
// Pages use full width as default, see below
if( empty( $layout ) && 'page' === get_post_type() )
$layout = 'full-width-content';
// If no post-specific layout, use site-wide default
elseif( empty( $layout ) )
$layout = genesis_get_option( 'site_layout' );
$classes .= ' ' . $layout . ' ';
return $classes;
}
add_filter( 'admin_body_class', 'ea_gutenberg_layout_class' );
/**
* Full width layout for pages as default
*
* @param string $layout
* @return string
*/
function ea_full_width_pages( $layout ) {
if( is_page() )
$layout = 'full-width-content';
return $layout;
}
add_filter( 'genesis_pre_get_option_site_layout', 'ea_full_width_pages' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.