I'm trying to add a Custom Palette Control for a section inside my Customizer options using this library: http://www.hardeepasrani.com/2017/10/color-palette-control-for-wordpress-customizer/. Everything's set up inside functions.php, however I'm unable to access the colors inside the "green" array when adding it to my CSS.
Tried accessing them with <?php echo get_theme_mod('o2_color_palette'); ?>
but it only returns the name of the array. Using get_theme_mod('o2_color_palette[1]')
returns nothing, same as o2_color_palette[colors][1]
.
$wp_customize->add_setting( 'o2_color_palette', array(
'default' => 'green',
'capability' => 'edit_theme_options'
));
$wp_customize->add_control(new O2_Customizer_Color_Palette_Control($wp_customize, 'o2_color_palette', array(
'label' => __('Color Scheme', 'WordpressTutorial'),
'description' => __('Choose a color scheme for your website.', 'WordpressTutorial'),
'section' => 'lwp_standard_colors',
'choices' => array (
'green' => array(
'label' => 'Green',
'colors' => array( '#bbdb9b', '#abc4a1', '#9db4ab', '#8d9d90', '#878e76' )
),
'purple' => array(
'label' => 'Purple',
'colors' => array( '#29274c', '#7e52a0', '#d295bf', '#e6bccd' )
),
'slate' => array(
'label' => 'Slate',
'colors' => array( '#b9bbbb', '#a2a3bb', '#5e5f87', '#b3b7ee', '#fbf9ff' )
)
),
'priority' => 5,
'settings' => 'o2_color_palette'
)));
I need get_theme_mod to return the selected color palette's array of colors so I can apply them.