wp/wp-admin/includes/screen.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * WordPress Administration Screen API.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Administration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * Get the column headers for a screen
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * @param string|WP_Screen $screen The screen you want the headers for
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 * @return array Containing the headers in the format id => UI String
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
function get_column_headers( $screen ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
	if ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
	static $column_headers = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
	if ( ! isset( $column_headers[ $screen->id ] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
		 * Filter the column headers for a list table on a specific screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
		 * The dynamic portion of the hook name, `$screen->id`, refers to the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
		 * ID of a specific screen. For example, the screen ID for the Posts
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
		 * list table is edit-post, so the filter for that screen would be
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
		 * manage_edit-post_columns.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
		 * @param array $columns An array of column headers. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    37
		$column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
	return $column_headers[ $screen->id ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
 * Get a list of hidden columns.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
 * @param string|WP_Screen $screen The screen you want the hidden columns for
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
 * @return array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
function get_hidden_columns( $screen ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
	if ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
	return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
 * Prints the meta box preferences for screen meta.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
 * @param WP_Screen $screen
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
function meta_box_prefs( $screen ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
	global $wp_meta_boxes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	if ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
	if ( empty($wp_meta_boxes[$screen->id]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
	$hidden = get_hidden_meta_boxes($screen);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
	foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
			foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
				if ( false == $box || ! $box['title'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
					continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
				// Submit box cannot be hidden
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
				if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
					continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
				$box_id = $box['id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
				echo '<label for="' . $box_id . '-hide">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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"' : '') . ' />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
				echo "{$box['title']}</label>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
 * Get Hidden Meta Boxes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
 * @param string|WP_Screen $screen Screen identifier
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
 * @return array Hidden Meta Boxes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
function get_hidden_meta_boxes( $screen ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
	if ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
	$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	$use_defaults = ! is_array( $hidden );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
	// Hide slug boxes by default
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
	if ( $use_defaults ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
		$hidden = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
		if ( 'post' == $screen->base ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
			if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
				$hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
				$hidden = array( 'slugdiv' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   119
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   120
		 * Filter the default list of hidden meta boxes.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   122
		 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   123
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   124
		 * @param array     $hidden An array of meta boxes hidden by default.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   125
		 * @param WP_Screen $screen WP_Screen object of the current screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   126
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
		$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   130
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
	 * Filter the list of hidden meta boxes.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   132
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
	 * @since 3.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
	 * @param array     $hidden       An array of hidden meta boxes.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
	 * @param WP_Screen $screen       WP_Screen object of the current screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
	 * @param bool      $use_defaults Whether to show the default meta boxes.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
	 *                                Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
	return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
 * Register and configure an admin screen option
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
 * @param string $option An option name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
 * @param mixed $args Option-dependent arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
function add_screen_option( $option, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
	$current_screen = get_current_screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
	if ( ! $current_screen )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
	$current_screen->add_option( $option, $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
 * Get the current screen object
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
 * @return WP_Screen Current screen object
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
function get_current_screen() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
	global $current_screen;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
	if ( ! isset( $current_screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
		return null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
	return $current_screen;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
 * Set the current screen object
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
 * @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
 *	or an existing screen object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
function set_current_screen( $hook_name = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
	WP_Screen::get( $hook_name )->set_current_screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
 * A class representing the admin screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
final class WP_Screen {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	 * Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
	public $action;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
	 * The base type of the screen. This is typically the same as $id but with any post types and taxonomies stripped.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
	 * For example, for an $id of 'edit-post' the base is 'edit'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
	public $base;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
	 * The number of columns to display. Access with get_columns().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
	 * @var int
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
	private $columns = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
	 * The unique ID of the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
	public $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
	 * Which admin the screen is in. network | user | site | false
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
	 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
	 * @access protected
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
	protected $in_admin;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
	 * Whether the screen is in the network admin.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
	 * Deprecated. Use in_admin() instead.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
	 * @deprecated 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
	 * @var bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
	public $is_network;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
	 * Whether the screen is in the user admin.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
	 * Deprecated. Use in_admin() instead.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
	 * @deprecated 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
	 * @var bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
	public $is_user;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
	 * The base menu parent.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
	 * This is derived from $parent_file by removing the query string and any .php extension.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
	 * $parent_file values of 'edit.php?post_type=page' and 'edit.php?post_type=post' have a $parent_base of 'edit'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
	public $parent_base;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
	 * The parent_file for the screen per the admin menu system.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
	 * Some $parent_file values are 'edit.php?post_type=page', 'edit.php', and 'options-general.php'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
	public $parent_file;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
	 * The post type associated with the screen, if any.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
	 * The 'edit.php?post_type=page' screen has a post type of 'page'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
	 * The 'edit-tags.php?taxonomy=$taxonomy&post_type=page' screen has a post type of 'page'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
	public $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
	 * The taxonomy associated with the screen, if any.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
	 * The 'edit-tags.php?taxonomy=category' screen has a taxonomy of 'category'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
	public $taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
	 * The help tab data associated with the screen, if any.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
	 * @var array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
	private $_help_tabs = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
	 * The help sidebar data associated with screen, if any.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
	private $_help_sidebar = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
	 * Stores old string-based help.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
	private static $_old_compat_help = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
	 * The screen options associated with screen, if any.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	 * @var array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
	private $_options = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
	 * The screen object registry.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
	 * @var array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
	private static $_registry = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
	 * Stores the result of the public show_screen_options function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
	 * @var bool
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
	private $_show_screen_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
	 * Stores the 'screen_settings' section of screen options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
	 * @var string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
	private $_screen_settings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
	 * Fetches a screen object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
	 * @access public
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   371
	 * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
	 * 	Defaults to the current $hook_suffix global.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
	 * @return WP_Screen Screen object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	public static function get( $hook_name = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   377
		if ( $hook_name instanceof WP_Screen ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
			return $hook_name;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   379
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		$post_type = $taxonomy = null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
		$in_admin = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
		$action = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
		if ( $hook_name )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
			$id = $hook_name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
			$id = $GLOBALS['hook_suffix'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
		// For those pesky meta boxes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
		if ( $hook_name && post_type_exists( $hook_name ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
			$post_type = $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
			$id = 'post'; // changes later. ends up being $base.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
			if ( '.php' == substr( $id, -4 ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
				$id = substr( $id, 0, -4 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
			if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
				$id = substr( $id, 0, -4 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
				$action = 'add';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
		if ( ! $post_type && $hook_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
			if ( '-network' == substr( $id, -8 ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
				$id = substr( $id, 0, -8 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
				$in_admin = 'network';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
			} elseif ( '-user' == substr( $id, -5 ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
				$id = substr( $id, 0, -5 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
				$in_admin = 'user';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
			$id = sanitize_key( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
			if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
				$maybe = substr( $id, 5 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
				if ( taxonomy_exists( $maybe ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
					$id = 'edit-tags';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
					$taxonomy = $maybe;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
				} elseif ( post_type_exists( $maybe ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
					$id = 'edit';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
					$post_type = $maybe;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
			if ( ! $in_admin )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
				$in_admin = 'site';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
			if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
				$in_admin = 'network';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
			elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
				$in_admin = 'user';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
				$in_admin = 'site';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
		if ( 'index' == $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
			$id = 'dashboard';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
		elseif ( 'front' == $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
			$in_admin = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
		$base = $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
		// If this is the current screen, see if we can be more accurate for post types and taxonomies.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
		if ( ! $hook_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
			if ( isset( $_REQUEST['post_type'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
				$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
			if ( isset( $_REQUEST['taxonomy'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
				$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
			switch ( $base ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
				case 'post' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
					if ( isset( $_GET['post'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
						$post_id = (int) $_GET['post'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
					elseif ( isset( $_POST['post_ID'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
						$post_id = (int) $_POST['post_ID'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
					else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
						$post_id = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
					if ( $post_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
						$post = get_post( $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
						if ( $post )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
							$post_type = $post->post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
				case 'edit-tags' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
					if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
						$post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
		switch ( $base ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
			case 'post' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
				if ( null === $post_type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
					$post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
				$id = $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
			case 'edit' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
				if ( null === $post_type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
					$post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
				$id .= '-' . $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
			case 'edit-tags' :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
				if ( null === $taxonomy )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
					$taxonomy = 'post_tag';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
				// The edit-tags ID does not contain the post type. Look for it in the request.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
				if ( null === $post_type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
					$post_type = 'post';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
					if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
						$post_type = $_REQUEST['post_type'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
				$id = 'edit-' . $taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
		if ( 'network' == $in_admin ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
			$id   .= '-network';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
			$base .= '-network';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
		} elseif ( 'user' == $in_admin ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
			$id   .= '-user';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
			$base .= '-user';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
		if ( isset( self::$_registry[ $id ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
			$screen = self::$_registry[ $id ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
			if ( $screen === get_current_screen() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
				return $screen;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
			$screen = new WP_Screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
			$screen->id     = $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
		$screen->base       = $base;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
		$screen->action     = $action;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
		$screen->post_type  = (string) $post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
		$screen->taxonomy   = (string) $taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
		$screen->is_user    = ( 'user' == $in_admin );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
		$screen->is_network = ( 'network' == $in_admin );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
		$screen->in_admin   = $in_admin;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
		self::$_registry[ $id ] = $screen;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
		return $screen;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
	 * Makes the screen object the current screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
	 * @see set_current_screen()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   533
	public function set_current_screen() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
		global $current_screen, $taxnow, $typenow;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
		$current_screen = $this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
		$taxnow = $this->taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
		$typenow = $this->post_type;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   538
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   539
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   540
		 * Fires after the current screen has been set.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   541
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   544
		 * @param WP_Screen $current_screen Current WP_Screen object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
		do_action( 'current_screen', $current_screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
	 * Constructor
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
	 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
	private function __construct() {}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
	 * Indicates whether the screen is in a particular admin
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
	 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
	 * @param string $admin The admin to check against (network | user | site).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
	 * If empty any of the three admins will result in true.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
	 * @return boolean True if the screen is in the indicated admin, false otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
	public function in_admin( $admin = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
		if ( empty( $admin ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
			return (bool) $this->in_admin;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
		return ( $admin == $this->in_admin );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
	 * Sets the old string-based contextual help for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
	 * For backwards compatibility.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
	 * @param WP_Screen $screen A screen object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
	 * @param string $help Help text.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
	public static function add_old_compat_help( $screen, $help ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
		self::$_old_compat_help[ $screen->id ] = $help;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
	 * Set the parent information for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
	 * This is called in admin-header.php after the menu parent for the screen has been determined.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
	 * @param string $parent_file The parent file of the screen. Typically the $parent_file global.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
	public function set_parentage( $parent_file ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
		$this->parent_file = $parent_file;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
		list( $this->parent_base ) = explode( '?', $parent_file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
		$this->parent_base = str_replace( '.php', '', $this->parent_base );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
	 * Adds an option for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
	 * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add screen options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
	 * @param string $option Option ID
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
	 * @param mixed $args Option-dependent arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
	public function add_option( $option, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
		$this->_options[ $option ] = $args;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
	/**
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   616
	 * Remove an option from the screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   617
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   618
	 * @since 3.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   619
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   620
	 * @param string $option Option ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   621
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   622
	public function remove_option( $option ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   623
		unset( $this->_options[ $option ] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   624
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   625
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   626
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   627
	 * Remove all options from the screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   628
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   629
	 * @since 3.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   630
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   631
	public function remove_options() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   632
		$this->_options = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   634
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   635
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   636
	 * Get the options registered for the screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   637
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
	 * @since 3.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   639
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
	 * @return array Options with arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   641
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   642
	public function get_options() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   643
		return $this->_options;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   644
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   645
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   646
	/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
	 * Gets the arguments for an option for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   651
	 * @param string $option Option name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   652
	 * @param string $key    Optional. Specific array key for when the option is an array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   653
	 *                       Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   654
	 * @return string The option value if set, null otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
	public function get_option( $option, $key = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
		if ( ! isset( $this->_options[ $option ] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
			return null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
		if ( $key ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
			if ( isset( $this->_options[ $option ][ $key ] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
				return $this->_options[ $option ][ $key ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
			return null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
		return $this->_options[ $option ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
	 * Gets the help tabs registered for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
	 * @return array Help tabs with arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
	public function get_help_tabs() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
		return $this->_help_tabs;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
	 * Gets the arguments for a help tab.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
	 * @param string $id Help Tab ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
	 * @return array Help tab arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
	public function get_help_tab( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
		if ( ! isset( $this->_help_tabs[ $id ] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
			return null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
		return $this->_help_tabs[ $id ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
	 * Add a help tab to the contextual help for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
	 * Call this on the load-$pagenow hook for the relevant screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
	 * @param array $args
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
	 * - string   - title    - Title for the tab.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
	 * - string   - id       - Tab ID. Must be HTML-safe.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
	 * - string   - content  - Help tab content in plain text or HTML. Optional.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
	 * - callback - callback - A callback to generate the tab content. Optional.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
	public function add_help_tab( $args ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
		$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
			'title'    => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
			'id'       => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
			'content'  => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
			'callback' => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
		$args = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
		$args['id'] = sanitize_html_class( $args['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
		// Ensure we have an ID and title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
		if ( ! $args['id'] || ! $args['title'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
		// Allows for overriding an existing tab with that ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
		$this->_help_tabs[ $args['id'] ] = $args;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
	 * Removes a help tab from the contextual help for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
	 * @param string $id The help tab ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
	public function remove_help_tab( $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
		unset( $this->_help_tabs[ $id ] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
	 * Removes all help tabs from the contextual help for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
	public function remove_help_tabs() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
		$this->_help_tabs = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
	 * Gets the content from a contextual help sidebar.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
	 * @return string Contents of the help sidebar.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   750
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
	public function get_help_sidebar() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
		return $this->_help_sidebar;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
	 * Add a sidebar to the contextual help for the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
	 * 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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
	 * @param string $content Sidebar content in plain text or HTML.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
	public function set_help_sidebar( $content ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
		$this->_help_sidebar = $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
	 * Gets the number of layout columns the user has selected.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
	 * The layout_columns option controls the max number and default number of
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
	 * columns. This method returns the number of columns within that range selected
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
	 * by the user via Screen Options. If no selection has been made, the default
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
	 * provisioned in layout_columns is returned. If the screen does not support
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
	 * selecting the number of layout columns, 0 is returned.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
	 * @return int Number of columns to display.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
	public function get_columns() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
		return $this->columns;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
	 * Render the screen's help section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
	 * This will trigger the deprecated filters for backwards compatibility.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
	public function render_screen_meta() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   793
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   794
		 * Filter the legacy contextual help list.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   795
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   796
		 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   797
		 * @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   798
		 *                   get_current_screen()->remove_help_tab() instead.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   799
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   800
		 * @param array     $old_compat_help Old contextual help.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   801
		 * @param WP_Screen $this            Current WP_Screen instance.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   802
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
		self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
		$old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   806
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   807
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   808
		 * Filter the legacy contextual help text.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   809
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   810
		 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   811
		 * @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   812
		 *                   get_current_screen()->remove_help_tab() instead.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   813
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   814
		 * @param string    $old_help  Help text that appears on the screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   815
		 * @param string    $screen_id Screen ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   816
		 * @param WP_Screen $this      Current WP_Screen instance.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   817
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   818
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
		$old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
		// Default help only if there is no old-style block of text and no new-style help tabs.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
		if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   823
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   824
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   825
			 * Filter the default legacy contextual help text.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   826
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   827
			 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   828
			 * @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   829
			 *                   get_current_screen()->remove_help_tab() instead.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   830
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   831
			 * @param string $old_help_default Default contextual help text.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   832
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   833
			$default_help = apply_filters( 'default_contextual_help', '' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   834
			if ( $default_help )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   835
				$old_help = '<p>' . $default_help . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   836
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   838
		if ( $old_help ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   839
			$this->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
				'id'      => 'old-contextual-help',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   841
				'title'   => __('Overview'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   842
				'content' => $old_help,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
			) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
		$help_sidebar = $this->get_help_sidebar();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
		$help_class = 'hidden';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
		if ( ! $help_sidebar )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
			$help_class .= ' no-sidebar';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
		// Time to render!
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
		<div id="screen-meta" class="metabox-prefs">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
			<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
				<div id="contextual-help-back"></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   858
				<div id="contextual-help-columns">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
					<div class="contextual-help-tabs">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   860
						<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   861
						<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
						$class = ' class="active"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
						foreach ( $this->get_help_tabs() as $tab ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
							$link_id  = "tab-link-{$tab['id']}";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
							$panel_id = "tab-panel-{$tab['id']}";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
							?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
							<li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
								<a href="<?php echo esc_url( "#$panel_id" ); ?>" aria-controls="<?php echo esc_attr( $panel_id ); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
									<?php echo esc_html( $tab['title'] ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
								</a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
							</li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
						<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
							$class = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
						endforeach;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   876
						?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
						</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
					</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
					<?php if ( $help_sidebar ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
					<div class="contextual-help-sidebar">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
						<?php echo $help_sidebar; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
					</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   884
					<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   886
					<div class="contextual-help-tabs-wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   887
						<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   888
						$classes = 'help-tab-content active';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   889
						foreach ( $this->get_help_tabs() as $tab ):
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   890
							$panel_id = "tab-panel-{$tab['id']}";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   891
							?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   892
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   893
							<div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo $classes; ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   894
								<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   895
								// Print tab content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   896
								echo $tab['content'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   897
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   898
								// If it exists, fire tab callback.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   899
								if ( ! empty( $tab['callback'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   900
									call_user_func_array( $tab['callback'], array( $this, $tab ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
								?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
							</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
						<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
							$classes = 'help-tab-content';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
						endforeach;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
						?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
					</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
				</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   910
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
		// Setup layout columns
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   913
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   914
		 * Filter the array of screen layout columns.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   915
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   916
		 * This hook provides back-compat for plugins using the back-compat
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   917
		 * filter instead of add_screen_option().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   918
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   919
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   920
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   921
		 * @param array     $empty_columns Empty array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   922
		 * @param string    $screen_id     Screen ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   923
		 * @param WP_Screen $this          Current WP_Screen instance.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   924
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
		$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
		if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
			$this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   930
		if ( $this->get_option( 'layout_columns' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
			$this->columns = (int) get_user_option("screen_layout_$this->id");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
			if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
				$this->columns = $this->get_option( 'layout_columns', 'default' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
		$GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
		// Add screen options
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
		if ( $this->show_screen_options() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
			$this->render_screen_options();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
		if ( ! $this->get_help_tabs() && ! $this->show_screen_options() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
		<div id="screen-meta-links">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
		<?php if ( $this->get_help_tabs() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
			<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
			<a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
		<?php endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
		if ( $this->show_screen_options() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
			<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
			<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
	public function show_screen_options() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
		global $wp_meta_boxes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   964
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
		if ( is_bool( $this->_show_screen_options ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
			return $this->_show_screen_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
		$columns = get_column_headers( $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   969
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
		$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   972
		switch ( $this->base ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
			case 'widgets':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
				$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";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
				break;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   976
			case 'post' :
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   977
				$expand = '<div class="editor-expand hidden"><label for="editor-expand-toggle">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   978
				$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   979
				$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   980
				$this->_screen_settings = $expand;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   981
				break;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
			default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
				$this->_screen_settings = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   987
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   988
		 * Filter the screen settings text displayed in the Screen Options tab.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   989
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   990
		 * This filter is currently only used on the Widgets screen to enable
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   991
		 * accessibility mode.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   992
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   993
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   994
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   995
		 * @param string    $screen_settings Screen settings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   996
		 * @param WP_Screen $this            WP_Screen object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   997
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
		$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
		if ( $this->_screen_settings || $this->_options )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
			$show_screen = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1004
		 * Filter whether to show the Screen Options tab.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1005
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1006
		 * @since 3.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1007
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1008
		 * @param bool      $show_screen Whether to show Screen Options tab.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1009
		 *                               Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1010
		 * @param WP_Screen $this        Current WP_Screen instance.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1011
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
		$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
		return $this->_show_screen_options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1015
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
	 * Render the screen options tab.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
	public function render_screen_options() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1022
		global $wp_meta_boxes;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
		$columns = get_column_headers( $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1025
		$hidden  = get_hidden_columns( $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
		<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1029
		<form id="adv-settings" method="post">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
		<?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
			<h5><?php _e( 'Show on screen' ); ?></h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
		endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
		if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
			<div class="metabox-prefs">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
				<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
					meta_box_prefs( $this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
					if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
						if ( isset( $_GET['welcome'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
							$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
							update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
						} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
							$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
							if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
								$welcome_checked = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
						}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
						echo '<label for="wp_welcome_panel-hide">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
						echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
						echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
				?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
				<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
			<?php endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
			if ( $columns ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1058
				if ( ! empty( $columns['_title'] ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1059
			<h5><?php echo $columns['_title']; ?></h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
			<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
			<div class="metabox-prefs">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
				<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
				$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
				foreach ( $columns as $column => $title ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
					// Can't hide these for they are special
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
					if ( in_array( $column, $special ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
						continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
					if ( empty( $title ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
						continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
					if ( 'comments' == $column )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
						$title = __( 'Comments' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
					$id = "$column-hide";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
					echo '<label for="' . $id . '">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
					echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
					echo "$title</label>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
				?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
				<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
		<?php endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
		$this->render_screen_layout();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
		$this->render_per_page_options();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
		echo $this->_screen_settings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1087
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1089
		<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
		</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
	 * Render the option for number of columns on the page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1100
	public function render_screen_layout() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
		if ( ! $this->get_option('layout_columns') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
		$screen_layout_columns = $this->get_columns();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
		$num = $this->get_option( 'layout_columns', 'max' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
		<h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
		<div class='columns-prefs'><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
			_e('Number of Columns:');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
			for ( $i = 1; $i <= $num; ++$i ):
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
				?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
				<label class="columns-prefs-<?php echo $i; ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
					<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
						<?php checked( $screen_layout_columns, $i ); ?> />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
					<?php echo esc_html( $i ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
				</label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
				<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
			endfor; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
	 * Render the items per page option
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1129
	public function render_per_page_options() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1130
		if ( null === $this->get_option( 'per_page' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1131
			return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1132
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
		$per_page_label = $this->get_option( 'per_page', 'label' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1135
		if ( null === $per_page_label ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1136
			$per_page_label = __( 'Number of items per page:' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1137
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
		$option = $this->get_option( 'per_page', 'option' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1140
		if ( ! $option ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1141
			$option = str_replace( '-', '_', "{$this->id}_per_page" );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1142
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1143
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
		$per_page = (int) get_user_option( $option );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
		if ( empty( $per_page ) || $per_page < 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
			$per_page = $this->get_option( 'per_page', 'default' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1147
			if ( ! $per_page ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1148
				$per_page = 20;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1149
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
		if ( 'edit_comments_per_page' == $option ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
			$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1154
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1155
			/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
			$per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
		} elseif ( 'categories_per_page' == $option ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1158
			/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1159
			$per_page = apply_filters( 'edit_categories_per_page', $per_page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1160
		} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1161
			/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1162
			$per_page = apply_filters( $option, $per_page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1163
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1165
		// Back compat
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1166
		if ( isset( $this->post_type ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1167
			/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1168
			$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1169
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1172
		<div class="screen-options">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
			<?php if ( $per_page_label ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1174
				<label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
				<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
					id="<?php echo esc_attr( $option ); ?>" maxlength="3"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
					value="<?php echo esc_attr( $per_page ); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
			<?php endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1179
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
			echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1181
			<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
}