FEATURE Handling Custom updated messages with artisan url for post type chantiers
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
805f861d5e
commit
1178028bfb
|
|
@ -1,5 +1,9 @@
|
|||
<?php
|
||||
|
||||
/* -----------------------------------------
|
||||
HANDLE TITLE CHANGES ON ACF SAVE POST
|
||||
-----------------------------------------*/
|
||||
|
||||
function metiers_patrimoine_chantiers_post_updater($post_id)
|
||||
{
|
||||
if (!$post_id || get_post_type() !== 'chantiers') return;
|
||||
|
|
@ -28,6 +32,32 @@ function metiers_patrimoine_chantiers_post_updater($post_id)
|
|||
add_action('acf/save_post', 'metiers_patrimoine_chantiers_post_updater', 20);
|
||||
|
||||
|
||||
|
||||
|
||||
/* -----------------------------------------
|
||||
HANDLE POST UPDATED MESSAGES
|
||||
-----------------------------------------*/
|
||||
|
||||
function chantiers_post_updated_messages($messages)
|
||||
{
|
||||
global $post;
|
||||
$post_type = get_post_type($post);
|
||||
$artisan = get_field('artisan', $post->ID);
|
||||
|
||||
if ($post_type === 'chantiers' && $artisan->ID) {
|
||||
$artisan_link = get_the_permalink($artisan->ID);
|
||||
|
||||
$messages[$post_type][1] = 'Chantier mis à jour. <a target="_blank" href="' . $artisan_link . '">Voir sur la fiche de l\'artisan</a>';
|
||||
$messages[$post_type][6] = 'Chantier publié. <a target="_blank" href="' . $artisan_link . '">Voir sur la fiche de l\'artisan</a>';
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
add_filter('post_updated_messages', 'chantiers_post_updated_messages');
|
||||
|
||||
|
||||
|
||||
|
||||
/* -----------------------------------------
|
||||
EDIT ARTISAN LINK ON CHANTIER EDIT PAGE
|
||||
-----------------------------------------*/
|
||||
|
|
@ -135,9 +165,9 @@ add_action('edit_form_after_title', function () {
|
|||
?>
|
||||
<div id="post-custom-superior-toolbar">
|
||||
<?php if ($return_to) : ?>
|
||||
<a href="<?php echo esc_url($return_to) ?>" class="edit-fiche-artisan-link"><img src='<?php echo get_stylesheet_directory_uri() . '/resources/img/icons/tools.svg' ?>' /> Retour vers la fiche de l’artisan </a>
|
||||
<a href="<?php echo esc_url($return_to) ?>" class="edit-fiche-artisan-link"><img src='<?php echo get_stylesheet_directory_uri() . '/resources/img/icons/tools.svg' ?>' /> Retour vers la fiche de l'artisan </a>
|
||||
<?php elseif ($linked_artisan_id) : ?>
|
||||
<a href="<?php echo esc_url($edit_artisan_link) ?>" class="edit-fiche-artisan-link"><img src='<?php echo get_stylesheet_directory_uri() . '/resources/img/icons/tools.svg' ?>' /> Retour vers la fiche de l’artisan </a>
|
||||
<a href="<?php echo esc_url($edit_artisan_link) ?>" class="edit-fiche-artisan-link"><img src='<?php echo get_stylesheet_directory_uri() . '/resources/img/icons/tools.svg' ?>' /> Retour vers la fiche de l'artisan </a>
|
||||
<?php endif; ?>
|
||||
<div id="save-post-custom">
|
||||
<button class="">Sauvegarder</button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user