|
|
|
@ -236,202 +236,22 @@ function convert_to_screen( $screen ) {
|
|
|
|
|
return $screen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function screen_meta($screen) {
|
|
|
|
|
global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options;
|
|
|
|
|
|
|
|
|
|
if ( is_string($screen) )
|
|
|
|
|
$screen = convert_to_screen($screen);
|
|
|
|
|
|
|
|
|
|
$columns = get_column_headers( $screen );
|
|
|
|
|
$hidden = get_hidden_columns( $screen );
|
|
|
|
|
|
|
|
|
|
$meta_screens = array('index' => 'dashboard');
|
|
|
|
|
|
|
|
|
|
if ( isset($meta_screens[$screen->id]) ) {
|
|
|
|
|
$screen->id = $meta_screens[$screen->id];
|
|
|
|
|
$screen->base = $screen->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$show_screen = false;
|
|
|
|
|
if ( !empty($wp_meta_boxes[$screen->id]) || !empty($columns) )
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
|
|
|
|
|
$screen_options = screen_options($screen);
|
|
|
|
|
if ( $screen_options )
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
|
|
|
|
|
if ( !isset($_wp_contextual_help) )
|
|
|
|
|
$_wp_contextual_help = array();
|
|
|
|
|
|
|
|
|
|
$settings = apply_filters('screen_settings', '', $screen);
|
|
|
|
|
|
|
|
|
|
switch ( $screen->id ) {
|
|
|
|
|
case 'widgets':
|
|
|
|
|
$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";
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if ( ! empty( $settings ) )
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
|
|
|
|
|
if ( !empty($wp_current_screen_options) )
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
|
|
|
|
|
$show_screen = apply_filters('screen_options_show_screen', $show_screen, $screen);
|
|
|
|
|
|
|
|
|
|
// If we have screen options, add the menu to the admin bar.
|
|
|
|
|
if ( $show_screen )
|
|
|
|
|
add_action( 'admin_bar_menu', 'wp_admin_bar_screen_options_menu', 80 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
<div id="screen-meta">
|
|
|
|
|
<?php if ( $show_screen ) : ?>
|
|
|
|
|
<div id="screen-options-wrap" class="hidden">
|
|
|
|
|
<form id="adv-settings" action="" method="post">
|
|
|
|
|
<?php if ( isset($wp_meta_boxes[$screen->id]) ) : ?>
|
|
|
|
|
<h5><?php _ex('Show on screen', 'Metaboxes') ?></h5>
|
|
|
|
|
<div class="metabox-prefs">
|
|
|
|
|
<?php meta_box_prefs($screen); ?>
|
|
|
|
|
<br class="clear" />
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif;
|
|
|
|
|
if ( ! empty($columns) ) : ?>
|
|
|
|
|
<h5><?php echo ( isset( $columns['_title'] ) ? $columns['_title'] : _x('Show on screen', 'Columns') ) ?></h5>
|
|
|
|
|
<div class="metabox-prefs">
|
|
|
|
|
<?php
|
|
|
|
|
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
|
|
|
|
|
|
|
|
|
|
foreach ( $columns as $column => $title ) {
|
|
|
|
|
// Can't hide these for they are special
|
|
|
|
|
if ( in_array( $column, $special ) )
|
|
|
|
|
continue;
|
|
|
|
|
if ( empty( $title ) )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ( 'comments' == $column )
|
|
|
|
|
$title = __( 'Comments' );
|
|
|
|
|
$id = "$column-hide";
|
|
|
|
|
echo '<label for="' . $id . '">';
|
|
|
|
|
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';
|
|
|
|
|
echo "$title</label>\n";
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<br class="clear" />
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif;
|
|
|
|
|
echo screen_layout($screen);
|
|
|
|
|
|
|
|
|
|
if ( !empty( $screen_options ) ) {
|
|
|
|
|
?>
|
|
|
|
|
<h5><?php _ex('Show on screen', 'Screen Options') ?></h5>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo $screen_options;
|
|
|
|
|
echo $settings; ?>
|
|
|
|
|
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php endif; // $show_screen
|
|
|
|
|
|
|
|
|
|
$_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
|
|
|
|
|
?>
|
|
|
|
|
<div id="contextual-help-wrap" class="hidden">
|
|
|
|
|
<?php
|
|
|
|
|
$contextual_help = '';
|
|
|
|
|
if ( isset($_wp_contextual_help[$screen->id]) && is_array($_wp_contextual_help[$screen->id]) ) {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Loop through ['contextual-help-tabs']
|
|
|
|
|
* - It's a nested array where $key=>$value >> $title=>$content
|
|
|
|
|
* Has no output so can only loop the array once
|
|
|
|
|
*/
|
|
|
|
|
$contextual_help_links = ''; // store looped content for later
|
|
|
|
|
$contextual_help_panels = ''; // store looped content for later
|
|
|
|
|
|
|
|
|
|
$tab_active = true;
|
|
|
|
|
|
|
|
|
|
foreach ( $_wp_contextual_help[$screen->id]['tabs'] as $tab ) {
|
|
|
|
|
list( $id, $title, $content ) = $tab;
|
|
|
|
|
|
|
|
|
|
// Generate IDs
|
|
|
|
|
$id = sanitize_html_class( $id );
|
|
|
|
|
$link_id = "tab-link-$id";
|
|
|
|
|
$panel_id = "tab-panel-$id";
|
|
|
|
|
|
|
|
|
|
$link_classes = '';
|
|
|
|
|
$panel_classes = 'help-tab-content';
|
|
|
|
|
|
|
|
|
|
if ( $tab_active ) {
|
|
|
|
|
$link_classes .= ' active';
|
|
|
|
|
$panel_classes .= ' active';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$link_classes = ( $tab_active ) ? 'active' : '';
|
|
|
|
|
|
|
|
|
|
$contextual_help_links .= '<li id="' . esc_attr( $link_id ) . '" class="' . esc_attr( $link_classes ) . '">';
|
|
|
|
|
$contextual_help_links .= '<a href="' . esc_url( "#$panel_id" ) . '">' . esc_html( $title ) . '</a>';
|
|
|
|
|
$contextual_help_links .= '</li>';
|
|
|
|
|
|
|
|
|
|
$contextual_help_panels .= '<div id="' . esc_attr( $panel_id ) . '" class="' . esc_attr( $panel_classes ) . '">';
|
|
|
|
|
$contextual_help_panels .= '<h3>' . esc_html( $title ) . '</h3>';
|
|
|
|
|
$contextual_help_panels .= $content;
|
|
|
|
|
$contextual_help_panels .= "</div>";
|
|
|
|
|
|
|
|
|
|
$tab_active = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Start output from loop: Tabbed help content
|
|
|
|
|
$contextual_help .= '<ul class="contextual-help-tabs">' . "\n";
|
|
|
|
|
$contextual_help .= $contextual_help_links;
|
|
|
|
|
$contextual_help .= '</ul>' ."\n";
|
|
|
|
|
|
|
|
|
|
// Sidebar to right of tabs
|
|
|
|
|
$contextual_help .= '<div class="contextual-help-sidebar">' . "\n";
|
|
|
|
|
$contextual_help .= $_wp_contextual_help[$screen->id]['sidebar'];
|
|
|
|
|
$contextual_help .= "</div>\n";
|
|
|
|
|
|
|
|
|
|
// Panel content
|
|
|
|
|
$contextual_help .= '<div class="contextual-help-tabs-wrap">' . "\n";
|
|
|
|
|
$contextual_help .= $contextual_help_panels;
|
|
|
|
|
$contextual_help .= "</div>\n";
|
|
|
|
|
|
|
|
|
|
} elseif ( isset( $_wp_contextual_help[ $screen->id ] ) ) {
|
|
|
|
|
$contextual_help .= $_wp_contextual_help[ $screen->id ];
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$default_help = __( '<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>' );
|
|
|
|
|
$default_help .= '<br />';
|
|
|
|
|
$default_help .= __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' );
|
|
|
|
|
|
|
|
|
|
$contextual_help .= apply_filters( 'default_contextual_help', $default_help );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$contextual_help = "<div class='metabox-prefs'>$contextual_help</div>";
|
|
|
|
|
|
|
|
|
|
echo apply_filters('contextual_help', $contextual_help, $screen->id, $screen);
|
|
|
|
|
?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div> <?php // #screen-meta
|
|
|
|
|
function screen_meta( $screen ) {
|
|
|
|
|
$current_screen = get_current_screen();
|
|
|
|
|
$current_screen->render_screen_meta();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add contextual help text for a page
|
|
|
|
|
* Add contextual help text for a page.
|
|
|
|
|
*
|
|
|
|
|
* The array $help takes the following format:
|
|
|
|
|
* array( 'contextual-help-tabs' => array( $tab1_title => $tab1_value [, $tab2_title => $tab2_value, ...] ),
|
|
|
|
|
* 'contextual-help-sidebar' => $help_links_as_string )
|
|
|
|
|
*
|
|
|
|
|
* For backwards compatability, a string is also accepted.
|
|
|
|
|
* Creates a 'Screen Info' help tab.
|
|
|
|
|
*
|
|
|
|
|
* @since 2.7.0
|
|
|
|
|
*
|
|
|
|
|
* @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
|
|
|
|
|
* @param array|string $help Creates tabs & links columns within help text in array.
|
|
|
|
|
* @param string $help The content of a 'Screen Info' help tab.
|
|
|
|
|
*
|
|
|
|
|
* @todo: deprecate?
|
|
|
|
|
*/
|
|
|
|
|
function add_contextual_help($screen, $help) {
|
|
|
|
|
global $_wp_contextual_help;
|
|
|
|
@ -445,41 +265,22 @@ function add_contextual_help($screen, $help) {
|
|
|
|
|
$_wp_contextual_help[$screen->id] = $help;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the screen layout options.
|
|
|
|
|
*
|
|
|
|
|
* @todo: deprecate?
|
|
|
|
|
*/
|
|
|
|
|
function screen_layout($screen) {
|
|
|
|
|
global $screen_layout_columns, $wp_current_screen_options;
|
|
|
|
|
$current_screen = get_current_screen();
|
|
|
|
|
|
|
|
|
|
if ( is_string($screen) )
|
|
|
|
|
$screen = convert_to_screen($screen);
|
|
|
|
|
|
|
|
|
|
// Back compat for plugins using the filter instead of add_screen_option()
|
|
|
|
|
$columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen);
|
|
|
|
|
if ( !empty($columns) && isset($columns[$screen->id]) )
|
|
|
|
|
add_screen_option('layout_columns', array('max' => $columns[$screen->id]) );
|
|
|
|
|
|
|
|
|
|
if ( !isset($wp_current_screen_options['layout_columns']) ) {
|
|
|
|
|
$screen_layout_columns = 0;
|
|
|
|
|
if ( ! $current_screen )
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$screen_layout_columns = get_user_option("screen_layout_$screen->id");
|
|
|
|
|
$num = $wp_current_screen_options['layout_columns']['max'];
|
|
|
|
|
ob_start();
|
|
|
|
|
$current_screen->render_screen_layout();
|
|
|
|
|
$screen_layout = ob_get_clean();
|
|
|
|
|
|
|
|
|
|
if ( ! $screen_layout_columns ) {
|
|
|
|
|
if ( isset($wp_current_screen_options['layout_columns']['default']) )
|
|
|
|
|
$screen_layout_columns = $wp_current_screen_options['layout_columns']['default'];
|
|
|
|
|
else
|
|
|
|
|
$screen_layout_columns = 'auto';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$i = 1;
|
|
|
|
|
$return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n";
|
|
|
|
|
while ( $i <= $num ) {
|
|
|
|
|
$return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n";
|
|
|
|
|
++$i;
|
|
|
|
|
}
|
|
|
|
|
$return .= "<label><input type='radio' id='wp_auto_columns' name='screen_columns' value='auto'" . ( ($screen_layout_columns == 'auto') ? " checked='checked'" : "" ) . " /> " . __('Auto') . "</label>\n";
|
|
|
|
|
$return .= "</div>\n";
|
|
|
|
|
return $return;
|
|
|
|
|
return $screen_layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -492,57 +293,31 @@ function screen_layout($screen) {
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
function add_screen_option( $option, $args = array() ) {
|
|
|
|
|
global $wp_current_screen_options;
|
|
|
|
|
$current_screen = get_current_screen();
|
|
|
|
|
|
|
|
|
|
if ( !isset($wp_current_screen_options) )
|
|
|
|
|
$wp_current_screen_options = array();
|
|
|
|
|
if ( ! $current_screen )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
$wp_current_screen_options[$option] = $args;
|
|
|
|
|
return $current_screen->add_option( $option, $args );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the screen's per-page options.
|
|
|
|
|
*
|
|
|
|
|
* @todo: deprecate?
|
|
|
|
|
*/
|
|
|
|
|
function screen_options($screen) {
|
|
|
|
|
global $wp_current_screen_options;
|
|
|
|
|
$current_screen = get_current_screen();
|
|
|
|
|
|
|
|
|
|
if ( is_string($screen) )
|
|
|
|
|
$screen = convert_to_screen($screen);
|
|
|
|
|
|
|
|
|
|
if ( !isset($wp_current_screen_options['per_page']) )
|
|
|
|
|
if ( ! $current_screen )
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
|
|
$per_page_label = $wp_current_screen_options['per_page']['label'];
|
|
|
|
|
ob_start();
|
|
|
|
|
$current_screen->render_per_page_options();
|
|
|
|
|
$per_page_options = ob_get_clean();
|
|
|
|
|
|
|
|
|
|
if ( empty($wp_current_screen_options['per_page']['option']) ) {
|
|
|
|
|
$option = str_replace( '-', '_', "{$screen->id}_per_page" );
|
|
|
|
|
} else {
|
|
|
|
|
$option = $wp_current_screen_options['per_page']['option'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$per_page = (int) get_user_option( $option );
|
|
|
|
|
if ( empty( $per_page ) || $per_page < 1 ) {
|
|
|
|
|
if ( isset($wp_current_screen_options['per_page']['default']) )
|
|
|
|
|
$per_page = $wp_current_screen_options['per_page']['default'];
|
|
|
|
|
else
|
|
|
|
|
$per_page = 20;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( 'edit_comments_per_page' == $option )
|
|
|
|
|
$per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
|
|
|
|
|
elseif ( 'categories_per_page' == $option )
|
|
|
|
|
$per_page = apply_filters( 'edit_categories_per_page', $per_page );
|
|
|
|
|
else
|
|
|
|
|
$per_page = apply_filters( $option, $per_page );
|
|
|
|
|
|
|
|
|
|
// Back compat
|
|
|
|
|
if ( isset( $screen->post_type ) )
|
|
|
|
|
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $screen->post_type );
|
|
|
|
|
|
|
|
|
|
$return = "<div class='screen-options'>\n";
|
|
|
|
|
if ( !empty($per_page_label) )
|
|
|
|
|
$return .= "<input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' /> <label for='$option'>$per_page_label</label>\n";
|
|
|
|
|
$return .= get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false );
|
|
|
|
|
$return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />";
|
|
|
|
|
$return .= "</div>\n";
|
|
|
|
|
return $return;
|
|
|
|
|
return $per_page_options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function screen_icon( $screen = '' ) {
|
|
|
|
@ -706,6 +481,52 @@ final class WP_Screen {
|
|
|
|
|
*/
|
|
|
|
|
public $taxonomy;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The help tab data associated with the screen, if any.
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
* @var array
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
public $help_tabs = array();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The help sidebar data associated with the screen, if any.
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
* @var string
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
public $help_sidebar = '';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The screen options associated with the screen, if any.
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
* @var array
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
public $options = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stores the result of the public show_screen_options function.
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
* @var bool
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
private $_show_screen_options;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stores the 'screen_settings' section of screen options.
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
* @var string
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
private $_screen_settings;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*
|
|
|
|
@ -800,7 +621,7 @@ final class WP_Screen {
|
|
|
|
|
* @param array $args Associative array of arguments particular to the given $option.
|
|
|
|
|
*/
|
|
|
|
|
public function add_option( $option, $args = array() ) {
|
|
|
|
|
return add_screen_option( $option, $args );
|
|
|
|
|
$this->options[ $option ] = $args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -809,14 +630,31 @@ final class WP_Screen {
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
*
|
|
|
|
|
* @param string $id Tab ID
|
|
|
|
|
* @param string $title Title for the tab
|
|
|
|
|
* @param string $content Help tab content in plain text or HTML.
|
|
|
|
|
* @param array $args
|
|
|
|
|
* - string - title - Title for the tab.
|
|
|
|
|
* - string - id - Tab ID. Optional.
|
|
|
|
|
* - string - content - Help tab content in plain text or HTML. Optional.
|
|
|
|
|
* - callback - callback - A callback to generate the tab content. Optional.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function add_help_tab( $id, $title, $content) {
|
|
|
|
|
global $_wp_contextual_help;
|
|
|
|
|
public function add_help_tab( $args ) {
|
|
|
|
|
$defaults = array(
|
|
|
|
|
'title' => false,
|
|
|
|
|
'id' => false,
|
|
|
|
|
'content' => '',
|
|
|
|
|
'callback' => false,
|
|
|
|
|
);
|
|
|
|
|
$args = wp_parse_args( $args, $defaults );
|
|
|
|
|
|
|
|
|
|
$_wp_contextual_help[$this->id]['tabs'][] = array( $id, $title, $content );
|
|
|
|
|
// Ensure we have a title.
|
|
|
|
|
if ( ! $args['title'] )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Create an id from the title if one is not provided.
|
|
|
|
|
if ( ! $args['id'] )
|
|
|
|
|
$args['id'] = sanitize_html_class( $args['title'] );
|
|
|
|
|
|
|
|
|
|
$this->help_tabs[] = $args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -828,8 +666,268 @@ final class WP_Screen {
|
|
|
|
|
* @param string $content Sidebar content in plain text or HTML.
|
|
|
|
|
*/
|
|
|
|
|
public function add_help_sidebar( $content ) {
|
|
|
|
|
$this->help_sidebar = $content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Render the screen's help section.
|
|
|
|
|
*
|
|
|
|
|
* This will trigger the deprecated filters for backwards compatibility.
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
*/
|
|
|
|
|
public function render_screen_meta() {
|
|
|
|
|
global $_wp_contextual_help;
|
|
|
|
|
|
|
|
|
|
$_wp_contextual_help[$this->id]['sidebar'] = $content;
|
|
|
|
|
// Call old contextual_help_list filter.
|
|
|
|
|
if ( ! isset( $_wp_contextual_help ) )
|
|
|
|
|
$_wp_contextual_help = array();
|
|
|
|
|
$_wp_contextual_help = apply_filters( 'contextual_help_list', $_wp_contextual_help, $this );
|
|
|
|
|
|
|
|
|
|
if ( isset( $_wp_contextual_help[ $this->id ] ) ) {
|
|
|
|
|
// Call old contextual_help filter.
|
|
|
|
|
$contextual_help = apply_filters( 'contextual_help', $_wp_contextual_help[ $this->id ], $this->id, $this );
|
|
|
|
|
|
|
|
|
|
$this->add_help_tab( array(
|
|
|
|
|
'title' => __('Screen Info'),
|
|
|
|
|
'content' => $contextual_help,
|
|
|
|
|
) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add screen options tab
|
|
|
|
|
if ( $this->show_screen_options() ) {
|
|
|
|
|
$this->add_help_tab( array(
|
|
|
|
|
'title' => __('Screen Options'),
|
|
|
|
|
'callback' => array( $this, 'render_screen_options' ),
|
|
|
|
|
) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Time to render!
|
|
|
|
|
?>
|
|
|
|
|
<div id="screen-meta" class='metabox-prefs'>
|
|
|
|
|
<div id="contextual-help-wrap" class="hidden">
|
|
|
|
|
<ul class="contextual-help-tabs">
|
|
|
|
|
<?php foreach ( $this->help_tabs as $i => $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" ); ?>">
|
|
|
|
|
<?php echo esc_html( $tab['title'] ); ?>
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div class="contextual-help-sidebar">
|
|
|
|
|
<?php echo $this->help_sidebar; ?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="contextual-help-tabs-wrap">
|
|
|
|
|
<?php foreach ( $this->help_tabs as $i => $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 ); ?>">
|
|
|
|
|
<h3><?php echo esc_html( $tab['title'] ); ?></h3>
|
|
|
|
|
<?php
|
|
|
|
|
// Print tab content.
|
|
|
|
|
echo $tab['content'];
|
|
|
|
|
|
|
|
|
|
// If it exists, fire tab callback.
|
|
|
|
|
if ( ! empty( $tab['callback'] ) )
|
|
|
|
|
call_user_func( $tab['callback'], $this );
|
|
|
|
|
?>
|
|
|
|
|
</div>
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function show_screen_options() {
|
|
|
|
|
global $wp_meta_boxes, $wp_list_table;
|
|
|
|
|
|
|
|
|
|
if ( is_bool( $this->_show_screen_options ) )
|
|
|
|
|
return $this->_show_screen_options;
|
|
|
|
|
|
|
|
|
|
$columns = get_column_headers( $this );
|
|
|
|
|
|
|
|
|
|
$show_screen = false;
|
|
|
|
|
if ( ! empty( $wp_meta_boxes[ $this->id ] ) || ! empty( $columns ) )
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
|
|
|
|
|
// Check if there are per-page options.
|
|
|
|
|
$show_screen = $show_screen || isset( $this->options['per_page'] );
|
|
|
|
|
|
|
|
|
|
$this->_screen_settings = apply_filters( 'screen_settings', '', $this );
|
|
|
|
|
|
|
|
|
|
switch ( $this->id ) {
|
|
|
|
|
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";
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( ! empty( $this->_screen_settings ) )
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
|
|
|
|
|
if ( ! empty( $this->options ) )
|
|
|
|
|
$show_screen = true;
|
|
|
|
|
|
|
|
|
|
$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
|
|
|
|
|
return $this->_show_screen_options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Render the screen options tab.
|
|
|
|
|
*
|
|
|
|
|
* @since 3.3.0
|
|
|
|
|
*/
|
|
|
|
|
public function render_screen_options() {
|
|
|
|
|
global $wp_meta_boxes, $wp_list_table;
|
|
|
|
|
|
|
|
|
|
$columns = get_column_headers( $this );
|
|
|
|
|
$hidden = get_hidden_columns( $this );
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
<form id="adv-settings" action="" method="post">
|
|
|
|
|
<?php if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?>
|
|
|
|
|
<h5><?php _ex('Show on screen', 'Metaboxes') ?></h5>
|
|
|
|
|
<div class="metabox-prefs">
|
|
|
|
|
<?php meta_box_prefs( $this ); ?>
|
|
|
|
|
<br class="clear" />
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif;
|
|
|
|
|
if ( ! empty( $columns ) ) : ?>
|
|
|
|
|
<h5><?php echo ( isset( $columns['_title'] ) ? $columns['_title'] : _x('Show on screen', 'Columns') ) ?></h5>
|
|
|
|
|
<div class="metabox-prefs">
|
|
|
|
|
<?php
|
|
|
|
|
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
|
|
|
|
|
|
|
|
|
|
foreach ( $columns as $column => $title ) {
|
|
|
|
|
// Can't hide these for they are special
|
|
|
|
|
if ( in_array( $column, $special ) )
|
|
|
|
|
continue;
|
|
|
|
|
if ( empty( $title ) )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if ( 'comments' == $column )
|
|
|
|
|
$title = __( 'Comments' );
|
|
|
|
|
$id = "$column-hide";
|
|
|
|
|
echo '<label for="' . $id . '">';
|
|
|
|
|
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';
|
|
|
|
|
echo "$title</label>\n";
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<br class="clear" />
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif;
|
|
|
|
|
|
|
|
|
|
$this->render_screen_layout();
|
|
|
|
|
$this->render_per_page_options();
|
|
|
|
|
echo $this->_screen_settings;
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
|
|
|
|
|
</form>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 ] ) )
|
|
|
|
|
add_screen_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
|
|
|
|
|
|
|
|
|
|
if ( ! isset( $this->options['layout_columns'] ) ) {
|
|
|
|
|
$screen_layout_columns = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$screen_layout_columns = get_user_option("screen_layout_$this->id");
|
|
|
|
|
$num = $this->options['layout_columns']['max'];
|
|
|
|
|
|
|
|
|
|
if ( ! $screen_layout_columns ) {
|
|
|
|
|
if ( isset( $this->options['layout_columns']['default'] ) )
|
|
|
|
|
$screen_layout_columns = $this->options['layout_columns']['default'];
|
|
|
|
|
else
|
|
|
|
|
$screen_layout_columns = 'auto';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
<h5><?php _e('Screen Layout'); ?></h5>
|
|
|
|
|
<div class='columns-prefs'><?php
|
|
|
|
|
_e('Number of Columns:');
|
|
|
|
|
for ( $i = 1; $i <= $num; ++$i ):
|
|
|
|
|
?>
|
|
|
|
|
<label>
|
|
|
|
|
<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
|
|
|
|
|
<?php checked( $screen_layout_columns, $i ); ?> />
|
|
|
|
|
<?php echo esc_html( $i ); ?>
|
|
|
|
|
</label>
|
|
|
|
|
<?php
|
|
|
|
|
endfor; ?>
|
|
|
|
|
<label>
|
|
|
|
|
<input type='radio' id='wp_auto_columns' name='screen_columns' value='auto'
|
|
|
|
|
<?php checked( $screen_layout_columns, 'auto' ); ?> />
|
|
|
|
|
<?php esc_html_e('Auto'); ?>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function render_per_page_options() {
|
|
|
|
|
if ( ! isset( $this->options['per_page'] ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
$per_page_label = $this->options['per_page']['label'];
|
|
|
|
|
|
|
|
|
|
if ( empty( $this->options['per_page']['option'] ) ) {
|
|
|
|
|
$option = str_replace( '-', '_', "{$this->id}_per_page" );
|
|
|
|
|
} else {
|
|
|
|
|
$option = $this->options['per_page']['option'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$per_page = (int) get_user_option( $option );
|
|
|
|
|
if ( empty( $per_page ) || $per_page < 1 ) {
|
|
|
|
|
if ( isset($this->options['per_page']['default']) )
|
|
|
|
|
$per_page = $this->options['per_page']['default'];
|
|
|
|
|
else
|
|
|
|
|
$per_page = 20;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( 'edit_comments_per_page' == $option ) {
|
|
|
|
|
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
|
|
|
|
|
$per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
|
|
|
|
|
} elseif ( 'categories_per_page' == $option ) {
|
|
|
|
|
$per_page = apply_filters( 'edit_categories_per_page', $per_page );
|
|
|
|
|
} else {
|
|
|
|
|
$per_page = apply_filters( $option, $per_page );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Back compat
|
|
|
|
|
if ( isset( $this->post_type ) )
|
|
|
|
|
$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='$option' maxlength='3' value='$per_page' /> <label for='$option'>$per_page_label</label>
|
|
|
|
|
<?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); ?>' />
|
|
|
|
|
</div>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
}
|