How to upload multiple images with WP_Customize_Media_Control

Use this JQuery for multiple image uploads: <!– js multi image –> jQuery(document).ready(function($) { // add image uploader functionality var meta_image_frame; $(‘.meta-image-button’).live(‘click’, function(e){ e.preventDefault(); if( meta_image_frame ){ wp.media.editor.open(); return; } meta_image_frame = wp.media.frames.file_frame = wp.media({ title: ‘Portfolio Image Gallery Selection Window’, button: {text: ‘Add to Gallery’}, library: { type: ‘image’}, multiple: false }); meta_image_frame.on(‘select’, function(){ … Read more

Need help setting default setting value for radio button in theme customizer

It is a long question but it is possible for some developers I would like to give this answer. Example: I have two choose for my home layout Grid and List and I prefer Grid is default choosing. I should add default value in add_setting simple like this ‘default’ => ‘grid’. $wp_customize->add_setting(‘yourtheme_home_layout_style’, array( ‘sanitize_callback’ => … Read more

WP Customizer – Prevent live preview

Visit this link and read about transporter argument: https://codex.wordpress.org/Theme_Customization_API Is that what you are looking for? Here is an example for you: <?php add_action( ‘customize_register’, ‘my_customizer’ ); function my_customizer($wp_customize){ $wp_customize->add_section( ‘my_section’, array( ‘title’ => __( ‘My Custom Section’, ‘mytheme’ ), //Visible title of section ‘capability’ => ‘edit_theme_options’, //Capability needed to tweak ) ); $wp_customize->add_setting( ‘my_setting’, … Read more

Disable Visible Edit Shortcuts in the Customizer

The simplest way to disable edit shortcuts without unwanted side effects is to no-op override the JS function that generates them in the first place. You can do this from PHP as follows: add_action( ‘wp_enqueue_scripts’, function () { $js=”wp.customize.selectiveRefresh.Partial.prototype.createEditShortcutForPlacement = function() {};”; wp_add_inline_script( ‘customize-selective-refresh’, $js ); } ); This will work for any theme.

Add a dropdown to theme customizer

Add Section to Theme Customizer: $wp_customize->add_section( ‘parsmizban_options’, array( ‘title’ => __( ‘Theme Options’, ‘parsmizban’ ), //Visible title of section ‘priority’ => 20, //Determines what order this appears in ‘capability’ => ‘edit_theme_options’, //Capability needed to tweak ‘description’ => __(‘Allows you to customize settings for Theme.’, ‘parsmizban’), //Descriptive tooltip ) ); Add new Setting: $wp_customize->add_setting( ‘bootstrap_theme_name’, //No … Read more

Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?

Just an idea: Make a user called ‘Guest’ and look up the user ID When redirecting your potential clients to the admin page, redirect to a script that’s logging in your clients as the guest user (Code #1) Add an WordPress action to disallow the user when logged in as ‘Guest’ and not on customize.php … Read more

When cropping a header image, retain meta data (i.e. name, description, etc.) from original image?

Here’s one idea, that might need further testing: /** * Cropped header image with the same description/caption as the original image */ add_filter( ‘wp_create_file_in_uploads’, function( $cropped, $attachment_id ) { add_filter( ‘wp_insert_attachment_data’, function( $data ) use ( $attachment_id) { if( doing_action( ‘wp_ajax_custom-header-crop’ ) && is_array( $data ) ) { // Copy the original description to the … Read more

wp.customize.bind ready event not fired

Do not put the Customizer ready event handler inside of the jQuery event handler. The Customizer ready will trigger at jQuery ready, so you are adding the event handler too late. Just do: wp.customize.bind(‘ready’, function(){ console.log(‘ready’); }); Your JS needs to be enqueued with customize-controls script as its dependency. Enqueue at the customize_controls_enqueue_scripts action.