diff --git a/functions.php b/functions.php index 12325b1..6b91729 100644 --- a/functions.php +++ b/functions.php @@ -16,3 +16,4 @@ require_once(__DIR__ . '/includes/wysiwyg.php'); require_once(__DIR__ . '/includes/search.php'); require_once(__DIR__ . '/includes/rooting.php'); require_once(__DIR__ . '/includes/forms.php'); +require_once(__DIR__ . '/includes/admin-columns.php'); diff --git a/includes/admin-columns.php b/includes/admin-columns.php new file mode 100644 index 0000000..f1f71a5 --- /dev/null +++ b/includes/admin-columns.php @@ -0,0 +1,116 @@ + 'Thématique') + array_slice($columns, 2, count($columns) - 2, true); + return array_merge($new_admin_col_arrays); +} +add_filter('manage_conseils_posts_columns', 'add_acf_posts_columns'); +add_filter('manage_questions_posts_columns', 'add_acf_posts_columns'); +add_filter('manage_brochures_posts_columns', 'add_acf_posts_columns'); + + + +/* ---------------------------------------------------------------------- + CUSTOMISATION DE LA COLONNE POUR AFFICHER : THEMATIQUE PARENT > THEMATIQUE + ------------------------------------------------------------------------*/ + +function handle_posts_custom_columns($column, $post_id) +{ + if ($column != 'thematiques_taxo') { + return; + } + $tax = get_the_terms($post_id, ('thematiques')); + $edit_link = esc_url(get_edit_term_link($tax[0]->term_id, 'thematiques', 'conseils')); + + echo ''; + if (isset($tax[0]->parent) && $tax[0]->parent != 0) { + $tax_parent = get_term($tax[0]->parent, 'thematiques'); + echo $tax_parent->name . " — "; + } + echo $tax[0]->name; + echo ''; +} +add_action('manage_conseils_posts_custom_column', 'handle_posts_custom_columns', 10, 2); +add_action('manage_questions_posts_custom_column', 'handle_posts_custom_columns', 10, 2); +add_action('manage_brochures_posts_custom_column', 'handle_posts_custom_columns', 10, 2); + + + + + +/* ---------------------------------------------------------------------- + GESTION DU FILTRAGE + ------------------------------------------------------------------------*/ +// **** CREATION DES DROPDOWN SELECT DE FILTRAGE +function homegrade_brochures_filter_posts_declare_dropdowns() +{ + global $typenow; + global $wp_meta_boxes; + + $post_type = (isset($_GET['post_type'])) ? $_GET['post_type'] : 'post'; + if ($post_type !== 'brochures' && $post_type !== 'fiches-infos' && $post_type !== 'videos-webinaires' && $post_type !== 'conseils' && $post_type !== 'questions') return; + + $thematiques_by_parent = getAllThematiquesTermsByParents(); + +?> + + + + + 'Thématique') + array_slice($columns, 2, count($columns) - 2, true); - return array_merge($new_admin_col_arrays); -} -add_filter('manage_conseils_posts_columns', 'add_acf_posts_columns'); -add_filter('manage_questions_posts_columns', 'add_acf_posts_columns'); -add_filter('manage_brochures_posts_columns', 'add_acf_posts_columns'); - - - -/* ---------------------------------------------------------------------- - CUSTOMISATION DE LA COLONNE POUR AFFICHER : THEMATIQUE PARENT > THEMATIQUE - ------------------------------------------------------------------------*/ - -function handle_posts_custom_columns($column, $post_id) -{ - if ($column != 'thematiques_taxo') { - return; - } - $tax = get_the_terms($post_id, ('thematiques')); - $edit_link = esc_url(get_edit_term_link($tax[0]->term_id, 'thematiques', 'conseils')); - - echo ''; - if (isset($tax[0]->parent) && $tax[0]->parent != 0) { - $tax_parent = get_term($tax[0]->parent, 'thematiques'); - echo $tax_parent->name . " — "; - } - echo $tax[0]->name; - echo ''; -} -add_action('manage_conseils_posts_custom_column', 'handle_posts_custom_columns', 10, 2); -add_action('manage_questions_posts_custom_column', 'handle_posts_custom_columns', 10, 2); -add_action('manage_brochures_posts_custom_column', 'handle_posts_custom_columns', 10, 2); - - -/* ------------------------------------------- - CREATION DU DROPDOWN SELECT AVEC LES OPTIONS - ---------------------------------------------*/ - -function filter_posts_per_thematique_declare_dropdown() -{ - global $pagenow; - $post_type = (isset($_GET['post_type'])) ? $_GET['post_type'] : 'post'; - - //only add filter to post type you want - if ($post_type == 'questions') { - $all_thematiques = get_terms([ - 'taxonomy' => 'thematiques', - 'hide_empty' => true, - ]); -?> - -query_vars['meta_key'] = 'thematiques_taxo'; // change to meta key created by acf. - $query->query_vars['meta_value'] = $_GET['thematiques']; - } -} - -// add_filter('parse_query', 'filter_post_by_thematiques_query'); - - - - /* ----------------------------------------------------------------------