src='https://www.youtube.com/embed/i7XNrXdiSCE?version=3&rel=1&fs=1&autohide=2&showsearch=0&showinfo=1&iv_load_policy=1&wmode=transparent' allowfullscreen='true' style='border:0;'><
src ='https://www.youtube.com/embed/i7XNrXdiSCE?version = 3&rel = 1&fs = 1&autohide = 2&showsearch = 0&showinfo = 1&iv_load_policy = 1&wmode = transparent'allowfullscreen ='true'style ='border:0;'> <
/iframe>
/ iframe> span>
This plugin provides one example implementation of inline editing this can be accomplished in the customizer.
此插件提供了内联编辑的一个示例实现,可以在定制程序中完成。
Version 0.1 of this plugin from 2014 was a precursor in some ways to selective refresh, specifically in regards to how CSS selectors are associated with customizer settings.
从2014年开始,此插件的版本0.1在某些方面是选择性刷新的先驱,特别是在CSS选择器与自定义程序设置相关联方面。 p>
Themes can opt-in to support this plugin’s inline editing within the customizer by assigning the appropriate type to the registered partials:
通过在注册的部分中分配适当的类型,主题可以选择在定制器中支持此插件的内联编辑: p>
add_action( 'customize_register', function( $wp_customize ) {
add_action('customize_register',function($ wp_customize){
$opt_in_partials = array_filter( array(
$ opt_in_partials = array_filter(array(
$wp_customize->selective_refresh->get_partial( 'blogname' ),
$ wp_customize-> selective_refresh-> get_partial('blogname'),
$wp_customize->selective_refresh->get_partial( 'blogdescription' )
$ wp_customize-> selective_refresh-> get_partial('blogdescription')
) );
));
foreach ( $opt_in_partials as $partial ) {
foreach($ opt_in_partials as $ partial){
$partial->type = 'inline_editable';
$ partial-> type ='inline_editable';
}
}
}, 100 );
},100);
pre>
Click on the edit shortcut to begin editing the element, with keyboard focus then given to the editable element.
单击编辑快捷方式以开始编辑元素,然后将键盘焦点赋予可编辑元素。
If the value has a server-side rendered value (e.g. where PHP filters like wptexturize
apply to improve typography), the raw value will be supplied when editing starts.
如果该值具有服务器端呈现的值(例如,像 wptexturize code>这样的PHP过滤器可用于改进版式),则在开始编辑时将提供原始值。Editing can be completed by clicking out of the editable element, tabbing out of the element (blurring it), or clicking the edit icon which then appears as a “done” checkmark icon.
可以通过以下方法来完成编辑:单击可编辑元素之外的选项卡,在元素中跳出标签(使其模糊),或单击编辑图标,该图标随后显示为“完成”复选标记图标。
You may also shift-click on an element to edit it.
您也可以在元素上按住Shift键并单击以对其进行编辑。 p>
Currently only basic text fields can currently be edited;
当前只能编辑基本文本字段;
styling and any tags added to contentEditable
areas will be stripped out.
样式和添加到 contentEditable code>区域的所有标签都将被删除。Eventually rich text formatting may be allowed, specifically for integrations with the Text widget (via JS Widgets
最终可能会允许使用富文本格式,特别是用于与文本小部件的集成(通过 JS小部件
) or post content (via Customize Posts).
)或发布内容(通过自定义帖子)。 p>
The selective refresh
选择性刷新
writeup from 4.5 concludes with a section on a possible future for it and inline editing:
从4.5开始的文章总结了一段可能的前景以及内联编辑的内容: p>
If we can eliminate full-page refreshes from being the norm for the Customizer, we can start to introduce controls inline with the preview.
如果我们可以取消整页刷新作为Customizer的规范,则可以开始在预览中引入控件。
If the entire preview does not reload, then the inline controls won’t get destroyed by the refresh with each change.
如果没有重新加载整个预览,则内联控件不会因每次更改而被破坏。
For example, consider a widget control floating immediately next to the widget in the sidebar it is editing.
例如,考虑一个窗口小部件控件紧挨它正在编辑的边栏中的窗口小部件浮动。
With selective refresh, it will then also be possible to eliminate the Customizer altogether.
通过选择性刷新,还可以完全消除定制程序 em>。The Customizer could be available to anyone who is logged in, with the controls being bootstrapped on demand when a user wants to edit a given element.
定制程序可以供任何登录用户使用,并且当用户想要编辑给定元素时,可以按需引导控件。
There would be no need to navigate way from a page on the frontend to enter a unique Customizer state: the Customizer would come to the user.
无需从前端页面上导航就可以进入唯一的定制器状态:定制器会出现在用户面前。
Any controls not relevant to being inline could remain in the Customizer pane, but it could slide in only as needed instead of appearing by default.
任何与内联无关的控件都可以保留在“定制器”窗格中,但是只能根据需要滑入,而不是默认显示。
That is to say, selective refresh makes the Customizer a much better framework for implementing frontend editing.
也就是说,选择性刷新使定制程序成为实现前端编辑 strong>的更好的框架。 p>
blockquote>
Development of this plugin is done on GitHub. 此插件的开发在GitHub上 完成。Pull requests welcome.
拉请求欢迎。
Please see issues reported there before going to the 问题,然后再转到
://wordpress.org/support/plugin/customize-inline-editing">plugin forum