FIX update artisan infinite loop when no artisan nl id
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nonimart 2025-09-02 10:16:24 +02:00
parent 3724a2229d
commit cde17bbf33

View File

@ -398,14 +398,15 @@ function update_artisan_nl_status_on_post_save($post_id)
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (defined('DOING_AJAX') && DOING_AJAX) return; if (defined('DOING_AJAX') && DOING_AJAX) return;
if (wp_is_post_revision($post_id)) return; if (wp_is_post_revision($post_id)) return;
if (get_post_status($post_id) === 'auto-draft') return;
// Récupérer la langue du post actuel
$current_language = apply_filters('wpml_post_language_details', null, $post_id); $current_language = apply_filters('wpml_post_language_details', null, $post_id);
// Si c'est un post français, synchroniser avec le post néerlandais
if (isset($current_language['language_code']) && $current_language['language_code'] === 'fr') { if (isset($current_language['language_code']) && $current_language['language_code'] === 'fr') {
// Récupérer l'ID du post correspondant en néerlandais // Récupérer l'ID du post correspondant en néerlandais
$nl_post_id = apply_filters('wpml_object_id', $post_id, 'artisans', TRUE, 'nl'); $nl_post_id = apply_filters('wpml_object_id', $post_id, 'artisans', false, 'nl');
if (!isset($nl_post_id)) return null;
wp_update_post(array( wp_update_post(array(
'ID' => $nl_post_id, 'ID' => $nl_post_id,