How to add "Edit Shortcuts" icon new feature in WordPress 4.7 to the customizer. I want to add this icon anywhere in my theme customizer
Asked
Active
Viewed 2,693 times
1 Answers
2
These are called 'Visible Edit Shortcuts' in Customizer Preview. You should read more about it here:
https://make.wordpress.org/core/2016/11/10/visible-edit-shortcuts-in-the-customizer-preview/
It's an extension of the selective refresh:
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'twentyfifteen_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'twentyfifteen_customize_partial_blogdescription',
) );
Where the render callbacks call bloginfo( 'name' );
and bloginfo( 'description' );
https://make.wordpress.org/core/2016/02/16/selective-refresh-in-the-customizer/
Also check out the official Customizer documentation
So basically if you had the selective refresh in your customizer, these will appear by default ;)

dingo_d
- 11,160
- 11
- 73
- 132
-
1I have a normal text control and I want to change it without refresh customizer live preview. ' $wp_customize->add_setting( 'copyright_text', array( 'default' => 'copyright', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control( 'copyright_text', array( 'label' => __( 'Footer copyright text' ), 'section' => 'footer_section', ) );' – Javad Dec 08 '16 at 16:28
-
What if I use direct javascript api instead of ajax refresh? How do I then create this edit shortcut? – Mirajul Momin Feb 02 '21 at 07:53
-
Not sure, but I'd move away from customizer, as the plan is to replace it with full site editing and Gutenberg. So my advice is: focus on gutenberg, blocks and full site editing instead of wasting your time on things that will be removed from the WP core soon – dingo_d Feb 02 '21 at 12:13