3
* WordPress Administration Screen API.
6
* @subpackage Administration
10
* Get the column headers for a screen
14
* @param string|WP_Screen $screen The screen you want the headers for
15
* @return array Containing the headers in the format id => UI String
17
function get_column_headers( $screen ) {
18
if ( is_string( $screen ) )
19
$screen = convert_to_screen( $screen );
21
static $column_headers = array();
23
if ( ! isset( $column_headers[ $screen->id ] ) ) {
26
* Filter the column headers for a list table on a specific screen.
28
* The dynamic portion of the hook name, $screen->id, refers to the
29
* ID of a specific screen. For example, the screen ID for the Posts
30
* list table is edit-post, so the filter for that screen would be
31
* manage_edit-post_columns.
35
* @param array $columns An array of column headers. Default empty.
37
$column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() );
40
return $column_headers[ $screen->id ];
44
* Get a list of hidden columns.
48
* @param string|WP_Screen $screen The screen you want the hidden columns for
51
function get_hidden_columns( $screen ) {
52
if ( is_string( $screen ) )
53
$screen = convert_to_screen( $screen );
55
return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' );
59
* Prints the meta box preferences for screen meta.
63
* @param string|WP_Screen $screen
65
function meta_box_prefs( $screen ) {
66
global $wp_meta_boxes;
68
if ( is_string( $screen ) )
69
$screen = convert_to_screen( $screen );
71
if ( empty($wp_meta_boxes[$screen->id]) )
74
$hidden = get_hidden_meta_boxes($screen);
76
foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
77
foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
78
foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
79
if ( false == $box || ! $box['title'] )
81
// Submit box cannot be hidden
82
if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
85
echo '<label for="' . $box_id . '-hide">';
86
echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
87
echo "{$box['title']}</label>\n";
94
* Get Hidden Meta Boxes
98
* @param string|WP_Screen $screen Screen identifier
99
* @return array Hidden Meta Boxes
101
function get_hidden_meta_boxes( $screen ) {
102
if ( is_string( $screen ) )
103
$screen = convert_to_screen( $screen );
105
$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
107
$use_defaults = ! is_array( $hidden );
109
// Hide slug boxes by default
110
if ( $use_defaults ) {
112
if ( 'post' == $screen->base ) {
113
if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type )
114
$hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
116
$hidden = array( 'slugdiv' );
120
* Filter the default list of hidden meta boxes.
124
* @param array $hidden An array of meta boxes hidden by default.
125
* @param WP_Screen $screen WP_Screen object of the current screen.
127
$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
131
* Filter the list of hidden meta boxes.
135
* @param array $hidden An array of hidden meta boxes.
136
* @param WP_Screen $screen WP_Screen object of the current screen.
137
* @param bool $use_defaults Whether to show the default meta boxes.
140
return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
144
* Register and configure an admin screen option
148
* @param string $option An option name.
149
* @param mixed $args Option-dependent arguments.
151
function add_screen_option( $option, $args = array() ) {
152
$current_screen = get_current_screen();
154
if ( ! $current_screen )
157
$current_screen->add_option( $option, $args );
161
* Get the current screen object
165
* @return WP_Screen Current screen object
167
function get_current_screen() {
168
global $current_screen;
170
if ( ! isset( $current_screen ) )
173
return $current_screen;
177
* Set the current screen object
180
* @uses $current_screen
182
* @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
183
* or an existing screen object.
185
function set_current_screen( $hook_name = '' ) {
186
WP_Screen::get( $hook_name )->set_current_screen();
190
* A class representing the admin screen.
195
final class WP_Screen {
197
* Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise.
206
* The base type of the screen. This is typically the same as $id but with any post types and taxonomies stripped.
207
* For example, for an $id of 'edit-post' the base is 'edit'.
216
* The number of columns to display. Access with get_columns().
222
private $columns = 0;
225
* The unique ID of the screen.
234
* Which admin the screen is in. network | user | site | false
243
* Whether the screen is in the network admin.
245
* Deprecated. Use in_admin() instead.
255
* Whether the screen is in the user admin.
257
* Deprecated. Use in_admin() instead.
267
* The base menu parent.
268
* This is derived from $parent_file by removing the query string and any .php extension.
269
* $parent_file values of 'edit.php?post_type=page' and 'edit.php?post_type=post' have a $parent_base of 'edit'.
278
* The parent_file for the screen per the admin menu system.
279
* Some $parent_file values are 'edit.php?post_type=page', 'edit.php', and 'options-general.php'.
288
* The post type associated with the screen, if any.
289
* The 'edit.php?post_type=page' screen has a post type of 'page'.
290
* The 'edit-tags.php?taxonomy=$taxonomy&post_type=page' screen has a post type of 'page'.
299
* The taxonomy associated with the screen, if any.
300
* The 'edit-tags.php?taxonomy=category' screen has a taxonomy of 'category'.
308
* The help tab data associated with the screen, if any.
314
private $_help_tabs = array();
317
* The help sidebar data associated with screen, if any.
323
private $_help_sidebar = '';
326
* Stores old string-based help.
328
private static $_old_compat_help = array();
331
* The screen options associated with screen, if any.
337
private $_options = array();
340
* The screen object registry.
346
private static $_registry = array();
349
* Stores the result of the public show_screen_options function.
355
private $_show_screen_options;
358
* Stores the 'screen_settings' section of screen options.
364
private $_screen_settings;
367
* Fetches a screen object.
372
* @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
373
* Defaults to the current $hook_suffix global.
374
* @return WP_Screen Screen object.
376
public static function get( $hook_name = '' ) {
378
if ( is_a( $hook_name, 'WP_Screen' ) )
381
$post_type = $taxonomy = null;
388
$id = $GLOBALS['hook_suffix'];
390
// For those pesky meta boxes.
391
if ( $hook_name && post_type_exists( $hook_name ) ) {
393
$id = 'post'; // changes later. ends up being $base.
395
if ( '.php' == substr( $id, -4 ) )
396
$id = substr( $id, 0, -4 );
398
if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) {
399
$id = substr( $id, 0, -4 );
404
if ( ! $post_type && $hook_name ) {
405
if ( '-network' == substr( $id, -8 ) ) {
406
$id = substr( $id, 0, -8 );
407
$in_admin = 'network';
408
} elseif ( '-user' == substr( $id, -5 ) ) {
409
$id = substr( $id, 0, -5 );
413
$id = sanitize_key( $id );
414
if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) {
415
$maybe = substr( $id, 5 );
416
if ( taxonomy_exists( $maybe ) ) {
419
} elseif ( post_type_exists( $maybe ) ) {
428
if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN )
429
$in_admin = 'network';
430
elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN )
436
if ( 'index' == $id )
438
elseif ( 'front' == $id )
443
// If this is the current screen, see if we can be more accurate for post types and taxonomies.
444
if ( ! $hook_name ) {
445
if ( isset( $_REQUEST['post_type'] ) )
446
$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
447
if ( isset( $_REQUEST['taxonomy'] ) )
448
$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
452
if ( isset( $_GET['post'] ) )
453
$post_id = (int) $_GET['post'];
454
elseif ( isset( $_POST['post_ID'] ) )
455
$post_id = (int) $_POST['post_ID'];
460
$post = get_post( $post_id );
462
$post_type = $post->post_type;
466
if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
474
if ( null === $post_type )
479
if ( null === $post_type )
481
$id .= '-' . $post_type;
484
if ( null === $taxonomy )
485
$taxonomy = 'post_tag';
486
// The edit-tags ID does not contain the post type. Look for it in the request.
487
if ( null === $post_type ) {
489
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
490
$post_type = $_REQUEST['post_type'];
493
$id = 'edit-' . $taxonomy;
497
if ( 'network' == $in_admin ) {
500
} elseif ( 'user' == $in_admin ) {
505
if ( isset( self::$_registry[ $id ] ) ) {
506
$screen = self::$_registry[ $id ];
507
if ( $screen === get_current_screen() )
510
$screen = new WP_Screen();
514
$screen->base = $base;
515
$screen->action = $action;
516
$screen->post_type = (string) $post_type;
517
$screen->taxonomy = (string) $taxonomy;
518
$screen->is_user = ( 'user' == $in_admin );
519
$screen->is_network = ( 'network' == $in_admin );
520
$screen->in_admin = $in_admin;
522
self::$_registry[ $id ] = $screen;
528
* Makes the screen object the current screen.
530
* @see set_current_screen()
533
public function set_current_screen() {
534
global $current_screen, $taxnow, $typenow;
535
$current_screen = $this;
536
$taxnow = $this->taxonomy;
537
$typenow = $this->post_type;
540
* Fires after the current screen has been set.
544
* @param WP_Screen $current_screen Current WP_Screen object.
546
do_action( 'current_screen', $current_screen );
555
private function __construct() {}
558
* Indicates whether the screen is in a particular admin
562
* @param string $admin The admin to check against (network | user | site).
563
* If empty any of the three admins will result in true.
564
* @return boolean True if the screen is in the indicated admin, false otherwise.
567
public function in_admin( $admin = null ) {
568
if ( empty( $admin ) )
569
return (bool) $this->in_admin;
571
return ( $admin == $this->in_admin );
575
* Sets the old string-based contextual help for the screen.
577
* For backwards compatibility.
581
* @param WP_Screen $screen A screen object.
582
* @param string $help Help text.
584
public static function add_old_compat_help( $screen, $help ) {
585
self::$_old_compat_help[ $screen->id ] = $help;
589
* Set the parent information for the screen.
590
* This is called in admin-header.php after the menu parent for the screen has been determined.
594
* @param string $parent_file The parent file of the screen. Typically the $parent_file global.
596
public function set_parentage( $parent_file ) {
597
$this->parent_file = $parent_file;
598
list( $this->parent_base ) = explode( '?', $parent_file );
599
$this->parent_base = str_replace( '.php', '', $this->parent_base );
603
* Adds an option for the screen.
604
* Call this in template files after admin.php is loaded and before admin-header.php is loaded to add screen options.
608
* @param string $option Option ID
609
* @param mixed $args Option-dependent arguments.
611
public function add_option( $option, $args = array() ) {
612
$this->_options[ $option ] = $args;
616
* Remove an option from the screen.
620
* @param string $option Option ID.
622
public function remove_option( $option ) {
623
unset( $this->_options[ $option ] );
627
* Remove all options from the screen.
631
public function remove_options() {
632
$this->_options = array();
636
* Get the options registered for the screen.
640
* @return array Options with arguments.
642
public function get_options() {
643
return $this->_options;
647
* Gets the arguments for an option for the screen.
651
* @param string $option Option ID.
652
* @param mixed $key Optional. Specific array key for when the option is an array.
654
public function get_option( $option, $key = false ) {
655
if ( ! isset( $this->_options[ $option ] ) )
658
if ( isset( $this->_options[ $option ][ $key ] ) )
659
return $this->_options[ $option ][ $key ];
662
return $this->_options[ $option ];
666
* Gets the help tabs registered for the screen.
670
* @return array Help tabs with arguments.
672
public function get_help_tabs() {
673
return $this->_help_tabs;
677
* Gets the arguments for a help tab.
681
* @param string $id Help Tab ID.
682
* @return array Help tab arguments.
684
public function get_help_tab( $id ) {
685
if ( ! isset( $this->_help_tabs[ $id ] ) )
687
return $this->_help_tabs[ $id ];
691
* Add a help tab to the contextual help for the screen.
692
* Call this on the load-$pagenow hook for the relevant screen.
697
* - string - title - Title for the tab.
698
* - string - id - Tab ID. Must be HTML-safe.
699
* - string - content - Help tab content in plain text or HTML. Optional.
700
* - callback - callback - A callback to generate the tab content. Optional.
703
public function add_help_tab( $args ) {
710
$args = wp_parse_args( $args, $defaults );
712
$args['id'] = sanitize_html_class( $args['id'] );
714
// Ensure we have an ID and title.
715
if ( ! $args['id'] || ! $args['title'] )
718
// Allows for overriding an existing tab with that ID.
719
$this->_help_tabs[ $args['id'] ] = $args;
723
* Removes a help tab from the contextual help for the screen.
727
* @param string $id The help tab ID.
729
public function remove_help_tab( $id ) {
730
unset( $this->_help_tabs[ $id ] );
734
* Removes all help tabs from the contextual help for the screen.
738
public function remove_help_tabs() {
739
$this->_help_tabs = array();
743
* Gets the content from a contextual help sidebar.
747
* @return string Contents of the help sidebar.
749
public function get_help_sidebar() {
750
return $this->_help_sidebar;
754
* Add a sidebar to the contextual help for the screen.
755
* Call this in template files after admin.php is loaded and before admin-header.php is loaded to add a sidebar to the contextual help.
759
* @param string $content Sidebar content in plain text or HTML.
761
public function set_help_sidebar( $content ) {
762
$this->_help_sidebar = $content;
766
* Gets the number of layout columns the user has selected.
768
* The layout_columns option controls the max number and default number of
769
* columns. This method returns the number of columns within that range selected
770
* by the user via Screen Options. If no selection has been made, the default
771
* provisioned in layout_columns is returned. If the screen does not support
772
* selecting the number of layout columns, 0 is returned.
776
* @return int Number of columns to display.
778
public function get_columns() {
779
return $this->columns;
783
* Render the screen's help section.
785
* This will trigger the deprecated filters for backwards compatibility.
789
public function render_screen_meta() {
792
* Filter the legacy contextual help list.
795
* @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
796
* get_current_screen()->remove_help_tab() instead.
798
* @param array $old_compat_help Old contextual help.
799
* @param WP_Screen $this Current WP_Screen instance.
801
self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this );
803
$old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
806
* Filter the legacy contextual help text.
809
* @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
810
* get_current_screen()->remove_help_tab() instead.
812
* @param string $old_help Help text that appears on the screen.
813
* @param string $screen_id Screen ID.
814
* @param WP_Screen $this Current WP_Screen instance.
817
$old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
819
// Default help only if there is no old-style block of text and no new-style help tabs.
820
if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
823
* Filter the default legacy contextual help text.
826
* @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
827
* get_current_screen()->remove_help_tab() instead.
829
* @param string $old_help_default Default contextual help text.
831
$default_help = apply_filters( 'default_contextual_help', '' );
833
$old_help = '<p>' . $default_help . '</p>';
837
$this->add_help_tab( array(
838
'id' => 'old-contextual-help',
839
'title' => __('Overview'),
840
'content' => $old_help,
844
$help_sidebar = $this->get_help_sidebar();
846
$help_class = 'hidden';
847
if ( ! $help_sidebar )
848
$help_class .= ' no-sidebar';
852
<div id="screen-meta" class="metabox-prefs">
854
<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>">
855
<div id="contextual-help-back"></div>
856
<div id="contextual-help-columns">
857
<div class="contextual-help-tabs">
860
$class = ' class="active"';
861
foreach ( $this->get_help_tabs() as $tab ) :
862
$link_id = "tab-link-{$tab['id']}";
863
$panel_id = "tab-panel-{$tab['id']}";
866
<li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>>
867
<a href="<?php echo esc_url( "#$panel_id" ); ?>" aria-controls="<?php echo esc_attr( $panel_id ); ?>">
868
<?php echo esc_html( $tab['title'] ); ?>
878
<?php if ( $help_sidebar ) : ?>
879
<div class="contextual-help-sidebar">
880
<?php echo $help_sidebar; ?>
884
<div class="contextual-help-tabs-wrap">
886
$classes = 'help-tab-content active';
887
foreach ( $this->get_help_tabs() as $tab ):
888
$panel_id = "tab-panel-{$tab['id']}";
891
<div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo $classes; ?>">
893
// Print tab content.
894
echo $tab['content'];
896
// If it exists, fire tab callback.
897
if ( ! empty( $tab['callback'] ) )
898
call_user_func_array( $tab['callback'], array( $this, $tab ) );
902
$classes = 'help-tab-content';
909
// Setup layout columns
912
* Filter the array of screen layout columns.
914
* This hook provides back-compat for plugins using the back-compat
915
* filter instead of add_screen_option().
919
* @param array $empty_columns Empty array.
920
* @param string $screen_id Screen ID.
921
* @param WP_Screen $this Current WP_Screen instance.
923
$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
925
if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
926
$this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
928
if ( $this->get_option( 'layout_columns' ) ) {
929
$this->columns = (int) get_user_option("screen_layout_$this->id");
931
if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) )
932
$this->columns = $this->get_option( 'layout_columns', 'default' );
934
$GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat.
936
// Add screen options
937
if ( $this->show_screen_options() )
938
$this->render_screen_options();
942
if ( ! $this->get_help_tabs() && ! $this->show_screen_options() )
945
<div id="screen-meta-links">
946
<?php if ( $this->get_help_tabs() ) : ?>
947
<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
948
<a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></a>
951
if ( $this->show_screen_options() ) : ?>
952
<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
953
<a href="#screen-options-wrap" id="show-settings-link" class="show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></a>
960
public function show_screen_options() {
961
global $wp_meta_boxes;
963
if ( is_bool( $this->_show_screen_options ) )
964
return $this->_show_screen_options;
966
$columns = get_column_headers( $this );
968
$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
970
switch ( $this->base ) {
972
$this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
975
$expand = '<div class="editor-expand hidden"><label for="editor-expand-toggle">';
976
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
977
$expand .= __( 'Expand the editor to match the window height.' ) . '</label></div>';
978
$this->_screen_settings = $expand;
981
$this->_screen_settings = '';
986
* Filter the screen settings text displayed in the Screen Options tab.
988
* This filter is currently only used on the Widgets screen to enable
989
* accessibility mode.
993
* @param string $screen_settings Screen settings.
994
* @param WP_Screen $this WP_Screen object.
996
$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
998
if ( $this->_screen_settings || $this->_options )
1002
* Filter whether to show the Screen Options tab.
1006
* @param bool $show_screen Whether to show Screen Options tab.
1008
* @param WP_Screen $this Current WP_Screen instance.
1010
$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
1011
return $this->_show_screen_options;
1015
* Render the screen options tab.
1019
public function render_screen_options() {
1020
global $wp_meta_boxes;
1022
$columns = get_column_headers( $this );
1023
$hidden = get_hidden_columns( $this );
1026
<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>">
1027
<form id="adv-settings" action="" method="post">
1028
<?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
1029
<h5><?php _e( 'Show on screen' ); ?></h5>
1033
if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?>
1034
<div class="metabox-prefs">
1036
meta_box_prefs( $this );
1038
if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
1039
if ( isset( $_GET['welcome'] ) ) {
1040
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
1041
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
1043
$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
1044
if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) )
1045
$welcome_checked = false;
1047
echo '<label for="wp_welcome_panel-hide">';
1048
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
1049
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
1052
<br class="clear" />
1056
if ( ! empty( $columns['_title'] ) ) : ?>
1057
<h5><?php echo $columns['_title']; ?></h5>
1059
<div class="metabox-prefs">
1061
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
1063
foreach ( $columns as $column => $title ) {
1064
// Can't hide these for they are special
1065
if ( in_array( $column, $special ) )
1067
if ( empty( $title ) )
1070
if ( 'comments' == $column )
1071
$title = __( 'Comments' );
1072
$id = "$column-hide";
1073
echo '<label for="' . $id . '">';
1074
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';
1075
echo "$title</label>\n";
1078
<br class="clear" />
1082
$this->render_screen_layout();
1083
$this->render_per_page_options();
1084
echo $this->_screen_settings;
1087
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
1094
* Render the option for number of columns on the page
1098
public function render_screen_layout() {
1099
if ( ! $this->get_option('layout_columns') )
1102
$screen_layout_columns = $this->get_columns();
1103
$num = $this->get_option( 'layout_columns', 'max' );
1106
<h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5>
1107
<div class='columns-prefs'><?php
1108
_e('Number of Columns:');
1109
for ( $i = 1; $i <= $num; ++$i ):
1111
<label class="columns-prefs-<?php echo $i; ?>">
1112
<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
1113
<?php checked( $screen_layout_columns, $i ); ?> />
1114
<?php echo esc_html( $i ); ?>
1123
* Render the items per page option
1127
public function render_per_page_options() {
1128
if ( ! $this->get_option( 'per_page' ) )
1131
$per_page_label = $this->get_option( 'per_page', 'label' );
1133
$option = $this->get_option( 'per_page', 'option' );
1135
$option = str_replace( '-', '_', "{$this->id}_per_page" );
1137
$per_page = (int) get_user_option( $option );
1138
if ( empty( $per_page ) || $per_page < 1 ) {
1139
$per_page = $this->get_option( 'per_page', 'default' );
1144
if ( 'edit_comments_per_page' == $option ) {
1145
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
1147
/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
1148
$per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
1149
} elseif ( 'categories_per_page' == $option ) {
1150
/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
1151
$per_page = apply_filters( 'edit_categories_per_page', $per_page );
1153
/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
1154
$per_page = apply_filters( $option, $per_page );
1158
if ( isset( $this->post_type ) ) {
1159
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
1160
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
1164
<div class="screen-options">
1165
<?php if ( $per_page_label ) : ?>
1166
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
1167
id="<?php echo esc_attr( $option ); ?>" maxlength="3"
1168
value="<?php echo esc_attr( $per_page ); ?>" />
1169
<label for="<?php echo esc_attr( $option ); ?>">
1170
<?php echo esc_html( $per_page_label ); ?>
1174
echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
1175
<input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' />