Compare commits
No commits in common. "6d7485dbcf4bf486d2e58e2f4c14121b180efc98" and "cde17bbf33d29327599e792dd157f1c04757827f" have entirely different histories.
6d7485dbcf
...
cde17bbf33
|
|
@ -53,19 +53,10 @@
|
|||
get_template_part("template-components/heading-box", null, array(
|
||||
"pageIcon" => $pageIcon,
|
||||
"title" => $currentPage->post_title ?? "",
|
||||
"description" => __("Cherchez une entreprise", "metiers-patrimoine-theme"),
|
||||
"description" => __("Cherchez une entreprise ou un artisan", "metiers-patrimoine-theme"),
|
||||
));
|
||||
?>
|
||||
|
||||
<section class="accroche-sectio text-center">
|
||||
<?php if(ICL_LANGUAGE_CODE=='fr'): ?>
|
||||
<p class="text-primary">Trouvez un professionnel pour rénover une ancienne menuiserie, un balcon, un vitrail,<br/> ou tout autre élément ancien qui caractérise votre bâtiment.</p>
|
||||
<?php elseif(ICL_LANGUAGE_CODE=='nl'): ?>
|
||||
<p class="text-primary">Zoek een vakman voor het renoveren van oud schrijnwerk, een balkon, <br/>een glas-in-loodraam of andere oude elementen die karakteristiek zijn voor uw gebouw.</p>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
|
||||
<section class="artisans-posts">
|
||||
<?php get_template_part("template-parts/artisan-filter-sidebar", null, array("foundPosts" => $initialPosts->found_posts)); ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
SUPPRIMER LA COLONNE RANK MATH SEO SI ELLE EST PRÉSENTE
|
||||
------------------------------------------------------------------------*/
|
||||
|
||||
function artisans_patrimoine_remove_rank_math_seo_column_for_artisans($columns)
|
||||
function remove_rank_math_seo_column_for_artisans($columns)
|
||||
{
|
||||
if (isset($columns['rank_math_seo_details'])) {
|
||||
unset($columns['rank_math_seo_details']);
|
||||
|
|
@ -13,7 +13,7 @@ function artisans_patrimoine_remove_rank_math_seo_column_for_artisans($columns)
|
|||
}
|
||||
|
||||
// Appliquer le filtre uniquement pour le post type "artisans"
|
||||
add_filter('manage_artisans_posts_columns', 'artisans_patrimoine_remove_rank_math_seo_column_for_artisans', 20);
|
||||
add_filter('manage_artisans_posts_columns', 'remove_rank_math_seo_column_for_artisans', 20);
|
||||
|
||||
|
||||
// ACF SAVE POST
|
||||
|
|
@ -35,36 +35,20 @@ add_action('acf/save_post', 'save_acf_post_mdp_status');
|
|||
function metiers_patrimoine_artisans_add_acf_posts_columns($columns)
|
||||
{
|
||||
global $current_screen;
|
||||
$my_current_lang = apply_filters('wpml_current_language', NULL);
|
||||
|
||||
// SUPPRIMER LA COLONNE 'date'
|
||||
if (isset($columns['date'])) {
|
||||
unset($columns['date']);
|
||||
}
|
||||
|
||||
if($my_current_lang == 'nl'):
|
||||
$customColumns = array(
|
||||
'metiers' => 'Métiers',
|
||||
//'elements' => 'Éléments du bâtiment',
|
||||
'conseiller' => 'Conseiller',
|
||||
'state' => 'État',
|
||||
'lastmodified' => 'Dernière modification',
|
||||
'onlinedate' => 'Mise en ligne',
|
||||
'remark' => 'Remarque'
|
||||
);
|
||||
else:
|
||||
$customColumns = array(
|
||||
'metiers' => 'Métiers',
|
||||
//'elements' => 'Éléments du bâtiment',
|
||||
'conseiller' => 'Conseiller',
|
||||
'state' => 'État',
|
||||
'mdpstatus' => 'Statut de travail',
|
||||
'lastmodified' => 'Dernière modification',
|
||||
'onlinedate' => 'Mise en ligne',
|
||||
'remark' => 'Remarque'
|
||||
);
|
||||
endif;
|
||||
|
||||
$customColumns = array(
|
||||
'metiers' => 'Métiers',
|
||||
'elements' => 'Éléments du bâtiment',
|
||||
'conseiller' => 'Conseiller',
|
||||
'state' => 'État',
|
||||
'mdpstatus' => 'Statut de travail',
|
||||
'lastmodified' => 'Dernière modification',
|
||||
'onlinedate' => 'Mise en ligne'
|
||||
);
|
||||
$new_admin_col_arrays = array_slice($columns, 0, 2, true) + $customColumns + array_slice($columns, 2, count($columns) - 2, true);
|
||||
return array_merge($new_admin_col_arrays);
|
||||
}
|
||||
|
|
@ -75,9 +59,9 @@ add_filter('manage_artisans_posts_columns', 'metiers_patrimoine_artisans_add_acf
|
|||
/* ----------------------------------------------------------------------
|
||||
GESTION DE LA VALEUR DE CHAQUE COLONNE
|
||||
------------------------------------------------------------------------*/
|
||||
function metiers_patrimoine_artisans_handle_posts_custom_columns($column, $post_id)
|
||||
function metiers_patrimoine_artisans_handle_posts_custom_columns($column)
|
||||
{
|
||||
//$post_id = get_the_ID();
|
||||
$post_id = get_the_ID();
|
||||
|
||||
if ($column == 'conseiller') {
|
||||
$conseiller = get_field('conseiller', $post_id);
|
||||
|
|
@ -122,24 +106,24 @@ function metiers_patrimoine_artisans_handle_posts_custom_columns($column, $post_
|
|||
echo '<p class="no-results"> × </p>';
|
||||
}
|
||||
}
|
||||
// if ($column == 'elements') {
|
||||
// $terms = get_the_terms_organised_by_parent('elementsbatiments', $post_id);
|
||||
// if ($terms) {
|
||||
// $parent_terms = array_filter($terms, function ($term) {
|
||||
// return $term->parent == 0;
|
||||
// });
|
||||
if ($column == 'elements') {
|
||||
$terms = get_the_terms_organised_by_parent('elementsbatiments', $post_id);
|
||||
if ($terms) {
|
||||
$parent_terms = array_filter($terms, function ($term) {
|
||||
return $term->parent == 0;
|
||||
});
|
||||
|
||||
// echo '<div class="admin-column-metiers-container">';
|
||||
// foreach ($terms as $term) {
|
||||
// echo '<a href="' . get_edit_term_link($term->term_id, 'metiers', 'artisans') . '" class="admin-column-taxonomy-term">';
|
||||
// echo esc_html($term->name);
|
||||
// echo '</a>';
|
||||
// }
|
||||
// echo '</div >';
|
||||
// } else {
|
||||
// echo '<p class="no-results"> × </p>';
|
||||
// }
|
||||
// }
|
||||
echo '<div class="admin-column-metiers-container">';
|
||||
foreach ($terms as $term) {
|
||||
echo '<a href="' . get_edit_term_link($term->term_id, 'metiers', 'artisans') . '" class="admin-column-taxonomy-term">';
|
||||
echo esc_html($term->name);
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</div >';
|
||||
} else {
|
||||
echo '<p class="no-results"> × </p>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($column == 'lastmodified') {
|
||||
// $last_modified_date = get_the_modified_date('j F Y \à H:i', $post_id);
|
||||
|
|
@ -152,72 +136,9 @@ function metiers_patrimoine_artisans_handle_posts_custom_columns($column, $post_
|
|||
if (!$published_date) return;
|
||||
echo $published_date;
|
||||
}
|
||||
|
||||
if ($column == 'remark') {
|
||||
$last_action = get_field('last_action', $post_id);
|
||||
//write_log($post_id);
|
||||
//write_log($last_action);
|
||||
|
||||
|
||||
if (!isset($last_action) || empty($last_action)) return; $remark = $last_action['comments'];
|
||||
|
||||
if (!isset($remark) || empty($remark)) return;
|
||||
|
||||
// $conseillerDatas = get_userdata($conseiller);
|
||||
// if (!isset($conseillerDatas->display_name)) return;
|
||||
|
||||
echo $remark;
|
||||
}
|
||||
}
|
||||
add_action('manage_artisans_posts_custom_column', 'metiers_patrimoine_artisans_handle_posts_custom_columns', 10, 2);
|
||||
|
||||
/* ------
|
||||
// Fonction pour charger les posts avec leurs ACF
|
||||
-------*/
|
||||
|
||||
function load_posts_with_acf() {
|
||||
// Vérifie si ACF est activé
|
||||
if ( ! function_exists('get_field') ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Récupère les posts (exemple : tous les articles publiés)
|
||||
$posts_query = new WP_Query([
|
||||
'post_type' => 'artisans', // Change selon ton besoin (page, custom post type...)
|
||||
'posts_per_page' => -1, // Tous les posts
|
||||
]);
|
||||
|
||||
$posts_data = [];
|
||||
|
||||
if ( $posts_query->have_posts() ) {
|
||||
while ( $posts_query->have_posts() ) {
|
||||
$posts_query->the_post();
|
||||
$post_id = get_the_ID();
|
||||
|
||||
// Récupère les champs ACF (automatique ou spécifiques)
|
||||
//$acf_fields = get_fields($post_id); // Renvoie tous les champs ACF du post
|
||||
|
||||
// Structure des données
|
||||
$posts_data[$post_id] = [
|
||||
'id' => $post_id,
|
||||
'acf' => [
|
||||
'conseiller' => get_field('conseiller', $post_id),
|
||||
'mdp_status' => get_field('mdp_status', $post_id),
|
||||
'last_action' => get_field('last_action', $post_id),
|
||||
]
|
||||
];
|
||||
}
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
return $posts_data;
|
||||
}
|
||||
|
||||
// Variable globale accessible partout
|
||||
global $global_posts_with_acf;
|
||||
$global_posts_with_acf = load_posts_with_acf();
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
GESTION DU FILTRAGE
|
||||
|
|
@ -227,9 +148,6 @@ function metiers_patrimoine_filter_posts_declare_dropdowns()
|
|||
{
|
||||
global $typenow;
|
||||
global $wp_meta_boxes;
|
||||
global $global_posts_with_acf;
|
||||
|
||||
//write_log($global_posts_with_acf);
|
||||
|
||||
$post_type = (isset($_GET['post_type'])) ? $_GET['post_type'] : 'post';
|
||||
if ($post_type !== 'artisans') return;
|
||||
|
|
@ -241,24 +159,25 @@ function metiers_patrimoine_filter_posts_declare_dropdowns()
|
|||
|
||||
$mdp_status_choices = isset($mdp_status_datas['choices']) ? $mdp_status_datas['choices'] : null;
|
||||
|
||||
// $meta_key = 'mdp_status';
|
||||
// $values = get_posts([
|
||||
// 'post_status' => 'any',
|
||||
// 'post_type' => 'artisans',
|
||||
// 'posts_per_page' => -1,
|
||||
// 'meta_key' => $meta_key,
|
||||
// 'fields' => 'ids',
|
||||
// ]);
|
||||
|
||||
// $unique_values = array_reduce(array_filter(array_map(
|
||||
// fn($post_id) => get_field('mdp_status', $post_id) ?? null,
|
||||
// $values
|
||||
// )), function ($acc, $item) {
|
||||
// if (isset($item['value'], $item['label'])) {
|
||||
// $acc[$item['value']] = $item['label'];
|
||||
// }
|
||||
// return $acc;
|
||||
// }, []);
|
||||
$meta_key = 'mdp_status';
|
||||
$values = get_posts([
|
||||
'post_status' => 'any',
|
||||
'post_type' => 'artisans',
|
||||
'posts_per_page' => -1,
|
||||
'meta_key' => $meta_key,
|
||||
'fields' => 'ids',
|
||||
]);
|
||||
|
||||
$unique_values = array_reduce(array_filter(array_map(
|
||||
fn($post_id) => get_field('mdp_status', $post_id) ?? null,
|
||||
$values
|
||||
)), function ($acc, $item) {
|
||||
if (isset($item['value'], $item['label'])) {
|
||||
$acc[$item['value']] = $item['label'];
|
||||
}
|
||||
return $acc;
|
||||
}, []);
|
||||
|
||||
?>
|
||||
<select name="metiers">
|
||||
|
|
@ -278,22 +197,22 @@ function metiers_patrimoine_filter_posts_declare_dropdowns()
|
|||
?>
|
||||
</select>
|
||||
|
||||
<!-- <select name="elementsbatiments">
|
||||
<select name="elementsbatiments">
|
||||
<option value="" class="please-select"><?php _e('Éléments du Bâtiment', 'metiers-patrimoine-theme'); ?></option>
|
||||
<?php
|
||||
// $is_current = isset($_GET['elementsbatiments']) ? $_GET['elementsbatiments'] : '';
|
||||
// foreach ($batiments_by_parent as $index => $parent_term_data) {
|
||||
// $parent_term = $parent_term_data['term'];
|
||||
$is_current = isset($_GET['elementsbatiments']) ? $_GET['elementsbatiments'] : '';
|
||||
foreach ($batiments_by_parent as $index => $parent_term_data) {
|
||||
$parent_term = $parent_term_data['term'];
|
||||
|
||||
// printf(
|
||||
// '<option value="%s"%s>%s</option>',
|
||||
// $parent_term->slug,
|
||||
// $parent_term->slug == $is_current ? ' selected="selected"' : '',
|
||||
// $parent_term->name
|
||||
// );
|
||||
// }
|
||||
printf(
|
||||
'<option value="%s"%s>%s</option>',
|
||||
$parent_term->slug,
|
||||
$parent_term->slug == $is_current ? ' selected="selected"' : '',
|
||||
$parent_term->name
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select> -->
|
||||
</select>
|
||||
|
||||
<select name="conseiller">
|
||||
<option value="" class="please-select"><?php _e('Conseiller', 'metiers-patrimoine-theme'); ?></option>
|
||||
|
|
@ -319,18 +238,8 @@ function metiers_patrimoine_filter_posts_declare_dropdowns()
|
|||
<option value="" class="please-select"><?php _e('Statut de travail', 'metiers-patrimoine-theme'); ?></option>
|
||||
<?php
|
||||
|
||||
//write_log($unique_values);
|
||||
$statuses = [
|
||||
'rejected' => 'Non sélectionné (hors ligne)',
|
||||
'to_contact' => 'Nouveau à contacter (Hors ligne)',
|
||||
'to_actualize' => 'À actualiser (en ligne)',
|
||||
'ok' => 'OK (en ligne)',
|
||||
'none' => '—— Pas de statut !',
|
||||
'deleted' => 'Supprimé (hors ligne)'
|
||||
];
|
||||
|
||||
$is_current = isset($_GET['mdpstatus']) ? $_GET['mdpstatus'] : '';
|
||||
foreach ($statuses as $index => $status) {
|
||||
foreach ($unique_values as $index => $status) {
|
||||
printf(
|
||||
'<option value="%s"%s>%s</option>',
|
||||
$index,
|
||||
|
|
@ -363,7 +272,7 @@ function filter_posts_by_acf_conseiller($query)
|
|||
}
|
||||
|
||||
// FILTRE CONSEILLER
|
||||
if (!empty($_GET['mdpstatus']) && empty($_GET['conseiller'])) {
|
||||
if (!empty($_GET['mdpstatus'])) {
|
||||
$query->set('meta_query', [
|
||||
[
|
||||
'key' => 'mdp_status',
|
||||
|
|
@ -374,7 +283,7 @@ function filter_posts_by_acf_conseiller($query)
|
|||
}
|
||||
|
||||
// FILTRE CONSEILLER
|
||||
if (!empty($_GET['conseiller']) && empty($_GET['mdpstatus'])) {
|
||||
if (!empty($_GET['conseiller'])) {
|
||||
|
||||
if ($_GET['conseiller'] == 'non_attribue') {
|
||||
$query->set('meta_query', [
|
||||
|
|
@ -394,25 +303,6 @@ function filter_posts_by_acf_conseiller($query)
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['mdpstatus']) && !empty($_GET['conseiller'])) {
|
||||
if ($_GET['conseiller'] == 'non_attribue'){
|
||||
$_GET['conseiller'] = '';
|
||||
}
|
||||
$query->set('meta_query', [
|
||||
[
|
||||
'key' => 'mdp_status',
|
||||
'value' => sanitize_text_field($_GET['mdpstatus']),
|
||||
'compare' => '='
|
||||
],
|
||||
[
|
||||
'key' => 'conseiller',
|
||||
'value' => sanitize_text_field($_GET['conseiller']),
|
||||
'compare' => '='
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_action('pre_get_posts', 'filter_posts_by_acf_conseiller');
|
||||
|
|
|
|||
|
|
@ -119,15 +119,10 @@ add_action('edit_form_after_title', function () {
|
|||
$post_status = get_post_status();
|
||||
$translatedStatus = translate_wordpress_online_statuses($post_status);
|
||||
$post_link = get_preview_post_link();
|
||||
$my_current_lang = apply_filters('wpml_current_language', NULL);
|
||||
|
||||
if ($screen && $screen->post_type === 'artisans') {
|
||||
?>
|
||||
<h1 class="admin-artisan-title"><?php echo get_the_title() ?></h1>
|
||||
<?php if($my_current_lang == 'nl'): ?>
|
||||
<h2 class="admin-artisan-alert-nl">Vous êtes sur la partie NL de la fiche de l'artisan</h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($post_link) && $screen->action !== 'add') : ?>
|
||||
<div class="preview-artisan-link">
|
||||
<a href="<?php echo $post_link; ?>" target="_blank" class="button button-primary">
|
||||
|
|
@ -142,7 +137,6 @@ add_action('edit_form_after_title', function () {
|
|||
<span class="post-state post-state--<?php echo $post_status; ?>"><?php echo $translatedStatus; ?></span>
|
||||
</div>
|
||||
|
||||
<?php if($my_current_lang == 'fr'): ?>
|
||||
<div class="state-container">
|
||||
<p>Statut de travail :</p>
|
||||
<?php if (isset($status_mdp) && isset($status_mdp['value']) && isset($status_mdp['label'])): ?>
|
||||
|
|
@ -152,7 +146,6 @@ add_action('edit_form_after_title', function () {
|
|||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- <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> -->
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@
|
|||
"nl": "Molières"
|
||||
},
|
||||
{
|
||||
"fr": "Namur",
|
||||
"nl": "Namen"
|
||||
"fr": "Namen",
|
||||
"nl": "Namur"
|
||||
},
|
||||
{
|
||||
"fr": "Jette",
|
||||
|
|
|
|||
|
|
@ -361,40 +361,3 @@ function translate_city_name($city, $required_language = 'fr')
|
|||
}
|
||||
return $city;
|
||||
}
|
||||
|
||||
|
||||
/* Scroll automatique vers le formulaire après soumission */
|
||||
add_action( 'wp_footer', function() {
|
||||
if ( is_page(309) ) { // remplace 'contact' par le slug de ta page
|
||||
?>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Si un paramètre de requête existe (ce qui est le cas après soumission)
|
||||
|
||||
const form = document.getElementById('gform_confirmation_message_1'); // <-- adapte le numéro ici
|
||||
if (form) {
|
||||
setTimeout(() => { form.scrollIntoView({ behavior: 'smooth' }); }, 400);
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( is_page(18713) ) { // remplace 'contact' par le slug de ta page
|
||||
?>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Si un paramètre de requête existe (ce qui est le cas après soumission)
|
||||
|
||||
const form = document.getElementById('gform_confirmation_message_2'); // <-- adapte le numéro ici
|
||||
if (form) {
|
||||
setTimeout(() => { form.scrollIntoView({ behavior: 'smooth' }); }, 400);
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -233,14 +233,6 @@ body.post-type-artisans {
|
|||
.admin-artisan-title {
|
||||
@apply text-patrimoine-sante-securite !font-semibold !text-2xl;
|
||||
}
|
||||
.admin-artisan-alert-nl {
|
||||
@apply text-green-800 bg-white;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-left-width: 4px;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
|
||||
margin: 5px 15px 2px;
|
||||
padding: 1px 12px;
|
||||
}
|
||||
.last-updated {
|
||||
@apply text-neutral-500 !text-xs my-0;
|
||||
}
|
||||
|
|
@ -683,8 +675,7 @@ select[data-enpassusermodified='yes'] {
|
|||
.row-actions .edit,
|
||||
.row-actions .view,
|
||||
.row-actions .inline.hide-if-no-js,
|
||||
#acfml-field-group-synchronise,
|
||||
#litespeed_meta_boxes{
|
||||
#acfml-field-group-synchronise {
|
||||
@apply !hidden;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,22 +145,13 @@ function handleHierarchicalTaxonomyCheckboxRelation(e) {
|
|||
if (e.target.checked && e.target.classList.contains('parent-checkbox')) {
|
||||
const parentRootTag = e.target.closest('.checkbox-choice');
|
||||
const children = parentRootTag.querySelectorAll('.child-checkbox');
|
||||
//alert('check parent là');
|
||||
/*children.forEach((child) => {
|
||||
|
||||
children.forEach((child) => {
|
||||
child.checked = true;
|
||||
});*/
|
||||
});
|
||||
}
|
||||
|
||||
if (e.target.checked && e.target.classList.contains('child-checkbox')) {
|
||||
//alert('check child là');
|
||||
const checkboxRootTag = e.target.closest('.checkbox-choice');
|
||||
const parentCheckbox = checkboxRootTag.parentElement.parentElement.querySelector('.parent-checkbox');
|
||||
|
||||
parentCheckbox.checked = false;
|
||||
}
|
||||
|
||||
if (!e.target.checked && e.target.classList.contains('parent-checkbox')) {
|
||||
//alert('uncheck parent');
|
||||
// alert('uncheck parent');
|
||||
const parent = e.target.closest('.checkbox-choice');
|
||||
const children = parent.querySelectorAll('.child-checkbox');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user