Changeset 4543 for trunk/includes/common/functions.php
- Timestamp:
- 12/05/2012 09:02:01 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/includes/common/functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/common/functions.php
r4508 r4543 1688 1688 $wp_query->set_404(); 1689 1689 } 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.