Created
August 21, 2012 10:07
-
-
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
This file contains hidden or 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
| 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()); | |
| }); | |
| }); |
This file contains hidden or 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 | |
| /** | |
| * 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