如何将“编辑快捷方式”图标添加到Wordpress自定义程序

时间:2016-12-07 06:57:58

标签: wordpress wordpress-4.7

如何将WordPress 4.7中的“编辑快捷方式”图标新功能添加到自定义程序。我想在我的主题定制器

中的任何位置添加此图标

Wordpress Edit Shortcut icon

1 个答案:

答案 0 :(得分:1)

这些被称为'可见编辑快捷方式'在Customizer Preview中。你应该在这里阅读更多相关信息:

https://make.wordpress.org/core/2016/11/10/visible-edit-shortcuts-in-the-customizer-preview/

它是选择性刷新的延伸:

$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',
) );

渲染回调调用bloginfo( 'name' );bloginfo( 'description' );

的位置

https://make.wordpress.org/core/2016/02/16/selective-refresh-in-the-customizer/

另请查看官方Customizer documentation

所以基本上如果您在自定义程序中进行了选择性刷新,默认情况下会出现这些选项;)