Changeset 8181
- Timestamp:
- 03/27/2014 10:47:56 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-functions.php
r8158 r8181 906 906 * Add a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads. 907 907 * 908 * @global BuddyPress $bp The one true BuddyPress instance.909 *910 908 * @param string $message Feedback message to be displayed. 911 909 * @param string $type Message type. 'updated', 'success', 'error', 'warning'. … … 913 911 */ 914 912 function bp_core_add_message( $message, $type = '' ) { 915 global $bp;916 913 917 914 // Success is the default 918 if ( empty( $type ) ) 915 if ( empty( $type ) ) { 919 916 $type = 'success'; 917 } 920 918 921 919 // Send the values to the cookie for page reload display 922 920 @setcookie( 'bp-message', $message, time() + 60 * 60 * 24, COOKIEPATH ); 923 921 @setcookie( 'bp-message-type', $type, time() + 60 * 60 * 24, COOKIEPATH ); 922 923 // Get BuddyPress 924 $bp = buddypress(); 924 925 925 926 /*** … … 941 942 * so that the message is not shown to the user multiple times. 942 943 * 943 * @global BuddyPress $bp BuddyPress global settings object.944 944 * @uses setcookie() Sets a cookie value for the user. 945 945 */ 946 946 function 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'] ) ) { 950 952 $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'] ) ) { 953 956 $bp->template_message_type = stripslashes( $_COOKIE['bp-message-type'] ); 957 } 954 958 955 959 add_action( 'template_notices', 'bp_core_render_message' ); 956 960 957 if ( isset( $_COOKIE['bp-message'] ) ) 961 if ( isset( $_COOKIE['bp-message'] ) ) { 958 962 @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH ); 959 if ( isset( $_COOKIE['bp-message-type'] ) ) 963 } 964 965 if ( isset( $_COOKIE['bp-message-type'] ) ) { 960 966 @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); 967 } 961 968 } 962 969 add_action( 'bp_actions', 'bp_core_setup_message', 5 ); … … 967 974 * The hook action 'template_notices' is used to call this function, it is not 968 975 * called directly. 969 *970 * @global BuddyPress $bp The one true BuddyPress instance.971 976 */ 972 977 function bp_core_render_message() { 973 global $bp; 978 979 // Get BuddyPress 980 $bp = buddypress(); 974 981 975 982 if ( !empty( $bp->template_message ) ) : 976 $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error';983 $type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error'; 977 984 $content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?> 978 985 979 <div id="message" class="bp-template-notice <?php echo $type; ?>">986 <div id="message" class="bp-template-notice <?php echo esc_attr( $type ); ?>"> 980 987 981 988 <?php echo $content; ?>
Note: See TracChangeset
for help on using the changeset viewer.