Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/02/2024 07:14:55 PM (20 months ago)
Author:
espellcaste
Message:

WPCS: Part IX: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883], [13886], [13887], [13888], [13891], [13892], [13893] and [13900]

See #9164 and #7228

File:
1 edited

Legend:

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

    r13818 r13901  
    233233     * @since 1.2.6
    234234     *
    235      * @param array|string $args See {@BP_Button}.
     235     * @param array|string $args See `BP_Button`.
    236236     */
    237237    public function __construct( $args = '' ) {
     
    246246
    247247        // Deprecated. Subject to removal in a future release.
     248
    248249        $this->wrapper = $r['wrapper'];
    249         if ( !empty( $r['link_id']    ) ) $this->link_id    = ' id="' .    $r['link_id']    . '"';
    250         if ( !empty( $r['link_href']  ) ) $this->link_href  = ' href="' .  $r['link_href']  . '"';
    251         if ( !empty( $r['link_title'] ) ) $this->link_title = ' title="' . $r['link_title'] . '"';
    252         if ( !empty( $r['link_rel']   ) ) $this->link_rel   = ' rel="' .   $r['link_rel']   . '"';
    253         if ( !empty( $r['link_class'] ) ) $this->link_class = ' class="' . $r['link_class'] . '"';
    254         if ( !empty( $r['link_text']  ) ) $this->link_text  =              $r['link_text'];
     250
     251        if ( ! empty( $r['link_id'] ) ) {
     252            $this->link_id = ' id="' . $r['link_id'] . '"';
     253        }
     254        if ( ! empty( $r['link_href'] ) ) {
     255            $this->link_href = ' href="' . $r['link_href'] . '"';
     256        }
     257        if ( ! empty( $r['link_title'] ) ) {
     258            $this->link_title = ' title="' . $r['link_title'] . '"';
     259        }
     260        if ( ! empty( $r['link_rel'] ) ) {
     261            $this->link_rel = ' rel="' . $r['link_rel'] . '"';
     262        }
     263        if ( ! empty( $r['link_class'] ) ) {
     264            $this->link_class = ' class="' . $r['link_class'] . '"';
     265        }
     266        if ( ! empty( $r['link_text'] ) ) {
     267            $this->link_text = $r['link_text'];
     268        }
    255269
    256270        // Required button properties.
     
    262276        // $id and $component are required and component must be active.
    263277        if ( empty( $r['id'] ) || empty( $r['component'] ) || ! bp_is_active( $this->component ) ) {
    264             return false;
     278            return;
    265279        }
    266280
    267281        // No button for guests if must be logged in.
    268         if ( true == $this->must_be_logged_in && ! is_user_logged_in() ) {
    269             return false;
     282        if ( true === $this->must_be_logged_in && ! is_user_logged_in() ) {
     283            return;
    270284        }
    271285
    272286        // The block_self property.
    273         if ( true == $this->block_self ) {
     287        if ( true === $this->block_self ) {
    274288            /*
    275289             * No button if you are the current user in a members loop.
     
    279293             */
    280294            if ( bp_get_member_user_id() ) {
    281                 if ( is_user_logged_in() && bp_loggedin_user_id() == bp_get_member_user_id() ) {
    282                     return false;
     295                if ( is_user_logged_in() && bp_loggedin_user_id() === bp_get_member_user_id() ) {
     296                    return;
    283297                }
    284298
    285             // No button if viewing your own profile (and not in a members loop).
     299                // No button if viewing your own profile (and not in a members loop).
    286300            } elseif ( bp_is_my_profile() ) {
    287                 return false;
     301                return;
    288302            }
    289303        }
     
    311325
    312326            // Render parent element attributes.
    313             $parent_elem = new BP_Core_HTML_Element( array(
    314                 'element' => $r['parent_element'],
    315                 'attr'    => $r['parent_attr']
    316             ) );
     327            $parent_elem = new BP_Core_HTML_Element(
     328                array(
     329                    'element' => $r['parent_element'],
     330                    'attr'    => $r['parent_attr'],
     331                )
     332            );
    317333
    318334            // Set before and after.
     
    320336            $after  = $parent_elem->get( 'close_tag' );
    321337
    322         // No parent element.
     338            // No parent element.
    323339        } else {
    324             $before = $after = '';
     340            $before = '';
     341            $after  = '';
    325342        }
    326343
     
    339356            }
    340357
    341             $button = new BP_Core_HTML_Element( array(
    342                 'element'    => $r['button_element'],
    343                 'attr'       => $r['button_attr'],
    344                 'inner_html' => ! empty( $r['link_text'] ) ? $r['link_text'] : ''
    345             ) );
     358            $button = new BP_Core_HTML_Element(
     359                array(
     360                    'element'    => $r['button_element'],
     361                    'attr'       => $r['button_attr'],
     362                    'inner_html' => ! empty( $r['link_text'] ) ? $r['link_text'] : '',
     363                )
     364            );
    346365            $button = $button->contents();
    347366        }
     
    374393     * @since 2.7.0.
    375394     *
    376      * @param  array $r See {@link BP_Button} class for full documentation.
     395     * @param  array $r See {@see BP_Button} class for full documentation.
    377396     * @return array
    378397     */
     
    380399        // Array of deprecated arguments.
    381400        $backpat_args = array(
    382             'wrapper', 'wrapper_class', 'wrapper_id',
    383             'link_href', 'link_class', 'link_id', 'link_rel', 'link_title'
     401            'wrapper',
     402            'wrapper_class',
     403            'wrapper_id',
     404            'link_href',
     405            'link_class',
     406            'link_id',
     407            'link_rel',
     408            'link_title',
    384409        );
    385410
     
    389414            }
    390415
    391             $parent = $child = false;
     416            $parent = false;
     417            $child  = false;
    392418            $sep    = strpos( $prop, '_' );
    393419
     
    410436                $r[ "{$parent}_element" ] = $r[ $prop ];
    411437
    412             // Set attributes.
     438                // Set attributes.
    413439            } elseif ( true === $child ) {
    414                 $new_prop = substr( $prop, strpos( $prop, '_' ) +1 );
     440                $new_prop = substr( $prop, strpos( $prop, '_' ) + 1 );
    415441                if ( empty( $r[ "{$parent}_attr" ] ) ) {
    416442                    $r[ "{$parent}_attr" ] = array();
Note: See TracChangeset for help on using the changeset viewer.