Skip to:
Content

BuddyPress.org

Changeset 7542


Ignore:
Timestamp:
11/09/2013 01:30:04 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Port request helper functions from bbPress, to be used as part of rewrite rules integration in a future release.

Location:
trunk/bp-core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-actions.php

    r7433 r7542  
    8585 *                                                           v---Load order
    8686 */
    87 add_action( 'bp_template_redirect', 'bp_redirect_canonical', 2 );
    88 add_action( 'bp_template_redirect', 'bp_actions',            4 );
    89 add_action( 'bp_template_redirect', 'bp_screens',            6 );
     87add_action( 'bp_template_redirect', 'bp_redirect_canonical', 2  );
     88add_action( 'bp_template_redirect', 'bp_actions',            4  );
     89add_action( 'bp_template_redirect', 'bp_screens',            6  );
     90add_action( 'bp_template_redirect', 'bp_post_request',       10 );
     91add_action( 'bp_template_redirect', 'bp_get_request',        10 );
    9092
    9193/**
  • trunk/bp-core/bp-core-dependency.php

    r7446 r7542  
    339339        return apply_filters( 'bp_allowed_themes', $themes );
    340340}
     341
     342/** Requests ******************************************************************/
     343
     344/**
     345 * The main action used for handling theme-side POST requests
     346 *
     347 * @since BuddyPress (1.9.0)
     348 * @uses do_action()
     349 */
     350function bp_post_request() {
     351
     352        // Bail if not a POST action
     353        if ( ! bp_is_post_request() )
     354                return;
     355
     356        // Bail if no action
     357        if ( empty( $_POST['action'] ) )
     358                return;
     359
     360        // This dynamic action is probably the one you want to use. It narrows down
     361        // the scope of the 'action' without needing to check it in your function.
     362        do_action( 'bp_post_request_' . $_POST['action'] );
     363
     364        // Use this static action if you don't mind checking the 'action' yourself.
     365        do_action( 'bp_post_request',   $_POST['action'] );
     366}
     367
     368/**
     369 * The main action used for handling theme-side GET requests
     370 *
     371 * @since BuddyPress (1.9.0)
     372 * @uses do_action()
     373 */
     374function bp_get_request() {
     375
     376        // Bail if not a POST action
     377        if ( ! bp_is_get_request() )
     378                return;
     379
     380        // Bail if no action
     381        if ( empty( $_GET['action'] ) )
     382                return;
     383
     384        // This dynamic action is probably the one you want to use. It narrows down
     385        // the scope of the 'action' without needing to check it in your function.
     386        do_action( 'bp_get_request_' . $_GET['action'] );
     387
     388        // Use this static action if you don't mind checking the 'action' yourself.
     389        do_action( 'bp_get_request',   $_GET['action'] );
     390}
  • trunk/bp-core/bp-core-functions.php

    r7541 r7542  
    14721472}
    14731473
     1474/** Requests ******************************************************************/
     1475
     1476/**
     1477 * Return true|false if this is a POST request
     1478 *
     1479 * @since BuddyPress (1.9.0)
     1480 * @return bool
     1481 */
     1482function bp_is_post_request() {
     1483        return (bool) ( 'POST' === strtoupper( $_SERVER['REQUEST_METHOD'] ) );
     1484}
     1485
     1486/**
     1487 * Return true|false if this is a GET request
     1488 *
     1489 * @since BuddyPress (1.9.0)
     1490 * @return bool
     1491 */
     1492function bp_is_get_request() {
     1493        return (bool) ( 'GET' === strtoupper( $_SERVER['REQUEST_METHOD'] ) );
     1494}
     1495
     1496
    14741497/** Miscellaneous hooks *******************************************************/
    14751498
Note: See TracChangeset for help on using the changeset viewer.