FEATURE Disable editor for 'analyses-etudes' post type based on term condition
This commit is contained in:
parent
9cda664791
commit
d657b68a9d
|
|
@ -329,3 +329,42 @@ add_action('admin_menu', function () {
|
||||||
add_filter('menu_order', 'carhop_new_admin_menu_order');
|
add_filter('menu_order', 'carhop_new_admin_menu_order');
|
||||||
add_filter('custom_menu_order', '__return_true');
|
add_filter('custom_menu_order', '__return_true');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
DESACTIVATE EDITOR FOR ANALYSES & ETUDES --> Analyse only
|
||||||
|
------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
function carhop_analyses_etudes_maybe_remove_editor()
|
||||||
|
{
|
||||||
|
if (get_current_blog_id() !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!post_type_exists('analyses-etudes')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_id = 0;
|
||||||
|
if (isset($_GET['post'])) {
|
||||||
|
$post_id = (int) $_GET['post'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($post_id > 0) {
|
||||||
|
$post = get_post($post_id);
|
||||||
|
if (!$post || $post->post_type !== 'analyses-etudes') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$is_analyse = has_term('analyse', 'type-analyse-etude', $post_id);
|
||||||
|
if ($is_analyse) {
|
||||||
|
remove_post_type_support('analyses-etudes', 'editor');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['post_type']) && $_GET['post_type'] === 'analyses-etudes') {
|
||||||
|
remove_post_type_support('analyses-etudes', 'editor');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action('load-post.php', 'carhop_analyses_etudes_maybe_remove_editor', 5);
|
||||||
|
add_action('load-post-new.php', 'carhop_analyses_etudes_maybe_remove_editor', 5);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user