WP_Customize_New_Menu_Section
概述
WP_Customize_New_Menu_Section 是 WordPress 自定义器中用于新菜单部分的类,继承自 WP_Customize_Section。该类自 4.9.0 版本起已弃用,不再使用。
关键要点
- WP_Customize_New_Menu_Section 继承自 WP_Customize_Section,用于自定义器的新菜单部分。
- 该类在 4.3.0 版本引入,但在 4.9.0 版本因菜单创建用户体验更新而被弃用。
- 主要方法包括 __construct 构造函数和 render 渲染方法,两者均标记为弃用。
- 类型属性 $type 设置为 'new_menu',用于标识该部分。
代码示例
class WP_Customize_New_Menu_Section extends WP_Customize_Section {
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 );
}
protected function render() {
_deprecated_function( __METHOD__, '4.9.0' );
?>
<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="accordion-section-new-menu">
<h3 class="accordion-section-title"><?php echo esc_html( $this->title ); ?></h3>
</li>
<?php
}
}注意事项
开发者应避免在新代码中使用此类,因为它已弃用,可能在未来版本中被移除。建议参考 WP_Customize_Section 或其他相关类进行替代开发。
Customize Menu Section Class
Description
See also
Methods
| Name | Description |
|---|---|
| WP_Customize_New_Menu_Section::__construct | Constructor. — deprecated |
| WP_Customize_New_Menu_Section::render | Render the section, and the controls that have been added to it. — deprecated |
Source
class WP_Customize_New_Menu_Section extends WP_Customize_Section {
/**
* Control type.
*
* @since 4.3.0
* @var string
*/
public $type = 'new_menu';
/**
* Constructor.
*
* Any supplied $args override class property defaults.
*
* @since 4.9.0
* @deprecated 4.9.0
*
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id A specific ID of the section.
* @param array $args Section arguments.
*/
public function __construct( WP_Customize_Manager $manager, $id, array $args = array() ) {
_deprecated_function( __METHOD__, '4.9.0' );
parent::__construct( $manager, $id, $args );
}
/**
* Render the section, and the controls that have been added to it.
*
* @since 4.3.0
* @deprecated 4.9.0
*/
protected function render() {
_deprecated_function( __METHOD__, '4.9.0' );
?>
<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="accordion-section-new-menu">
<button type="button" class="button add-new-menu-item add-menu-toggle" aria-expanded="false">
title ); ?>
</button>
<ul class="new-menu-section-content"></ul>
</li>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-includes/customize/class-wp-customize-new-menu-section.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-section.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-section.php#L21-L65">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_section/">WP_Customize_Section</a><code>wp-includes/class-wp-customize-section.php
Customize Section class.