";
+ }
+ if (!empty($_REQUEST['bulk_offline_updated'])) {
+ $message = sprintf(__('%d artisans mis hors ligne', 'metiers-patrimoine-theme'), intval($_REQUEST['bulk_offline_updated']));
+ echo "
{$message}
";
+ }
+}
+add_action('admin_notices', 'custom_bulk_admin_notices');
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* -----------------------------------------------------
+ POST STATUS AFTER TITLE ON EDIT PAGE WITH ALL POSTS
+-----------------------------------------------------*/
+
// Ajouter un statut personnalisé dans la colonne des statuts, uniquement dans la vue "Tous"
function add_custom_post_status($post_states, $post)
@@ -126,12 +239,12 @@ function add_custom_post_status($post_states, $post)
// Ajouter le statut "Publié" si l'article est publié
if ('publish' === $post->post_status) {
- $post_states[] = __('Publié', 'metiers-patrimoine-theme'); // Affiche "Publié"
+ $post_states[] = __('En ligne', 'metiers-patrimoine-theme'); // Affiche "Publié"
}
// Ajouter votre statut personnalisé (ex : "offline") si c'est le cas
if ('offline' === get_post_status($post->ID)) {
- $post_states[] = __('Offline', 'metiers-patrimoine-theme'); // Affiche "En attente"
+ $post_states[] = __('Hors ligne', 'metiers-patrimoine-theme'); // Affiche "En attente"
}
}
}
@@ -145,10 +258,6 @@ add_filter('display_post_states', 'add_custom_post_status', 10, 2);
/* ----------------------------------------------------------------------
REORDER ADMIN MENU & POST TYPE ORDER ON MENU BAR
------------------------------------------------------------------------*/
-/**
- * Activates the 'menu_order' filter and then hooks into 'menu_order'
- */
-
/**
* Filters WordPress' default menu order
*/
@@ -247,57 +356,82 @@ function hide_wpml_language_metabox()
// Applique la fonction pour masquer la meta box "Langue"
// add_action('admin_menu', 'hide_wpml_language_metabox');
+
+/* ----------------------------------------------------------------------
+ BODY CLASS
+ ------------------------------------------------------------------------*/
+
+//** BODY CLASS FOR USER ROLE *//
function add_user_role_to_admin_body_class($classes)
{
$current_user = wp_get_current_user();
if (!empty($current_user->roles)) {
foreach ($current_user->roles as $role) {
$classes .= ' role-' . $role;
- $classes .= ' salut fred';
}
}
+
return $classes;
}
-// Applique le filtre pour ajouter la classe au corps de l'interface admin
add_filter('admin_body_class', 'add_user_role_to_admin_body_class');
+//** BODY CLASS FOR POST STATUS *//
+function add_post_status_to_body_class($classes)
+{
+ global $post;
+
+ if ($post && isset($post->post_status)) {
+ $post_status = $post->post_status;
+ $classes .= ' post-status-' . $post_status;
+ // $classes[] = 'post-status-' . $post_status; // Ajoute une classe pour le statut du post
+ write_log($post_status);
+ }
+
+ return $classes;
+}
+add_filter('admin_body_class', 'add_post_status_to_body_class');
+
+
+
+
+/* ---------------------------------------------------------------------------------
+ RÉ-AJOUT DES ITEMS DE TAXONOMY DANS LE MENU, MAIS PAS SOUS ARTISANS MAIS À PART
+ -----------------------------------------------------------------------------------*/
function add_custom_taxonomy_menu_item()
{
add_menu_page(
- 'Métiers', // Titre de la page dans le navigateur
- 'Métiers', // Texte à afficher dans le menu
- 'edit_others_posts', // Capacité requise pour voir le menu
- 'edit-tags.php?taxonomy=metiers&post_type=artisans', // URL de la taxonomie
- '', // Pas de fonction de rappel, car nous redirigeons
- 'dashicons-tag', // Icône (facultatif)
- 50 // Position dans le menu (facultatif)
+ 'Métiers',
+ 'Métiers',
+ 'edit_others_posts',
+ 'edit-tags.php?taxonomy=metiers&post_type=artisans',
+ '',
+ 'dashicons-tag',
+ 50
);
add_menu_page(
- 'Éléments du batiment', // Titre de la page dans le navigateur
- 'Éléments du batiment', // Texte à afficher dans le menu
- 'edit_others_posts', // Capacité requise pour voir le menu
- 'edit-tags.php?taxonomy=elementsbatiments&post_type=artisans', // URL de la taxonomie
- '', // Pas de fonction de rappel, car nous redirigeons
- 'dashicons-tag', // Icône (facultatif)
- 58 // Position dans le menu (facultatif)
+ 'Éléments du batiment',
+ 'Éléments du batiment',
+ 'edit_others_posts',
+ 'edit-tags.php?taxonomy=elementsbatiments&post_type=artisans',
+ '',
+ 'dashicons-tag',
+ 58
);
}
-
-// Ajoute l'élément de menu lors de l'initialisation de l'admin
add_action('admin_menu', 'add_custom_taxonomy_menu_item');
-function add_custom_update_button()
-{
- global $post;
+// function add_custom_update_button()
+// {
+// global $post;
- if ($post->post_status === 'publish') {
- $update_url = admin_url('post.php?post=' . $post->ID . '&action=edit');
- echo 'Mettre à jour l\'article';
- }
-}
-add_action('post_submitbox_misc_actions', 'add_custom_update_button');
+// if ($post->post_status === 'publish') {
+// $update_url = admin_url('post.php?post=' . $post->ID . '&action=edit');
+// echo 'Mettre à jour l\'article';
+// }
+// }
+// add_action('post_submitbox_misc_actions', 'add_custom_update_button');
diff --git a/includes/artisans.php b/includes/artisans.php
index dccb63d..2259130 100644
--- a/includes/artisans.php
+++ b/includes/artisans.php
@@ -26,33 +26,6 @@ function metiers_patrimoine_artisans_post_updater($post_id)
add_action('acf/save_post', 'metiers_patrimoine_artisans_post_updater', 20);
-function metiers_patrimoine_chantiers_post_updater($post_id)
-{
- if (!$post_id || get_post_type() !== 'chantiers') return;
-
- $my_post = array();
- $my_post['ID'] = $post_id;
-
- $artisan = get_field("artisan", $post_id) ?? "";
- $chantier_name = get_field("chantier_name", $post_id) ?? "";
- $date = get_field("date", $post_id) ?? "";
- $localisation = get_field("localisation", $post_id) ?? "";
-
- if (!$artisan || !$chantier_name) return;
-
- $title = $artisan->post_title . " | " . $chantier_name;
-
- if ($localisation && isset($localisation['city'])) {
- $title .= " | " . $localisation['city'];
- }
- if ($date) {
- $title .= " | " . $date;
- }
- $my_post['post_title'] = $title;
- wp_update_post($my_post);
-}
-add_action('acf/save_post', 'metiers_patrimoine_chantiers_post_updater', 20);
-
/* ---------------------------------------
CUSTOM CONTENT AFTER POST TYPE TITLE
------------------------------------------*/
@@ -77,9 +50,25 @@ add_action('edit_form_after_title', function () {
Statut :
+
+
+
+
+
-
-
-
-
Page d’options personnalisée
-
-
- 'core'));
-
/* ----------------------------------------------------------------------
SUPPRIMER LA COLONNE RANK MATH SEO SI ELLE EST PRÉSENTE
------------------------------------------------------------------------*/
diff --git a/includes/chantiers.php b/includes/chantiers.php
index 9f47a0d..29f2b5d 100644
--- a/includes/chantiers.php
+++ b/includes/chantiers.php
@@ -1,5 +1,33 @@
post_title . " | " . $chantier_name;
+
+ if ($localisation && isset($localisation['city'])) {
+ $title .= " | " . $localisation['city'];
+ }
+ if ($date) {
+ $title .= " | " . $date;
+ }
+ $my_post['post_title'] = $title;
+ wp_update_post($my_post);
+}
+add_action('acf/save_post', 'metiers_patrimoine_chantiers_post_updater', 20);
+
+
/* -----------------------------------------
EDIT ARTISAN LINK ON CHANTIER EDIT PAGE
-----------------------------------------*/