Skip to:
Content

BuddyPress.org

Changeset 8181


Ignore:
Timestamp:
03/27/2014 10:47:56 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Remove $bp global from core messages functions. See #5138.

File:
1 edited

Legend:

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

    r8158 r8181  
    906906 * Add a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
    907907 *
    908  * @global BuddyPress $bp The one true BuddyPress instance.
    909  *
    910908 * @param string $message Feedback message to be displayed.
    911909 * @param string $type Message type. 'updated', 'success', 'error', 'warning'.
     
    913911 */
    914912function bp_core_add_message( $message, $type = '' ) {
    915     global $bp;
    916913
    917914    // Success is the default
    918     if ( empty( $type ) )
     915    if ( empty( $type ) ) {
    919916        $type = 'success';
     917    }
    920918
    921919    // Send the values to the cookie for page reload display
    922920    @setcookie( 'bp-message',      $message, time() + 60 * 60 * 24, COOKIEPATH );
    923921    @setcookie( 'bp-message-type', $type,    time() + 60 * 60 * 24, COOKIEPATH );
     922
     923    // Get BuddyPress
     924    $bp = buddypress();
    924925
    925926    /***
     
    941942 * so that the message is not shown to the user multiple times.
    942943 *
    943  * @global BuddyPress $bp BuddyPress global settings object.
    944944 * @uses setcookie() Sets a cookie value for the user.
    945945 */
    946946function bp_core_setup_message() {
    947     global $bp;
    948 
    949     if ( empty( $bp->template_message ) && isset( $_COOKIE['bp-message'] ) )
     947
     948    // Get BuddyPress
     949    $bp = buddypress();
     950
     951    if ( empty( $bp->template_message ) && isset( $_COOKIE['bp-message'] ) ) {
    950952        $bp->template_message = stripslashes( $_COOKIE['bp-message'] );
    951 
    952     if ( empty( $bp->template_message_type ) && isset( $_COOKIE['bp-message-type'] ) )
     953    }
     954
     955    if ( empty( $bp->template_message_type ) && isset( $_COOKIE['bp-message-type'] ) ) {
    953956        $bp->template_message_type = stripslashes( $_COOKIE['bp-message-type'] );
     957    }
    954958
    955959    add_action( 'template_notices', 'bp_core_render_message' );
    956960
    957     if ( isset( $_COOKIE['bp-message'] ) )
     961    if ( isset( $_COOKIE['bp-message'] ) ) {
    958962        @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
    959     if ( isset( $_COOKIE['bp-message-type'] ) )
     963    }
     964
     965    if ( isset( $_COOKIE['bp-message-type'] ) ) {
    960966        @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
     967    }
    961968}
    962969add_action( 'bp_actions', 'bp_core_setup_message', 5 );
     
    967974 * The hook action 'template_notices' is used to call this function, it is not
    968975 * called directly.
    969  *
    970  * @global BuddyPress $bp The one true BuddyPress instance.
    971976 */
    972977function bp_core_render_message() {
    973     global $bp;
     978
     979    // Get BuddyPress
     980    $bp = buddypress();
    974981
    975982    if ( !empty( $bp->template_message ) ) :
    976         $type    = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error';
     983        $type    = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error';
    977984        $content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?>
    978985
    979         <div id="message" class="bp-template-notice <?php echo $type; ?>">
     986        <div id="message" class="bp-template-notice <?php echo esc_attr( $type ); ?>">
    980987
    981988            <?php echo $content; ?>
Note: See TracChangeset for help on using the changeset viewer.