Created
September 7, 2012 19:03
-
-
Save wpsmith/3668649 to your computer and use it in GitHub Desktop.
Hides meta box based on page template 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
| /* | |
| * Meta Box Admin Script | |
| * | |
| * @author Travis Smith | |
| * @version 1.0.0 | |
| */ | |
| /* | |
| * Hides meta box based on page template selected. | |
| * | |
| * @param string metabox_name Meta Box Selector ID | |
| * @param string page_template_file Template File | |
| */ | |
| function wps_hide_mb( metabox_name, page_template_file ) { | |
| 'use strict'; | |
| var metabox = jQuery('#'+metabox_name); | |
| var page_template = jQuery('#page_template'); | |
| page_template.change(function() { | |
| if ( page_template_file == jQuery(this).val() ) { | |
| metabox.show(); | |
| jQuery('#'+metabox_name+'-hide').attr("checked", "checked"); | |
| } else { | |
| metabox.hide(); | |
| jQuery('#'+metabox_name+'-hide').removeAttr("checked"); | |
| } | |
| }).change(); | |
| } | |
| jQuery(document).ready( function() { | |
| wps_hide_mb( 'wps_portfolio_box', 'page_portfolio.php' ); | |
| wps_hide_mb( 'wps_services_box', 'page_services.php' ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment