diff --git a/includes/artisans.php b/includes/artisans.php
index 5b1343c..dccb63d 100644
--- a/includes/artisans.php
+++ b/includes/artisans.php
@@ -53,61 +53,54 @@ function metiers_patrimoine_chantiers_post_updater($post_id)
}
add_action('acf/save_post', 'metiers_patrimoine_chantiers_post_updater', 20);
-
-
-/* ---------------------------
-CUSTOM CODE FOR TITLE
----------------------------*/
+/* ---------------------------------------
+CUSTOM CONTENT AFTER POST TYPE TITLE
+------------------------------------------*/
add_action('edit_form_after_title', function () {
- // Vérifie si on est sur le bon post type
$screen = get_current_screen();
- $last_modified_date = get_the_modified_date('j F Y');
+
+ $status_mdp = get_field('mdp_status', get_the_ID());
+ $post_status = get_post_status();
+ $translatedStatus = translate_wordpress_online_statuses($post_status);
+
if ($screen && $screen->post_type === 'artisans') {
- echo '
' . get_the_title() . '
';
- // echo '
Dernière modification : ' . $last_modified_date . '
';
+?>
+
+
+
+
+
État :
+
+
+
+
+
Statut :
+
+
+
+
+
+ ID) {
- // Récupérer la date de dernière modification
- $dashicon = '';
- $last_modified_date = get_the_modified_date('j F Y \à H:i', $post->ID);
-
- // Afficher la date de dernière modification dans le panneau
- echo '
';
- }
-}
-add_action('post_submitbox_start', 'add_last_modified_date_to_publish_box');
-
-
-/* ---------------------------
-CUSTOM CHANTIER META BOX AT THE END OF THE PAGE
----------------------------*/
+/* ---------------------------------------
+ METABOXES
+------------------------------------------*/
+/** ENQUEUE CUSTOM CHANTIER META BOX AT THE END OF THE PAGE **/
add_action('add_meta_boxes', function () {
- // Ajout de la metabox uniquement pour le post type 'artisans'
add_meta_box(
- 'admin_artisan_chantier_list', // ID de la metabox
- 'Chantiers réalisé par l\'entreprise', // Titre de la metabox
- 'render_custom_chantier_box_content', // Fonction de rendu
+ 'admin_artisan_chantier_list',
+ 'Chantiers réalisé par l\'entreprise',
+ 'render_custom_chantier_box_content',
'artisans', // Post type
'normal', // Contexte
- 'low' // Priorité
+ 'default' // Priorité
);
});
-/**
- * Fonction de rendu du contenu de la metabox.
- */
+/** RENDER CHANTIER METABOX **/
function render_custom_chantier_box_content($post)
{
@@ -146,6 +139,175 @@ function render_custom_chantier_box_content($post)
}
}
+/** REMOVE SUBMITDIV METABOX **/
+
+add_action('admin_menu', 'remove_submit_div');
+function remove_submit_div()
+{
+ remove_meta_box('submitdiv', 'artisans', 'side');
+ remove_meta_box('postimagediv', 'artisans', 'normal');
+ remove_meta_box('postimagediv', 'artisans', 'side');
+ remove_meta_box('postimagediv', 'artisans', 'advanced');
+
+ $user = wp_get_current_user();
+ $metaboxes = get_user_meta($user->ID, 'metaboxhidden_artisans', true);
+ $metabox_order = get_user_meta($user->ID, 'meta-box-order_artisans', true);
+}
+
+/** UPDATE USER METABOX PREFERENCES WITH MANUAL ARRAY **/
+function set_user_metabox_order($user_id)
+{
+ $new_order = [
+ 'acf_after_title' => '',
+ 'side' => 'postimagediv,icl_div',
+ 'normal' => 'acf-group_670d265c6ec0e,admin_artisan_chantier_list,acf-group_67581cdaf3262,acf-group_672358433051b,submitdiv,slugdiv,revisionsdiv',
+ 'advanced' => 'rank_math_metabox',
+ ];
+ update_user_meta($user_id, 'meta-box-order_artisans', $new_order);
+
+ $metaboxes_hidden = get_user_meta($user_id, 'metaboxhidden_artisans', true);
+ if ($metaboxes_hidden === false) return;
+
+ $newArrray = array_merge($metaboxes_hidden, ['postimagediv', 'icldiv']);
+ update_user_meta($user_id, 'metaboxhidden_artisans', $newArrray);
+}
+// set_user_metabox_order(get_current_user_id());
+add_action('admin_init', 'set_user_metabox_order');
+
+/** RE-ENQUEUE SUBMITDIV METABOX **/
+add_action('do_meta_boxes', 'reinsert_submitdiv_meta_box');
+function reinsert_submitdiv_meta_box()
+{
+ add_meta_box(
+ 'submitdiv',
+ __('Sauver'),
+ 'post_submit_meta_box',
+ 'artisans',
+ 'normal',
+ 'low'
+ );
+}
+
+
+/** DE ACTIVATE SCREEN OPTIONS **/
+function de_activite_screen_options()
+{
+ $current_user = wp_get_current_user();
+ if ($current_user->roles[0] !== 'administrator') {
+ add_filter('screen_options_show_screen', '__return_false');
+ }
+}
+add_action('admin_init', 'de_activite_screen_options');
+
+
+/** FORBID SAVING USER REORGANISATION ON DRAG **/
+add_action('check_ajax_referer', 'prevent_meta_box_order');
+function prevent_meta_box_order($action)
+{
+ if ('meta-box-order' == $action /* && $wp_user == 'santa claus' */) {
+ die('-1');
+ }
+}
+
+
+
+
+/* ---------------------------------------
+ DELETE USER PREFERENCES
+------------------------------------------*/
+// function reset_user_metabox_order()
+// {
+// write_log('#############reset_user_metabox_order');
+// $user_id = get_current_user_id();
+// if ($user_id) {
+// delete_user_meta($user_id, 'meta-box-order_artisans');
+// }
+// }
+// add_action('load-post.php', 'reset_user_metabox_order');
+// add_action('load-post-new.php', 'reset_user_metabox_order');
+
+
+
+
+function my_custom_admin_button()
+{
+ ?>
+
+
+
+
Page d’options personnalisée
+
+
+ ID) {
+ // Récupérer la date de dernière modification
+ $dashicon = '';
+ $last_modified_date = get_the_modified_date('j F Y \à H:i', $post->ID);
+
+ // Afficher la date de dernière modification dans le panneau
+ echo '
';
+ }
+}
+// add_action('post_submitbox_start', 'add_last_modified_date_to_publish_box');
+
+
+// post_submit_meta_box($post, array('side' => 'core'));
+
+
+
/* ----------------------------------------------------------------------
SUPPRIMER LA COLONNE RANK MATH SEO SI ELLE EST PRÉSENTE
------------------------------------------------------------------------*/
@@ -266,7 +428,7 @@ add_action('manage_artisans_posts_custom_column', 'metiers_patrimoine_artisans_h
/* ----------------------------------------------------------------------
- GESTION DDU FILTRAGES PAR METIERS
+ GESTION DU FILTRAGES PAR METIERS
------------------------------------------------------------------------*/
// **** CREATION DU DROPDOWN SELECT AVEC LES OPTIONS
function metiers_patrimoine_filter_posts_per_metiers_declare_dropdown()
@@ -278,7 +440,7 @@ function metiers_patrimoine_filter_posts_per_metiers_declare_dropdown()
if ($post_type == 'artisans') {
$metiers_by_parent = getAllMetiersTermsByParents();
-?>
+ ?>