Make WordPress Core

Changeset 18941


Ignore:
Timestamp:
10/11/2011 07:29:09 PM (14 years ago)
Author:
nacin
Message:

Enforce IDs for add_help_tab(). props mbijon. Restore default_contextual_help, for now. see #18785.

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r18911 r18941  
    190190
    191191    $current_screen->add_help_tab( array(
     192        'id'      => 'publish-box',
    192193        'title'   => __('Publish Box'),
    193194        'content' => $publish_box,
     
    198199
    199200    $current_screen->add_help_tab( array(
     201        'id'      => 'discussion-settings',
    200202        'title'   => __('Discussion Settings'),
    201203        'content' => $discussion_settings,
     
    209211    );
    210212} elseif ( 'page' == $post_type ) {
    211     $current_screen->add_help_tab( 'about-pages', __('About Pages'), '<p>' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the &#8220;Parent&#8221; of the other, creating a group of Pages.') . '</p>' .
    212                 '<p>' . __('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the new in 3.2 distraction-free writing space, available in both the Visual and HTML modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box:') . '</p>' );
    213     $current_screen->add_help_tab('page-attributes', ('Page Attributes'),
    214                 '<p>' . __('<strong>Parent</strong> - You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.') . '</p>' .
    215                 '<p>' . __('<strong>Template</strong> - Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.') . '</p>' .
    216                 '<p>' . __('<strong>Order</strong> - Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '</p>' );
     213    $about_pages = '<p>' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the &#8220;Parent&#8221; of the other, creating a group of Pages.') . '</p>' .
     214        '<p>' . __('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the new in 3.2 distraction-free writing space, available in both the Visual and HTML modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box:') . '</p>';
     215   
     216    $current_screen->add_help_tab( array(
     217        'id'      => 'about-pages',
     218        'title'   => __('About Pages'),
     219        'content' => $about_pages,
     220    ) );
     221   
     222    $page_attributes = '<p>' . __('<strong>Parent</strong> - You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.') . '</p>' .
     223        '<p>' . __('<strong>Template</strong> - Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.') . '</p>' .
     224        '<p>' . __('<strong>Order</strong> - Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '</p>';
     225   
     226    $current_screen->add_help_tab( array(
     227        'id' => 'page-attributes',
     228        'title' => __('Page Attributes'),
     229        'content' => $page_attributes,
     230    ) );
     231   
    217232    $current_screen->add_help_sidebar(
    218233            '<p><strong>' . __('For more information:') . '</strong></p>' .
  • trunk/wp-admin/includes/screen.php

    r18915 r18941  
    591591     * @param array $args
    592592     * - string   - title    - Title for the tab.
    593      * - string   - id       - Tab ID. Optional.
     593     * - string   - id       - Tab ID. Must be HTML-safe.
    594594     * - string   - content  - Help tab content in plain text or HTML. Optional.
    595595     * - callback - callback - A callback to generate the tab content. Optional.
     
    605605        $args = wp_parse_args( $args, $defaults );
    606606
    607         // Ensure we have a title.
    608         if ( ! $args['title'] )
     607        $args['id'] = sanitize_html_class( $args['id'] );
     608
     609        // Ensure we have an ID and title.
     610        if ( ! $args['id'] || ! $args['title'] )
    609611            return;
    610 
    611         // Create an id from the title if one is not provided.
    612         if ( ! $args['id'] )
    613             $args['id'] = sanitize_html_class( $args['title'] );
    614612
    615613        $this->_help_tabs[] = $args;
     
    643641        $_wp_contextual_help = apply_filters( 'contextual_help_list', $_wp_contextual_help, $this );
    644642
    645         if ( isset( $_wp_contextual_help[ $this->id ] ) ) {
     643        if ( isset( $_wp_contextual_help[ $this->id ] ) || ! $this->_help_tabs ) {
    646644            // Call old contextual_help filter.
    647             $contextual_help = apply_filters( 'contextual_help', $_wp_contextual_help[ $this->id ], $this->id, $this );
     645            if ( isset( $_wp_contextual_help[ $this->id ] ) )
     646                $contextual_help = apply_filters( 'contextual_help', $_wp_contextual_help[ $this->id ], $this->id, $this );
     647
     648            if ( empty( $contextual_help ) ) {
     649                $default_help = __( '<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>' );
     650                $default_help .= '<br />';
     651                $default_help .= __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' );
     652                $contextual_help = '<p>' . apply_filters( 'default_contextual_help', $default_help ) . '</p>';
     653            }
    648654
    649655            $this->add_help_tab( array(
     656                'id'      => 'contextual-help',
    650657                'title'   => __('Screen Info'),
    651658                'content' => $contextual_help,
     
    656663        if ( $this->show_screen_options() ) {
    657664            $this->add_help_tab( array(
     665                'id'       => 'screen-options',
    658666                'title'    => __('Screen Options'),
    659667                'callback' => array( $this, 'render_screen_options' ),
  • trunk/wp-admin/index.php

    r18914 r18941  
    3737
    3838$current_screen->add_help_tab( array(
     39        'id'      => 'help-navigation',
    3940    'title'   => __('Navigation'),
    4041    'content' => $help_navigation,
     
    4748
    4849$current_screen->add_help_tab( array(
     50        'id'      => 'help-layout',
    4951    'title'   => __('Layout'),
    5052    'content' => $help_layout,
     
    6264
    6365$current_screen->add_help_tab( array(
     66        'id'      => 'help-content',
    6467    'title'   => __('Content'),
    6568    'content' => $help_content,
Note: See TracChangeset for help on using the changeset viewer.