Skip to:
Content

bbPress.org

Changeset 4548


Ignore:
Timestamp:
12/06/2012 09:36:18 AM (12 years ago)
Author:
johnjamesjacoby
Message:

AJAX:

  • Introduce common/ajax.php, along with new AJAX handlers and helpers.
  • Move bbp_ajax_response() into it.
  • Include new file in bbpress.php.
Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bbpress.php

    r4514 r4548  
    288288
    289289        // Common
     290        require( $this->includes_dir . 'common/ajax.php'           );
    290291        require( $this->includes_dir . 'common/classes.php'        );
    291292        require( $this->includes_dir . 'common/functions.php'      );
  • trunk/includes/common/functions.php

    r4543 r4548  
    16881688    $wp_query->set_404();
    16891689}
    1690 
    1691 /**
    1692  * Helper method to return JSON response for the ajax calls
    1693  *
    1694  * @since bbPress (r4542)
    1695  *
    1696  * @param bool $success
    1697  * @param string $content
    1698  * @param array $extras
    1699  */
    1700 function bbp_ajax_response( $success = false, $content = '', $status = -1, $extras = array() ) {
    1701 
    1702     // Set status to 200 if setting response as successful
    1703     if ( ( true === $success ) && ( -1 === $status ) )
    1704         $status = 200;
    1705 
    1706     // Setup the response array
    1707     $response = array(
    1708         'success' => $success,
    1709         'status'  => $status,
    1710         'content' => $content
    1711     );
    1712 
    1713     // Merge extra response parameters in
    1714     if ( !empty( $extras ) && is_array( $extras ) ) {
    1715         $response = array_merge( $response, $extras );
    1716     }
    1717 
    1718     // Send back the JSON
    1719     header( 'Content-type: application/json' );
    1720     echo json_encode( $response );
    1721     die();
    1722 }
Note: See TracChangeset for help on using the changeset viewer.