Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/15/2021 11:44:42 AM (5 years ago)
Author:
imath
Message:

Ensure the href attribute is not wrongly used inside button elements

Props sbrajesh

Fixes #8498

File:
1 edited

Legend:

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

    r11563 r13014  
    325325                $button = '';
    326326                if ( ! empty( $r['button_element'] ) ) {
     327                        // Ensure the `href` attribute is not wrongly used inside buttons.
     328                        if ( 'button' === $r['button_element'] && ! empty( $r['button_attr']['href'] ) ) {
     329                                _doing_it_wrong(
     330                                        __CLASS__,
     331                                        __( 'The `href` attribute is not available inside the `<button>` tag. Please use a `data-*` attribute to transport a link into this tag.', 'buddypress' ),
     332                                        '9.0.0'
     333                                );
     334
     335                                unset( $r['button_attr']['href'] );
     336                        }
     337
    327338                        $button = new BP_Core_HTML_Element( array(
    328339                                'element'    => $r['button_element'],
Note: See TracChangeset for help on using the changeset viewer.