• Resolved Calin MANESCU

    (@atelieruldeweb)


    Hi, before i used astra and with a code entered in functions.php (following the instructions from here: https://www.intelliwolf.com/change-default-colors-in-wordpress-customizer/), i was able to change the color picker colors in wordpress customizer with my own color scheme.
    I tried the same in Neve, replacing astra with neve, but it doesnt work:
    function ohu_custom_palettes($color_palettes) {
    $color_palettes = array(
    ‘#5752B2’,
    ‘#BDBAEB’,
    ‘#3A349E’,
    ‘#D2F585’,
    ‘#75A310’,
    ‘#FF7B5F’,
    ‘#FFD95F’,
    ‘#FFF0C1’,
    );

    return $color_palettes;
    }

    add_filter(‘neve_color_palettes’, ‘ohu_custom_palettes’);

    // END ENQUEUE PARENT ACTION

    What should i do?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey @atelieruldeweb ,

    I’ll leave the solution to that below. Just note that this will work for the classic color pickers – i.e. it’s not available for the other color controls unfortunately, at least at the moment.

    
    add_action( 'customize_controls_enqueue_scripts', 'neve__custom_color_palettes' );
    
    /**
     * Adds custom color palettes to wp.color picker.
     */
    function neve__custom_color_palettes() {
    	$color_palettes = json_encode(
    		array(
    			'#673ab7',
    			'#3f51b5',
    			'#2196f3',
    			'#00bcd4',
    			'#009688',
    			'#4caf50',
    		)
    	);
    	wp_add_inline_script( 'wp-color-picker', 'jQuery.wp.wpColorPicker.prototype.options.palettes = ' . $color_palettes . ';' );
    }

    Have an awesome day!

    Thread Starter Calin MANESCU

    (@atelieruldeweb)

    Thanks, i solved it with a plugin called Central Color Palette, which allows more options. Anyway, good to have an elegant code solution at hand too. Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change color picker palette in functions.php with my own scheme’ is closed to new replies.