wp_register_tinymce_scripts

函数
wp_register_tinymce_scripts ( $scripts, $force_uncompressed = false )
参数
  • (WP_Scripts) $scripts WP_Scripts object.
    Required:
  • (bool) $force_uncompressed Whether to forcibly prevent gzip compression. Default false.
    Required:
    Default: false
定义位置
相关方法
wp_register_scriptwp_deregister_scriptwp_register_development_scriptswp_register_alignment_supportwp_register_duotone_support
引入
5.0.0
弃用
-

wp_register_tinymce_scripts: 这个函数用来注册在TinyMCE编辑器中使用的脚本。它接受几个参数,包括脚本的名称、源URL、依赖性和版本。

注册TinyMCE脚本。

function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) {
	global $tinymce_version, $concatenate_scripts, $compress_scripts;

	$suffix     = wp_scripts_get_suffix();
	$dev_suffix = wp_scripts_get_suffix( 'dev' );

	script_concat_settings();

	$compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )
		&& false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed;

	// Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production)
	// or tinymce.min.js (when SCRIPT_DEBUG is true).
	if ( $compressed ) {
		$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version );
	} else {
		$scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version );
		$scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version );
	}

	$scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version );
}

常见问题

FAQs
查看更多 >