Changing the entire control choices using wp.customize with JavaScript

You’re close. You just need to replace changeTheChoices() with set() as this is a method on wp.customize.Setting. See the following which also refactors a bit: wp.customize( ‘setting_category’, ‘setting_font’, function( categorySetting, fontSetting ) { categorySetting.bind( function( category ) { var newChoices = {}; // get new data from JSON using ‘category’ and populate the ‘newChoices’ fontSetting.set( … Read more

How to get input_attrs in the sanitize function?

Your control is named custom_num but your setting is named my_custom_num. Modify your setting’s sanitize function to use the former: $input_attrs = $setting->manager->get_control( ‘custom_num’ )->input_attrs; See also the Customize Input Validity Constraints plugin, where you can see how to obtain the control for a given setting without having to hard-code it: $controls = array(); foreach … Read more

Copy customizer options to child theme

Definitely backup your database FIRST before trying this out. I just tested changing the option_name of a set of customizer changes to match a different theme, and it appears we can make the customizer changes switch to another theme simply by changing the option_name to match our new theme, instead of copying the option_value serialized … Read more

Add inline css to theme

According to Codex, this function accepts 2 arguments: <?php wp_add_inline_style( $handle, $data ); ?> Take a look at this example: function my_inline_css() { wp_enqueue_style( ‘custom-style’, get_template_directory_uri() . ‘/css/custom_script.css’ ); $btn_color = esc_attr( get_theme_mod( ‘my-custom-color’ ) ); $custom_css = ” .btn-default{ background-color: {$btn_color}; }”; wp_add_inline_style( ‘custom-style’, $my_custom_css ); } add_action( ‘wp_enqueue_scripts’, ‘my_inline_css’ ); You should have … Read more

WordPress Customizer: How can you have multiple active callbacks on one control?

You can create a third active callback function that just references the two existing ones, for example via an anonymous function (PHP≥5.3): // About Block Button Text $wp_customize->add_setting( ‘about_block_button_text’, array( ‘default’ => __( ‘Read More’, ‘my_theme_name’ ) ) ); $wp_customize->add_control( ‘about_block_button_text’, array( ‘label’ => __( ‘About Button Text’, ‘my_theme_name’ ), ‘type’ => ‘text’, ‘section’ => … Read more

Why does get_theme_mod return blank (or default value) but get_option returns saved value?

This is original code from wordpress: function get_theme_mods() { $theme_slug = get_option(‘stylesheet’); $mods = get_option(“theme_mods_$theme_slug”); if (false === $mods) { $theme_name = get_option(‘current_theme’); if (false === $theme_name) $theme_name = wp_get_theme()->get(‘Name’); $mods = get_option(“mods_$theme_name”); // Deprecated location. if (is_admin() && false !== $mods) { update_option(“theme_mods_$theme_slug”, $mods); delete_option(“mods_$theme_name”); } } return $mods; } function get_theme_mods() { $theme_slug … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)