FEAT Enhanced artisans post management with automated title and status updates, custom metaboxes, and improved admin interface elements.
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
242682bd5d
commit
e3be26b295
|
|
@ -1,330 +1,330 @@
|
||||||
<?php
|
<?php
|
||||||
/* ---------------------------------------
|
/* ---------------------------------------
|
||||||
ARTISANS POST TITLE & ADRESS STATE UPDATER
|
ARTISANS POST TITLE & ADRESS STATE UPDATER
|
||||||
------------------------------------------*/
|
------------------------------------------*/
|
||||||
function metiers_patrimoine_artisans_post_updater($post_id)
|
function metiers_patrimoine_artisans_post_updater($post_id)
|
||||||
{
|
{
|
||||||
if (!$post_id) return;
|
if (!$post_id) return;
|
||||||
|
|
||||||
$my_post = array();
|
$my_post = array();
|
||||||
$my_post['ID'] = $post_id;
|
$my_post['ID'] = $post_id;
|
||||||
$name = get_field("name", $post_id);
|
$name = get_field("name", $post_id);
|
||||||
$address = get_field("adresse", $post_id);
|
$address = get_field("adresse", $post_id);
|
||||||
|
|
||||||
if (get_post_type() == 'artisans' && $name) {
|
if (get_post_type() == 'artisans' && $name) {
|
||||||
$my_post['post_title'] = "";
|
$my_post['post_title'] = "";
|
||||||
$my_post['post_title'] = $name;
|
$my_post['post_title'] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($address && isset($address['country'])) {
|
if ($address && isset($address['country'])) {
|
||||||
$stateGenericName = getGenericStateNameFromAcfStateName($address['state']) ?? "";
|
$stateGenericName = getGenericStateNameFromAcfStateName($address['state']) ?? "";
|
||||||
update_post_meta($post_id, 'state', $stateGenericName);
|
update_post_meta($post_id, 'state', $stateGenericName);
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_update_post($my_post);
|
wp_update_post($my_post);
|
||||||
}
|
}
|
||||||
add_action('acf/save_post', 'metiers_patrimoine_artisans_post_updater', 20);
|
add_action('acf/save_post', 'metiers_patrimoine_artisans_post_updater', 20);
|
||||||
|
|
||||||
/* -----------------------------------------------
|
/* -----------------------------------------------
|
||||||
AUTOMATIZE POST STATUS DEPENDING ON MDP STATUS
|
AUTOMATIZE POST STATUS DEPENDING ON MDP STATUS
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
function update_post_status_based_on_mdp_status($post_id)
|
function update_post_status_based_on_mdp_status($post_id)
|
||||||
{
|
{
|
||||||
if (get_post_type($post_id) !== 'artisans') return;
|
if (get_post_type($post_id) !== 'artisans') return;
|
||||||
|
|
||||||
$mdp_status = get_field('mdp_status', $post_id);
|
$mdp_status = get_field('mdp_status', $post_id);
|
||||||
$post_update = array(
|
$post_update = array(
|
||||||
'ID' => $post_id
|
'ID' => $post_id
|
||||||
);
|
);
|
||||||
// Définir le statut en fonction de la valeur du statut de travail mdp_status
|
// Définir le statut en fonction de la valeur du statut de travail mdp_status
|
||||||
if ($mdp_status && isset($mdp_status['value'])) {
|
if ($mdp_status && isset($mdp_status['value'])) {
|
||||||
switch ($mdp_status['value']) {
|
switch ($mdp_status['value']) {
|
||||||
case 'ok':
|
case 'ok':
|
||||||
case 'to_actualize':
|
case 'to_actualize':
|
||||||
$post_update['post_status'] = 'publish';
|
$post_update['post_status'] = 'publish';
|
||||||
break;
|
break;
|
||||||
case 'to_contact':
|
case 'to_contact':
|
||||||
case 'deleted':
|
case 'deleted':
|
||||||
case 'rejected':
|
case 'rejected':
|
||||||
case 'none':
|
case 'none':
|
||||||
$post_update['post_status'] = 'offline';
|
$post_update['post_status'] = 'offline';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_update_post($post_update);
|
wp_update_post($post_update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('acf/save_post', 'update_post_status_based_on_mdp_status', 20);
|
add_action('acf/save_post', 'update_post_status_based_on_mdp_status', 20);
|
||||||
|
|
||||||
/* ---------------------------------------
|
/* ---------------------------------------
|
||||||
CUSTOM TOP CONTENT AFTER POST TYPE TITLE
|
CUSTOM TOP CONTENT AFTER POST TYPE TITLE
|
||||||
------------------------------------------*/
|
------------------------------------------*/
|
||||||
add_action('edit_form_after_title', function () {
|
add_action('edit_form_after_title', function () {
|
||||||
$screen = get_current_screen();
|
$screen = get_current_screen();
|
||||||
|
|
||||||
$status_mdp = get_field('mdp_status', get_the_ID());
|
$status_mdp = get_field('mdp_status', get_the_ID());
|
||||||
$post_status = get_post_status();
|
$post_status = get_post_status();
|
||||||
$translatedStatus = translate_wordpress_online_statuses($post_status);
|
$translatedStatus = translate_wordpress_online_statuses($post_status);
|
||||||
$post_link = get_preview_post_link();
|
$post_link = get_preview_post_link();
|
||||||
|
|
||||||
if ($screen && $screen->post_type === 'artisans') {
|
if ($screen && $screen->post_type === 'artisans') {
|
||||||
?>
|
?>
|
||||||
<h1 class="admin-artisan-title"><?php echo get_the_title() ?></h1>
|
<h1 class="admin-artisan-title"><?php echo get_the_title() ?></h1>
|
||||||
<?php if (!empty($post_link) && $screen->action !== 'add') : ?>
|
<?php if (!empty($post_link) && $screen->action !== 'add') : ?>
|
||||||
<div class="preview-artisan-link">
|
<div class="preview-artisan-link">
|
||||||
<a href="<?php echo $post_link; ?>" target="_blank" class="button button-primary">
|
<a href="<?php echo $post_link; ?>" target="_blank" class="button button-primary">
|
||||||
<span class="dashicons dashicons-admin-users" style="margin-right: 5px;"></span>
|
<span class="dashicons dashicons-admin-users" style="margin-right: 5px;"></span>
|
||||||
Voir la fiche
|
Voir la fiche
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div id="top-status" class="top-status">
|
<div id="top-status" class="top-status">
|
||||||
<div class="state-container">
|
<div class="state-container">
|
||||||
<p>État :</p>
|
<p>État :</p>
|
||||||
<span class="post-state post-state--<?php echo $post_status; ?>"><?php echo $translatedStatus; ?></span>
|
<span class="post-state post-state--<?php echo $post_status; ?>"><?php echo $translatedStatus; ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="state-container">
|
<div class="state-container">
|
||||||
<p>Statut de travail :</p>
|
<p>Statut de travail :</p>
|
||||||
<?php if (isset($status_mdp) && isset($status_mdp['value']) && isset($status_mdp['label'])): ?>
|
<?php if (isset($status_mdp) && isset($status_mdp['value']) && isset($status_mdp['label'])): ?>
|
||||||
<span class="status-state status-state--<?php echo $status_mdp['value']; ?> "><?php echo $status_mdp['label']; ?></span>
|
<span class="status-state status-state--<?php echo $status_mdp['value']; ?> "><?php echo $status_mdp['label']; ?></span>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<span class="status-state status-state--none">Aucun !!</span>
|
<span class="status-state status-state--none">Aucun !!</span>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <button id="set-offline-status" class="button button-secondary">Mettre Hors Ligne</button>
|
<!-- <button id="set-offline-status" class="button button-secondary">Mettre Hors Ligne</button>
|
||||||
<button id="set-online-status" class="button button-secondary">Mettre En Ligne</button> -->
|
<button id="set-online-status" class="button button-secondary">Mettre En Ligne</button> -->
|
||||||
<div id="save-post-custom">
|
<div id="save-post-custom">
|
||||||
<button class="">Sauvegarder</button>
|
<button class="">Sauvegarder</button>
|
||||||
<span class="spinner"></span>
|
<span class="spinner"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
$('#save-post-custom').on('click', function(e) {
|
$('#save-post-custom').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const $button = $(this.querySelector('button'));
|
const $button = $(this.querySelector('button'));
|
||||||
const $spinner = $(this.querySelector('.spinner'));
|
const $spinner = $(this.querySelector('.spinner'));
|
||||||
|
|
||||||
// Désactiver le bouton et changer le texte
|
// Désactiver le bouton et changer le texte
|
||||||
$button.prop('disabled', true).text('Sauvegarde en cours...');
|
$button.prop('disabled', true).text('Sauvegarde en cours...');
|
||||||
$spinner.show();
|
$spinner.show();
|
||||||
$spinner.addClass('is-active');
|
$spinner.addClass('is-active');
|
||||||
|
|
||||||
// Déclencher la sauvegarde
|
// Déclencher la sauvegarde
|
||||||
$('#publish').trigger('click');
|
$('#publish').trigger('click');
|
||||||
|
|
||||||
// Vérifier les erreurs ACF après un court délai
|
// Vérifier les erreurs ACF après un court délai
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// Vérifier s'il y a des messages d'erreur ACF
|
// Vérifier s'il y a des messages d'erreur ACF
|
||||||
if ($('.acf-notice.-error').length > 0) {
|
if ($('.acf-notice.-error').length > 0) {
|
||||||
// Réinitialiser le bouton immédiatement si une erreur est détectée
|
// Réinitialiser le bouton immédiatement si une erreur est détectée
|
||||||
$button.prop('disabled', false).text('Sauvegarder');
|
$button.prop('disabled', false).text('Sauvegarder');
|
||||||
$spinner.hide();
|
$spinner.hide();
|
||||||
$spinner.removeClass('is-active');
|
$spinner.removeClass('is-active');
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
// Réactiver le bouton et restaurer le texte après un délai plus long
|
// Réactiver le bouton et restaurer le texte après un délai plus long
|
||||||
// (ceci ne s'exécutera que si la page n'est pas rechargée)
|
// (ceci ne s'exécutera que si la page n'est pas rechargée)
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$button.prop('disabled', false).text('Sauvegarder');
|
$button.prop('disabled', false).text('Sauvegarder');
|
||||||
$spinner.hide();
|
$spinner.hide();
|
||||||
$spinner.removeClass('is-active');
|
$spinner.removeClass('is-active');
|
||||||
}, 20000);
|
}, 20000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------
|
/* ---------------------------------------
|
||||||
METABOXES
|
METABOXES
|
||||||
------------------------------------------*/
|
------------------------------------------*/
|
||||||
/** ENQUEUE CUSTOM CHANTIER META BOX AT THE END OF THE PAGE **/
|
/** ENQUEUE CUSTOM CHANTIER META BOX AT THE END OF THE PAGE **/
|
||||||
add_action('add_meta_boxes', function () {
|
add_action('add_meta_boxes', function () {
|
||||||
add_meta_box(
|
add_meta_box(
|
||||||
'admin_artisan_chantier_list',
|
'admin_artisan_chantier_list',
|
||||||
'Chantiers réalisés',
|
'Chantiers réalisés',
|
||||||
'render_custom_chantier_box_content',
|
'render_custom_chantier_box_content',
|
||||||
'artisans',
|
'artisans',
|
||||||
'normal',
|
'normal',
|
||||||
'default'
|
'default'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
/** RENDER CHANTIER METABOX **/
|
/** RENDER CHANTIER METABOX **/
|
||||||
function render_custom_chantier_box_content($post)
|
function render_custom_chantier_box_content($post)
|
||||||
{
|
{
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'chantiers',
|
'post_type' => 'chantiers',
|
||||||
'posts_per_page' => -1,
|
'posts_per_page' => -1,
|
||||||
'post_status' => 'publish',
|
'post_status' => 'publish',
|
||||||
'meta_query' => array(
|
'meta_query' => array(
|
||||||
array(
|
array(
|
||||||
'key' => 'artisan',
|
'key' => 'artisan',
|
||||||
'value' => $post->ID,
|
'value' => $post->ID,
|
||||||
'compare' => '=',
|
'compare' => '=',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$chantiers = new WP_Query($args);
|
$chantiers = new WP_Query($args);
|
||||||
|
|
||||||
|
|
||||||
// Afficher les chantiers
|
// Afficher les chantiers
|
||||||
|
|
||||||
if ($chantiers->have_posts()) {
|
if ($chantiers->have_posts()) {
|
||||||
|
|
||||||
$artisan_id = get_the_ID();
|
$artisan_id = get_the_ID();
|
||||||
$return_to = get_edit_post_link($artisan_id);
|
$return_to = get_edit_post_link($artisan_id);
|
||||||
|
|
||||||
|
|
||||||
echo '<h3> Chantiers réalisés </h3>';
|
echo '<h3> Chantiers réalisés </h3>';
|
||||||
echo '<ul>';
|
echo '<ul>';
|
||||||
while ($chantiers->have_posts()) {
|
while ($chantiers->have_posts()) {
|
||||||
$chantiers->the_post();
|
$chantiers->the_post();
|
||||||
$chantier_name = get_field('chantier_name');
|
$chantier_name = get_field('chantier_name');
|
||||||
echo '<li><a href="' . get_edit_post_link() . '"> <img src=' . get_stylesheet_directory_uri() . '/resources/img/icons/document-inspect.svg' . ' /> ' . $chantier_name . '</a></li>';
|
echo '<li><a href="' . get_edit_post_link() . '"> <img src=' . get_stylesheet_directory_uri() . '/resources/img/icons/document-inspect.svg' . ' /> ' . $chantier_name . '</a></li>';
|
||||||
}
|
}
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
echo '<a href="' . admin_url('post-new.php?post_type=chantiers&return_to=' . urlencode($return_to)) . '" class="new-chantier">Ajouter un chantier</a>';
|
echo '<a href="' . admin_url('post-new.php?post_type=chantiers&return_to=' . urlencode($return_to)) . '" class="new-chantier">Ajouter un chantier</a>';
|
||||||
} else {
|
} else {
|
||||||
echo '<h3> Chantiers réalisés</h3>';
|
echo '<h3> Chantiers réalisés</h3>';
|
||||||
echo '<p class="no-results">Aucun chantier pour cette entreprise</p>';
|
echo '<p class="no-results">Aucun chantier pour cette entreprise</p>';
|
||||||
echo '<a href="' . admin_url('post-new.php?post_type=chantiers') . '" class="new-chantier">Ajouter un chantier</a>';
|
echo '<a href="' . admin_url('post-new.php?post_type=chantiers') . '" class="new-chantier">Ajouter un chantier</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** REMOVE SUBMITDIV METABOX **/
|
/** REMOVE SUBMITDIV METABOX **/
|
||||||
add_action('admin_menu', 'remove_submit_div');
|
add_action('admin_menu', 'remove_submit_div');
|
||||||
function remove_submit_div()
|
function remove_submit_div()
|
||||||
{
|
{
|
||||||
remove_meta_box('submitdiv', 'artisans', 'side');
|
remove_meta_box('submitdiv', 'artisans', 'side');
|
||||||
remove_meta_box('postimagediv', 'artisans', 'normal');
|
remove_meta_box('postimagediv', 'artisans', 'normal');
|
||||||
remove_meta_box('postimagediv', 'artisans', 'side');
|
remove_meta_box('postimagediv', 'artisans', 'side');
|
||||||
remove_meta_box('postimagediv', 'artisans', 'advanced');
|
remove_meta_box('postimagediv', 'artisans', 'advanced');
|
||||||
|
|
||||||
$user = wp_get_current_user();
|
$user = wp_get_current_user();
|
||||||
$metaboxes = get_user_meta($user->ID, 'metaboxhidden_artisans', true);
|
$metaboxes = get_user_meta($user->ID, 'metaboxhidden_artisans', true);
|
||||||
$metabox_order = get_user_meta($user->ID, 'meta-box-order_artisans', true);
|
$metabox_order = get_user_meta($user->ID, 'meta-box-order_artisans', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** UPDATE USER METABOX PREFERENCES WITH MANUAL ARRAY **/
|
/** UPDATE USER METABOX PREFERENCES WITH MANUAL ARRAY **/
|
||||||
function set_user_metabox_order($user_id)
|
function set_user_metabox_order($user_id)
|
||||||
{
|
{
|
||||||
$user_id = get_current_user_id();
|
$user_id = get_current_user_id();
|
||||||
// $metaboxes_order = get_user_meta($user_id, 'meta-box-order_artisans', true);
|
// $metaboxes_order = get_user_meta($user_id, 'meta-box-order_artisans', true);
|
||||||
// $user_info = get_user_meta($user_id);
|
// $user_info = get_user_meta($user_id);
|
||||||
$metaboxes_hidden = get_user_meta($user_id, 'metaboxhidden_artisans', true);
|
$metaboxes_hidden = get_user_meta($user_id, 'metaboxhidden_artisans', true);
|
||||||
|
|
||||||
$new_order = [
|
$new_order = [
|
||||||
'acf_after_title' => '',
|
'acf_after_title' => '',
|
||||||
'side' => 'postimagediv,icl_div',
|
'side' => 'postimagediv,icl_div',
|
||||||
'normal' => 'acf-group_670d265c6ec0e,admin_artisan_chantier_list,acf-group_67581cdaf3262,acf-group_672358433051b,submitdiv,slugdiv,revisionsdiv',
|
'normal' => 'acf-group_670d265c6ec0e,admin_artisan_chantier_list,acf-group_67581cdaf3262,acf-group_672358433051b,submitdiv,slugdiv,revisionsdiv',
|
||||||
'advanced' => 'rank_math_metabox',
|
'advanced' => 'rank_math_metabox',
|
||||||
];
|
];
|
||||||
update_user_meta($user_id, 'meta-box-order_artisans', $new_order);
|
update_user_meta($user_id, 'meta-box-order_artisans', $new_order);
|
||||||
|
|
||||||
if ($metaboxes_hidden === false || !is_array($metaboxes_hidden)) return;
|
if ($metaboxes_hidden === false || !is_array($metaboxes_hidden)) return;
|
||||||
|
|
||||||
$newArrray = array_merge($metaboxes_hidden, ['postimagediv', 'icldiv']);
|
$newArrray = array_merge($metaboxes_hidden, ['postimagediv', 'icldiv']);
|
||||||
update_user_meta($user_id, 'metaboxhidden_artisans', $newArrray);
|
update_user_meta($user_id, 'metaboxhidden_artisans', $newArrray);
|
||||||
}
|
}
|
||||||
add_action('admin_init', 'set_user_metabox_order');
|
add_action('admin_init', 'set_user_metabox_order');
|
||||||
|
|
||||||
/** RE-ENQUEUE SUBMITDIV METABOX **/
|
/** RE-ENQUEUE SUBMITDIV METABOX **/
|
||||||
add_action('do_meta_boxes', 'reinsert_submitdiv_meta_box');
|
add_action('do_meta_boxes', 'reinsert_submitdiv_meta_box');
|
||||||
function reinsert_submitdiv_meta_box()
|
function reinsert_submitdiv_meta_box()
|
||||||
{
|
{
|
||||||
add_meta_box(
|
add_meta_box(
|
||||||
'submitdiv',
|
'submitdiv',
|
||||||
__('Sauver'),
|
__('Sauver'),
|
||||||
'post_submit_meta_box',
|
'post_submit_meta_box',
|
||||||
'artisans',
|
'artisans',
|
||||||
'normal',
|
'normal',
|
||||||
'low'
|
'low'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** DE ACTIVATE SCREEN OPTIONS **/
|
/** DE ACTIVATE SCREEN OPTIONS **/
|
||||||
function de_activite_screen_options()
|
function de_activite_screen_options()
|
||||||
{
|
{
|
||||||
$current_user = wp_get_current_user();
|
$current_user = wp_get_current_user();
|
||||||
if (isset($current_user->roles) && is_array($current_user->roles) && isset($current_user->roles[0]) && $current_user->roles[0] !== 'administrator') {
|
if (isset($current_user->roles) && is_array($current_user->roles) && isset($current_user->roles[0]) && $current_user->roles[0] !== 'administrator') {
|
||||||
add_filter('screen_options_show_screen', '__return_false');
|
add_filter('screen_options_show_screen', '__return_false');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('admin_init', 'de_activite_screen_options');
|
add_action('admin_init', 'de_activite_screen_options');
|
||||||
|
|
||||||
|
|
||||||
/** FORBID SAVING USER REORGANISATION ON DRAG **/
|
/** FORBID SAVING USER REORGANISATION ON DRAG **/
|
||||||
add_action('check_ajax_referer', 'prevent_meta_box_order');
|
add_action('check_ajax_referer', 'prevent_meta_box_order');
|
||||||
function prevent_meta_box_order($action)
|
function prevent_meta_box_order($action)
|
||||||
{
|
{
|
||||||
// if ('meta-box-order' == $action /* && $wp_user == 'santa claus' */) {
|
// if ('meta-box-order' == $action /* && $wp_user == 'santa claus' */) {
|
||||||
// die('-1');
|
// die('-1');
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------
|
/* ---------------------------------------
|
||||||
DELETE USER PREFERENCES
|
DELETE USER PREFERENCES
|
||||||
------------------------------------------*/
|
------------------------------------------*/
|
||||||
// function reset_user_metabox_order()
|
// function reset_user_metabox_order()
|
||||||
// {
|
// {
|
||||||
// $user_id = get_current_user_id();
|
// $user_id = get_current_user_id();
|
||||||
// if ($user_id && !current_user_can('administrator')) {
|
// if ($user_id && !current_user_can('administrator')) {
|
||||||
// delete_user_meta($user_id, 'meta-box-order_artisans');
|
// delete_user_meta($user_id, 'meta-box-order_artisans');
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// add_action('load-post.php', 'reset_user_metabox_order');
|
// add_action('load-post.php', 'reset_user_metabox_order');
|
||||||
// add_action('load-post-new.php', 'reset_user_metabox_order');
|
// add_action('load-post-new.php', 'reset_user_metabox_order');
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------
|
/* -------------------------------------------------
|
||||||
ADD LAST MODIFIED DATE TO SUBMIT DIV PUBLISH BOX
|
ADD LAST MODIFIED DATE TO SUBMIT DIV PUBLISH BOX
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
function add_last_modified_date_to_publish_box()
|
function add_last_modified_date_to_publish_box()
|
||||||
{
|
{
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
// Vérifiez que vous êtes dans un post et que l'ID du post est valide
|
// Vérifiez que vous êtes dans un post et que l'ID du post est valide
|
||||||
if ($post && $post->ID) {
|
if ($post && $post->ID) {
|
||||||
// Récupérer la date de dernière modification
|
// Récupérer la date de dernière modification
|
||||||
$dashicon = '<span class="dashicons dashicons-update"></span>';
|
$dashicon = '<span class="dashicons dashicons-update"></span>';
|
||||||
$last_modified_date = get_the_modified_date('j F Y \à H:i', $post->ID);
|
$last_modified_date = get_the_modified_date('j F Y \à H:i', $post->ID);
|
||||||
|
|
||||||
// Afficher la date de dernière modification dans le panneau
|
// Afficher la date de dernière modification dans le panneau
|
||||||
echo '<div class="misc-pub-section">';
|
echo '<div class="misc-pub-section">';
|
||||||
echo $dashicon . ' Dernière update : ';
|
echo $dashicon . ' Dernière update : ';
|
||||||
echo $last_modified_date;
|
echo $last_modified_date;
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add_action('post_submitbox_start', 'add_last_modified_date_to_publish_box');
|
// add_action('post_submitbox_start', 'add_last_modified_date_to_publish_box');
|
||||||
|
|
||||||
|
|
||||||
// post_submit_meta_box($post, array('side' => 'core'));
|
// post_submit_meta_box($post, array('side' => 'core'));
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------
|
/* -------------------------------------------------
|
||||||
CHANGE ACF GALLERY ADD BUTTON TEXT TO "Ajouter des photos 📸"
|
CHANGE ACF GALLERY ADD BUTTON TEXT TO "Ajouter des photos 📸"
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
add_action('admin_enqueue_scripts', function () {
|
add_action('admin_enqueue_scripts', function () {
|
||||||
wp_add_inline_script('acf-input', "
|
wp_add_inline_script('acf-input', "
|
||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
$('.acf-gallery-add').text('🏞️ Ajouter des photos');
|
$('.acf-gallery-add').text('🏞️ Ajouter des photos');
|
||||||
});
|
});
|
||||||
");
|
");
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user