Skip to:
Content

BuddyPress.org

Changeset 12890


Ignore:
Timestamp:
04/17/2021 08:31:38 AM (8 months ago)
Author:
imath
Message:

BP Nouveau: improve the way we get the nonce in JavaScript main file

Splitting the data-bp-nonce attribute to get Ajax buttons nonce is not the right way to do it. There can be situation where the _wpnonce URL param is not the last one (eg: the data-bp-nonce attribute of the Accept Group Invite button contains a redirect_to param). Using the bp.Nouveau.getLinkParams() function is fixing the issue.

Prop meijioro

Fixes #8396

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/js/buddypress-nouveau.js

    r12856 r12890  
    662662            }
    663663
    664             // Find the required wpnonce string.
    665             // if  button element set we'll have our nonce set on a data attr
    666             // Check the value & if exists split the string to obtain the nonce string
    667             // if no value, i.e false, null then the href attr is used.
    668             if ( nonceUrl ) {
    669                 nonce = nonceUrl.split('?_wpnonce=');
    670                 nonce = nonce[1];
    671             } else {
    672                 nonce = self.getLinkParams( target.prop( 'href' ), '_wpnonce' );
    673             }
     664            // If the nonceUrl is not set, use the `href` attribute.
     665            if ( ! nonceUrl ) {
     666                nonceUrl = target.prop( 'href' );
     667            }
     668
     669            // Set the nonce.
     670            nonce = self.getLinkParams( nonceUrl, '_wpnonce' );
    674671
    675672            // Unfortunately unlike groups
Note: See TracChangeset for help on using the changeset viewer.