Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2021 01:22:58 AM (5 years ago)
Author:
imath
Message:

Add a tab to the WP Admin Add Plugin screen to easily get BP Add-ons

BuddyPress Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory. Thanks to this new tab, Admins will be able to find these Add-ons faster and will eventually contribute to beta features early to give the BuddyPress development team their feedbacks.

Props johnjamesjacoby

See #8148

File:
1 edited

Legend:

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

    r13140 r13163  
    204204                add_action( 'load-edit-tags.php', array( 'BP_Admin_Types', 'register_types_admin' ) );
    205205
     206                // Official BuddyPress supported Add-ons.
     207                add_action( 'install_plugins_bp-add-ons', array( $this, 'display_addons_table' ) );
     208
    206209                /* Filters ***********************************************************/
    207210
     
    216219                // Emails
    217220                add_filter( 'bp_admin_menu_order', array( $this, 'emails_admin_menu_order' ), 20 );
     221
     222                // Official BuddyPress supported Add-ons.
     223                add_filter( 'install_plugins_tabs', array( $this, 'addons_tab' ) );
     224                add_filter( 'install_plugins_table_api_args_bp-add-ons', array( $this,'addons_args' ) );
    218225        }
    219226
     
    13571364                }
    13581365        }
     1366
     1367        /**
     1368         * Add a "BuddyPress Add-ons" tab to the Add Plugins Admin screen.
     1369         *
     1370         * @since 10.0.0
     1371         *
     1372         * @param array $tabs The list of "Add Plugins" Tabs (Featured, Recommended, etc..).
     1373         * @return array      The same list including the "BuddyPress Add-ons" tab.
     1374         */
     1375        public function addons_tab( $tabs = array() ) {
     1376                $keys  = array_keys( $tabs );
     1377                $index = array_search( 'favorites', $keys, true );
     1378
     1379                // Makes sure the "BuddyPress Add-ons" tab is right after the "Favorites" one.
     1380                $new_tabs = array_merge(
     1381                        array_slice( $tabs, 0, $index + 1, true ),
     1382                        array(
     1383                                'bp-add-ons' => __( 'BuddyPress Add-ons', 'buddypress' ),
     1384                        ),
     1385                        $tabs
     1386                );
     1387
     1388                return $new_tabs;
     1389        }
     1390
     1391        /**
     1392         * Customize the Plugins API query arguments.
     1393         *
     1394         * The most important argument is the $user one which is set to "buddypress".
     1395         * Using this key and value will fetch the plugins the w.org "buddypress" user favorited.
     1396         *
     1397         * @since 10.0.0
     1398         *
     1399         * @global int        $paged The current page of the Plugin results.
     1400         * @param false|array $args  `false` by default.
     1401         * @return array             The "BuddyPress add-ons" args.
     1402         */
     1403        public function addons_args( $args = false ) {
     1404                global $paged;
     1405
     1406                return array(
     1407                        'page'     => $paged,
     1408                        'per_page' => 10,
     1409                        'locale'   => get_user_locale(),
     1410                        'user'     => 'buddypress',
     1411                );
     1412        }
     1413
     1414        /**
     1415         * Displays the list of "BuddyPress Add-ons".
     1416         *
     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         *
     1420         * @since 10.0.0
     1421         */
     1422        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>
     1432                        </div>
     1433                </div>
     1434                <?php
     1435                // Display the "buddypress" favorites ;)
     1436                display_plugins_table();
     1437        }
    13591438}
    13601439endif; // End class_exists check.
Note: See TracChangeset for help on using the changeset viewer.