handling publications brochures

This commit is contained in:
Antoine M 2023-07-20 11:54:51 +02:00
parent 45dbe21d98
commit 12b0baf4e1
11 changed files with 194 additions and 74 deletions

View File

@ -4,4 +4,12 @@
#menu-posts { #menu-posts {
border-top: 1px solid rgba(255, 255, 255, 0.2) !important; border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
}
#menu-posts-conseils {
border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
}
#toplevel_page_theme-general-settings {
border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
} }

View File

@ -903,6 +903,10 @@ video {
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}
.alignfull { .alignfull {
margin: 2rem calc(50% - 50vw) !important; margin: 2rem calc(50% - 50vw) !important;
max-width: 100vw !important; max-width: 100vw !important;

View File

@ -350,6 +350,10 @@
-moz-osx-font-smoothing: grayscale -moz-osx-font-smoothing: grayscale
} }
.filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)
}
.alignfull { .alignfull {
margin: 2rem calc(50% - 50vw) !important; margin: 2rem calc(50% - 50vw) !important;
max-width: 100vw !important; max-width: 100vw !important;

View File

@ -5,6 +5,7 @@ require_once(__DIR__ . '/includes/rooting.php');
require_once(__DIR__ . '/includes/init.php'); require_once(__DIR__ . '/includes/init.php');
require_once(__DIR__ . '/includes/blocks.php'); require_once(__DIR__ . '/includes/blocks.php');
require_once(__DIR__ . '/includes/post_types.php'); require_once(__DIR__ . '/includes/post_types.php');
require_once(__DIR__ . '/includes/post-brochures.php');
require_once(__DIR__ . '/includes/admin.php'); require_once(__DIR__ . '/includes/admin.php');
require_once(__DIR__ . '/includes/logos.php'); require_once(__DIR__ . '/includes/logos.php');
require_once(__DIR__ . '/includes/taxonomy.php'); require_once(__DIR__ . '/includes/taxonomy.php');

View File

@ -17,7 +17,7 @@ function register_theme_settings_option_page()
'menu_slug' => 'theme-general-settings', 'menu_slug' => 'theme-general-settings',
'capability' => 'activate_plugins', 'capability' => 'activate_plugins',
'redirect' => false, 'redirect' => false,
'position' => 9, 'position' => 20,
)); ));
} }
} }
@ -119,6 +119,8 @@ function add_acf_posts_columns($columns)
return array_merge($new_admin_col_arrays); return array_merge($new_admin_col_arrays);
} }
add_filter('manage_conseils_posts_columns', 'add_acf_posts_columns'); add_filter('manage_conseils_posts_columns', 'add_acf_posts_columns');
add_filter('manage_fiche-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 // CUSTOMISATION DE LA COLONNE POUR AFFICHER : THEMATIQUE PARENT > THEMATIQUE
function handle_posts_custom_columns($column, $post_id) function handle_posts_custom_columns($column, $post_id)
@ -135,3 +137,5 @@ function handle_posts_custom_columns($column, $post_id)
echo '</a>'; echo '</a>';
} }
add_action('manage_conseils_posts_custom_column', 'handle_posts_custom_columns', 10, 2); add_action('manage_conseils_posts_custom_column', 'handle_posts_custom_columns', 10, 2);
add_action('manage_fiche-questions_posts_custom_column', 'handle_posts_custom_columns', 10, 2);
add_action('manage_brochures_posts_custom_column', 'handle_posts_custom_columns', 10, 2);

View File

@ -0,0 +1,22 @@
<?php
function homegrade_brochure_post_title_updater($post_id)
{
$my_post = array();
$my_post['ID'] = $post_id;
$brochureTaxonomy = get_the_terms($post_id, 'thematiques')[0];
write_log($brochureTaxonomy);
if (get_post_type() == 'brochures') {
$my_post['post_title'] = "";
$my_post['post_title'] = $brochureTaxonomy->name;
}
wp_update_post($my_post);
}
add_action('acf/save_post', 'homegrade_brochure_post_title_updater', 20);

View File

