Skip to content

Instantly share code, notes, and snippets.

@scottnix
Created May 7, 2013 22:50
Show Gist options
  • Save scottnix/5536807 to your computer and use it in GitHub Desktop.
Save scottnix/5536807 to your computer and use it in GitHub Desktop.
Removes the Deprecated Templates from the dropdowns in the Page Admin screens in WordPress
// remove the deprecated options from the Page Template menu in WordPress Admin
// this removes them in both sections, the main edit screen and the quick edit opion using jQuery
// http://wordpress.stackexchange.com/questions/13671/how-to-remove-a-parent-theme-page-template-from-a-child-theme
function wpse_13671_script_enqueuer() {
global $current_screen;
/**
* /wp-admin/edit.php?post_type=page
*/
if('edit-page' == $current_screen->id)
{
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$("a.editinline").live("click", function () {
var ilc_qe_id = inlineEditPost.getId(this);
setTimeout(function() {
$('#edit-'+ilc_qe_id+' select[name="page_template"] option[value="template-page-blog.php"]').remove();
$('#edit-'+ilc_qe_id+' select[name="page_template"] option[value="archives.php"]').remove();
}, 100);
});
$('#doaction, #doaction2').live("click", function () {
setTimeout(function() {
$('#bulk-edit select[name="page_template"] option[value="template-page-blog.php"]').remove();
$('#bulk-edit select[name="page_template"] option[value="archives.php"]').remove();
}, 100);
});
});
</script>
<?php
}
/**
* /wp-admin/post.php?post=21&action=edit
*/
if( 'page' == $current_screen->id )
{
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$('#page_template option[value="template-page-blog.php"]').remove();
$('#page_template option[value="archives.php"]').remove();
});
</script>
<?php
}
}
add_action('admin_head', 'wpse_13671_script_enqueuer');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment