meta_box_prefs() - WordPress 函数参考中文文档

返回介绍

meta_box_prefs()

发布于 2017-09-11 字数2443 浏览 805 评论 0

meta_box_prefs( WP_Screen $screen )

Prints the meta box preferences for screen meta.


描述


参数

$screen

(WP_Screen)
(Required)


源代码

File: wp-admin/includes/screen.php

function meta_box_prefs( $screen ) {
	global $wp_meta_boxes;

	if ( is_string( $screen ) )
		$screen = convert_to_screen( $screen );

	if ( empty($wp_meta_boxes[$screen->id]) )
		return;

	$hidden = get_hidden_meta_boxes($screen);

	foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) {
		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
			if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) {
				continue;
			}
			foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) {
				if ( false == $box || ! $box['title'] )
					continue;
				// Submit box cannot be hidden
				if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
					continue;

				$widget_title = $box['title'];

				if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
					$widget_title = $box['args']['__widget_basename'];
				}

				printf(
					'<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>',
					esc_attr( $box['id'] ),
					checked( in_array( $box['id'], $hidden ), false, false ),
					$widget_title
				);
			}
		}
	}
}

更新日志

Version 描述
2.7.0 Introduced.

相关函数

Uses

  • wp-admin/includes/screen.php:
    get_hidden_meta_boxes()
  • wp-admin/includes/template.php:
    convert_to_screen()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/general-template.php:
    checked()

Used By

  • wp-admin/includes/class-wp-screen.php:
    WP_Screen::render_meta_boxes_preferences()

User Contributed Notes

上一篇:metadata_exists()

下一篇:meta_form()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!