@ -44,25 +44,6 @@ add_action('admin_menu', 'change_menu_icon');
// #### POST TYPES // #### POST TYPES
function create_posttype() function create_posttype()
{ {
register_post_type(
'fiche-questions',
array(
'labels' => array(
'name' => __('Questions', 'homegrade-theme__texte-backoffice'),
'singular_name' => __('Question', 'homegrade-theme__texte-backoffice')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'fiche-question'),
'show_in_rest' => true,
'menu_icon' => 'dashicons-admin-comments',
'menu_icon' => 'dashicons-editor-help',
'menu_position' => 4,
'supports' => array('title', 'custom-fields', 'excerpt'),
)
);
register_post_type( register_post_type(
'conseils', 'conseils',
array( array(
@ -75,13 +56,45 @@ function create_posttype()
'has_archive' => true, 'has_archive' => true,
'show_in_rest' => true, 'show_in_rest' => true,
'menu_icon' => 'dashicons-pressthis', 'menu_icon' => 'dashicons-pressthis',
'menu_position' => 4, 'menu_position' => 2,
// 'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'), 'supports' => array('title', 'editor', 'page-attributes'),
// 'supports' => array('title', 'custom-fields', 'editor'), // 'supports' => array('title', 'custom-fields', 'editor'),
) )
); );
register_post_type(
'brochures',
array(
'labels' => array(
'name' => __('Brochures', 'homegrade-theme__texte-backoffice'),
'singular_name' => __('Brochure', 'homegrade-theme__texte-backoffice')
),
'hierarchical' => true,
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-book',
'menu_position' => 2,
'position' => 2,
'supports' => array('custom-fields', 'page-attributes'),
)
);
register_post_type(
'fiche-questions',
array(
'labels' => array(
'name' => __('Questions', 'homegrade-theme__texte-backoffice'),
'singular_name' => __('Question', 'homegrade-theme__texte-backoffice')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'fiche-question'),
'show_in_rest' => true,
'menu_icon' => 'dashicons-editor-help',
'menu_position' => 4,
'supports' => array('title', 'custom-fields', 'editor', 'excerpt'),
)
);
register_post_type( register_post_type(
'vocabulaire', 'vocabulaire',
array( array(
@ -93,57 +106,54 @@ function create_posttype()
'has_archive' => true, 'has_archive' => true,
'rewrite' => array('slug' => 'fiche'), 'rewrite' => array('slug' => 'fiche'),
'show_in_rest' => true, 'show_in_rest' => true,
// 'menu_icon' => 'dashicons-image-filter',
'menu_icon' => 'dashicons-media-spreadsheet',
'menu_icon' => 'dashicons-info-outline', 'menu_icon' => 'dashicons-info-outline',
'menu_position' => 5.1,
'menu_position' => 4, 'supports' => array('title', 'custom-fields'),
'supports' => array('title', 'custxom-fields'),
) )
); );
} }
add_action('init', 'create_posttype'); add_action('init', 'create_posttype');
// function remove_editor()
// {
// if (isset($_GET['post'])) {
// $id = $_GET['post'];
// $template = get_post_meta($id, '_wp_page_template', true);
// switch ($template) {
// case 'template_01.php':
// case 'template_02.php':
// case 'template_03.php':
// case 'template_04.php':
// // the below removes 'editor' support for 'pages'
// // if you want to remove for posts or custom post types as well
// // add this line for posts:
// // remove_post_type_support('post', 'editor');
// // add this line for custom post types and replace
// // custom-post-type-name with the name of post type:
// // remove_post_type_support('custom-post-type-name', 'editor');
// remove_post_type_support('page', 'editor');
// break;
// default:
// // Don't remove any other template.
// break;
// }
// }
// }
// add_action('init', 'remove_editor');
/* ----------------------------------------------------------------------
// add_action( 'admin_init', 'hide_editor' ); POST TYPE ORDER
------------------------------------------------------------------------*/
// function hide_editor() { /**
// $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; * Activates the 'menu_order' filter and then hooks into 'menu_order'
// if( !isset( $post_id ) ) return; */
add_filter('custom_menu_order', function () {
// $template_file = get_post_meta($post_id, '_wp_page_template', true); return true;
});
// if($template_file == 'submit.php'){ // edit the template name add_filter('menu_order', 'my_new_admin_menu_order');
// remove_post_type_support('page', 'editor'); /**
// } * Filters WordPress' default menu order
// } */
function my_new_admin_menu_order($menu_order)
{
// define your new desired menu positions here
// for example, move 'upload.php' to position #9 and built-in pages to position #1
$new_positions = array(
'upload.php' => 9,
// 'edit.php?post_type=page' => 1,
'edit.php?post_type=conseils' => 1,
'edit.php?post_type=fiche-questions' => 2,
'edit.php?post_type=brochures' => 3,
'edit.php?post_type=vocabulaire' => 4,
);
// helper function to move an element inside an array
function move_element(&$array, $a, $b)
{
$out = array_splice($array, $a, 1);
array_splice($array, $b, 0, $out);
}
// traverse through the new positions and move
// the items if found in the original menu_positions
foreach ($new_positions as $value => $new_index) {
if ($current_index = array_search($value, $menu_order)) {
move_element($menu_order, $current_index, $new_index);
}
}
return $menu_order;
};

