git-svn-id: https://develop.svn.wordpress.org/trunk@18853 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1aad45debc
commit
a5acbaa574
|
@ -117,7 +117,8 @@ $current_screen->set_parentage( $parent_file );
|
|||
|
||||
<div id="wpbody-content">
|
||||
<?php
|
||||
screen_meta($current_screen);
|
||||
|
||||
$current_screen->render_screen_meta();
|
||||
|
||||
if ( is_network_admin() )
|
||||
do_action('network_admin_notices');
|
||||
|
|
|
@ -164,12 +164,20 @@ $current_screen->add_option('layout_columns', array('max' => 2, 'default' => 'au
|
|||
if ( 'post' == $post_type ) {
|
||||
$customize_display = '<p>' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '</p>';
|
||||
|
||||
$current_screen->add_help_tab( 'customize-display', __('Customizing This Display'), $customize_display );
|
||||
$current_screen->add_help_tab( array(
|
||||
'id' => 'customize-display',
|
||||
'title' => __('Customizing This Display'),
|
||||
'content' => $customize_display,
|
||||
) );
|
||||
|
||||
$title_and_editor = '<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.') . '</p>';
|
||||
$title_and_editor .= '<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions. You can go the distraction-free writing screen, new in 3.2, via the Fullscreen icon in Visual mode (second to last in the top row) or the Fullscreen button in HTML mode (last in the row). Once there, you can make buttons visible by hovering over the top area. Exit Fullscreen back to the regular post editor.') . '</p>';
|
||||
|
||||
$current_screen->add_help_tab( 'title-post-editor', __('Title and Post Editor'), $title_and_editor );
|
||||
$current_screen->add_help_tab( array(
|
||||
'id' => 'title-post-editor',
|
||||
'title' => __('Title and Post Editor'),
|
||||
'content' => $title_and_editor,
|
||||
) );
|
||||
|
||||
$publish_box = '<p>' . __('<strong>Publish</strong> - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '</p>';
|
||||
|
||||
|
@ -181,12 +189,18 @@ if ( 'post' == $post_type ) {
|
|||
$publish_box .= '<p>' . __('<strong>Featured Image</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '</p>';
|
||||
}
|
||||
|
||||
$current_screen->add_help_tab( 'publish-box', __('Publish Box'), $publish_box );
|
||||
$current_screen->add_help_tab( array(
|
||||
'title' => __('Publish Box'),
|
||||
'content' => $publish_box,
|
||||
) );
|
||||
|
||||
$discussion_settings = '<p>' . __('<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>';
|
||||
$discussion_settings .= '<p>' . __('<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>';
|
||||
|
||||
$current_screen->add_help_tab( 'discussion-settings', __('Discussion Settings'), $discussion_settings );
|
||||
$current_screen->add_help_tab( array(
|
||||
'title' => __('Discussion Settings'),
|
||||
'content' => $discussion_settings,
|
||||
) );
|
||||
|
||||
$current_screen->add_help_sidebar(
|
||||
'<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
|
||||
|
|
|
@ -897,9 +897,14 @@ class WP_List_Table {
|
|||
* @access private
|
||||
*/
|
||||
function _js_vars() {
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
$args = array(
|
||||
'class' => get_class( $this ),
|
||||
'screen' => get_current_screen()
|
||||
'class' => get_class( $this ),
|
||||
'screen' => array(
|
||||
'id' => $current_screen->id,
|
||||
'base' => $current_screen->base,
|
||||
)
|
||||
);
|
||||
|
||||
printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
|
||||
|
|
|
@ -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 $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
|
||||
* @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
|
||||
}
|
||||
}
|
|
@ -32,19 +32,28 @@ else
|
|||
|
||||
$help_overview = '<p>' . __('Welcome to your WordPress Dashboard! This is the screen you will see when you log in to your site, and gives you access to all the site management features of WordPress. You can get help for any screen by clicking the Help tab in the top bar.') . '</p>';
|
||||
|
||||
$current_screen->add_help_tab( 'overview', __('Overview'), $help_overview );
|
||||
$current_screen->add_help_tab( array(
|
||||
'title' => __('Overview'),
|
||||
'content' => $help_overview,
|
||||
) );
|
||||
|
||||
$help_navigation = '<p>' . __('The left-hand navigation menu provides links to all of the WordPress administration screens, with submenu items displayed on hover. You can minimize this menu to a narrow icon strip by clicking on the Collapse Menu arrow at the bottom.') . '</p>';
|
||||
$help_navigation .= '<p>' . __('Links in the “admin bar” at the top of the screen connect your dashboard and the front end of your site, and provide access to your profile and helpful WordPress information.') . '</p>';
|
||||
|
||||
$current_screen->add_help_tab( 'navigation', __('Navigation'), $help_navigation );
|
||||
$current_screen->add_help_tab( array(
|
||||
'title' => __('Navigation'),
|
||||
'content' => $help_navigation,
|
||||
) );
|
||||
|
||||
$help_layout = '<p>' . __('You can use the following controls to arrange your Dashboard screen to suit your workflow. This is true on most other administration screens as well.') . '</p>';
|
||||
$help_layout .= '<p>' . __('<strong>Screen Options</strong> - Use the Screen Options tab to choose which Dashboard boxes to show, and how many columns to display.') . '</p>';
|
||||
$help_layout .= '<p>' . __('<strong>Drag and Drop</strong> - To rearrange the boxes, drag and drop by clicking on the title bar of the selected box and releasing when you see a gray dotted-line rectangle appear in the location you want to place the box.') . '</p>';
|
||||
$help_layout .= '<p>' . __('<strong>Box Controls</strong> - Click the title bar of the box to expand or collapse it. In addition, some box have configurable content, and will show a “Configure” link in the title bar if you hover over it.') . '</p>';
|
||||
|
||||
$current_screen->add_help_tab( 'layout', __('Layout'), $help_layout );
|
||||
$current_screen->add_help_tab( array(
|
||||
'title' => __('Layout'),
|
||||
'content' => $help_layout,
|
||||
) );
|
||||
|
||||
$help_content = '<p>' . __('The boxes on your Dashboard screen are:') . '</p>';
|
||||
$help_content .= '<p>' . __('<strong>Right Now</strong> - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.') . '</p>';
|
||||
|
@ -56,7 +65,10 @@ $help_content .= '<p>' . __('<strong>WordPress Blog</strong> - Latest news from
|
|||
$help_content .= '<p>' . __('<strong>Other WordPress News</strong> - Shows the <a href="http://planet.wordpress.org" target="_blank">WordPress Planet</a> feed. You can configure it to show a different feed of your choosing.') . '</p>';
|
||||
$help_content .= '<p>' . __('<strong>Plugins</strong> - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.') . '</p>';
|
||||
|
||||
$current_screen->add_help_tab( 'content', __('Content'), $help_content );
|
||||
$current_screen->add_help_tab( array(
|
||||
'title' => __('Content'),
|
||||
'content' => $help_content,
|
||||
) );
|
||||
|
||||
$current_screen->add_help_sidebar(
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
|
|
|
@ -266,7 +266,7 @@ $('.contextual-help-tabs').delegate('a', 'click focus', function(e) {
|
|||
panel.addClass('active').show();
|
||||
|
||||
// Adjust the height of the help columns
|
||||
columns = $('#contextual-help-wrap').children('.metabox-prefs').children();
|
||||
columns = $('#contextual-help-wrap').children();
|
||||
columns.height('auto');
|
||||
|
||||
height = Math.max.apply( null, $.map( columns, function( el ) { return $(el).height(); }) );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -576,22 +576,6 @@ function wp_admin_bar_updates_menu( $wp_admin_bar ) {
|
|||
$wp_admin_bar->add_menu( array( 'id' => 'updates', 'title' => $update_title, 'href' => network_admin_url( 'update-core.php' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add screen options link.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*/
|
||||
function wp_admin_bar_screen_options_menu( $wp_admin_bar ) {
|
||||
$wp_admin_bar->add_menu( array(
|
||||
'id' => 'screen-options',
|
||||
'title' => __('Screen Options'),
|
||||
'href' => '#',
|
||||
'meta' => array(
|
||||
'class' => 'screen-meta-toggle hide-if-no-js',
|
||||
),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add help link.
|
||||
*
|
||||
|
|
|
@ -61,7 +61,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
|
||||
|
||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110927', 1 );
|
||||
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20110930', 1 );
|
||||
$scripts->add_script_data( 'common', 'commonL10n', array(
|
||||
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.")
|
||||
) );
|
||||
|
|
Loading…
Reference in New Issue