Last active
August 29, 2015 14:13
-
-
Save joshuadavidnelson/abf807f973b86ae144a7 to your computer and use it in GitHub Desktop.
Remove Genesis Framework inpost layout box for posts only
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 | |
/** | |
* Don't show layout box on posts, only pages | |
* @author Joshua David Nelson, josh@joshaudnelson.com | |
*/ | |
add_action( 'init', 'jdn_remove_inpost_layouts' ); | |
function jdn_remove_inpost_layouts() { | |
// Bail if it's not an admin | |
if( !is_admin() ) | |
return; | |
// Method from Ross McCay: http://snippets.webaware.com.au/snippets/wordpress-admin_init-hook-and-the-elusive-typenow/ | |
global $typenow; | |
// when editing pages, $typenow isn't set until later! | |
if (empty($typenow)) { | |
// try to pick it up from the query string | |
if (!empty($_GET['post'])) { | |
$post = get_post($_GET['post']); | |
$typenow = $post->post_type; | |
} | |
// try to pick it up from the quick edit AJAX post | |
elseif (!empty($_POST['post_ID'])) { | |
$post = get_post($_POST['post_ID']); | |
$typenow = $post->post_type; | |
} | |
} | |
// Verify we're on the post page | |
if( !isset( $typenow ) || $typenow != 'post' ) | |
return; | |
// Remove the inpost layout action | |
remove_action( 'admin_menu', 'genesis_add_inpost_layout_box' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment