Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/18/2012 02:49:20 AM (7 years ago)
Author:
johnjamesjacoby
Message:

Refactor forum/topic/reply contextual help, shamelessly sampled from the WordPress 'post' content type. See #1699.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-topics.php

    r3660 r3686  
    4242        $this->setup_globals();
    4343        $this->setup_actions();
    44         $this->setup_help();
    4544    }
    4645
     
    8786        add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown'  ) );
    8887        add_filter( 'request',               array( $this, 'filter_post_rows' ) );
     88
     89        // Contextual Help
     90        add_action( 'load-edit.php',     array( $this, 'edit_help' ) );
     91        add_action( 'load-post-new.php', array( $this, 'new_help'  ) );
    8992    }
    9093
     
    101104    }
    102105
    103     /**
    104      * Contextual help for topics
     106    /** Contextual Help *******************************************************/
     107
     108    /**
     109     * Contextual help for bbPress topic edit page
    105110     *
    106111     * @since bbPress (r3119)
    107      * @access private
    108      */
    109     function setup_help() {
    110 
    111         // Define local variable(s)
    112         $contextual_help     = '';
    113         $bbp_contextual_help = array();
    114 
    115         /** New/Edit **********************************************************/
    116 
    117         $bbp_contextual_help[] = __( 'The topic title field and the big topic 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 the box. Use the Screen Options tab to unhide more boxes (Topic Tags, Topic Attributes, or Slug) or to choose a 1- or 2-column layout for this screen.', 'bbpress' );
    118         $bbp_contextual_help[] = __( '<strong>Title</strong> - Enter a title for your topic. After you enter a title, you will see the permalink below, which you can edit.', 'bbpress' );
    119         $bbp_contextual_help[] = __( '<strong>Post editor</strong> - Enter the text for your topic. 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 screen icon just before that allows you to expand the edit box to full screen. The HTML mode allows you to enter raw HTML along with your forum text. You can insert media files by clicking the icons above the post editor and following the directions.', 'bbpress' );
    120         $bbp_contextual_help[] = __( '<strong>Topic Attributes</strong> - Select the attributes that your topic should have. The Forum dropdown determines the parent forum that the topic belongs to. Select the forum or category from the dropdown, or leave the default (No Forum) to post the topic without an assigned forum. The topic type drop down indicates the sticky status of the topic. Selecting the super sticky option would stick the topic to the front of your forums, i.e. the topic index, sticky option would stick the topic to its respective forum. Selecting normal would not stick the topic anywhere.', 'bbpress' );
    121         $bbp_contextual_help[] = __( '<strong>Publish</strong> - The Publish box will allow you to save your topic as Draft or Pending Review. You may Preview your topic before it is published as well. The Visibility will determine whether the topic is Public, Password protected (requiring a password on the site to view) or Private (only the author will have access to it). Topics may be published immediately by clicking the dropdown, or at a specific date and time by clicking the Edit link.', 'bbpress' );
    122         $bbp_contextual_help[] = __( '<strong>Topic Tags</strong> - You can assign keywords to your topics using Topic Tags. Unlike categories, tags have no hierarchy, meaning there is no relationship from one tag to another. Topics can be added and modified further from the Topic Tags screen.', 'bbpress' );
    123         $bbp_contextual_help[] = __( '<strong>Revisions</strong> - Revisions show past versions of the saved topic. Each revision can be compared to the current version, or another revision. Revisions can also be restored to the current version.', 'bbpress' );
    124         $bbp_contextual_help[] = __( '<strong>For more information:</strong>', 'bbpress' );
    125         $bbp_contextual_help[] =
    126             '<ul>' .
    127                 '<li>' . __( '<a href="http://bbpress.org/documentation/">bbPress Documentation</a>', 'bbpress' ) . '</li>' .
    128                 '<li>' . __( '<a href="http://bbpress.org/forums/">bbPress Support Forums</a>',       'bbpress' ) . '</li>' .
    129             '</ul>';
    130 
    131         // Wrap each help item in paragraph tags
    132         foreach( $bbp_contextual_help as $paragraph )
    133             $contextual_help .= '<p>' . $paragraph . '</p>';
    134 
    135         // Add help
    136         add_contextual_help( bbp_get_topic_post_type(), $contextual_help );
    137 
    138         // Reset
    139         $contextual_help     = '';
    140         $bbp_contextual_help = array();
    141 
    142         /** Post Rows *********************************************************/
    143 
    144         $bbp_contextual_help[] = __( 'This screen displays the topics created on your site.',             'bbpress' );
    145         $bbp_contextual_help[] = __( 'You can customize the display of this screen in a number of ways:', 'bbpress' );
    146         $bbp_contextual_help[] =
    147             '<ul>' .
    148                 '<li>' . __( 'You can hide/display columns based on your needs and decide how many topics to list per screen using the Screen Options tab.',                                                                             'bbpress' ) . '</li>' .
    149                 '<li>' . __( 'You can filter the list of topics by topics status using the text links in the upper left to show All, Published, Pending Review, Draft, or Trashed topics. The default view is to show all topics.',      'bbpress' ) . '</li>' .
    150                 '<li>' . __( 'You can view topics in a simple title list or with an excerpt. Choose the view you prefer by clicking on the icons at the top of the list on the right.',                                                  'bbpress' ) . '</li>' .
    151                 '<li>' . __( 'You can refine the list to show only topics from a specific month by using the dropdown menus above the topics list. Click the Filter button after making your selection.',                                'bbpress' ) . '</li>' .
    152                 '<li>' . __( 'You can also show only topics from a specific parent forum by using the parent forum dropdown above the topics list and selecting the parent forum. Click the Filter button after making your selection.', 'bbpress' ) . '</li>' .
    153                 '<li>' . __( 'You can refine the list by clicking on the topic creator in the topics list.', 'bbpress' ) . '</li>' .
    154             '</ul>' .
    155 
    156         $bbp_contextual_help[] = __( 'Hovering over a row in the topics list will display action links that allow you to manage your topic. You can perform the following actions:', 'bbpress' );
    157         $bbp_contextual_help[] =
    158             '<ul>' .
    159                 '<li>' . __( 'Edit takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.',                                                                            'bbpress' ) . '</li>' .
    160                 '<li>' . __( 'Trash removes your topic from this list and places it in the trash, from which you can permanently delete it.',                                                                                  'bbpress' ) . '</li>' .
    161                 '<li>' . __( 'View will take you to your live topic to view the topic.',                                                                                                                                       'bbpress' ) . '</li>' .
    162                 '<li>' . __( 'Close will close your topic, disabling new replies within it. It will remain viewable to users, but replies will not be allowed.',                                                               'bbpress' ) . '</li>' .
    163                 '<li>' . __( 'Stick (to front) will pin the topic to the front page of the forum that it&rsquo;s in. New topics will begin beneath the list of "stuck" topics, which will always sit at the top of the list.', 'bbpress' ) . '</li>' .
    164                 '<li>' . __( 'Spam will mark the topic as spam, closing the post to new replies and removing it from the public view.',                                                                                        'bbpress' ) . '</li>' .
    165             '</ul>' .
    166 
    167         $bbp_contextual_help[] = __( 'You can also edit multiple topics at once. Select the topics you want to edit using the checkboxes, select Edit from the Bulk Actions menu and click Apply. You will be able to change the metadata for all selected topics at once. To remove a topic from the grouping, just click the x next to its name in the Bulk Edit area that appears.', 'bbpress' );
    168         $bbp_contextual_help[] = __( 'The Bulk Actions menu may also be used to delete multiple topics at once. Select Delete from the dropdown after making your selection.', 'bbpress' );
    169         $bbp_contextual_help[] = __( '<strong>For more information:</strong>', 'bbpress' );
    170         $bbp_contextual_help[] =
    171             '<ul>' .
    172                 '<li>' . __( '<a href="http://bbpress.org/documentation/">bbPress Documentation</a>', 'bbpress' ) . '</li>' .
    173                 '<li>' . __( '<a href="http://bbpress.org/forums/">bbPress Support Forums</a>'      , 'bbpress' ) . '</li>' .
    174             '</ul>';
    175 
    176         // Wrap each help item in paragraph tags
    177         foreach( $bbp_contextual_help as $paragraph )
    178             $contextual_help .= '<p>' . $paragraph . '</p>';
    179 
    180         // Add help
    181         add_contextual_help( 'edit-' . bbp_get_topic_post_type(), $contextual_help );
    182 
    183         // Reset
    184         $contextual_help = '';
    185         $bbp_contextual_help = array();
    186 
    187         /** Topic Tags **********************************************************/
    188 
    189         $bbp_contextual_help[] = __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen (20 by default) and to display/hide columns in the table (Description, Slug, and Topics).', 'bbpress' );
    190         $bbp_contextual_help[] = __( 'You can assign keywords to your topics using Topic Tags. Unlike categories, tags have no hierarchy, meaning there is no relationship from one tag to another.', 'bbpress' );
    191         $bbp_contextual_help[] = __( 'Normally, tags are ad-hoc keywords that identify important information in your topic (names, subjects, etc) that may or may not recur in other topics. If you think of your forum like a book, the tags are like the terms in the index.', 'bbpress' );
    192         $bbp_contextual_help[] = __( 'When editing a topic tag on this screen, you will fill in the following fields:', 'bbpress' );
    193         $bbp_contextual_help[] =
    194             '<ul>' .
    195                 '<li>' . __( '<strong>Name</strong> - The name is how it appears on your site.',                                                                                       'bbpress' ) . '</li>' .
    196                 '<li>' . __( '<strong>Slug</strong> - The Slug is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'bbpress' ) . '</li>' .
    197                 '<li>' . __( '<strong>Description</strong> - The description is not prominent by default; however, some forum themes may display it.',                                 'bbpress' ) . '</li>' .
    198             '</ul>' ;
    199 
    200         // Wrap each help item in paragraph tags
    201         foreach( $bbp_contextual_help as $paragraph )
    202             $contextual_help .= '<p>' . $paragraph . '</p>';
    203 
    204         // Add help
    205         add_contextual_help( 'edit-' . bbp_get_topic_tag_tax_id(), $contextual_help );
     112     * @uses get_current_screen()
     113     */
     114    public function edit_help() {
     115
     116        $current_screen = get_current_screen();
     117        $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
     118
     119        // Bail if current screen could not be found
     120        if ( empty( $current_screen ) )
     121            return;
     122
     123        // Bail if not the topic post type
     124        if ( $post_type != $this->post_type )
     125            return;
     126
     127        // Overview
     128        $current_screen->add_help_tab( array(
     129            'id'        => 'overview',
     130            'title'     => __( 'Overview', 'bbpress' ),
     131            'content'   =>
     132                '<p>' . __( 'This screen provides access to all of your replies. You can customize the display of this screen to suit your workflow.', 'bbpress' ) . '</p>'
     133        ) );
     134
     135        // Screen Content
     136        $current_screen->add_help_tab( array(
     137            'id'        => 'screen-content',
     138            'title'     => __( 'Screen Content', 'bbpress' ),
     139            'content'   =>
     140                '<p>' . __( 'You can customize the display of this screen&#8217;s contents in a number of ways:' ) . '</p>' .
     141                '<ul>' .
     142                    '<li>' . __( 'You can hide/display columns based on your needs and decide how many replies to list per screen using the Screen Options tab.',                                                                                                                                                                          'bbpress' ) . '</li>' .
     143                    '<li>' . __( 'You can filter the list of replies by topic status using the text links in the upper left to show All, Published, Draft, or Trashed replies. The default view is to show all replies.',                                                                                                                   'bbpress' ) . '</li>' .
     144                    '<li>' . __( 'You can view replies in a simple title list or with an excerpt. Choose the view you prefer by clicking on the icons at the top of the list on the right.',                                                                                                                                             'bbpress' ) . '</li>' .
     145                    '<li>' . __( 'You can refine the list to show only replies in a specific category or from a specific month by using the dropdown menus above the replies list. Click the Filter button after making your selection. You also can refine the list by clicking on the topic author, category or tag in the replies list.', 'bbpress' ) . '</li>' .
     146                '</ul>'
     147        ) );
     148
     149        // Available Actions
     150        $current_screen->add_help_tab( array(
     151            'id'        => 'action-links',
     152            'title'     => __( 'Available Actions', 'bbpress' ),
     153            'content'   =>
     154                '<p>' . __( 'Hovering over a row in the replies list will display action links that allow you to manage your topic. You can perform the following actions:', 'bbpress' ) . '</p>' .
     155                '<ul>' .
     156                    '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.',                                                                                 'bbpress' ) . '</li>' .
     157                    //'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your topic, allowing you to update topic details without leaving this screen.',                                                                  'bbpress' ) . '</li>' .
     158                    '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.',                                                                                       'bbpress' ) . '</li>' .
     159                    '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.',                                                                                   'bbpress' ) . '</li>' .
     160                    '<li>' . __( '<strong>Preview</strong> will show you what your draft topic will look like if you publish it. View will take you to your live site to view the topic. Which link is available depends on your topic&#8217;s status.', 'bbpress' ) . '</li>' .
     161                '</ul>'
     162        ) );
     163
     164        // Bulk Actions
     165        $current_screen->add_help_tab( array(
     166            'id'        => 'bulk-actions',
     167            'title'     => __( 'Bulk Actions', 'bbpress' ),
     168            'content'   =>
     169                '<p>' . __( 'You can also edit or move multiple replies to the trash at once. Select the replies you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.',           'bbpress' ) . '</p>' .
     170                '<p>' . __( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected replies at once. To remove a topic from the grouping, just click the x next to its name in the Bulk Edit area that appears.', 'bbpress' ) . '</p>'
     171        ) );
     172
     173        // Help Sidebar
     174        $current_screen->set_help_sidebar(
     175            '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     176            '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
     177            '<p>' . __( '<a href="http://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>',       'bbpress' ) . '</p>'
     178        );
     179    }
     180
     181    /**
     182     * Contextual help for bbPress topic edit page
     183     *
     184     * @since bbPress (r3119)
     185     * @uses get_current_screen()
     186     */
     187    public function new_help() {
     188
     189        $current_screen = get_current_screen();
     190        $post_type      = !empty( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : '';
     191
     192        // Bail if current screen could not be found
     193        if ( empty( $current_screen ) )
     194            return;
     195
     196        // Bail if not the topic post type
     197        if ( $post_type != $this->post_type )
     198            return;
     199
     200        $customize_display = '<p>' . __( 'The title field and the big topic 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.', 'bbpress' ) . '</p>';
     201
     202        $current_screen->add_help_tab( array(
     203            'id'      => 'customize-display',
     204            'title'   => __( 'Customizing This Display', 'bbpress' ),
     205            'content' => $customize_display,
     206        ) );
     207
     208        $current_screen->add_help_tab( array(
     209            'id'      => 'title-topic-editor',
     210            'title'   => __( 'Title and Topic Editor', 'bbpress' ),
     211            'content' =>
     212                '<p>' . __( '<strong>Title</strong> - Enter a title for your topic. After you enter a title, you&#8217;ll see the permalink below, which you can edit.', 'bbpress' ) . '</p>' .
     213                '<p>' . __( '<strong>Topic Editor</strong> - Enter the text for your topic. 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 topic text. You can insert media files by clicking the icons above the topic editor and following the directions. You can go to the distraction-free writing screen 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 topic editor.', 'bbpress' ) . '</p>'
     214        ) );
     215
     216        $publish_box = '<p>' . __( '<strong>Publish</strong> - You can set the terms of publishing your topic 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 topic 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 topic to be published in the future or backdate a topic.', 'bbpress' ) . '</p>';
     217
     218        if ( current_theme_supports( 'topic-formats' ) && topic_type_supports( 'topic', 'topic-formats' ) ) {
     219            $publish_box .= '<p>' . __( '<strong>topic Format</strong> - This designates how your theme will display a specific topic. For example, you could have a <em>standard</em> blog topic with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="http://codex.wordpress.org/topic_Formats#Supported_Formats">descriptions of each topic format</a>. Your theme could enable all or some of 10 possible formats.', 'bbpress' ) . '</p>';
     220        }
     221
     222        if ( current_theme_supports( 'topic-thumbnails' ) && topic_type_supports( 'topic', 'thumbnail' ) ) {
     223            $publish_box .= '<p>' . __( '<strong>Featured Image</strong> - This allows you to associate an image with your topic without inserting it. This is usually useful only if your theme makes use of the featured image as a topic thumbnail on the home page, a custom header, etc.', 'bbpress' ) . '</p>';
     224        }
     225
     226        $current_screen->add_help_tab( array(
     227            'id'      => 'publish-box',
     228            'title'   => __( 'Publish Box', 'bbpress' ),
     229            'content' => $publish_box,
     230        ) );
     231
     232        $current_screen->add_help_tab( array(
     233            'id'      => 'discussion-settings',
     234            'title'   => __( 'Discussion Settings', 'bbpress' ),
     235            'content' =>
     236                '<p>' . __( '<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.', 'bbpress' ) . '</p>' .
     237                '<p>' . __( '<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the topic, you can see them here and moderate them.', 'bbpress' ) . '</p>'
     238        ) );
     239
     240        $current_screen->set_help_sidebar(
     241            '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' .
     242            '<p>' . __( '<a href="http://bbpress.org/documentation/" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' .
     243            '<p>' . __( '<a href="http://bbpress.org/forums/" target="_blank">bbPress Support Forums</a>',       'bbpress' ) . '</p>'
     244        );
    206245    }
    207246
Note: See TracChangeset for help on using the changeset viewer.