FEATURE Updating NL post status on fr post save
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ae3b45601a
commit
3724a2229d
|
|
@ -384,3 +384,32 @@ add_action('admin_enqueue_scripts', function () {
|
||||||
});
|
});
|
||||||
");
|
");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_action('save_post', 'update_artisan_nl_status_on_post_save');
|
||||||
|
|
||||||
|
function update_artisan_nl_status_on_post_save($post_id)
|
||||||
|
{
|
||||||
|
if (get_post_type($post_id) !== 'artisans') return;
|
||||||
|
|
||||||
|
// Éviter les sauvegardes en boucle
|
||||||
|
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
|
||||||
|
if (defined('DOING_AJAX') && DOING_AJAX) return;
|
||||||
|
if (wp_is_post_revision($post_id)) return;
|
||||||
|
|
||||||
|
// Récupérer la langue du post actuel
|
||||||
|
$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') {
|
||||||
|
|
||||||
|
// Récupérer l'ID du post correspondant en néerlandais
|
||||||
|
$nl_post_id = apply_filters('wpml_object_id', $post_id, 'artisans', TRUE, 'nl');
|
||||||
|
|
||||||
|
wp_update_post(array(
|
||||||
|
'ID' => $nl_post_id,
|
||||||
|
'post_status' => get_post_status($post_id)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user