函数文档

wp_print_file_editor_templates()

💡 云策文档标注

概述

wp_print_file_editor_templates() 函数用于输出文件编辑器模板,主要用于插件和主题开发。

关键要点

  • 函数功能:打印文件编辑器模板,支持插件和主题
  • 引入版本:WordPress 4.9.0
  • 相关函数:__() 用于获取翻译文本,_e() 用于显示翻译文本

📄 原文内容

Prints file editor templates (for plugins and themes).

Source

function wp_print_file_editor_templates() {
?>
<script type="text/html" id="tmpl-wp-file-editor-notice">
<div class="notice inline notice-
{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} {{ data.classes || '' }}">
<# if ( 'php_error' === data.code ) { #>
<p>
<?php
printf(
/* translators: 1: Line number, 2: File path. */
__( 'Your PHP code changes were not applied due to an error on line %1$s of file %2$s. Please fix and try saving again.' ),
'
{{ data.line }}',
'
{{ data.file }}'
);
?>

</p>
<pre>
{{ data.message }}</pre>
<# } else if ( 'file_not_writable' === data.code ) { #>
<p>
<?php
printf(
/* translators: %s: Documentation URL. */
__( 'You need to make this file writable before you can save your changes. See <a href="%s">Changing File Permissions</a> for more information.' ),
__( 'https://developer.wordpress.org/advanced-administration/server/file-permissions/' )
);
?>

</p>
<# } else { #>
<p>
{{ data.message || data.code }}</p>

<# if ( 'lint_errors' === data.code ) { #>
<p>
<# var elementId = 'el-' + String( Math.random() ); #>
<input id="{{ elementId }}" type="checkbox">
<label for="
{{ elementId }}"><?php _e( 'Update anyway, even though it might break your site?' ); ?></label>
</p>
<# } #>
<# } #>
<# if ( data.dismissible ) { #>
<button type="button" class="notice-dismiss"><span class="screen-reader-text">
<?php
/* translators: Hidden accessibility text. */
_e( 'Dismiss' );
?>

</span></button>
<# } #>
</div>
</script>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-admin/includes/file.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/file.php#L307">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/file.php#L307-L355">View on GitHub</a></p></section>

<section class="wp-block-wporg-code-reference-related" data-nosnippet="true"><h2 id="related" class="is-toc-heading wp-block-heading has-heading-5-font-size" tabindex="-1" ><a href="#related">Related</a></h2> <section style="margin-top:var(--wp--preset--spacing--20)" class="wp-block-wporg-code-table" id="uses"><figure class="wp-block-table "><table><thead><tr><th scope="col">Uses</th><th scope="col">Description</th></tr></thead><tbody><tr class=""><td><a href="https://developer.wordpress.org/reference/functions/__/">__()</a><code>wp-includes/l10n.php

Retrieves the translation of $text.

_e()wp-includes/l10n.php

Displays translated text.

Changelog

Version Description
4.9.0 Introduced.