^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 5年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云1核2g仅需102元/年,今日10点开抢

wordpress函数do_accordion_sections()用法示例

do_accordion_sections( string|object $screen,  string $context,  mixed $object )

Meta Box Accordion Template Function


描述

Largely made up of abstracted code from do_meta_boxes(), this function serves to build meta boxes as list items for display as a collapsible accordion.


参数

$screen

(string|object)
(Required)
The screen identifier.

$context

(string)
(Required)
The meta box context.

$object

(mixed)
(Required)
gets passed to the section callback function as first parameter.


返回值

(int) number of meta boxes as accordion sections.


源代码

File: wp-admin/includes/template.php

function do_accordion_sections( $screen, $context, $object ) {
	global $wp_meta_boxes;

	wp_enqueue_script( 'accordion' );

	if ( empty( $screen ) )
		$screen = get_current_screen();
	elseif ( is_string( $screen ) )
		$screen = convert_to_screen( $screen );

	$page = $screen->id;

	$hidden = get_hidden_meta_boxes( $screen );
	?>
	<div id="side-sortables" class="accordion-container">
		<ul class="outer-border">
	<?php
	$i = 0;
	$first_open = false;

	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
					if ( false == $box || ! $box['title'] )
continue;
					$i++;
					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';

					$open_class = '';
					if ( ! $first_open && empty( $hidden_class ) ) {
$first_open = true;
$open_class = 'open';
					}
					?>
					<li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
<h3 class="accordion-section-title hndle" tabindex="0">
<?php echo esc_html( $box['title'] ); ?>
<span class="screen-reader-text"><?php _e( 'Press return or enter to open this section' ); ?></span>
</h3>
<div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
<div class="inside">
	<?php call_user_func( $box['callback'], $object, $box ); ?>
</div><!-- .inside -->
</div><!-- .accordion-section-content -->
					</li><!-- .accordion-section -->
					<?php
				}
			}
		}
	}
	?>
		</ul><!-- .outer-border -->
	</div><!-- .accordion-container -->
	<?php
	return $i;
}

更新日志

Version 描述
3.6.0 Introduced.

相关函数

Uses

  • wp-admin/includes/screen.php:
    get_current_screen()
  • wp-admin/includes/screen.php:
    get_hidden_meta_boxes()
  • wp-admin/includes/template.php:
    convert_to_screen()
  • wp-admin/includes/post.php:
    postbox_classes()
  • wp-includes/l10n.php:
    _e()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/formatting.php:
    esc_html()
  • wp-includes/functions.wp-scripts.php:
    wp_enqueue_script()
  • Show 3 more uses
    Hide more uses


User Contributed Notes

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