Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2021 01:29:52 AM (4 years ago)
Author:
imath
Message:

Use an XHR request to dismiss the BP Add-ons screen welcome panel

This commit also improves oursrc/js folder to be able to generate Modern JavaScript files for BP Admin screens. It starts with removing the need to add a dependency to jQuery for the BP Add-ons screen and the WP-Admin extended profile screen.

Fixes #8148

File:
1 edited

Legend:

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

    r13137 r13164  
    14171417    }
    14181418
    1419     if ( empty( $_POST['nonce'] ) || empty( $_POST['notice_id'] ) ) {
     1419    $nonce_data = array();
     1420    if ( isset( $_SERVER['HTTP_X_BP_NONCE'] ) ) {
     1421        $nonce_data = array(
     1422            'nonce'  => $_SERVER['HTTP_X_BP_NONCE'],
     1423            'action' => 'bp_dismiss_admin_notice',
     1424        );
     1425    } elseif ( isset( $_POST['nonce'] ) ) {
     1426        $nonce_data['nonce'] = $_POST['nonce'];
     1427    }
     1428
     1429    if ( empty( $nonce_data['nonce'] ) || empty( $_POST['notice_id'] ) ) {
    14201430        wp_send_json_error();
    14211431    }
    14221432
    14231433    $notice_id = wp_unslash( $_POST['notice_id'] );
    1424 
    1425     if ( ! wp_verify_nonce( $_POST['nonce'], 'bp-dismissible-notice-' . $notice_id ) ) {
     1434    if ( ! isset( $nonce_data['action'] ) ) {
     1435        $nonce_data['action'] = 'bp-dismissible-notice-' . $notice_id;
     1436    }
     1437
     1438    if ( ! wp_verify_nonce( $nonce_data['nonce'], $nonce_data['action'] ) ) {
    14261439        wp_send_json_error();
    14271440    }
    14281441
    1429     bp_update_option( "bp-dismissed-notice-$notice_id", 1 );
     1442    bp_update_option( "bp-dismissed-notice-{$notice_id}", true );
    14301443
    14311444    wp_send_json_success();
Note: See TracChangeset for help on using the changeset viewer.