handling thumbnails for reportages
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2026-05-27 12:11:53 +02:00
parent 6584f7edf2
commit 11ea2f9fde

View File

@ -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);