View File

@ -40,7 +40,7 @@ function undo_create_term($term_id, $tt_id, $taxonomy)
function add_custom_taxonomies() function add_custom_taxonomies()
{ {
// ————— Thématiques ————— // ————— Thématiques —————
register_taxonomy('thematiques', ['fiche-questions', 'conseils'], array( register_taxonomy('thematiques', ['fiche-questions', 'conseils', 'brochures'], array(
// 'hierarchical' => true, // 'hierarchical' => true,
'labels' => array( 'labels' => array(
'name' => __('Thématiques', 'homegrade-theme__texte-backoffice'), 'name' => __('Thématiques', 'homegrade-theme__texte-backoffice'),
@ -56,12 +56,19 @@ function add_custom_taxonomies()
'menu_name' => __('Thématiques', 'homegrade-theme__texte-backoffice'), 'menu_name' => __('Thématiques', 'homegrade-theme__texte-backoffice'),
), ),
'public' => true, 'public' => true,
'show_in_rest' => false, // Needed for tax to appear in Gutenberg editor 'show_in_rest' => true, // Needed for tax to appear in Gutenberg editor
'show_ui' => true, 'show_ui' => true,
'show_admin_column' => false, 'show_admin_column' => false,
'hierarchical' => true, // This will allow URL's like "/locations/boston/cambridge/" 'hierarchical' => true, // This will allow URL's like "/locations/boston/cambridge/"
'show_in_quick_edit' => false, 'show_in_quick_edit' => false,
'meta_box_cb' => false, 'meta_box_cb' => false,
'rewrite' => array(
'slug' => 'nos-conseils-thematiques',
// 'with_front' => false,
'hierarchical' => true,
'has_archive' => true
),
)); ));

View File

@ -2,5 +2,11 @@
background: red !important; background: red !important;
} */ } */
#menu-posts { #menu-posts {
border-top: 1px solid rgba(255, 255, 255, 0.2) !important; border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
}
#menu-posts-conseils {
border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
}
#toplevel_page_theme-general-settings {
border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
} }

View File

@ -1,7 +1,7 @@
/* /*
Theme Name: Homegrade_Theme Theme Name: Homegrade_Theme
Author: Deligraph Author: Deligraph
Author URI: https://deligraph.com/ Author URI: https://deligraph.com/
Version: 1.0.0 Version: 1.0.0
Text Domain: homegrade-theme__texte-fonctionnel Text Domain: homegrade-theme__texte-fonctionnel
*/ */

54
taxonomy-thematiques.php Normal file
View File

@ -0,0 +1,54 @@
<?php get_header();
$term = get_queried_object();
echo '<pre>';
print_r($term);
print_r(is_tax('thematiques', 'thematiques'));
echo '</pre>';
$args = array(
'posts_per_page' => 1,
'post_type' => 'conseils',
'tax_query' => array(
array(
'slug' => 'locations',
'taxonomy' => 'thematiques',
'field' => 'slug',
'terms' => $term->slug,
'include_children' => false,
)
)
);
$query_thematique_posts = new WP_Query($args);
$thematique_related_page = $query_thematique_posts->posts[0];
if ($term->parent == 0) {
$args = array(
'child_of' => $term->term_id,
'taxonomy' => $term->taxonomy,
'hide_empty' => 0,
'hierarchical' => true,
'depth' => 1,
);
wp_list_categories($args);
}
// echo '<pre>';
// print_r($thematique_related_page);
// echo '</pre>';
// echo $the_query->posts[0]->post_content;
?>
<div class="container my-8 mx-auto">
<?php
echo $thematique_related_page->post_content;
?>
</div>
<?php
get_footer();