passing theme colors

This commit is contained in:
Antoine 2025-03-06 10:10:15 +01:00
parent 9df008e310
commit 3980fdc384

View File

@ -1,6 +1,8 @@
<?php
// #### ADMIN STYLE
/* ----------------------------------------------------------------
##### ENQUEUE ADMIN STYLE
------------------------------------------------------------------*/
function my_custom_admin()
{
wp_enqueue_style('admin_styles', get_template_directory_uri() . '/css/admin-style.css');
@ -8,7 +10,9 @@ function my_custom_admin()
add_action('admin_head', 'my_custom_admin');
// ##### REMOVE FROM ADMIN MENU
/* ----------------------------------------------------------------
##### REMOVE FROM ADMIN MENU
------------------------------------------------------------------*/
function custom_menu_page_removing()
{
// remove_menu_page('edit.php'); // Hide Articles
@ -17,7 +21,9 @@ function custom_menu_page_removing()
add_action('admin_menu', 'custom_menu_page_removing');
// ##### Removes from admin bar
/* ----------------------------------------------------------------
##### REMOVES FROM ADMIN BAR
------------------------------------------------------------------*/
function mytheme_admin_bar_render()
{
global $wp_admin_bar;
@ -26,16 +32,44 @@ function mytheme_admin_bar_render()
add_action('wp_before_admin_bar_render', 'mytheme_admin_bar_render');
// ##### MODIFIER LE LIEN DU LOGO SUR LA BLADE DE CONNEXION À L'INTERFACE ADMIN
/* -----------------------------------------------------------------------------
##### 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');
// ##### ENQUEUE DU CSS BLADE LOGIN 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');
/* ----------------------------------------------------------------------
PASSER LES COULEURS DU THEMES AU COLOR PICKER ACF
------------------------------------------------------------------------*/
function change_acf_input_colors()
{ ?>
<script type="text/javascript">
(function($) {
acf.add_filter('color_picker_args', function($args, $field) {
// this will create a settings variable with all settings
const $settings = wp.data.select("core/editor").getEditorSettings();
// pull out the colors from that variable
let $colors = $settings.colors.map(x => x.color);
// assign those colors to palettes
$args.palettes = $colors;
return $args;
});
})(jQuery);
</script>
<?php }
add_action('acf/input/admin_footer', 'change_acf_input_colors');