Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2021 01:29:52 AM (4 years ago)
Author:
imath
Message:

Use an XHR request to dismiss the BP Add-ons screen welcome panel

This commit also improves oursrc/js folder to be able to generate Modern JavaScript files for BP Admin screens. It starts with removing the need to add a dependency to jQuery for the BP Add-ons screen and the WP-Admin extended profile screen.

Fixes #8148

File:
1 edited

Legend:

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

    r13163 r13164  
    12961296                'footer'       => true,
    12971297            ),
     1298
     1299            // 10.0
     1300            'bp-dismissible-admin-notices' => array(
     1301                'file'         => "{$url}dismissible-admin-notices.js",
     1302                'dependencies' => array(),
     1303                'footer'       => true,
     1304                'extra'        => array(
     1305                    'name' => 'bpDismissibleAdminNoticesSettings',
     1306                    'data' => array(
     1307                        'url'    => bp_core_ajax_url(),
     1308                        'nonce'  => wp_create_nonce( 'bp_dismiss_admin_notice' ),
     1309                    ),
     1310                ),
     1311            ),
    12981312        ) );
    12991313
     
    13021316        foreach ( $scripts as $id => $script ) {
    13031317            wp_register_script( $id, $script['file'], $script['dependencies'], $version, $script['footer'] );
     1318
     1319            if ( isset( $script['extra'] ) ) {
     1320                // List the block specific props.
     1321                wp_add_inline_script(
     1322                    $id,
     1323                    sprintf( 'var %1$s = %2$s;', $script['extra']['name'], wp_json_encode( $script['extra']['data'] ) ),
     1324                    'before'
     1325                );
     1326            }
    13041327        }
    13051328    }
     
    14151438     * Displays the list of "BuddyPress Add-ons".
    14161439     *
    1417      * @todo we should have a page on the BuddyPress codex to explain feature plugins like this one:
    1418      *       https://make.wordpress.org/core/features/
    1419      *
    14201440     * @since 10.0.0
    14211441     */
    14221442    public function display_addons_table() {
    1423         ?>
    1424         <div id="welcome-panel" class="welcome-panel">
    1425             <a class="welcome-panel-close" href="#" aria-label="Dismiss the welcome panel"><?php esc_html_e( 'Dismiss', 'buddypress' ); ?></a>
    1426             <div class="welcome-panel-content">
    1427                 <h2><span class="bp-badge"></span> <?php esc_html_e( 'Hello BuddyPress Add-ons!', 'buddypress' ); ?></h2>
    1428                 <p class="about-description">
    1429                     <?php esc_html_e( 'Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory.', 'buddypress' ); ?>
    1430                     <?php esc_html_e( 'Thanks to this new tab inside your Dashboard screen to add plugins, you’ll be able to find them faster and eventually contribute to beta features early to give the BuddyPress development team your feedbacks.', 'buddypress' ); ?>
    1431                 </p>
     1443        $notice_id = 'bp100-welcome-addons';
     1444        $dismissed = bp_get_option( "bp-dismissed-notice-{$notice_id}", false );
     1445
     1446        if ( ! $dismissed ) {
     1447            // Enqueue the Script to Ajax Dismiss an Admin notice.
     1448            wp_enqueue_script( 'bp-dismissible-admin-notices' );
     1449
     1450            ?>
     1451            <div id="welcome-panel" class="welcome-panel bp-notice-container">
     1452                <a class="welcome-panel-close bp-is-dismissible" href="#" data-notice_id="<?php echo esc_attr( $notice_id ); ?>" aria-label="<?php esc_attr_e( 'Dismiss the welcome panel', 'buddypress' ); ?>"><?php esc_html_e( 'Dismiss', 'buddypress' ); ?></a>
     1453                <div class="welcome-panel-content">
     1454                    <h2><span class="bp-badge"></span> <?php esc_html_e( 'Hello BuddyPress Add-ons!', 'buddypress' ); ?></h2>
     1455                    <p class="about-description">
     1456                        <?php esc_html_e( 'Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory.', 'buddypress' ); ?>
     1457                        <?php esc_html_e( 'Thanks to this new tab inside your Dashboard screen to add plugins, you’ll be able to find them faster and eventually contribute to beta features early to give the BuddyPress development team your feedbacks.', 'buddypress' ); ?>
     1458                    </p>
     1459                </div>
    14321460            </div>
    1433         </div>
    1434         <?php
    1435         // Display the "buddypress" favorites ;)
     1461            <?php
     1462        }
     1463
     1464        // Display the "buddypress" favorites.
    14361465        display_plugins_table();
    14371466    }
Note: See TracChangeset for help on using the changeset viewer.