Skip to:
Content

BuddyPress.org

Changeset 13879


Ignore:
Timestamp:
06/01/2024 04:30:27 PM (4 months ago)
Author:
espellcaste
Message:

WPCS: miscellaneous fixes for the src/bp-core/admin/bp-core-admin-functions.php template.

See #7224
See #9164

File:
1 edited

Legend:

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

    r13878 r13879  
    4747     * 'bp-general-settings' menu, it will only contain one item. Kill it.
    4848     */
    49     if ( 1 != count( $submenu['bp-general-settings'] ) ) {
     49    if ( 1 !== count( $submenu['bp-general-settings'] ) ) {
    5050        return;
    5151    }
     
    7777
    7878    // This tweaks the Settings subnav menu to show only one BuddyPress menu item.
    79     if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings' ) ) ) {
     79    if ( ! in_array( $plugin_page, array( 'bp-activity', 'bp-general-settings' ), true ) ) {
    8080        $submenu_file = 'bp-components';
    8181    }
    8282
    8383    // Network Admin > Tools.
    84     if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) {
     84    if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ), true ) ) {
    8585        $submenu_file = $plugin_page;
    8686    }
     
    441441                                'a' => array(
    442442                                    'href'  => true,
    443                                     'class' => true
     443                                    'class' => true,
    444444                                ),
    445445                            )
     
    464464 * @since 8.0.0 Adds the `$context` parameter.
    465465 *
    466  * @param string $active_tab Name of the tab that is active. Optional.
    467  * @param string $context    The context of use for the tabs. Defaults to 'settings'.
    468  *                           Possible values are 'settings' & 'tools'.
    469  */
    470 function bp_core_admin_tabs( $active_tab = '', $context = 'settings', $echo = true ) {
     466 * @param string $active_tab Optional. Name of the tab that is active.
     467 * @param string $context    Optional. The context of use for the tabs. Defaults to 'settings'.
     468 *                           Possible values are 'settings' or 'tools'.
     469 * @param bool   $echo_tabs  Optional. Whether to echo or return the tabs. Default: true.
     470 * @return string|null
     471 */
     472function bp_core_admin_tabs( $active_tab = '', $context = 'settings', $echo_tabs = true ) {
    471473    $tabs_html    = '';
    472474    $idle_class   = 'buddypress-nav-tab';
     
    478480     * @since 1.9.0
    479481     *
    480      * @param array $value Array of tabs to output to the admin area.
     482     * @param array $admin_tabs Array of tabs to output to the admin area.
    481483     */
    482     $tabs         = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab, $context ) );
    483     $tabs_html    = array();
     484    $tabs      = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab, $context ) );
     485    $tabs_html = array();
    484486
    485487    // Loop through tabs and build navigation.
    486488    foreach ( array_values( $tabs ) as $tab_data ) {
    487         $is_current     = (bool) ( $tab_data['name'] == $active_tab );
    488         $tab_class      = $is_current ? $active_class : $idle_class;
    489         $tabs_html[]    = '<a href="' . esc_url( $tab_data['href'] ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab_data['name'] ) . '</a>';
    490     }
    491 
    492     if ( ! $echo ) {
     489        $is_current  = (bool) ( $tab_data['name'] === $active_tab );
     490        $tab_class   = $is_current ? $active_class : $idle_class;
     491        $tabs_html[] = '<a href="' . esc_url( $tab_data['href'] ) . '" class="' . esc_attr( $tab_class ) . '">' . esc_html( $tab_data['name'] ) . '</a>';
     492    }
     493
     494    if ( ! $echo_tabs ) {
    493495        return $tabs_html;
    494496    }
     
    504506     * @since 10.0.0 Adds the `$active_tab` parameter.
    505507     *
    506      * @param string $context The context of use for the tabs.
     508     * @param string $context    The context of use for the tabs.
     509     * @param string $active_tab The active tab.
    507510     */
    508511    do_action( 'bp_admin_tabs', $context, $active_tab );
     
    515518 *
    516519 * @param bool $apply_filters Whether to apply filters or not.
    517  * @return array              The BP Admin settings tabs.
     520 * @return array The BP Admin settings tabs.
    518521 */
    519522function bp_core_get_admin_settings_tabs( $apply_filters = true ) {
     
    577580 *
    578581 * @param bool $apply_filters Whether to apply filters or not.
    579  * @return array              The BP Admin tools tabs.
     582 * @return array The BP Admin tools tabs.
    580583 */
    581584function bp_core_get_admin_tools_tabs( $apply_filters = true ) {
     
    784787            break;
    785788
    786         case 'edit-bp_member_type' :
     789        case 'edit-bp_member_type':
    787790            // Help tab.
    788791            $screen->add_help_tab(
     
    985988 * @since 1.7.0
    986989 *
    987  * @param bool $menu_order Menu order.
    988  * @return bool Always true.
     990 * @param bool $menu_order Optional. Menu order. Default: false.
     991 * @return bool False if user cannot see admin pages, otherwise true.
    989992 */
    990993function bp_admin_custom_menu_order( $menu_order = false ) {
     
    10401043
    10411044        // Position BuddyPress menus above appearance.
    1042         if ( $last_sep == $item ) {
     1045        if ( $last_sep === $item ) {
    10431046
    10441047            // Add our custom menus.
    10451048            foreach ( (array) $custom_menus as $custom_menu ) {
    1046                 if ( array_search( $custom_menu, $menu_order ) ) {
     1049                if ( array_search( $custom_menu, $menu_order, true ) ) {
    10471050                    $bp_menu_order[] = $custom_menu;
    10481051                }
     
    10531056
    10541057            // Skip our menu items.
    1055         } elseif ( ! in_array( $item, $custom_menus ) ) {
     1058        } elseif ( ! in_array( $item, $custom_menus, true ) ) {
    10561059            $bp_menu_order[] = $item;
    10571060        }
     
    10761079 */
    10771080function bp_admin_list_table_current_bulk_action() {
    1078 
    10791081    $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
    10801082
    10811083    // If the bottom is set, let it override the action.
    1082     if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] != '-1' ) {
     1084    if ( ! empty( $_REQUEST['action2'] ) && $_REQUEST['action2'] !== '-1' ) {
    10831085        $action = $_REQUEST['action2'];
    10841086    }
     
    11091111 * @since 7.0.0
    11101112 *
    1111  * @param null     $null     A null value.
     1113 * @param null     $nil      A null value.
    11121114 * @param WP_Query $wp_query The WP_Query instance (passed by reference).
    11131115 * @return array   The BP Member nav items to short-circuit WP's query,
    11141116 */
    1115 function bp_admin_get_wp_nav_menu_items( $null, $wp_query ) {
     1117function bp_admin_get_wp_nav_menu_items( $nil, $wp_query ) {
    11161118    if ( isset( $wp_query->query['orderby'], $wp_query->query['order'] ) && 'post_date' === $wp_query->query['orderby'] && 'DESC' === $wp_query->query['order'] ) {
    11171119        return bp_nav_menu_get_loggedin_pages();
     
    11301132 *
    11311133 * @global $nav_menu_selected_id
    1132  */
    1133 function bp_admin_do_wp_nav_menu_meta_box( $object = '', $box = array() ) {
     1134 *
     1135 * @param WP_Post $post The current post object.
     1136 * @param array   $box     The meta box arguments.
     1137 */
     1138function bp_admin_do_wp_nav_menu_meta_box( $post = '', $box = array() ) {
    11341139    global $nav_menu_selected_id;
    11351140
     
    11431148        'bp_nav_menu_item',
    11441149        array(
    1145             'label'  => 'BuddyPress',
    1146             'labels' => array(
     1150            'label'        => 'BuddyPress',
     1151            'labels'       => array(
    11471152                'search_items' => __( 'Search BuddyPress member menu items', 'buddypress' ),
    11481153                'all_items'    => __( 'All BuddyPress Member menu items', 'buddypress' ),
    11491154            ),
    1150             'public' => true,
     1155            'public'       => true,
    11511156            'hierarchical' => false,
    11521157            'has_archive'  => false,
     
    11621167    $output = ob_get_clean();
    11631168
    1164     $get_bp_items = new WP_Query;
     1169    $get_bp_items = new WP_Query();
    11651170    $all_bp_items = $get_bp_items->query( array( 'nopaging' => true ) );
    11661171    $walker       = new Walker_Nav_Menu_Checklist();
     
    13061311 *
    13071312 * @param WP_Post $post Post object.
    1308  * @param array   $box {
    1309  *     Tags meta box arguments.
    1310  *
    1311  *     @type string   $id       Meta box ID.
    1312  *     @type string   $title    Meta box title.
    1313  *     @type callable $callback Meta box display callback.
    1314  * }
    1315  */
    1316 function bp_email_tax_type_metabox( $post, $box ) {
     1313 */
     1314function bp_email_tax_type_metabox( $post ) {
    13171315    $r = array(
    13181316        'taxonomy' => bp_get_email_tax_type(),
     
    13261324        <div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
    13271325            <?php
    1328             $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
     1326            $name = ( $tax_name === 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
    13291327            echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
    13301328            ?>
     
    13671365 * @since 2.5.0
    13681366 *
    1369  * @param WP_Post $post
     1367 * @param WP_Post $post Post object.
    13701368 */
    13711369function bp_email_plaintext_metabox( $post ) {
     
    13781376    ?>
    13791377    </label>
    1380         <textarea rows="5" cols="40" name="excerpt" id="excerpt"><?php
     1378        <textarea rows="5" cols="40" name="excerpt" id="excerpt">
     1379        <?php
    13811380            // phpcs:ignore WordPress.Security.EscapeOutput
    1382             echo $post->post_excerpt; ?>
     1381            echo $post->post_excerpt;
     1382        ?>
    13831383        </textarea>
    13841384
     
    14251425 * @since 2.0.0
    14261426 *
    1427  * @param array  $actions    User row action links.
    1428  * @param object $user_object Current user information.
     1427 * @param string[] $actions User row action links.
     1428 * @param WP_User  $user_object WP_User object for the currently listed user.
    14291429 * @return array $actions User row action links.
    14301430 */
     
    14531453            );
    14541454            $unspam_link    = wp_nonce_url( $url, 'bp-spam-user' );
    1455             $actions['ham'] = sprintf('<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) );
     1455            $actions['ham'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', 'buddypress' ) );
    14561456
    14571457            // If not already spammed, create spam link.
     
    14921492
    14931493    // If this is a multisite, bulk request, stop now!
    1494     if ( 'list' == $mode ) {
     1494    if ( 'list' === $mode ) {
    14951495        return;
    14961496    }
    14971497
    14981498    // Process a spam/ham request.
    1499     if ( ! empty( $action ) && in_array( $action, array( 'spam', 'ham' ) ) ) {
     1499    if ( ! empty( $action ) && in_array( $action, array( 'spam', 'ham' ), true ) ) {
    15001500
    15011501        check_admin_referer( 'bp-spam-user' );
     
    15091509        $redirect = wp_get_referer();
    15101510
    1511         $status = ( $action == 'spam' ) ? 'spam' : 'ham';
     1511        $status = ( $action === 'spam' ) ? 'spam' : 'ham';
    15121512
    15131513        // Process the user.
     
    15211521
    15221522    // Display feedback.
    1523     if ( ! empty( $updated ) && in_array( $updated, array( 'marked-spam', 'marked-ham' ) ) ) {
     1523    if ( ! empty( $updated ) && in_array( $updated, array( 'marked-spam', 'marked-ham' ), true ) ) {
    15241524
    15251525        if ( 'marked-spam' === $updated ) {
     
    15951595 *
    15961596 * @param string $classes CSS classes for the body tag in the admin, a space separated string.
    1597  *
    15981597 * @return string
    15991598 */
     
    16141613 *
    16151614 * @since 5.0.0
    1616  * @since 8.0.0 The `bp_block_category_post_types` filter has been deprecated.
     1615 * @since 8.0.0  The `bp_block_category_post_types` filter has been deprecated.
    16171616 * @since 12.0.0 This category is left for third party plugin but not used anymore.
    16181617 *
    16191618 * @todo deprecate.
    16201619 *
    1621  * @param array          $categories Array of block categories.
    1622  * @param string|WP_Post $post      Post being loaded.
     1620 * @param array               $categories Array of block categories.
     1621 * @param string|WP_Post|null $editor_name_or_post Post being loaded.
    16231622 */
    16241623function bp_block_category( $categories = array(), $editor_name_or_post = null ) {
     
    16511650 * @since 11.4.0
    16521651 *
    1653  * @param object $notification An Admin Notification object.
     1652 * @param object|null $notification An Admin Notification object.
    16541653 */
    16551654function bp_core_admin_format_notifications( $notification = null ) {
    16561655    if ( ! isset( $notification->id ) ) {
    1657         return '';
     1656        return;
    16581657    }
    16591658    ?>
     
    16631662            <h2><span class="bp-version"><?php echo esc_html( number_format_i18n( $notification->version, 1 ) ); ?></span> <?php echo esc_html( $notification->title ); ?></h2>
    16641663            <p class="about-description">
    1665                 <?php echo wp_kses( $notification->content, array( 'a' => array( 'href' => true ), 'br' => array(), 'strong' => array() ) ); ?>
     1664                <?php
     1665                echo wp_kses(
     1666                    $notification->content,
     1667                    array(
     1668                        'a'      => array( 'href' => true ),
     1669                        'br'     => array(),
     1670                        'strong' => array(),
     1671                    )
     1672                );
     1673                ?>
    16661674            </p>
    16671675            <div class="bp-admin-notification-action"><a href="<?php echo esc_url( $notification->href ); ?>" class="button button-primary"><?php echo esc_html( $notification->text ); ?></a></div>
Note: See TracChangeset for help on using the changeset viewer.