-
-
Save billerickson/ca40ce486ce3512b0c1ce90840c232c8 to your computer and use it in GitHub Desktop.
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
wp.domReady(function () { | |
yourTheme.updateLayoutClass(); | |
var layouts = document.querySelector(".genesis-layout-selector"); | |
if( null === layouts ) | |
return; | |
layouts.addEventListener("input", function (e) { | |
yourTheme.updateLayoutClass(); | |
}); | |
}); | |
var yourTheme = { | |
getLayout: function () { | |
var inputs = document.querySelectorAll(".genesis-layout-selector input"); | |
var layout = ""; | |
for (var i = 0, len = inputs.length; i < len; i++) { | |
if (inputs[i].checked) { | |
layout = inputs[i].getAttribute("id"); | |
break; | |
} | |
} | |
if (layout === "default-layout") layout = yourThemeConfig.defaultLayout; | |
return layout; | |
}, | |
setWrapperClass: function (layout) { | |
var root = document.querySelector("body"); | |
var classes = root.classList; | |
classes.forEach(function(c){ | |
if (c.includes("genesis-")) root.classList.remove(c); | |
}); | |
root.classList.add("genesis-" + layout); | |
}, | |
updateLayoutClass: function() { | |
var layout = yourTheme.getLayout(); | |
yourTheme.setWrapperClass(layout); | |
} | |
}; |
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
<?php | |
/** | |
* Gutenberg scripts and styles | |
* | |
*/ | |
function ea_gutenberg_scripts() { | |
wp_enqueue_style( 'ea-genesis-layout', get_stylesheet_directory_uri() . '/assets/css/genesis-layout.css' ); | |
wp_enqueue_script( 'ea-editor', get_stylesheet_directory_uri() . '/assets/js/editor.js', array( 'wp-blocks', 'wp-dom' ), filemtime( get_stylesheet_directory() . '/assets/js/editor.js' ), true ); | |
$post_id = isset( $_GET['post'] ) ? intval( $_GET['post'] ) : false; | |
$post_type = isset( $_GET['post_type'] ) ? esc_attr( $_GET['post_type'] ) : false; | |
$default_layout = ( !empty( $post_id ) && 'page' === get_post_type( $post_id ) ) || ( !empty( $post_type ) && 'page' === $post_type ) ? 'full-width-content' : genesis_get_default_layout(); | |
wp_localize_script( 'ea-editor', 'yourThemeConfig', array( | |
'defaultLayout' => $default_layout, | |
)); | |
} | |
add_action( 'enqueue_block_editor_assets', 'ea_gutenberg_scripts' ); |
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
.genesis-content-sidebar .editor-styles-wrapper .wp-block, | |
.genesis-sidebar-content .editor-styles-wrapper .wp-block { | |
max-width: 640px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment