Accessing customizer values in javascript

Given a setting with an ID of “foo” you can obtain the value via: var value = wp.customize( ‘foo’ ).get() To ensure that the setting is registered before you attempt to get its value, you can use this deferred pattern: wp.customize( ‘foo’, function( setting ) { var value = setting.get(); // … }); This should … Read more

How can i add edit shortcut icon in wordpress customizer without using selective refresh?

What you need to do is implement a custom Partial in JS which applies a custom refresh behavior of modifying the background-color instead of fetching a newly-rendered partial from the server. So it’s partials with edit shortcuts but without any server-side selective refresh. For example, enqueue the following JS in the customizer preview with a … Read more

Is there any function that would allow me to register custom stylesheets for the Customizer itself?

If you’re after getting custom CSS ontop of WordPress’s Admins Customizer buttons, inputs, and controls – you can do something like this: add_action( ‘admin_enqueue_scripts’, function(){ $screen = get_current_screen(); if ($screen->base == ‘customize’) { wp_register_style( ‘custom_wp_admin_css’, plugins_url( ‘your-file.css’, __FILE__ ), //get_template_directory_uri().’your-file.css’, false, filemtime( plugin_dir_path( __FILE__ ) . ‘/your-file.css’ ) // get_template_directory() . ‘/your-file.css’ ) ); wp_enqueue_style( … Read more

Wp Customizer event for when a new widget has been added

In order to interact with the event “widget-added” , you should enqueue your JavaScript file using “customize_controls_enqueue_scripts” to avoid it being part of the repetitively loading preview iframe ( where $(document) is different from the parent page document). I was able of interacting with the “widget-added” event using this example : in theme’s functions.php function … Read more

How to remove scripts/style added to customize_controls_enqueue_scripts hook by current active theme

You can use the global $wp_scripts and global $wp_styles; to get all registerd scripts and styles. Eg. All Scripts // All Scripts global $wp_scripts; $all_scripts = array(); foreach( $wp_scripts->registered as $script ) : $all_scripts[$script->handle] = $script->src; endforeach; // echo ‘<pre>’; // print_r( $all_scripts ); // echo ‘</pre>’; All Styles // All Styles global $wp_styles; $all_styles … Read more

Issue with Customizer: only last field shown in section

WP_Customize_Color_Control takes 3 parameters: /** * @param WP_Customize_Manager $manager Customizer bootstrap instance. * @param string $id Control ID. * @param array $args Optional. Arguments to override class property defaults. */ The problem with the original code is that you’ve passed the same Control ID (link_color) to two separate instances. So, the most recently added control … Read more

Theme customization based on grouped pages

You can either: A: Use Posts rather than Pages. WP enables Categories on Posts by default, so it’s easy to select a Category for each Post (all categories are shown with checkboxes, or it’s easy to add a new one). B: Use Pages, and create a custom “Page Category” taxonomy to categorize them, which also … Read more

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