我正在开发一个主题,我想知道是否无论如何我可以添加一个视觉编辑快捷方式而无需选择性刷新?
$wp_customize->get_setting( \'blogname\' )->transport = \'postMessage\';
$wp_customize->selective_refresh->add_partial( \'blogname\', array(
\'selector\' => \'.site-title a\',
\'render_callback\' => \'twentyfifteen_customize_partial_blogname\',
) );
我能喜欢吗
$wp_customize->get_setting( \'blogname\' )->transport = \'postMessage\';
$wp_customize->get_setting( \'blogdescription\' )->transport = \'postMessage\';
$wp_customize->add_partial( \'blogname\', array(
\'selector\' => \'.site-title a\',
\'render_callback\' => \'twentyfifteen_customize_partial_blogname\',
) );
实际上,它起作用了,并给出了预期的结果。。但我使用Kirki作为我的框架,由于某种原因,我无法做到这一点。我只是不想使用默认的选择性刷新,我想在postMessage中使用自己的javascript函数,但我无法在这里实现选择器标记。
这是我的代码:
Kirki::add_field( \'theme_config\', array(
\'type\' => \'text\',
\'settings\' => \'about_us_video_setting\',
\'label\' => __( \'Video Link\', \'rst\' ),
\'section\' => \'about_us_section\',
\'default\' => esc_attr__( \'youtube.com\', \'rst\' ),
\'transport\' => \'postMessage\',
\'partial_refresh\' => array(
\'about_us_video_setting\' => array(
\'selector\' => \'#youtube-video\',
\'render_callback\' => \'show_video\',
) ),
\'active_callback\' => array(
array(
\'setting\' => \'is_front_page\',
\'operator\' => \'==\',
\'value\' => true,
),
),
) );
我想要的是
Kirki::add_field( \'theme_config\', array(
\'type\' => \'text\',
\'settings\' => \'about_us_video_setting\',
\'label\' => __( \'Video Link\', \'rst\' ),
\'section\' => \'about_us_section\',
\'default\' => esc_attr__( \'youtube.com\', \'rst\' ),
\'transport\' => \'postMessage\',
\'selector\' => \'#youtube-video\',
\'active_callback\' => array(
array(
\'setting\' => \'is_front_page\',
\'operator\' => \'==\',
\'value\' => true,
),
),
) );
这是。。即使我将传输作为postMessage,is所做的只是默认刷新,而不是使用我自己的javascript
( function( $ ) {
// Change the previewed URL to the selected page when changing the page_for_posts.
wp.customize( \'about_us_video_setting\', function( setting ) {
setting.bind( function( url ) {
$(\'.embed-responsive-item\').attr(\'src\',url);
});
});
} )( jQuery );
我只是想澄清一下,因为我没有找到任何文档。是否有条件使用选择性刷新来显示编辑屏幕?
从编辑shorcuts我是说这个铅笔图标这会将您带到所需的编辑位置。