Archived
Wordpress++
This commit is contained in:
1 parent
b3ac616fe8
commit
6e249f4820
1175 files changed
+305248
-54197
No files matched your search
+392
-158
@@ -20,8 +20,22 @@ function get_column_headers( $screen ) {
|
||||
|
||||
static $column_headers = array();
|
||||
|
||||
if ( ! isset( $column_headers[ $screen->id ] ) )
|
||||
$column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() );
|
||||
if ( ! isset( $column_headers[ $screen->id ] ) ) {
|
||||
|
||||
/**
|
||||
* Filter the column headers for a list table on a specific screen.
|
||||
*
|
||||
* The dynamic portion of the hook name, `$screen->id`, refers to the
|
||||
* ID of a specific screen. For example, the screen ID for the Posts
|
||||
* list table is edit-post, so the filter for that screen would be
|
||||
* manage_edit-post_columns.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $columns An array of column headers. Default empty.
|
||||
*/
|
||||
$column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() );
|
||||
}
|
||||
|
||||
return $column_headers[ $screen->id ];
|
||||
}
|
||||
@@ -46,7 +60,7 @@ function get_hidden_columns( $screen ) {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string|WP_Screen $screen
|
||||
* @param WP_Screen $screen
|
||||
*/
|
||||
function meta_box_prefs( $screen ) {
|
||||
global $wp_meta_boxes;
|
||||
@@ -96,14 +110,33 @@ function get_hidden_meta_boxes( $screen ) {
|
||||
if ( $use_defaults ) {
|
||||
$hidden = array();
|
||||
if ( 'post' == $screen->base ) {
|
||||
if ( 'post' == $screen->post_type || 'page' == $screen->post_type )
|
||||
if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type )
|
||||
$hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
|
||||
else
|
||||
$hidden = array( 'slugdiv' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the default list of hidden meta boxes.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param array $hidden An array of meta boxes hidden by default.
|
||||
* @param WP_Screen $screen WP_Screen object of the current screen.
|
||||
*/
|
||||
$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the list of hidden meta boxes.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param array $hidden An array of hidden meta boxes.
|
||||
* @param WP_Screen $screen WP_Screen object of the current screen.
|
||||
* @param bool $use_defaults Whether to show the default meta boxes.
|
||||
* Default true.
|
||||
*/
|
||||
return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
|
||||
}
|
||||
|
||||
@@ -114,7 +147,6 @@ function get_hidden_meta_boxes( $screen ) {
|
||||
*
|
||||
* @param string $option An option name.
|
||||
* @param mixed $args Option-dependent arguments.
|
||||
* @return void
|
||||
*/
|
||||
function add_screen_option( $option, $args = array() ) {
|
||||
$current_screen = get_current_screen();
|
||||
@@ -125,58 +157,12 @@ function add_screen_option( $option, $args = array() ) {
|
||||
$current_screen->add_option( $option, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a screen icon.
|
||||
*
|
||||
* @uses get_screen_icon()
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object)
|
||||
* which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID.
|
||||
*/
|
||||
function screen_icon( $screen = '' ) {
|
||||
echo get_screen_icon( $screen );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a screen icon.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object)
|
||||
* which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID.
|
||||
* @return string HTML for the screen icon.
|
||||
*/
|
||||
function get_screen_icon( $screen = '' ) {
|
||||
if ( empty( $screen ) )
|
||||
$screen = get_current_screen();
|
||||
elseif ( is_string( $screen ) )
|
||||
$icon_id = $screen;
|
||||
|
||||
$class = 'icon32';
|
||||
|
||||
if ( empty( $icon_id ) ) {
|
||||
if ( ! empty( $screen->parent_base ) )
|
||||
$icon_id = $screen->parent_base;
|
||||
else
|
||||
$icon_id = $screen->base;
|
||||
|
||||
if ( 'page' == $screen->post_type )
|
||||
$icon_id = 'edit-pages';
|
||||
|
||||
if ( $screen->post_type )
|
||||
$class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type );
|
||||
}
|
||||
|
||||
return '<div id="icon-' . esc_attr( $icon_id ) . '" class="' . $class . '"><br /></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current screen object
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @return object Current screen object
|
||||
* @return WP_Screen Current screen object
|
||||
*/
|
||||
function get_current_screen() {
|
||||
global $current_screen;
|
||||
@@ -191,12 +177,11 @@ function get_current_screen() {
|
||||
* Set the current screen object
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @uses $current_screen
|
||||
*
|
||||
* @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
|
||||
* or an existing screen object.
|
||||
*/
|
||||
function set_current_screen( $hook_name = '' ) {
|
||||
function set_current_screen( $hook_name = '' ) {
|
||||
WP_Screen::get( $hook_name )->set_current_screen();
|
||||
}
|
||||
|
||||
@@ -208,7 +193,7 @@ function set_current_screen( $hook_name = '' ) {
|
||||
*/
|
||||
final class WP_Screen {
|
||||
/**
|
||||
* Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise.
|
||||
* Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @var string
|
||||
@@ -217,7 +202,7 @@ final class WP_Screen {
|
||||
public $action;
|
||||
|
||||
/**
|
||||
* The base type of the screen. This is typically the same as $id but with any post types and taxonomies stripped.
|
||||
* The base type of the screen. This is typically the same as $id but with any post types and taxonomies stripped.
|
||||
* For example, for an $id of 'edit-post' the base is 'edit'.
|
||||
*
|
||||
* @since 3.3.0
|
||||
@@ -226,6 +211,15 @@ final class WP_Screen {
|
||||
*/
|
||||
public $base;
|
||||
|
||||
/**
|
||||
* The number of columns to display. Access with get_columns().
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $columns = 0;
|
||||
|
||||
/**
|
||||
* The unique ID of the screen.
|
||||
*
|
||||
@@ -235,10 +229,22 @@ final class WP_Screen {
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Which admin the screen is in. network | user | site | false
|
||||
*
|
||||
* @since 3.5.0
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $in_admin;
|
||||
|
||||
/**
|
||||
* Whether the screen is in the network admin.
|
||||
*
|
||||
* Deprecated. Use in_admin() instead.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @deprecated 3.5.0
|
||||
* @var bool
|
||||
* @access public
|
||||
*/
|
||||
@@ -247,7 +253,10 @@ final class WP_Screen {
|
||||
/**
|
||||
* Whether the screen is in the user admin.
|
||||
*
|
||||
* Deprecated. Use in_admin() instead.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @deprecated 3.5.0
|
||||
* @var bool
|
||||
* @access public
|
||||
*/
|
||||
@@ -296,20 +305,20 @@ final class WP_Screen {
|
||||
|
||||
/**
|
||||
* The help tab data associated with the screen, if any.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $_help_tabs = array();
|
||||
|
||||
/**
|
||||
/**
|
||||
* The help sidebar data associated with screen, if any.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
*/
|
||||
private $_help_sidebar = '';
|
||||
|
||||
/**
|
||||
@@ -353,23 +362,24 @@ final class WP_Screen {
|
||||
*/
|
||||
private $_screen_settings;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fetches a screen object.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
|
||||
*
|
||||
* @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
|
||||
* Defaults to the current $hook_suffix global.
|
||||
* @return WP_Screen Screen object.
|
||||
*/
|
||||
*/
|
||||
public static function get( $hook_name = '' ) {
|
||||
|
||||
if ( is_a( $hook_name, 'WP_Screen' ) )
|
||||
if ( $hook_name instanceof WP_Screen ) {
|
||||
return $hook_name;
|
||||
}
|
||||
|
||||
$post_type = $taxonomy = null;
|
||||
$is_network = $is_user = false;
|
||||
$in_admin = false;
|
||||
$action = '';
|
||||
|
||||
if ( $hook_name )
|
||||
@@ -394,30 +404,39 @@ final class WP_Screen {
|
||||
if ( ! $post_type && $hook_name ) {
|
||||
if ( '-network' == substr( $id, -8 ) ) {
|
||||
$id = substr( $id, 0, -8 );
|
||||
$is_network = true;
|
||||
$in_admin = 'network';
|
||||
} elseif ( '-user' == substr( $id, -5 ) ) {
|
||||
$id = substr( $id, 0, -5 );
|
||||
$is_user = true;
|
||||
$in_admin = 'user';
|
||||
}
|
||||
|
||||
$id = sanitize_key( $id );
|
||||
if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) {
|
||||
$maybe = substr( $id, 5 );
|
||||
if ( taxonomy_exists( $maybe ) ) {
|
||||
$id = 'edit-tags';
|
||||
$id = 'edit-tags';
|
||||
$taxonomy = $maybe;
|
||||
} elseif ( post_type_exists( $maybe ) ) {
|
||||
$id = 'edit';
|
||||
$post_type = $maybe;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $in_admin )
|
||||
$in_admin = 'site';
|
||||
} else {
|
||||
$is_network = is_network_admin();
|
||||
$is_user = is_user_admin();
|
||||
if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN )
|
||||
$in_admin = 'network';
|
||||
elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN )
|
||||
$in_admin = 'user';
|
||||
else
|
||||
$in_admin = 'site';
|
||||
}
|
||||
|
||||
if ( 'index' == $id )
|
||||
$id = 'dashboard';
|
||||
elseif ( 'front' == $id )
|
||||
$in_admin = false;
|
||||
|
||||
$base = $id;
|
||||
|
||||
@@ -448,7 +467,7 @@ final class WP_Screen {
|
||||
$post_type = 'post';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ( $base ) {
|
||||
case 'post' :
|
||||
@@ -464,17 +483,24 @@ final class WP_Screen {
|
||||
case 'edit-tags' :
|
||||
if ( null === $taxonomy )
|
||||
$taxonomy = 'post_tag';
|
||||
// The edit-tags ID does not contain the post type. Look for it in the request.
|
||||
if ( null === $post_type ) {
|
||||
$post_type = 'post';
|
||||
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
|
||||
$post_type = $_REQUEST['post_type'];
|
||||
}
|
||||
|
||||
$id = 'edit-' . $taxonomy;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $is_network ) {
|
||||
if ( 'network' == $in_admin ) {
|
||||
$id .= '-network';
|
||||
$base .= '-network';
|
||||
} elseif ( $is_user ) {
|
||||
} elseif ( 'user' == $in_admin ) {
|
||||
$id .= '-user';
|
||||
$base .= '-user';
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( self::$_registry[ $id ] ) ) {
|
||||
$screen = self::$_registry[ $id ];
|
||||
@@ -489,13 +515,14 @@ final class WP_Screen {
|
||||
$screen->action = $action;
|
||||
$screen->post_type = (string) $post_type;
|
||||
$screen->taxonomy = (string) $taxonomy;
|
||||
$screen->is_user = $is_user;
|
||||
$screen->is_network = $is_network;
|
||||
$screen->is_user = ( 'user' == $in_admin );
|
||||
$screen->is_network = ( 'network' == $in_admin );
|
||||
$screen->in_admin = $in_admin;
|
||||
|
||||
self::$_registry[ $id ] = $screen;
|
||||
|
||||
return $screen;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the screen object the current screen.
|
||||
@@ -503,11 +530,19 @@ final class WP_Screen {
|
||||
* @see set_current_screen()
|
||||
* @since 3.3.0
|
||||
*/
|
||||
function set_current_screen() {
|
||||
public function set_current_screen() {
|
||||
global $current_screen, $taxnow, $typenow;
|
||||
$current_screen = $this;
|
||||
$taxnow = $this->taxonomy;
|
||||
$typenow = $this->post_type;
|
||||
|
||||
/**
|
||||
* Fires after the current screen has been set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param WP_Screen $current_screen Current WP_Screen object.
|
||||
*/
|
||||
do_action( 'current_screen', $current_screen );
|
||||
}
|
||||
|
||||
@@ -519,6 +554,23 @@ final class WP_Screen {
|
||||
*/
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Indicates whether the screen is in a particular admin
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param string $admin The admin to check against (network | user | site).
|
||||
* If empty any of the three admins will result in true.
|
||||
* @return boolean True if the screen is in the indicated admin, false otherwise.
|
||||
*
|
||||
*/
|
||||
public function in_admin( $admin = null ) {
|
||||
if ( empty( $admin ) )
|
||||
return (bool) $this->in_admin;
|
||||
|
||||
return ( $admin == $this->in_admin );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the old string-based contextual help for the screen.
|
||||
*
|
||||
@@ -529,7 +581,7 @@ final class WP_Screen {
|
||||
* @param WP_Screen $screen A screen object.
|
||||
* @param string $help Help text.
|
||||
*/
|
||||
static function add_old_compat_help( $screen, $help ) {
|
||||
public static function add_old_compat_help( $screen, $help ) {
|
||||
self::$_old_compat_help[ $screen->id ] = $help;
|
||||
}
|
||||
|
||||
@@ -539,9 +591,9 @@ final class WP_Screen {
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param string $parent_file The parent file of the screen. Typically the $parent_file global.
|
||||
* @param string $parent_file The parent file of the screen. Typically the $parent_file global.
|
||||
*/
|
||||
function set_parentage( $parent_file ) {
|
||||
public function set_parentage( $parent_file ) {
|
||||
$this->parent_file = $parent_file;
|
||||
list( $this->parent_base ) = explode( '?', $parent_file );
|
||||
$this->parent_base = str_replace( '.php', '', $this->parent_base );
|
||||
@@ -560,12 +612,46 @@ final class WP_Screen {
|
||||
$this->_options[ $option ] = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an option from the screen.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*
|
||||
* @param string $option Option ID.
|
||||
*/
|
||||
public function remove_option( $option ) {
|
||||
unset( $this->_options[ $option ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all options from the screen.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*/
|
||||
public function remove_options() {
|
||||
$this->_options = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the options registered for the screen.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*
|
||||
* @return array Options with arguments.
|
||||
*/
|
||||
public function get_options() {
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the arguments for an option for the screen.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param string
|
||||
* @param string $option Option name.
|
||||
* @param string $key Optional. Specific array key for when the option is an array.
|
||||
* Default false.
|
||||
* @return string The option value if set, null otherwise.
|
||||
*/
|
||||
public function get_option( $option, $key = false ) {
|
||||
if ( ! isset( $this->_options[ $option ] ) )
|
||||
@@ -578,6 +664,31 @@ final class WP_Screen {
|
||||
return $this->_options[ $option ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help tabs registered for the screen.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return array Help tabs with arguments.
|
||||
*/
|
||||
public function get_help_tabs() {
|
||||
return $this->_help_tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the arguments for a help tab.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param string $id Help Tab ID.
|
||||
* @return array Help tab arguments.
|
||||
*/
|
||||
public function get_help_tab( $id ) {
|
||||
if ( ! isset( $this->_help_tabs[ $id ] ) )
|
||||
return null;
|
||||
return $this->_help_tabs[ $id ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a help tab to the contextual help for the screen.
|
||||
* Call this on the load-$pagenow hook for the relevant screen.
|
||||
@@ -606,7 +717,8 @@ final class WP_Screen {
|
||||
if ( ! $args['id'] || ! $args['title'] )
|
||||
return;
|
||||
|
||||
$this->_help_tabs[] = $args;
|
||||
// Allows for overriding an existing tab with that ID.
|
||||
$this->_help_tabs[ $args['id'] ] = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -629,6 +741,17 @@ final class WP_Screen {
|
||||
$this->_help_tabs = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content from a contextual help sidebar.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return string Contents of the help sidebar.
|
||||
*/
|
||||
public function get_help_sidebar() {
|
||||
return $this->_help_sidebar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a sidebar to the contextual help for the screen.
|
||||
* 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.
|
||||
@@ -641,6 +764,23 @@ final class WP_Screen {
|
||||
$this->_help_sidebar = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of layout columns the user has selected.
|
||||
*
|
||||
* The layout_columns option controls the max number and default number of
|
||||
* columns. This method returns the number of columns within that range selected
|
||||
* by the user via Screen Options. If no selection has been made, the default
|
||||
* provisioned in layout_columns is returned. If the screen does not support
|
||||
* selecting the number of layout columns, 0 is returned.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @return int Number of columns to display.
|
||||
*/
|
||||
public function get_columns() {
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the screen's help section.
|
||||
*
|
||||
@@ -650,14 +790,46 @@ final class WP_Screen {
|
||||
*/
|
||||
public function render_screen_meta() {
|
||||
|
||||
// Call old contextual_help_list filter.
|
||||
/**
|
||||
* Filter the legacy contextual help list.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
|
||||
* get_current_screen()->remove_help_tab() instead.
|
||||
*
|
||||
* @param array $old_compat_help Old contextual help.
|
||||
* @param WP_Screen $this Current WP_Screen instance.
|
||||
*/
|
||||
self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this );
|
||||
|
||||
$old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
|
||||
|
||||
/**
|
||||
* Filter the legacy contextual help text.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
|
||||
* get_current_screen()->remove_help_tab() instead.
|
||||
*
|
||||
* @param string $old_help Help text that appears on the screen.
|
||||
* @param string $screen_id Screen ID.
|
||||
* @param WP_Screen $this Current WP_Screen instance.
|
||||
*
|
||||
*/
|
||||
$old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
|
||||
|
||||
// Default help only if there is no old-style block of text and no new-style help tabs.
|
||||
if ( empty( $old_help ) && empty( $this->_help_tabs ) ) {
|
||||
if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
|
||||
|
||||
/**
|
||||
* Filter the default legacy contextual help text.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @deprecated 3.3.0 Use get_current_screen()->add_help_tab() or
|
||||
* get_current_screen()->remove_help_tab() instead.
|
||||
*
|
||||
* @param string $old_help_default Default contextual help text.
|
||||
*/
|
||||
$default_help = apply_filters( 'default_contextual_help', '' );
|
||||
if ( $default_help )
|
||||
$old_help = '<p>' . $default_help . '</p>';
|
||||
@@ -671,50 +843,54 @@ final class WP_Screen {
|
||||
) );
|
||||
}
|
||||
|
||||
$has_sidebar = ! empty( $this->_help_sidebar );
|
||||
$help_sidebar = $this->get_help_sidebar();
|
||||
|
||||
$help_class = 'hidden';
|
||||
if ( ! $has_sidebar )
|
||||
if ( ! $help_sidebar )
|
||||
$help_class .= ' no-sidebar';
|
||||
|
||||
// Time to render!
|
||||
?>
|
||||
<div id="screen-meta" class="metabox-prefs">
|
||||
|
||||
<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>">
|
||||
<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>">
|
||||
<div id="contextual-help-back"></div>
|
||||
<div id="contextual-help-columns">
|
||||
<div class="contextual-help-tabs">
|
||||
<ul>
|
||||
<?php foreach ( $this->_help_tabs as $i => $tab ):
|
||||
<?php
|
||||
$class = ' class="active"';
|
||||
foreach ( $this->get_help_tabs() as $tab ) :
|
||||
$link_id = "tab-link-{$tab['id']}";
|
||||
$panel_id = "tab-panel-{$tab['id']}";
|
||||
$classes = ( $i == 0 ) ? 'active' : '';
|
||||
?>
|
||||
|
||||
<li id="<?php echo esc_attr( $link_id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
|
||||
<a href="<?php echo esc_url( "#$panel_id" ); ?>">
|
||||
<li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>>
|
||||
<a href="<?php echo esc_url( "#$panel_id" ); ?>" aria-controls="<?php echo esc_attr( $panel_id ); ?>">
|
||||
<?php echo esc_html( $tab['title'] ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
$class = '';
|
||||
endforeach;
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php if ( $has_sidebar ) : ?>
|
||||
<?php if ( $help_sidebar ) : ?>
|
||||
<div class="contextual-help-sidebar">
|
||||
<?php echo self::$this->_help_sidebar; ?>
|
||||
<?php echo $help_sidebar; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="contextual-help-tabs-wrap">
|
||||
<?php foreach ( $this->_help_tabs as $i => $tab ):
|
||||
<?php
|
||||
$classes = 'help-tab-content active';
|
||||
foreach ( $this->get_help_tabs() as $tab ):
|
||||
$panel_id = "tab-panel-{$tab['id']}";
|
||||
$classes = ( $i == 0 ) ? 'active' : '';
|
||||
$classes .= ' help-tab-content';
|
||||
?>
|
||||
|
||||
<div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
|
||||
<div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo $classes; ?>">
|
||||
<?php
|
||||
// Print tab content.
|
||||
echo $tab['content'];
|
||||
@@ -724,29 +900,59 @@ final class WP_Screen {
|
||||
call_user_func_array( $tab['callback'], array( $this, $tab ) );
|
||||
?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php
|
||||
$classes = 'help-tab-content';
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
// Setup layout columns
|
||||
|
||||
/**
|
||||
* Filter the array of screen layout columns.
|
||||
*
|
||||
* This hook provides back-compat for plugins using the back-compat
|
||||
* filter instead of add_screen_option().
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param array $empty_columns Empty array.
|
||||
* @param string $screen_id Screen ID.
|
||||
* @param WP_Screen $this Current WP_Screen instance.
|
||||
*/
|
||||
$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
|
||||
|
||||
if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
|
||||
$this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
|
||||
|
||||
if ( $this->get_option( 'layout_columns' ) ) {
|
||||
$this->columns = (int) get_user_option("screen_layout_$this->id");
|
||||
|
||||
if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) )
|
||||
$this->columns = $this->get_option( 'layout_columns', 'default' );
|
||||
}
|
||||
$GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat.
|
||||
|
||||
// Add screen options
|
||||
if ( $this->show_screen_options() )
|
||||
$this->render_screen_options();
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if ( ! $this->_help_tabs && ! $this->show_screen_options() )
|
||||
if ( ! $this->get_help_tabs() && ! $this->show_screen_options() )
|
||||
return;
|
||||
?>
|
||||
<div id="screen-meta-links">
|
||||
<?php if ( $this->_help_tabs ) : ?>
|
||||
<?php if ( $this->get_help_tabs() ) : ?>
|
||||
<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
|
||||
<a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings"><?php _e( 'Help' ); ?></a>
|
||||
<a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></a>
|
||||
</div>
|
||||
<?php endif;
|
||||
if ( $this->show_screen_options() ) : ?>
|
||||
<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
|
||||
<a href="#screen-options-wrap" id="show-settings-link" class="show-settings"><?php _e( 'Screen Options' ); ?></a>
|
||||
<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>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -763,17 +969,46 @@ final class WP_Screen {
|
||||
|
||||
$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
|
||||
|
||||
$this->_screen_settings = apply_filters( 'screen_settings', '', $this );
|
||||
|
||||
switch ( $this->id ) {
|
||||
switch ( $this->base ) {
|
||||
case 'widgets':
|
||||
$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";
|
||||
break;
|
||||
case 'post' :
|
||||
$expand = '<div class="editor-expand hidden"><label for="editor-expand-toggle">';
|
||||
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
|
||||
$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></div>';
|
||||
$this->_screen_settings = $expand;
|
||||
break;
|
||||
default:
|
||||
$this->_screen_settings = '';
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the screen settings text displayed in the Screen Options tab.
|
||||
*
|
||||
* This filter is currently only used on the Widgets screen to enable
|
||||
* accessibility mode.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $screen_settings Screen settings.
|
||||
* @param WP_Screen $this WP_Screen object.
|
||||
*/
|
||||
$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
|
||||
|
||||
if ( $this->_screen_settings || $this->_options )
|
||||
$show_screen = true;
|
||||
|
||||
/**
|
||||
* Filter whether to show the Screen Options tab.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param bool $show_screen Whether to show Screen Options tab.
|
||||
* Default true.
|
||||
* @param WP_Screen $this Current WP_Screen instance.
|
||||
*/
|
||||
$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
|
||||
return $this->_show_screen_options;
|
||||
}
|
||||
@@ -784,22 +1019,25 @@ final class WP_Screen {
|
||||
* @since 3.3.0
|
||||
*/
|
||||
public function render_screen_options() {
|
||||
global $wp_meta_boxes, $wp_list_table;
|
||||
global $wp_meta_boxes;
|
||||
|
||||
$columns = get_column_headers( $this );
|
||||
$hidden = get_hidden_columns( $this );
|
||||
|
||||
?>
|
||||
<div id="screen-options-wrap" class="hidden">
|
||||
<form id="adv-settings" action="" method="post">
|
||||
<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>">
|
||||
<form id="adv-settings" method="post">
|
||||
<?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
|
||||
<h5><?php _e( 'Show on screen' ); ?></h5>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?>
|
||||
<h5><?php _ex('Show on screen', 'Metaboxes') ?></h5>
|
||||
<div class="metabox-prefs">
|
||||
<?php
|
||||
meta_box_prefs( $this );
|
||||
|
||||
if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) {
|
||||
if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
|
||||
if ( isset( $_GET['welcome'] ) ) {
|
||||
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
|
||||
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
|
||||
@@ -809,15 +1047,17 @@ final class WP_Screen {
|
||||
$welcome_checked = false;
|
||||
}
|
||||
echo '<label for="wp_welcome_panel-hide">';
|
||||
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
|
||||
echo __( 'Welcome' ) . "</label>\n";
|
||||
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
|
||||
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
|
||||
}
|
||||
?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<?php endif;
|
||||
if ( ! empty( $columns ) ) : ?>
|
||||
<h5><?php echo ( isset( $columns['_title'] ) ? $columns['_title'] : _x('Show on screen', 'Columns') ) ?></h5>
|
||||
if ( $columns ) :
|
||||
if ( ! empty( $columns['_title'] ) ) : ?>
|
||||
<h5><?php echo $columns['_title']; ?></h5>
|
||||
<?php endif; ?>
|
||||
<div class="metabox-prefs">
|
||||
<?php
|
||||
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
|
||||
@@ -857,35 +1097,20 @@ final class WP_Screen {
|
||||
*
|
||||
* @since 3.3.0
|
||||
*/
|
||||
function render_screen_layout() {
|
||||
global $screen_layout_columns;
|
||||
|
||||
// Back compat for plugins using the filter instead of add_screen_option()
|
||||
$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
|
||||
|
||||
if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
|
||||
$this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
|
||||
|
||||
if ( ! $this->get_option('layout_columns') ) {
|
||||
$screen_layout_columns = 0;
|
||||
public function render_screen_layout() {
|
||||
if ( ! $this->get_option('layout_columns') )
|
||||
return;
|
||||
}
|
||||
|
||||
$screen_layout_columns = get_user_option("screen_layout_$this->id");
|
||||
$screen_layout_columns = $this->get_columns();
|
||||
$num = $this->get_option( 'layout_columns', 'max' );
|
||||
|
||||
if ( ! $screen_layout_columns || 'auto' == $screen_layout_columns ) {
|
||||
if ( $this->get_option( 'layout_columns', 'default' ) )
|
||||
$screen_layout_columns = $this->get_option( 'layout_columns', 'default' );
|
||||
}
|
||||
|
||||
?>
|
||||
<h5><?php _e('Screen Layout'); ?></h5>
|
||||
<h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5>
|
||||
<div class='columns-prefs'><?php
|
||||
_e('Number of Columns:');
|
||||
for ( $i = 1; $i <= $num; ++$i ):
|
||||
?>
|
||||
<label>
|
||||
<label class="columns-prefs-<?php echo $i; ?>">
|
||||
<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
|
||||
<?php checked( $screen_layout_columns, $i ); ?> />
|
||||
<?php echo esc_html( $i ); ?>
|
||||
@@ -901,50 +1126,59 @@ final class WP_Screen {
|
||||
*
|
||||
* @since 3.3.0
|
||||
*/
|
||||
function render_per_page_options() {
|
||||
if ( ! $this->get_option( 'per_page' ) )
|
||||
public function render_per_page_options() {
|
||||
if ( null === $this->get_option( 'per_page' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$per_page_label = $this->get_option( 'per_page', 'label' );
|
||||
if ( null === $per_page_label ) {
|
||||
$per_page_label = __( 'Number of items per page:' );
|
||||
}
|
||||
|
||||
$option = $this->get_option( 'per_page', 'option' );
|
||||
if ( ! $option )
|
||||
if ( ! $option ) {
|
||||
$option = str_replace( '-', '_', "{$this->id}_per_page" );
|
||||
}
|
||||
|
||||
$per_page = (int) get_user_option( $option );
|
||||
if ( empty( $per_page ) || $per_page < 1 ) {
|
||||
$per_page = $this->get_option( 'per_page', 'default' );
|
||||
if ( ! $per_page )
|
||||
if ( ! $per_page ) {
|
||||
$per_page = 20;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'edit_comments_per_page' == $option ) {
|
||||
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
|
||||
|
||||
/** This filter is documented in wp-admin/includes/class-wp-comments-list-table.php */
|
||||
$per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
|
||||
} elseif ( 'categories_per_page' == $option ) {
|
||||
/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
|
||||
$per_page = apply_filters( 'edit_categories_per_page', $per_page );
|
||||
} else {
|
||||
/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
|
||||
$per_page = apply_filters( $option, $per_page );
|
||||
}
|
||||
|
||||
// Back compat
|
||||
if ( isset( $this->post_type ) )
|
||||
if ( isset( $this->post_type ) ) {
|
||||
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
|
||||
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
|
||||
}
|
||||
|
||||
?>
|
||||
<h5><?php _ex('Show on screen', 'Screen Options') ?></h5>
|
||||
<div class='screen-options'>
|
||||
<?php if ( !empty($per_page_label) ): ?>
|
||||
<input type='text' class='screen-per-page' name='wp_screen_options[value]'
|
||||
id='<?php echo esc_attr( $option ); ?>' maxlength='3'
|
||||
value='<?php echo esc_attr( $per_page ); ?>' />
|
||||
<label for='<?php echo esc_attr( $option ); ?>'>
|
||||
<?php echo esc_html( $per_page_label ); ?>
|
||||
</label>
|
||||
<div class="screen-options">
|
||||
<?php if ( $per_page_label ) : ?>
|
||||
<label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
|
||||
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
|
||||
id="<?php echo esc_attr( $option ); ?>" maxlength="3"
|
||||
value="<?php echo esc_attr( $per_page ); ?>" />
|
||||
<?php endif;
|
||||
|
||||
echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
|
||||
<input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' />
|
||||
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user