Last active
October 23, 2023 05:27
-
-
Save Rupashdas/4036322a5577be84cc9c677b46d21a4f to your computer and use it in GitHub Desktop.
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 | |
function get_page_id_by_template($page_template_filename){ | |
$pages = get_pages( array( | |
'meta_key' => '_wp_page_template', | |
'meta_value' => $page_template_filename | |
) ); | |
$pageIds = array(); | |
foreach($pages as $page){ | |
$pageId = $page->ID; | |
array_push($pageIds, $pageId); | |
} | |
return $pageIds; | |
} | |
function croft_hide_editor() { | |
$page_id = isset($_GET['post']) ? $_GET['post'] : '' ; | |
if($page_id != ""){ | |
$disabled_IDs = array(); | |
$croft_page_templates = array( 'template-home.php'); | |
foreach($croft_page_templates as $croft_page_template){ | |
$pageIds = get_page_id_by_template('templates/'.$croft_page_template); | |
foreach($pageIds as $pageId){ | |
array_push($disabled_IDs, $pageId); | |
} | |
} | |
if (in_array($page_id, $disabled_IDs)) { | |
remove_post_type_support('page', 'editor'); | |
} | |
} | |
} | |
add_action( 'admin_init', 'croft_hide_editor' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment