I am developing a WordPress theme that uses a color picker in the admin panel in which users can pick a custom link color. I want the link hover color to be the same as the normal link color, but darkened 10%. In LESS I can use the link color as a variable and use @link-hover: darken(@link-color, 10%);
but then that doesn't connect with the PHP color picker. Is there a way to get PHP to refer to a LESS or SASS mixin variable? Or maybe some other solution that gets the result I'm looking for?
Using: PHP 5.4.4 / WordPress 3.5 / LESS 2.7.1
My function for the WordPress "Theme Customizer" (from hal gatewood):
function stillcalm_customize_register( $wp_customize )
{
$colors = array();
$colors[] = array( 'slug'=>'content_bg_color', 'default' => '#ffffff', 'label' => __( 'Background Color', 'stillcalm' ) );
$colors[] = array( 'slug'=>'content_text_color', 'default' => '#000000', 'label' => __( 'Text Color', 'stillcalm' ) );
foreach($colors as $color)
{
// SETTINGS
$wp_customize->add_setting( $color['slug'], array( 'default' => $color['default'], 'type' => 'option', 'capability' => 'edit_theme_options' ));
// CONTROLS
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $color['slug'], array( 'label' => $color['label'], 'section' => 'colors', 'settings' => $color['slug'] )));
}
}
and then this in the header:
<?php
$text_color = get_option('text_color');
$background_color = get_option('background_color');
?>
<style>
body {
color: <?php echo $text_color; ?>;
background-color: <?php echo $background_color; ?>;
}
</style>