WP Customizer set a value via javascript (to create presets)

The solution is to simply enqueue the JS value syncing snippet so that it is added in the customizer pane (customize.php) instead of the customizer preview window (on the frontend). In other words, enqueue your JS at customize_controls_enqueue_scripts instead of wp_enqueue_scripts. Here’s one snippet: wp.customize( ‘field1’, ‘field2’, function( field1, field2 ) { field1.bind( function( value … Read more

WordPress Customize — Move “menus” options / field to another section

The customizer is divided into panels, then sections, then controls. You cannot move a panel inside another panel. However, you can move sections from one panel to another. In this case you can move the sections inside “Menus” to the “Header panel” like this: $wp_customize->get_section (‘AAA’)->panel=”BBB”; Where AAA is the slug of the section you … Read more

WordPress Customizer Typography: How to load just the unique Google Fonts?

This question is way too broad for a complete answer in a Q&A format, but here is roughly what I would do: Collect all system fonts in an array $sys_fonts Collect all Google fonts in an array $ggl_fonts Collect the complete info about Google fonts in a multidimensional array $ggl_fontinfo Merge $sys_fonts and $ggl_fonts in … Read more

WordPress customizer: load controls in a custom div

Put below codes in your functions.php function sorcey_customize_register($wp_customize){ $wp_customize->add_section(‘sorcey_footer’, array( ‘title’ => __(‘New Section’, ‘text_domain’), ‘description’ => ”, ‘priority’ => 120, )); /* ============================= Text input ===============================*/ $wp_customize->add_setting(“sr_copyright”, array( “default” => “”, ‘capability’ => ‘edit_theme_options’, “transport” => “postMessage”, )); $wp_customize->add_control(new WP_Customize_Control($wp_customize, “sr_copyright_ctrl”, array( “label” => __(“Title”, “text_domain”), “section” => “sorcey_footer”, “settings” => “sr_copyright”, “type” => … Read more

How do I conditionally enqueue stylesheets or scripts in theme customizer settings?

Got it! Here’s the code that worked for me. — Theme Customizer settings and controls (mine are in a separate customizer.php file): function themename_customize_register( $wp_customize ) { … $wpcustomize->add_setting( ‘themename_skin’, array( ‘default’ => ‘light’, ), ); $wp_customize->add_control( ‘themename_skin’, array( ‘label’ => ‘Skin’, ‘section’ => ‘colors’, ‘settings’ => ‘themename_skin’, ‘type’ => ‘radio’, ‘choices’ => array( ‘light’ … Read more

Make Theme Options Native to Theme Customizer

Step 1: Register the setting in the customizer Add this to your wptuts_theme_customizer() function, which will register a new “Pagination” section, as well as a “Pagination Style” setting: /* Section: Pagination */ $wp_customize->add_section( ‘themeslug_pagination’, array( ‘title’ => __( ‘Pagination’, ‘themeslug’ ), ) ); $wp_customize->add_setting( ‘pagination_style’, array( ‘default’ => ‘next-previous-links’, ) ); $wp_customize->add_control( ‘pagination_style’, array( ‘label’ … Read more

Add a “loading” notice when Customizer is making changes

While this might not a be the perfect solution but this should work. You can set an interval to check against the preview iframe, like this: var previewDiv = $(‘#customize-preview’); previewDiv.prepend(‘<div class=”loading-overlay”></div>’); var loadingOverlay = previewDiv.find(‘.loading-overlay’); setInterval(function(){ if( previewDiv.children(‘iframe’).length > 1 ) { previewDiv.addClass(‘loading’); } else{ previewDiv.removeClass(‘loading’); previewDiv.addClass(‘loaded’); } }, 100);

How to access the nav_menus panel with the customizer api?

The Nav Menus panel is added at customize_register action priority 11, so you need to set the priority at priority 12 (or above). This works for me: <?php add_action( ‘customize_register’, function ( \WP_Customize_Manager $wp_customize ) { $panel = $wp_customize->get_panel( ‘nav_menus’ ); if ( $panel ) { $panel->priority = 1; } }, 12 );

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