Make WordPress Core


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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' ),
Note: See TracChangeset for help on using the changeset viewer.