钩子文档

wp_code_editor_settings

💡 云策文档标注

概述

wp_code_editor_settings 是一个 WordPress 过滤器,用于修改传递给代码编辑器的设置数组。返回 falsey 值可以禁用语法高亮编辑器。

关键要点

  • 过滤器名称:wp_code_editor_settings
  • 参数:$settings(设置数组,falsey 值禁用编辑器)和 $args(包含 type、file、theme、plugin、codemirror、csslint、jshint、htmlhint 等键的数组)
  • 用途:允许开发者自定义代码编辑器行为,如覆盖 CodeMirror、CSSLint、JSHint、HTMLHint 设置
  • 相关函数:wp_get_code_editor_settings() 用于生成设置
  • 引入版本:4.9.0

📄 原文内容

Filters settings that are passed into the code editor.

Description

Returning a falsey value will disable the syntax-highlighting code editor.

Parameters

$settingsarray
The array of settings passed to the code editor.
A falsey value disables the editor.
$argsarray
Args passed when calling get_code_editor_settings().

  • type string
    The MIME type of the file to be edited.
  • file string
    Filename being edited.
  • theme WP_Theme
    Theme being edited when on the theme file editor.
  • plugin string
    Plugin being edited when on the plugin file editor.
  • codemirror array
    Additional CodeMirror setting overrides.
  • csslint array
    CSSLint rule overrides.
  • jshint array
    JSHint rule overrides.
  • htmlhint array
    HTMLHint rule overrides.

Source

return apply_filters( 'wp_code_editor_settings', $settings, $args );

Changelog

Version Description
4.9.0 Introduced.