Changeset 7552 for trunk/bp-core/admin/bp-core-functions.php
- Timestamp:
- 11/09/2013 08:53:27 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/admin/bp-core-functions.php
r7427 r7552 121 121 */ 122 122 function bp_core_print_admin_notices() { 123 $bp = buddypress();124 123 125 124 // Only the super admin should see messages 126 if ( !bp_current_user_can( 'bp_moderate' ) ) 127 return; 128 129 // On multisite installs, don't show on the Site Admin of a non-root blog, unless 130 // do_network_admin is overridden 131 if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() ) 132 return; 125 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 126 return; 127 } 128 129 // On multisite installs, don't show on a non-root blog, unless 130 // 'do_network_admin' is overridden. 131 if ( is_multisite() && bp_core_do_network_admin() && ! bp_is_root_blog() ) { 132 return; 133 } 134 135 // Get the admin notices 136 $admin_notices = buddypress()->admin->notices; 133 137 134 138 // Show the messages 135 if ( !empty( $ bp->admin->notices ) ) {136 ?> 139 if ( !empty( $admin_notices ) ) : ?> 140 137 141 <div id="message" class="updated fade"> 138 <?php foreach ( $bp->admin->notices as $notice ) : ?> 139 <p><?php echo $notice ?></p> 140 <?php endforeach ?> 142 143 <?php foreach ( $admin_notices as $notice ) : ?> 144 145 <p><?php echo $notice; ?></p> 146 147 <?php endforeach; ?> 148 141 149 </div> 142 <?php 143 }150 151 <?php endif; 144 152 } 145 153 add_action( 'admin_notices', 'bp_core_print_admin_notices' ); … … 158 166 * @param string $notice The notice you are adding to the queue 159 167 */ 160 function bp_core_add_admin_notice( $notice ) { 161 $bp = buddypress(); 162 163 if ( empty( $bp->admin->notices ) ) { 164 $bp->admin->notices = array(); 165 } 166 167 $bp->admin->notices[] = $notice; 168 function bp_core_add_admin_notice( $notice = '' ) { 169 170 // Do not add if the notice is empty 171 if ( empty( $notice ) ) { 172 return; 173 } 174 175 // Double check the object before referencing it 176 if ( ! isset( buddypress()->admin->notices ) ) { 177 buddypress()->admin->notices = array(); 178 } 179 180 // Add the notice 181 buddypress()->admin->notices[] = $notice; 168 182 } 169 183 … … 187 201 188 202 // Only the super admin gets warnings 189 if ( !bp_current_user_can( 'bp_moderate' ) ) 190 return; 203 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 204 return; 205 } 191 206 192 207 // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden 193 if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() ) 194 return; 208 if ( is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog() ) { 209 return; 210 } 195 211 196 212 /** … … 210 226 * Are pretty permalinks enabled? 211 227 */ 212 if ( isset( $_POST['permalink_structure'] ) ) 213 return; 228 if ( isset( $_POST['permalink_structure'] ) ) { 229 return; 230 } 214 231 215 232 if ( empty( $wp_rewrite->permalink_structure ) ) { … … 248 265 249 266 // On the first admin screen after a new installation, this isn't set, so grab it to supress a misleading error message. 250 if ( empty( $bp->pages->members ) ) 267 if ( empty( $bp->pages->members ) ) { 251 268 $bp->pages = bp_core_get_directory_pages(); 269 } 252 270 253 271 foreach( $wp_page_components as $component ) {
Note: See TracChangeset
for help on using the changeset viewer.