handle_direct_changes() code>)通知用户有关更改的信息。 p>On file updates through the code editor the plugin checks if the file has actually changed before WordPress writes to it.
在通过代码编辑器更新文件时,插件会在WordPress写入文件之前检查文件是否已实际更改。
Only when changes are found a revision needs to be created.
仅当发现更改时,才需要创建修订。
If no post is associated with the file yet a new post is created with the old contents.
如果没有与该文件关联的帖子,但是使用旧内容创建了一个新帖子。
This post is then updated with the new content.
然后,该帖子将使用新内容进行更新。
This process guarantees that there is a revision with the initial file content to which the user can revert to (handle_file_update()
).
此过程保证存在一个带有初始文件内容的修订版本,用户可以将其还原为( handle_file_update() code>)。Additionally the plugin tries to do a syntax check for *.php
files to prevent breaking the WordPress installation (check_syntax()
).
另外,该插件会尝试对 *。php code>文件进行语法检查,以防止破坏WordPress安装( check_syntax() code>)。As mostly recommended the plugin utilizes php -l
for this by writing the new contents to a temporary file.
正如大多数推荐的那样,该插件通过将新内容写入临时文件来利用 php -l </ code>。If this feature is not available a more basic check using eval is performed.
如果此功能不可用,则使用eval进行更基本的检查。
When a syntax error is found the actual file is not written, but the user is redirected back to the editor with a notification about the error and it’s location with line highlighting.
如果发现语法错误,则不会写入实际文件,但会将用户重定向到编辑器,并提供有关该错误及其位置(带有高亮显示)的通知。 p>
inc/plugged.php: Contains a slightly changed version of the pluggable wp_text_diff()
function.
inc / plugged.php: strong>包含可插拔 wp_text_diff() code>函数的稍微变化的版本。 wp_text_diff()
is utilized for generating the diffs rendered in the revision viewer.
wp_text_diff() code>用于生成在修订版查看器中呈现的差异。Normally it strips leading, trailing and multiple successive whitespaces.
通常,它会去除前导,尾随和多个连续的空格。
However this behavior is not very helpful when viewing code revisions, wherefore the plugin suppresses it for revisions associated with the custom code revisions post type.
但是,此行为在查看代码修订时不是很有用,因此插件会在与自定义代码修订过帐类型相关联的修订中禁止使用它。 p>
inc/metabox.php: The template for the revision metabox.
inc / metabox.php: strong>修订版元框的模板。 p>js/editors.js: JavaScript for customizing the code editor pages (wp-admin/plugin-editor.php
and wp-admin/theme- js / editors.js: strong>用于自定义代码编辑器页面的JavaScript( wp-admin / plugin-editor.php code>和 wp-admin / theme- editor.php
).editor.php code>)。
It adds the revisions metabox below the editors, the revisions text with link next to the ‘Update File’ button and handles the text replacement and line highlighting when a syntax error was found.
它会在编辑器下方添加修订版本元框,在“更新文件”按钮旁边添加带有链接的修订文本,并在发现语法错误时处理文本替换和行高亮显示。 p>
css/editors.css: Styles for the code editors.
css / editors.css strong>:代码编辑器的样式。Enqueued in inc/class-code-revisions-editors.php -> scripts()
.
排入 inc / class-code-revisions-editors.php-> scripts() code>。 p>css/viewer.css: Styles for the revision viewer (wp-adminevisions.php
).
css / viewer.css strong>:修订版查看器的样式( wp-admin / revisions.php code>)。Enqueued only when viewing code revisions in inc/class-code-revisions.php -> styles()
.
仅当在 inc / class-code-revisions.php-> styles() code>中查看代码修订时才入队。 p>