From 11ea2f9fdee2550303f63dd8c171d8428bb5fc93 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 27 May 2026 12:11:53 +0200 Subject: [PATCH] handling thumbnails for reportages --- mu-plugins/carhop-post-types.php | 40 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/mu-plugins/carhop-post-types.php b/mu-plugins/carhop-post-types.php index 4f62873..d30dc40 100644 --- a/mu-plugins/carhop-post-types.php +++ b/mu-plugins/carhop-post-types.php @@ -264,7 +264,7 @@ function carhop_create_posttype() 'rewrite' => array('slug' => 'reportages'), 'menu_icon' => 'dashicons-megaphone', 'show_in_rest' => true, - 'supports' => array('title', 'revisions'), + 'supports' => array('title', 'revisions', 'thumbnail'), 'menu_position' => 4, ) ); @@ -334,37 +334,27 @@ add_action('admin_menu', function () { DESACTIVATE EDITOR FOR ANALYSES & ETUDES --> Analyse only ------------------------------------------------------------------------*/ -function carhop_analyses_etudes_maybe_remove_editor() +/* ---------------------------------------------------------------------- + DESACTIVATE EDITOR FOR ANALYSES --> Analyse only +------------------------------------------------------------------------*/ + +function carhop_disable_editor_for_analyses($use_block_editor, $post) { if (get_current_blog_id() !== 1) { - return; - } - if (!post_type_exists('analyses-etudes')) { - return; + return $use_block_editor; } - $post_id = 0; - if (isset($_GET['post'])) { - $post_id = (int) $_GET['post']; + if (!$post || $post->post_type !== 'analyses-etudes') { + return $use_block_editor; } - 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; + $is_analyse = has_term('analyse', 'type-analyse-etude', $post); + + if ($is_analyse) { + return false; } - if (isset($_GET['post_type']) && $_GET['post_type'] === 'analyses-etudes') { - remove_post_type_support('analyses-etudes', 'editor'); - } + return $use_block_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); - +add_filter('use_block_editor_for_post', 'carhop_disable_editor_for_analyses', 10, 2); \ No newline at end of file