Skip to content

Instantly share code, notes, and snippets.

@hotzeplotz
Created August 21, 2012 10:07
Show Gist options
  • Select an option

  • Save hotzeplotz/3414146 to your computer and use it in GitHub Desktop.

Select an option

Save hotzeplotz/3414146 to your computer and use it in GitHub Desktop.
Hide WordPress editor box while editing a page if a specific template is selected
jQuery(document).ready(function($) {
var editorElement = '#postdivrich';
var podsPrefix = /^pods-/;
function hideElementIfUnused(element, match, val) {
if(match.test(val)) {
$(element).hide();
} else {
$(element).show();
}
}
hideElementIfUnused(editorElement, podsPrefix, $('#page_template').val());
$('#page_template').change(function() {
hideElementIfUnused(editorElement, podsPrefix, $(this).val());
});
});
<?php
/**
* Hide WP Page editor box when we are editing a WP Page with a Pods
* template that doesn't grab content from the WP Page itself
*/
function hide_editor_box_when_editing_pods_pages($hook) {
if($hook != 'post.php')
return;
wp_enqueue_script('hide_editor_box', plugins_url('/lc-pods-ui.js', __FILE__));
}
add_action('admin_enqueue_scripts', 'hide_editor_box_when_editing_pods_pages');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment