Last active
April 16, 2019 15:06
-
-
Save seothemes/e7b16502eec2843f00f1548421fec1ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Register settings and controls with the Customizer. | |
add_action( 'customize_register', 'seo_customizer_register' ); | |
function seo_customizer_register() { | |
global $wp_customize; | |
global $seo_default_colors; | |
// Loop through each variable in the array | |
foreach($seo_default_colors as $key => $value) { | |
// Add setting for each variable | |
$wp_customize->add_setting( $key , array( | |
'default' => $value, | |
'sanitize_callback' => 'sanitize_hex_color', | |
) ); | |
// Add control for each variable | |
$wp_customize->add_control( | |
new WP_Customize_Color_Control( | |
$wp_customize, | |
$key, | |
array( | |
'label' => ucwords( str_replace( 'color-', '', $key ) ) . ' Color', | |
'section' => 'colors', | |
'settings' => $key, | |
) ) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment