Skip to:
Content

BuddyPress.org

Changeset 13868


Ignore:
Timestamp:
05/19/2024 11:00:37 AM (2 years ago)
Author:
imath
Message:

Add Help tabs to inform about BP Emails management & BP Email tokens

  • Improve bp_core_add_contextual_help() to avoid code duplication.
  • Add an help tab linking to the user documentation page explaining how to manage BP Emails.
  • Add an help tab linking to the user documentation page explaining BP Email tokens usage.
  • Deprecate bp_admin_email_add_codex_notice().

Fixes #9159
Closes https://github.com/buddypress/buddypress/pull/291

Location:
trunk/src/bp-core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-functions.php

    r13818 r13868  
    703703function bp_core_add_contextual_help( $screen = '' ) {
    704704
    705         $screen   = get_current_screen();
    706         $bp_forum = sprintf(
    707                 '<a href="%1$s">%2$s</a>',
    708                 esc_url( 'https://buddypress.org/support/' ),
    709                 esc_html__( 'Support Forums', 'buddypress' )
    710         );
     705        $screen             = get_current_screen();
     706        $documentation_link = '';
    711707
    712708        switch ( $screen->id ) {
     
    724720                        );
    725721
    726                         $manage_components = sprintf(
     722                        $documentation_link = sprintf(
    727723                                '<a href="%1$s">%2$s</a>',
    728724                                esc_url( 'https://github.com/buddypress/buddypress/blob/master/docs/user/administration/settings/components.md' ),
    729725                                esc_html__( 'Managing Components', 'buddypress' )
    730                         );
    731 
    732                         // Help panel - sidebar links.
    733                         $screen->set_help_sidebar(
    734                                 '<p><strong>' . esc_html__( 'For more information:', 'buddypress' ) . '</strong></p>' .
    735                                 '<p>' . $manage_components . '</p>' .
    736                                 '<p>' . $bp_forum . '</p>'
    737726                        );
    738727                        break;
     
    750739                        );
    751740
    752                         $manage_rewrites = sprintf(
     741                        $documentation_link = sprintf(
    753742                                '<a href="%1$s">%2$s</a>',
    754743                                esc_url( 'https://github.com/buddypress/buddypress/blob/master/docs/user/administration/settings/urls.md' ),
    755744                                esc_html__( 'Managing URLs', 'buddypress' )
    756                         );
    757 
    758                         // Help panel - sidebar links.
    759                         $screen->set_help_sidebar(
    760                                 '<p><strong>' . esc_html__( 'For more information:', 'buddypress' ) . '</strong></p>' .
    761                                 '<p>' . $manage_rewrites . '</p>' .
    762                                 '<p>' . $bp_forum . '</p>'
    763745                        );
    764746                        break;
     
    776758                        );
    777759
    778                         $manage_settings = sprintf(
     760                        $documentation_link = sprintf(
    779761                                '<a href="%1$s">%2$s</a>',
    780762                                esc_url( 'https://github.com/buddypress/buddypress/blob/master/docs/user/administration/settings/options.md' ),
    781763                                esc_html__( 'Managing Settings', 'buddypress' )
    782764                        );
    783 
    784                         // Help panel - sidebar links.
    785                         $screen->set_help_sidebar(
    786                                 '<p><strong>' . esc_html__( 'For more information:', 'buddypress' ) . '</strong></p>' .
    787                                 '<p>' . $manage_settings . '</p>' .
    788                                 '<p>' . $bp_forum . '</p>'
    789                         );
    790 
    791765                        break;
    792766
     
    803777                        );
    804778
    805                         $manage_profile_fields = sprintf(
     779                        $documentation_link = sprintf(
    806780                                '<a href="%1$s">%2$s</a>',
    807781                                esc_url( 'https://github.com/buddypress/buddypress/blob/master/docs/user/administration/users/xprofile.md' ),
    808782                                esc_html__( 'Managing Profile Fields', 'buddypress' )
    809783                        );
    810 
    811                         // Help panel - sidebar links.
    812                         $screen->set_help_sidebar(
    813                                 '<p><strong>' . esc_html__( 'For more information:', 'buddypress' ) . '</strong></p>' .
    814                                 '<p>' . $manage_profile_fields . '</p>' .
    815                                 '<p>' . $bp_forum . '</p>'
    816                         );
    817 
    818784                        break;
    819785
     
    828794                        );
    829795
    830                         $manage_member_types = sprintf(
     796                        $documentation_link = sprintf(
    831797                                '<a href="%1$s">%2$s</a>',
    832798                                esc_url( 'https://github.com/buddypress/buddypress/blob/master/docs/user/administration/users/member-types.md' ),
    833799                                esc_html__( 'Managing Member Types', 'buddypress' )
    834800                        );
    835 
    836                         // Help panel - sidebar links.
    837                         $screen->set_help_sidebar(
    838                                 '<p><strong>' . esc_html__( 'For more information:', 'buddypress' ) . '</strong></p>' .
    839                                 '<p>' . $manage_member_types . '</p>' .
    840                                 '<p>' . $bp_forum . '</p>'
    841                         );
    842 
    843801                        break;
     802
     803                case 'edit-bp-email':
     804                        // Help tab.
     805                        $screen->add_help_tab(
     806                                array(
     807                                        'id'      => 'bp-emails-overview',
     808                                        'title'   => __( 'Overview', 'buddypress' ),
     809                                        'content' => bp_core_add_contextual_help_content( 'bp-emails-overview' ),
     810                                )
     811                        );
     812
     813                        $documentation_link = sprintf(
     814                                '<a href="%1$s">%2$s</a>',
     815                                esc_url( 'https://github.com/buddypress/buddypress/blob/master/docs/user/administration/emails/README.md' ),
     816                                esc_html__( 'Managing BP Emails', 'buddypress' )
     817                        );
     818                        break;
     819
     820                case 'bp-email':
     821                        // Help tab.
     822                        $screen->add_help_tab(
     823                                array(
     824                                        'id'      => 'bp-email-overview',
     825                                        'title'   => __( 'Overview', 'buddypress' ),
     826                                        'content' => bp_core_add_contextual_help_content( 'bp-email-overview' ),
     827                                )
     828                        );
     829
     830                        $documentation_link = sprintf(
     831                                '<a href="%1$s">%2$s</a>',
     832                                esc_url( 'https://github.com/buddypress/buddypress/blob/master/docs/user/administration/emails/tokens.md' ),
     833                                esc_html__( 'BP Email tokens usage', 'buddypress' )
     834                        );
     835                        break;
     836        }
     837
     838        if ( $documentation_link ) {
     839                $bp_forum = sprintf(
     840                        '<a href="%1$s">%2$s</a>',
     841                        esc_url( 'https://buddypress.org/support/' ),
     842                        esc_html__( 'Support Forums', 'buddypress' )
     843                );
     844
     845                // Help panel - sidebar links.
     846                $screen->set_help_sidebar(
     847                        '<p><strong>' . esc_html__( 'For more information:', 'buddypress' ) . '</strong></p>' .
     848                        '<p>' . $documentation_link . '</p>' .
     849                        '<p>' . $bp_forum . '</p>'
     850                );
    844851        }
    845852}
     
    883890                case 'bp-member-types-overview':
    884891                        $retval = __( 'Member Types in BuddyPress provide a powerful way to classify users within your community. By defining various member types, such as "Students", "Teachers", or "Alumni", you can create a more organized and tailored community environment. This feature is especially useful for communities with diverse user groups, allowing customized interactions, content access, and privileges.', 'buddypress' );
     892                        break;
     893
     894                case 'bp-emails-overview':
     895                        $retval = __( 'This screen provides access to all BP Emails. Hovering over a row in the BP Emails list will display action links that allow you to manage the corresponding BP Email.', 'buddypress' );
     896                        break;
     897
     898                case 'bp-email-overview':
     899                        $retval = sprintf(
     900                                /* Translators: %s contains braces within a code tag. */
     901                                __( 'Phrases wrapped in braces %s are email tokens. Tokens are variable strings that will get replaced with dynamic content when the email gets sent.', 'buddypress' ),
     902                                '<code>{{ }}</code>'
     903                        );
    885904                        break;
    886905
     
    12561275}
    12571276add_action( 'admin_head-edit.php', 'bp_admin_email_maybe_add_translation_notice' );
    1258 
    1259 /**
    1260  * In emails editor, add notice linking to token documentation on Codex.
    1261  *
    1262  * @since 2.5.0
    1263  */
    1264 function bp_admin_email_add_codex_notice() {
    1265         if ( get_current_screen()->post_type !== bp_get_email_post_type() ) {
    1266                 return;
    1267         }
    1268 
    1269         bp_core_add_admin_notice(
    1270                 sprintf(
    1271                         // Translators: %s is the url to the BuddyPress codex page about BP Email tokens.
    1272                         __( 'Phrases wrapped in braces <code>{{ }}</code> are email tokens. <a href="%s">Learn about tokens on the BuddyPress Codex</a>.', 'buddypress' ),
    1273                         esc_url( 'https://codex.buddypress.org/emails/email-tokens/' )
    1274                 ),
    1275                 'error'
    1276         );
    1277 }
    1278 add_action( 'admin_head-post.php', 'bp_admin_email_add_codex_notice' );
    12791277
    12801278/**
  • trunk/src/bp-core/classes/class-bp-admin.php

    r13840 r13868  
    227227                // Emails
    228228                add_filter( 'bp_admin_menu_order', array( $this, 'emails_admin_menu_order' ), 20 );
     229                add_action( 'load-edit.php', array( $this, 'post_type_load_admin_screen' ), 20 );
     230                add_action( 'load-post.php', array( $this, 'post_type_load_admin_screen' ), 20 );
    229231
    230232                // Official BuddyPress supported Add-ons.
     
    12901292        }
    12911293
     1294        /**
     1295         * Adds BP Custom Post Types Admin screen's help tab.
     1296         *
     1297         * @since 14.0.0
     1298         */
     1299        public function post_type_load_admin_screen() {
     1300                $screen = null;
     1301                if ( function_exists( 'get_current_screen' ) ) {
     1302                        $screen = get_current_screen();
     1303                }
     1304
     1305                if ( ! isset( $screen->post_type ) || bp_get_email_post_type() !== $screen->post_type ) {
     1306                        return;
     1307                }
     1308
     1309                bp_core_add_contextual_help( $screen );
     1310        }
     1311
    12921312        /** Helpers ***************************************************************/
    12931313
  • trunk/src/bp-core/deprecated/14.0.php

    r13741 r13868  
    6464        return apply_filters_deprecated( 'bp_use_wp_admin_bar', array( $use_admin_bar ), '14.0.0' );
    6565}
     66
     67/**
     68 * In emails editor, add notice linking to token documentation on Codex.
     69 *
     70 * @since 2.5.0
     71 * @deprecated 14.0.0
     72 */
     73function bp_admin_email_add_codex_notice() {
     74        _deprecated_function( __FUNCTION__, '14.0.0' );
     75
     76        if ( get_current_screen()->post_type !== bp_get_email_post_type() ) {
     77                return;
     78        }
     79
     80        bp_core_add_admin_notice(
     81                sprintf(
     82                        // Translators: %s is the url to the BuddyPress codex page about BP Email tokens.
     83                        __( 'Phrases wrapped in braces <code>{{ }}</code> are email tokens. <a href="%s">Learn about tokens on the BuddyPress Codex</a>.', 'buddypress' ),
     84                        esc_url( 'https://codex.buddypress.org/emails/email-tokens/' )
     85                ),
     86                'error'
     87        );
     88}
Note: See TracChangeset for help on using the changeset viewer.