Cutomize Colors utility: How to add more configurable colors to a theme

So I wrote down the whole process of how I found the answer myself, hope it’s useful to someone (assumes basic unix and programming skills). Finding where the current color options are defined: grep -ir ‘Header and Sidebar Text Color’ . ./wp-content/themes/twentyfifteen/inc/customizer.php: // Add custom header and sidebar text color setting and control. ./wp-content/themes/twentyfifteen/inc/customizer.php: ‘label’ … Read more

How to trigger function on theme delete?

As long as you don’t delete your theme by ftp, but use the regular way of switching to another theme in the admin, there is a hook to use, switch_theme. It works like this: add_action(‘switch_theme’, ‘mytheme_setup_options’); function mytheme_setup_options () { delete_option(‘mytheme_option1’); delete_option(‘mytheme_option2′); } There’s a sister hook called after_switch_theme, which you could use, for instance, … Read more

get_template_directory has an odd functionality

It is a bug the get_template_directory(); should not return a string that looks like that, try making another installation of WordPress, and echo the get_template_directory(); and see if the output is the same, if it is not then there is something wrong with the first installation.

How Can I Create a List of Values to Be Iterated Through via WordPress Customization API?

Assuming you have an array $locations available, you can use this code to generate a dropdown in the customizer. It’s not that different from a single value. $section_name=”wpse213980_section_name”; // adapt to your naming system $section_title=”wpse213980_section_title”; // adapt to your naming system $setting_name=”wpse213980_setting_name”; // adapt to your naming system $setting_field_type=”select”; $setting_field_options = $locations; $sanitize_callback = ‘sanitize_text_field’; … Read more