WP_Customize_New_Menu_Control
概述
WP_Customize_New_Menu_Control 是 WordPress 自定义器中用于创建新菜单的控制类,继承自 WP_Customize_Control。该类自 4.9.0 版本起已被弃用,不再使用。
关键要点
- 该类是 WP_Customize_Control 的子类,专用于新菜单的创建控制。
- 控制类型为 'new_menu',通过 $type 属性定义。
- 构造函数 __construct 和 render_content 方法均自 4.9.0 版本起被弃用,使用时会触发 _deprecated_function 警告。
- 弃用原因是自 4.9.0 版本起,菜单创建用户界面(UX)已更新,该类不再被使用。
- 相关类为 WP_Customize_Control,定义在 wp-includes/class-wp-customize-control.php 文件中。
代码示例
class WP_Customize_New_Menu_Control extends WP_Customize_Control {
public $type = 'new_menu';
public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) {
_deprecated_function( __METHOD__, '4.9.0' );
parent::__construct( $manager, $id, $args );
}
public function render_content() {
_deprecated_function( __METHOD__, '4.9.0' );
}
}注意事项
- 自 WordPress 4.9.0 版本起,应避免使用此类,因为它已被弃用且不再在菜单创建流程中起作用。
- 开发者在维护或升级旧代码时,需注意替换或移除对该类的依赖。
Customize control class for new menus.
Description
See also
Methods
| Name | Description |
|---|---|
| WP_Customize_New_Menu_Control::__construct | Constructor. — deprecated |
| WP_Customize_New_Menu_Control::render_content | Render the control’s content. — deprecated |
Source
class WP_Customize_New_Menu_Control extends WP_Customize_Control {
/**
* Control type.
*
* @since 4.3.0
* @var string
*/
public $type = 'new_menu';
/**
* Constructor.
*
* @since 4.9.0
* @deprecated 4.9.0
*
* @see WP_Customize_Control::__construct()
*
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id The control ID.
* @param array $args Optional. Arguments to override class property defaults.
* See WP_Customize_Control::__construct() for information
* on accepted arguments. Default empty array.
*/
public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) {
_deprecated_function( __METHOD__, '4.9.0' );
parent::__construct( $manager, $id, $args );
}
/**
* Render the control's content.
*
* @since 4.3.0
* @deprecated 4.9.0
*/
public function render_content() {
_deprecated_function( __METHOD__, '4.9.0' );
?>
<button type="button" class="button button-primary" id="create-new-menu-submit"></button>
<span class="spinner"></span>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-includes/customize/class-wp-customize-new-menu-control.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/customize/class-wp-customize-new-menu-control.php#L21">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/customize/class-wp-customize-new-menu-control.php#L21-L63">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/classes/wp_customize_control/">WP_Customize_Control</a><code>wp-includes/class-wp-customize-control.php