169 lines
5.2 KiB
PHP
169 lines
5.2 KiB
PHP
<?php
|
|
|
|
/* ---------------------------
|
|
PAGE D'OPTIONS DU THEME
|
|
---------------------------*/
|
|
|
|
function register_theme_settings_option_page()
|
|
{
|
|
|
|
// Check function exists.
|
|
if (function_exists('acf_add_options_page')) {
|
|
|
|
// Register options page.
|
|
$option_page = acf_add_options_page(array(
|
|
'page_title' => __('Paramètres du site', 'homegrade-theme__texte-backoffice'),
|
|
'menu_title' => __('Paramètres du site', 'homegrade-theme__texte-backoffice'),
|
|
'menu_slug' => 'theme-general-settings',
|
|
'capability' => 'activate_plugins',
|
|
'redirect' => false,
|
|
'position' => 20,
|
|
));
|
|
}
|
|
}
|
|
// add_options_page( 'MyPlugin Options', 'MyPlugin Options', 'activate_plugins', 'myplugin-options', 'myplugin_options' );
|
|
|
|
|
|
add_action('acf/init', 'register_theme_settings_option_page');
|
|
|
|
|
|
/* ---------------------------
|
|
ADMIN STYLES
|
|
---------------------------*/
|
|
|
|
// Amin Stylesheet
|
|
function my_custom_admin()
|
|
{
|
|
wp_enqueue_style('admin_styles', get_template_directory_uri() . '/css/admin-style.css');
|
|
}
|
|
|
|
add_action('admin_head', 'my_custom_admin');
|
|
|
|
// ENQUEUE DU CSS BLADE LOGIN ADMIN
|
|
function enqueue_custom_login_stylesheet()
|
|
{
|
|
wp_enqueue_style('custom-login', get_stylesheet_directory_uri() . '/style-login.css');
|
|
}
|
|
add_action('login_enqueue_scripts', 'enqueue_custom_login_stylesheet');
|
|
|
|
|
|
|
|
/* ----------------------------------
|
|
ENQUEUE DU COLOR SCHEME ADMIN
|
|
-----------------------------------*/
|
|
|
|
function homegrade_admin_color_scheme()
|
|
{
|
|
//Get the theme directory
|
|
$theme_dir = get_stylesheet_directory_uri();
|
|
|
|
//Homegrade
|
|
wp_admin_css_color(
|
|
'homegrade_light',
|
|
'Homegrade Light',
|
|
$theme_dir . '/homegrade-light-color-scheme.css',
|
|
array('#cf4944', '#fff', '#d54e21', '#2f0154')
|
|
);
|
|
wp_admin_css_color(
|
|
'homegrade_dark',
|
|
'Homegrade Dark',
|
|
$theme_dir . '/homegrade-dark-color-scheme.css',
|
|
array('#2f2a33', '#fff', '#e14d43', '#e14d43')
|
|
);
|
|
}
|
|
add_action('admin_init', 'homegrade_admin_color_scheme');
|
|
|
|
|
|
/* ----------------------------------
|
|
REMOVE FROM ADMIN MENU
|
|
-----------------------------------*/
|
|
function custom_menu_page_removing()
|
|
{
|
|
// remove_menu_page('edit.php'); // Hide Articles
|
|
remove_menu_page('edit-comments.php'); // Hide Commentaires
|
|
}
|
|
add_action('admin_menu', 'custom_menu_page_removing');
|
|
|
|
/* ----------------------------------
|
|
REMOVE FROM ADMIN BAR
|
|
-----------------------------------*/
|
|
|
|
function mytheme_admin_bar_render()
|
|
{
|
|
global $wp_admin_bar;
|
|
$wp_admin_bar->remove_menu('comments');
|
|
}
|
|
add_action('wp_before_admin_bar_render', 'mytheme_admin_bar_render');
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
MODIFIER LE LIEN DU LOGO SUR LA BLADE DE CONNEXION À L'INTERFACE ADMIN
|
|
------------------------------------------------------------------------*/
|
|
function change_login_logo_url($url)
|
|
{
|
|
return site_url();
|
|
}
|
|
add_filter('login_headerurl', 'change_login_logo_url');
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
GESTION DE LA COLONNE THEMATIQUE DANS LA LISTE DES POSTS CONSEILS
|
|
------------------------------------------------------------------------*/
|
|
|
|
// AJOUT D'UNE COLONNE CUSTOM
|
|
function add_acf_posts_columns($columns)
|
|
{
|
|
global $current_screen;
|
|
$new_admin_col_arrays = array_slice($columns, 0, 2, true) + array('thematiques_taxo' => '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 '<a href="' . $edit_link . '">';
|
|
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 '</a>';
|
|
}
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------
|
|
ADDING CLASS TO ADMIN BODY
|
|
------------------------------------------------------------------------*/
|
|
function wpdocs_admin_classes($classes)
|
|
{
|
|
global $pagenow;
|
|
global $post;
|
|
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0];
|
|
$thematiqueParent = getParentThematique($thematique);
|
|
$thematiqueColorSlug = getThematiqueFamilySlug($thematiqueParent->slug);
|
|
|
|
|
|
if (in_array($pagenow, array('post.php', 'post-new.php'), true) && $thematiqueColorSlug) {
|
|
$classes .= ' salut ' . $thematiqueColorSlug;
|
|
}
|
|
|
|
return $classes;
|
|
}
|
|
|
|
add_filter('admin_body_class', 'wpdocs_admin_classes');
|