removing uncessary metabox
This commit is contained in:
parent
2a67691d1a
commit
e0ecb88b5e
|
|
@ -1,58 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* ---------------------------
|
/* ---------------------------
|
||||||
CUSTOM CHANTIER META BOX AT THE END OF THE PAGE
|
EDIT ARTISAN LINK
|
||||||
---------------------------*/
|
---------------------------*/
|
||||||
add_action('add_meta_boxes', function () {
|
|
||||||
// Ajout de la metabox uniquement pour le post type 'artisans'
|
|
||||||
add_meta_box(
|
|
||||||
'admin_chantier_artisan_ref', // ID de la metabox
|
|
||||||
'Artisan du chantier', // Titre de la metabox
|
|
||||||
'render_artisan_box_content', // Fonction de rendu
|
|
||||||
'chantiers', // Post type
|
|
||||||
'normal', // Contexte
|
|
||||||
'high' // Priorité
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fonction de rendu du contenu de la metabox.
|
|
||||||
*/
|
|
||||||
function render_artisan_box_content($post)
|
|
||||||
{
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => 'chantiers',
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'meta_query' => array(
|
|
||||||
array(
|
|
||||||
'key' => 'artisan',
|
|
||||||
'value' => $post->ID,
|
|
||||||
'compare' => '=',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$chantiers = new WP_Query($args);
|
|
||||||
|
|
||||||
|
|
||||||
// Afficher les chantiers
|
|
||||||
|
|
||||||
if ($chantiers->have_posts()) {
|
|
||||||
|
|
||||||
echo '<ul>';
|
|
||||||
while ($chantiers->have_posts()) {
|
|
||||||
$chantiers->the_post();
|
|
||||||
$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 '</ul>';
|
|
||||||
} else {
|
|
||||||
echo '<p style="font-size: 1rem;">Ce chantier n\'est relié à aucun artisan</p>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
add_action('acf/render_field', function ($field) {
|
add_action('acf/render_field', function ($field) {
|
||||||
// Vérifiez si le champ est celui que vous voulez personnaliser
|
// Vérifiez si le champ est celui que vous voulez personnaliser
|
||||||
|
|
@ -66,7 +16,7 @@ add_action('acf/render_field', function ($field) {
|
||||||
|
|
||||||
if ($linked_post_id) {
|
if ($linked_post_id) {
|
||||||
$edit_link = get_edit_post_link($linked_post_id);
|
$edit_link = get_edit_post_link($linked_post_id);
|
||||||
echo '<a href="' . esc_url($edit_link) . '" target="_blank" class="edit-fiche-artisan-link"><img src=' . get_stylesheet_directory_uri() . '/resources/img/icons/tools.svg' . ' /> Voir la fiche de l\'artisan </a>';
|
echo '<a href="' . esc_url($edit_link) . '" class="edit-fiche-artisan-link"><img src=' . get_stylesheet_directory_uri() . '/resources/img/icons/tools.svg' . ' /> Voir la fiche de l\'artisan </a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 10, 1);
|
}, 10, 1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user