Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/15/2018 03:52:40 PM (8 years ago)
Author:
espellcaste
Message:

Make use of bp_is_post_request() instead of hardcoding POST verifications directly.

BuddyPress is not making use of the bp_is_post_request() in several ajax scenarios to confirm if the post request is indeed a POST request. Instead, it is hardcoding the check directly. This change updates those places making use of this function.

Props DjPaul

Fixes #7684

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-settings/bp-settings-actions.php

    r11705 r11858  
    2828 */
    2929function bp_settings_action_general() {
    30 
    31     // Bail if not a POST action.
    32     if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    33         return;
     30    if ( ! bp_is_post_request() ) {
     31        return;
     32    }
    3433
    3534    // Bail if no submit action.
    36     if ( ! isset( $_POST['submit'] ) )
    37         return;
     35    if ( ! isset( $_POST['submit'] ) ) {
     36        return;
     37    }
    3838
    3939    // Bail if not in settings.
    40     if ( ! bp_is_settings_component() || ! bp_is_current_action( 'general' ) )
    41         return;
     40    if ( ! bp_is_settings_component() || ! bp_is_current_action( 'general' ) ) {
     41        return;
     42    }
    4243
    4344    // 404 if there are any additional action variables attached
     
    260261 */
    261262function bp_settings_action_notifications() {
    262 
    263     // Bail if not a POST action.
    264     if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    265         return;
     263    if ( ! bp_is_post_request() ) {
     264        return;
     265    }
    266266
    267267    // Bail if no submit action.
    268     if ( ! isset( $_POST['submit'] ) )
    269         return;
     268    if ( ! isset( $_POST['submit'] ) ) {
     269        return;
     270    }
    270271
    271272    // Bail if not in settings.
    272     if ( ! bp_is_settings_component() || ! bp_is_current_action( 'notifications' ) )
     273    if ( ! bp_is_settings_component() || ! bp_is_current_action( 'notifications' ) ) {
    273274        return false;
     275    }
    274276
    275277    // 404 if there are any additional action variables attached
     
    307309 */
    308310function bp_settings_action_capabilities() {
    309 
    310     // Bail if not a POST action.
    311     if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    312         return;
     311    if ( ! bp_is_post_request() ) {
     312        return;
     313    }
    313314
    314315    // Bail if no submit action.
    315     if ( ! isset( $_POST['capabilities-submit'] ) )
    316         return;
     316    if ( ! isset( $_POST['capabilities-submit'] ) ) {
     317        return;
     318    }
    317319
    318320    // Bail if not in settings.
    319     if ( ! bp_is_settings_component() || ! bp_is_current_action( 'capabilities' ) )
     321    if ( ! bp_is_settings_component() || ! bp_is_current_action( 'capabilities' ) ) {
    320322        return false;
     323    }
    321324
    322325    // 404 if there are any additional action variables attached
     
    381384 */
    382385function bp_settings_action_delete_account() {
    383 
    384     // Bail if not a POST action.
    385     if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
    386         return;
     386    if ( ! bp_is_post_request() ) {
     387        return;
     388    }
    387389
    388390    // Bail if no submit action.
    389     if ( ! isset( $_POST['delete-account-understand'] ) )
    390         return;
     391    if ( ! isset( $_POST['delete-account-understand'] ) ) {
     392        return;
     393    }
    391394
    392395    // Bail if not in settings.
    393     if ( ! bp_is_settings_component() || ! bp_is_current_action( 'delete-account' ) )
     396    if ( ! bp_is_settings_component() || ! bp_is_current_action( 'delete-account' ) ) {
    394397        return false;
     398    }
    395399
    396400    // 404 if there are any additional action variables attached
Note: See TracChangeset for help on using the changeset viewer.