Changeset 8698 for trunk/src/bp-core/bp-core-template.php
- Timestamp:
- 07/27/2014 04:07:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template.php
r8682 r8698 29 29 */ 30 30 function bp_get_options_nav() { 31 global $bp;32 33 // If we are looking at a member profile, then the we can use the current component as an34 // index. Otherwise we need to use the component's root_slug31 $bp = buddypress(); 32 33 // If we are looking at a member profile, then the we can use the current 34 // component as an index. Otherwise we need to use the component's root_slug 35 35 $component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() ); 36 36 37 if ( ! bp_is_single_item() ) {37 if ( ! bp_is_single_item() ) { 38 38 if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) { 39 39 return false; … … 51 51 // Loop through each navigation item 52 52 foreach ( (array) $bp->bp_options_nav[$the_index] as $subnav_item ) { 53 if ( !$subnav_item['user_has_access'] )53 if ( empty( $subnav_item['user_has_access'] ) ) { 54 54 continue; 55 } 55 56 56 57 // If the current action or an action variable matches the nav item id, then add a highlight CSS class. … … 76 77 */ 77 78 function bp_get_options_title() { 78 global $bp;79 80 if ( empty( $bp->bp_options_title ) ) 79 $bp = buddypress(); 80 81 if ( empty( $bp->bp_options_title ) ) { 81 82 $bp->bp_options_title = __( 'Options', 'buddypress' ); 83 } 82 84 83 85 echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) ); … … 119 121 * Not currently used in BuddyPress. 120 122 * 121 * @global BuddyPress $bp The one true BuddyPress instance. 123 * @return bool Returns true if an options avatar has been set, otherwise false. 124 */ 125 function bp_has_options_avatar() { 126 return (bool) buddypress()->bp_options_avatar; 127 } 128 129 /** 130 * Output the options avatar. 131 * 132 * Not currently used in BuddyPress. 133 * 122 134 * @todo Deprecate. 123 * 124 * @return bool Returns true if an options avatar has been set, otherwise 125 * false. 126 */ 127 function bp_has_options_avatar() { 128 global $bp; 129 130 if ( empty( $bp->bp_options_avatar ) ) 131 return false; 132 133 return true; 134 } 135 136 /** 137 * Output the options avatar. 135 */ 136 function bp_get_options_avatar() { 137 echo apply_filters( 'bp_get_options_avatar', buddypress()->bp_options_avatar ); 138 } 139 140 /** 141 * Output a comment author's avatar. 138 142 * 139 143 * Not currently used in BuddyPress. 140 *141 * @todo Deprecate.142 */143 function bp_get_options_avatar() {144 global $bp;145 146 echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar );147 }148 149 /**150 * Output a comment author's avatar.151 *152 * Not currently used in BuddyPress.153 *154 * @todo Deprecate.155 144 */ 156 145 function bp_comment_author_avatar() { 157 146 global $comment; 158 147 159 if ( function_exists( 'bp_core_fetch_avatar' ) ) 160 echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $comment->user_id ) ) ) ) ); 161 else if ( function_exists('get_avatar') ) 148 if ( function_exists( 'bp_core_fetch_avatar' ) ) { 149 echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 150 'item_id' => $comment->user_id, 151 'type' => 'thumb', 152 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $comment->user_id ) ) 153 ) ) ); 154 } elseif ( function_exists( 'get_avatar' ) ) { 162 155 get_avatar(); 156 } 163 157 } 164 158 … … 167 161 * 168 162 * Not currently used in BuddyPress. 169 *170 * @todo Deprecate.171 163 */ 172 164 function bp_post_author_avatar() { 173 165 global $post; 174 166 175 if ( function_exists( 'bp_core_fetch_avatar' ) ) 176 echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) ) ) ) ); 177 else if ( function_exists('get_avatar') ) 167 if ( function_exists( 'bp_core_fetch_avatar' ) ) { 168 echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 169 'item_id' => $post->post_author, 170 'type' => 'thumb', 171 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) ) 172 ) ) ); 173 } elseif ( function_exists( 'get_avatar' ) ) { 178 174 get_avatar(); 175 } 179 176 } 180 177 … … 192 189 */ 193 190 function bp_get_avatar_admin_step() { 194 global $bp; 195 196 if ( isset( $bp->avatar_admin->step ) ) 197 $step = $bp->avatar_admin->step; 198 else 199 $step = 'upload-image'; 191 $bp = buddypress(); 192 $step = isset( $bp->avatar_admin->step ) 193 ? $step = $bp->avatar_admin->step 194 : 'upload-image'; 200 195 201 196 return apply_filters( 'bp_get_avatar_admin_step', $step ); … … 214 209 */ 215 210 function bp_get_avatar_to_crop() { 216 global $bp; 217 218 if ( isset( $bp->avatar_admin->image->url ) ) 219 $url = $bp->avatar_admin->image->url; 220 else 221 $url = ''; 211 $bp = buddypress(); 212 $url = isset( $bp->avatar_admin->image->url ) 213 ? $bp->avatar_admin->image->url 214 : $url = ''; 222 215 223 216 return apply_filters( 'bp_get_avatar_to_crop', $url ); … … 236 229 */ 237 230 function bp_get_avatar_to_crop_src() { 238 global $bp; 239 240 return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) ); 231 return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', buddypress()->avatar_admin->image->dir ) ); 241 232 } 242 233 … … 249 240 */ 250 241 function bp_avatar_cropper() { 251 global $bp; 252 253 echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />'; 242 ?> 243 <img id="avatar-to-crop" class="avatar" src="<?php echo esc_url( buddypress()->avatar_admin->image ); ?>" /> 244 <?php 254 245 } 255 246 … … 282 273 */ 283 274 function bp_format_time( $time, $just_date = false, $localize_time = true ) { 284 if ( !isset( $time ) || !is_numeric( $time ) ) 275 276 if ( ! isset( $time ) || ! is_numeric( $time ) ) { 285 277 return false; 278 } 286 279 287 280 // Get GMT offset from root blog 288 281 $root_blog_offset = false; 289 if ( $localize_time )282 if ( ! empty( $localize_time ) ) { 290 283 $root_blog_offset = get_blog_option( bp_get_root_blog_id(), 'gmt_offset' ); 284 } 291 285 292 286 // Calculate offset time … … 297 291 298 292 // Should we show the time also? 299 if ( !$just_date) {293 if ( empty( $just_date ) ) { 300 294 // Current time (9:50pm) 301 295 $time = date_i18n( get_option( 'time_format' ), $time_offset ); … … 328 322 function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) { 329 323 330 if ( ! empty( $capitalize ) )324 if ( ! empty( $capitalize ) ) { 331 325 $youtext = bp_core_ucfirst( $youtext ); 326 } 332 327 333 328 if ( bp_displayed_user_id() == bp_loggedin_user_id() ) { … … 383 378 $options = array(); 384 379 385 if ( bp_is_active( 'xprofile' ) ) 380 if ( bp_is_active( 'xprofile' ) ) { 386 381 $options['members'] = __( 'Members', 'buddypress' ); 387 388 if ( bp_is_active( 'groups' ) ) 382 } 383 384 if ( bp_is_active( 'groups' ) ) { 389 385 $options['groups'] = __( 'Groups', 'buddypress' ); 390 391 if ( bp_is_active( 'blogs' ) && is_multisite() ) 386 } 387 388 if ( bp_is_active( 'blogs' ) && is_multisite() ) { 392 389 $options['blogs'] = __( 'Blogs', 'buddypress' ); 393 394 if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() ) 390 } 391 392 if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() ) { 395 393 $options['forums'] = __( 'Forums', 'buddypress' ); 394 } 396 395 397 396 $options['posts'] = __( 'Posts', 'buddypress' ); … … 402 401 403 402 $options = apply_filters( 'bp_search_form_type_select_options', $options ); 404 foreach( (array) $options as $option_value => $option_title ) 403 foreach( (array) $options as $option_value => $option_title ) { 405 404 $selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title ); 405 } 406 406 407 407 $selection_box .= '</select>'; … … 433 433 global $bp; 434 434 435 if ( empty( $component ) ) 435 if ( empty( $component ) ) { 436 436 $component = bp_current_component(); 437 } 437 438 438 439 $default_text = __( 'Search anything...', 'buddypress' ); … … 447 448 if ( !empty( $bp->pages->{$component}->slug ) ) { 448 449 $key = $bp->pages->{$component}->slug; 449 if ( !empty( $bp->{$key}->search_string ) ) 450 if ( !empty( $bp->{$key}->search_string ) ) { 450 451 $default_text = $bp->{$key}->search_string; 452 } 451 453 } 452 454 } … … 534 536 */ 535 537 function bp_create_excerpt( $text, $length = 225, $options = array() ) { 538 536 539 // Backward compatibility. The third argument used to be a boolean $filter_shortcodes 537 540 $filter_shortcodes_default = is_bool( $options ) ? $options : true; 538 541 539 $ defaults =array(542 $r = wp_parse_args( $options, array( 540 543 'ending' => __( ' […]', 'buddypress' ), 541 544 'exact' => false, 542 545 'html' => true, 543 546 'filter_shortcodes' => $filter_shortcodes_default 544 ); 545 $r = wp_parse_args( $options, $defaults ); 547 ) ); 546 548 extract( $r ); 547 549 … … 554 556 555 557 // Remove shortcodes if necessary 556 if ( ! empty( $filter_shortcodes ) )558 if ( ! empty( $filter_shortcodes ) ) { 557 559 $text = strip_shortcodes( $text ); 560 } 558 561 559 562 // When $html is true, the excerpt should be created without including HTML tags in the 560 563 // excerpt length 561 if ( ! empty( $html ) ) {564 if ( ! empty( $html ) ) { 562 565 // The text is short enough. No need to truncate 563 566 if ( mb_strlen( preg_replace( '/<.*?>/', '', $text ) ) <= $length ) { … … 692 695 */ 693 696 function bp_get_blog_signup_allowed() { 694 global $bp; 695 696 if ( !is_multisite() ) 697 698 if ( ! is_multisite() ) { 697 699 return false; 698 699 $status = $bp->site_options['registration']; 700 if ( 'none' != $status && 'user' != $status ) 700 } 701 702 $status = buddypress()->site_options['registration']; 703 if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) { 701 704 return true; 705 } 702 706 703 707 return false; … … 711 715 */ 712 716 function bp_account_was_activated() { 713 global $bp; 714 715 $activation_complete = !empty( $bp->activation_complete ) ? $bp->activation_complete : false; 717 $bp = buddypress(); 718 $activation_complete = !empty( $bp->activation_complete ) 719 ? $bp->activation_complete 720 : false; 716 721 717 722 return $activation_complete; … … 756 761 function bp_get_email_subject( $args = array() ) { 757 762 758 $r = wp_parse_args( $args, array(763 $r = bp_parse_args( $args, array( 759 764 'before' => '[', 760 765 'after' => ']', 761 766 'default' => __( 'Community', 'buddypress' ), 762 767 'text' => '' 763 ) );768 ), 'get_email_subject' ); 764 769 765 770 $subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text']; … … 782 787 */ 783 788 function bp_ajax_querystring( $object = false ) { 784 global $bp;785 786 if ( ! isset( $bp->ajax_querystring ) )789 $bp = buddypress(); 790 791 if ( ! isset( $bp->ajax_querystring ) ) { 787 792 $bp->ajax_querystring = ''; 793 } 788 794 789 795 return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object ); … … 798 804 */ 799 805 function bp_current_component() { 800 global $bp;806 $bp = buddypress(); 801 807 $current_component = !empty( $bp->current_component ) ? $bp->current_component : false; 802 808 return apply_filters( 'bp_current_component', $current_component ); … … 809 815 */ 810 816 function bp_current_action() { 811 global $bp;817 $bp = buddypress(); 812 818 $current_action = !empty( $bp->current_action ) ? $bp->current_action : ''; 813 819 return apply_filters( 'bp_current_action', $current_action ); … … 820 826 */ 821 827 function bp_current_item() { 822 global $bp;828 $bp = buddypress(); 823 829 $current_item = !empty( $bp->current_item ) ? $bp->current_item : false; 824 830 return apply_filters( 'bp_current_item', $current_item ); … … 832 838 */ 833 839 function bp_action_variables() { 834 global $bp;840 $bp = buddypress(); 835 841 $action_variables = !empty( $bp->action_variables ) ? $bp->action_variables : false; 836 842 return apply_filters( 'bp_action_variables', $action_variables ); … … 865 871 */ 866 872 function bp_get_root_domain() { 867 global $bp;873 $bp = buddypress(); 868 874 869 875 if ( isset( $bp->root_domain ) && !empty( $bp->root_domain ) ) { … … 920 926 */ 921 927 function bp_get_root_slug( $component = '' ) { 922 global $bp; 923 928 $bp = buddypress(); 924 929 $root_slug = ''; 925 930 926 931 // Use current global component if none passed 927 if ( empty( $component ) ) 932 if ( empty( $component ) ) { 928 933 $component = bp_current_component(); 934 } 929 935 930 936 // Component is active … … 941 947 942 948 // No specific root slug, so fall back to component slug 943 if ( empty( $root_slug ) ) 949 if ( empty( $root_slug ) ) { 944 950 $root_slug = $component; 951 } 945 952 946 953 return apply_filters( 'bp_get_root_slug', $root_slug, $component ); … … 958 965 */ 959 966 function bp_get_name_from_root_slug( $root_slug = '' ) { 960 global $bp;967 $bp = buddypress(); 961 968 962 969 // If no slug is passed, look at current_component 963 if ( empty( $root_slug ) ) 970 if ( empty( $root_slug ) ) { 964 971 $root_slug = bp_current_component(); 972 } 965 973 966 974 // No current component or root slug, so flee 967 if ( empty( $root_slug ) ) 975 if ( empty( $root_slug ) ) { 968 976 return false; 977 } 969 978 970 979 // Loop through active components and look for a match … … 1060 1069 1061 1070 // Backward compatibility: 'xprofile' should be read as 'profile' 1062 if ( 'xprofile' == $component )1071 if ( 'xprofile' === $component ) { 1063 1072 $component = 'profile'; 1073 } 1064 1074 1065 1075 if ( ! empty( $bp->current_component ) ) { … … 1141 1151 */ 1142 1152 function bp_is_current_action( $action = '' ) { 1143 if ( $action == bp_current_action() )1153 if ( $action === bp_current_action() ) { 1144 1154 return true; 1155 } 1145 1156 1146 1157 return false; … … 1194 1205 */ 1195 1206 function bp_is_current_item( $item = '' ) { 1196 if ( !empty( $item ) && $item == bp_current_item() ) 1197 return true; 1198 1199 return false; 1207 $retval = ( $item === bp_current_item() ); 1208 1209 return (bool) apply_filters( 'bp_is_current_item', $retval, $item ); 1200 1210 } 1201 1211 … … 1206 1216 */ 1207 1217 function bp_is_single_item() { 1208 global $bp; 1209 1210 if ( !empty( $bp->is_single_item ) ) 1211 return true; 1212 1213 return false; 1218 $bp = buddypress(); 1219 $retval = false; 1220 1221 if ( isset( $bp->is_single_item ) ) { 1222 $retval = $bp->is_single_item; 1223 } 1224 1225 return (bool) apply_filters( 'bp_is_single_item', $retval ); 1214 1226 } 1215 1227 … … 1221 1233 */ 1222 1234 function bp_is_item_admin() { 1223 global $bp; 1224 1225 if ( !empty( $bp->is_item_admin ) ) 1226 return true; 1227 1228 return false; 1235 $bp = buddypress(); 1236 $retval = false; 1237 1238 if ( isset( $bp->is_item_admin ) ) { 1239 $retval = $bp->is_item_admin; 1240 } 1241 1242 return (bool) apply_filters( 'bp_is_item_admin', $retval ); 1229 1243 } 1230 1244 … … 1236 1250 */ 1237 1251 function bp_is_item_mod() { 1238 global $bp; 1239 1240 if ( !empty( $bp->is_item_mod ) ) 1241 return true; 1242 1243 return false; 1252 $bp = buddypress(); 1253 $retval = false; 1254 1255 if ( isset( $bp->is_item_mod ) ) { 1256 $retval = $bp->is_item_mod; 1257 } 1258 1259 return (bool) apply_filters( 'bp_is_item_mod', $retval ); 1244 1260 } 1245 1261 … … 1251 1267 */ 1252 1268 function bp_is_directory() { 1253 global $bp; 1254 1255 if ( !empty( $bp->is_directory ) ) 1256 return true; 1257 1258 return false; 1269 $bp = buddypress(); 1270 $retval = false; 1271 1272 if ( isset( $bp->is_directory ) ) { 1273 $retval = $bp->is_directory; 1274 } 1275 1276 return (bool) apply_filters( 'bp_is_directory', $retval ); 1259 1277 } 1260 1278 … … 1262 1280 * Check to see if a component's URL should be in the root, not under a member page. 1263 1281 * 1264 * Yes ('groups' is root): http://domain.com/groups/the-group 1265 * No ('groups' is not-root): http://domain.com/members/andy/groups/the-group 1282 * - Yes ('groups' is root) : http://domain.com/groups/the-group 1283 * - No ('groups' is not-root): http://domain.com/members/andy/groups/the-group 1284 * 1285 * This function is on the chopping block. It's currently only used by a few 1286 * already deprecated functions. 1266 1287 * 1267 1288 * @return bool True if root component, else false. 1268 1289 */ 1269 function bp_is_root_component( $component_name ) { 1270 global $bp; 1271 1272 if ( !isset( $bp->active_components ) ) 1290 function bp_is_root_component( $component_name = '' ) { 1291 $bp = buddypress(); 1292 $retval = false; 1293 1294 // Default to the current component if none is passed 1295 if ( empty( $component_name ) ) { 1296 $component_name = bp_current_component(); 1297 } 1298 1299 // Loop through active components and check for key/slug matches 1300 if ( ! empty( $bp->active_components ) ) { 1301 foreach ( (array) $bp->active_components as $key => $slug ) { 1302 if ( ( $key === $component_name ) || ( $slug === $component_name ) ) { 1303 $retval = true; 1304 break; 1305 } 1306 } 1307 } 1308 1309 return (bool) apply_filters( 'bp_is_root_component', $retval ); 1310 } 1311 1312 /** 1313 * Check if the specified BuddyPress component directory is set to be the front page. 1314 * 1315 * Corresponds to the setting in wp-admin's Settings > Reading screen. 1316 * 1317 * @since BuddyPress (1.5.0) 1318 * 1319 * @global $current_blog WordPress global for the current blog. 1320 * 1321 * @param string $component Optional. Name of the component to check for. 1322 * Default: current component. 1323 * @return bool True if the specified component is set to be the site's front 1324 * page, otherwise false. 1325 */ 1326 function bp_is_component_front_page( $component = '' ) { 1327 global $current_blog; 1328 1329 $bp = buddypress(); 1330 1331 // Default to the current component if none is passed 1332 if ( empty( $component ) ) { 1333 $component = bp_current_component(); 1334 } 1335 1336 // Get the path for the current blog/site 1337 $path = is_main_site() 1338 ? bp_core_get_site_path() 1339 : $current_blog->path; 1340 1341 // Get the front page variables 1342 $show_on_front = get_option( 'show_on_front' ); 1343 $page_on_front = get_option( 'page_on_front' ); 1344 1345 if ( ( 'page' !== $show_on_front ) || empty( $component ) || empty( $bp->pages->{$component} ) || ( $_SERVER['REQUEST_URI'] !== $path ) ) { 1273 1346 return false; 1274 1275 foreach ( (array) $bp->active_components as $key => $slug ) { 1276 if ( $key == $component_name || $slug == $component_name ) 1277 return true; 1278 } 1279 1280 return false; 1281 } 1282 1283 /** 1284 * Check if the specified BuddyPress component directory is set to be the front page. 1285 * 1286 * Corresponds to the setting in wp-admin's Settings > Reading screen. 1287 * 1288 * @since BuddyPress (1.5.0) 1289 * 1290 * @global BuddyPress $bp The one true BuddyPress instance. 1291 * @global $current_blog WordPress global for the current blog. 1292 * 1293 * @param string $component Optional. Name of the component to check for. 1294 * Default: current component. 1295 * @return bool True if the specified component is set to be the site's front 1296 * page, otherwise false. 1297 */ 1298 function bp_is_component_front_page( $component = '' ) { 1299 global $bp, $current_blog; 1300 1301 if ( !$component && !empty( $bp->current_component ) ) 1302 $component = $bp->current_component; 1303 1304 $path = is_main_site() ? bp_core_get_site_path() : $current_blog->path; 1305 1306 if ( 'page' != get_option( 'show_on_front' ) || !$component || empty( $bp->pages->{$component} ) || $_SERVER['REQUEST_URI'] != $path ) 1307 return false; 1308 1309 return apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == get_option( 'page_on_front' ) ), $component ); 1347 } 1348 1349 return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component ); 1310 1350 } 1311 1351 … … 1322 1362 $is_blog_page = false; 1323 1363 1324 // Generally, we can just check to see that there's no current component. The one exception1325 // is single user home tabs, where $bp->current_component is unset. Thus the addition1326 // of the bp_is_user() check.1327 if ( ! bp_current_component() && !bp_is_user() )1364 // Generally, we can just check to see that there's no current component. 1365 // The one exception is single user home tabs, where $bp->current_component 1366 // is unset. Thus the addition of the bp_is_user() check. 1367 if ( ! bp_current_component() && ! bp_is_user() ) { 1328 1368 $is_blog_page = true; 1329 1330 return apply_filters( 'bp_is_blog_page', $is_blog_page ); 1369 } 1370 1371 return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page ); 1331 1372 } 1332 1373 … … 1359 1400 * @return bool True if the component is active, otherwise false. 1360 1401 */ 1361 function bp_is_active( $component ) { 1362 global $bp; 1363 1364 if ( isset( $bp->active_components[$component] ) || 'core' == $component ) 1365 return true; 1366 1367 return false; 1402 function bp_is_active( $component = '' ) { 1403 $retval = false; 1404 1405 // Default to the current component if none is passed 1406 if ( empty( $component ) ) { 1407 $component = bp_current_component(); 1408 } 1409 1410 // Is component in either the active or required components arrays 1411 if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) { 1412 $retval = true; 1413 } 1414 1415 return apply_filters( 'bp_is_active', $retval, $component ); 1368 1416 } 1369 1417 … … 1374 1422 */ 1375 1423 function bp_is_members_component() { 1376 if ( bp_is_current_component( 'members' ) ) 1377 return true; 1378 1379 return false; 1424 return (bool) bp_is_current_component( 'members' ); 1380 1425 } 1381 1426 … … 1386 1431 */ 1387 1432 function bp_is_profile_component() { 1388 if ( bp_is_current_component( 'xprofile' ) ) 1389 return true; 1390 1391 return false; 1433 return (bool) bp_is_current_component( 'xprofile' ); 1392 1434 } 1393 1435 … … 1398 1440 */ 1399 1441 function bp_is_activity_component() { 1400 if ( bp_is_current_component( 'activity' ) ) 1401 return true; 1402 1403 return false; 1442 return (bool) bp_is_current_component( 'activity' ); 1404 1443 } 1405 1444 … … 1422 1461 */ 1423 1462 function bp_is_messages_component() { 1424 if ( bp_is_current_component( 'messages' ) ) 1425 return true; 1426 1427 return false; 1463 return (bool) bp_is_current_component( 'messages' ); 1428 1464 } 1429 1465 … … 1434 1470 */ 1435 1471 function bp_is_friends_component() { 1436 if ( bp_is_current_component( 'friends' ) ) 1437 return true; 1438 1439 return false; 1472 return (bool) bp_is_current_component( 'friends' ); 1440 1473 } 1441 1474 … … 1446 1479 */ 1447 1480 function bp_is_groups_component() { 1448 if ( bp_is_current_component( 'groups' ) ) 1449 return true; 1450 1451 return false; 1481 return (bool) bp_is_current_component( 'groups' ); 1452 1482 } 1453 1483 … … 1458 1488 */ 1459 1489 function bp_is_forums_component() { 1460 if ( bp_is_current_component( 'forums' ) ) 1461 return true; 1462 1463 return false; 1490 return (bool) bp_is_current_component( 'forums' ); 1464 1491 } 1465 1492 … … 1472 1499 */ 1473 1500 function bp_is_notifications_component() { 1474 if ( bp_is_current_component( 'notifications' ) ) { 1475 return true; 1476 } 1477 1478 return false; 1501 return (bool) bp_is_current_component( 'notifications' ); 1479 1502 } 1480 1503 … … 1485 1508 */ 1486 1509 function bp_is_settings_component() { 1487 if ( bp_is_current_component( 'settings' ) ) 1488 return true; 1489 1490 return false; 1510 return (bool) bp_is_current_component( 'settings' ); 1491 1511 } 1492 1512 … … 1527 1547 */ 1528 1548 function bp_is_activity_directory() { 1529 if ( ! bp_displayed_user_id() && bp_is_activity_component() && ! bp_current_action() ) 1549 if ( ! bp_displayed_user_id() && bp_is_activity_component() && ! bp_current_action() ) { 1530 1550 return true; 1551 } 1531 1552 1532 1553 return false; … … 1539 1560 */ 1540 1561 function bp_is_single_activity() { 1541 if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) 1562 return (bool) ( bp_is_activity_component() && is_numeric( bp_current_action() ) ); 1563 } 1564 1565 /** User **********************************************************************/ 1566 1567 /** 1568 * Is the current page the members directory ? 1569 * 1570 * @since BuddyPress (2.0.0) 1571 * 1572 * @return True if the current page is the members directory. 1573 */ 1574 function bp_is_members_directory() { 1575 if ( ! bp_is_user() && bp_is_members_component() ) { 1542 1576 return true; 1543 1544 return false; 1545 } 1546 1547 /** User **********************************************************************/ 1548 1549 /** 1550 * Is the current page the members directory ? 1551 * 1552 * @since BuddyPress (2.0.0) 1553 * 1554 * @return True if the current page is the members directory. 1555 */ 1556 function bp_is_members_directory() { 1557 if ( ! bp_is_user() && bp_is_members_component() ) 1558 return true; 1577 } 1559 1578 1560 1579 return false; … … 1570 1589 */ 1571 1590 function bp_is_my_profile() { 1572 if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() ) 1591 if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() ) { 1573 1592 $my_profile = true; 1574 else1593 } else { 1575 1594 $my_profile = false; 1595 } 1576 1596 1577 1597 return apply_filters( 'bp_is_my_profile', $my_profile ); … … 1586 1606 */ 1587 1607 function bp_is_user() { 1588 if ( bp_displayed_user_id() ) 1608 return (bool) bp_displayed_user_id(); 1609 } 1610 1611 /** 1612 * Is the current page a user's activity stream page? 1613 * 1614 * Eg http://example.com/members/joe/activity/ (or any subpages thereof). 1615 * 1616 * @return True if the current page is a user's activity stream page. 1617 */ 1618 function bp_is_user_activity() { 1619 return (bool) ( bp_is_user() && bp_is_activity_component() ); 1620 } 1621 1622 /** 1623 * Is the current page a user's Friends activity stream? 1624 * 1625 * Eg http://example.com/members/joe/friends/ 1626 * 1627 * @return True if the current page is a user's Friends activity stream. 1628 */ 1629 function bp_is_user_friends_activity() { 1630 1631 if ( ! bp_is_active( 'friends' ) ) { 1632 return false; 1633 } 1634 1635 $slug = bp_get_friends_slug(); 1636 1637 if ( empty( $slug ) ) { 1638 $slug = 'friends'; 1639 } 1640 1641 if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) { 1589 1642 return true; 1643 } 1590 1644 1591 1645 return false; … … 1593 1647 1594 1648 /** 1595 * Is the current page a user's activity stream page? 1596 * 1597 * Eg http://example.com/members/joe/activity/ (or any subpages thereof). 1598 * 1599 * @return True if the current page is a user's activity stream page. 1600 */ 1601 function bp_is_user_activity() { 1602 if ( bp_is_user() && bp_is_activity_component() ) 1649 * Is the current page a user's Groups activity stream? 1650 * 1651 * Eg http://example.com/members/joe/groups/ 1652 * 1653 * @return True if the current page is a user's Groups activity stream. 1654 */ 1655 function bp_is_user_groups_activity() { 1656 1657 if ( ! bp_is_active( 'groups' ) ) { 1658 return false; 1659 } 1660 1661 $slug = ( bp_get_groups_slug() ) 1662 ? bp_get_groups_slug() 1663 : 'groups'; 1664 1665 if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) { 1603 1666 return true; 1667 } 1604 1668 1605 1669 return false; … … 1607 1671 1608 1672 /** 1609 * Is the current page a user's Friends activity stream? 1610 * 1611 * Eg http://example.com/members/joe/friends/ 1612 * 1613 * @return True if the current page is a user's Friends activity stream. 1614 */ 1615 function bp_is_user_friends_activity() { 1616 1617 if ( !bp_is_active( 'friends' ) ) 1673 * Is the current page part of a user's extended profile? 1674 * 1675 * Eg http://example.com/members/joe/profile/ (or a subpage thereof). 1676 * 1677 * @return True if the current page is part of a user's extended profile. 1678 */ 1679 function bp_is_user_profile() { 1680 return (bool) ( bp_is_profile_component() || bp_is_current_component( 'profile' ) ); 1681 } 1682 1683 /** 1684 * Is the current page part of a user's profile editing section? 1685 * 1686 * Eg http://example.com/members/joe/profile/edit/ (or a subpage thereof). 1687 * 1688 * @return True if the current page is a user's profile edit page. 1689 */ 1690 function bp_is_user_profile_edit() { 1691 return (bool) ( bp_is_profile_component() && bp_is_current_action( 'edit' ) ); 1692 } 1693 1694 function bp_is_user_change_avatar() { 1695 return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) ); 1696 } 1697 1698 /** 1699 * Is this a user's forums page? 1700 * 1701 * Eg http://example.com/members/joe/forums/ (or a subpage thereof). 1702 * 1703 * @return bool True if the current page is a user's forums page. 1704 */ 1705 function bp_is_user_forums() { 1706 1707 if ( ! bp_is_active( 'forums' ) ) { 1618 1708 return false; 1619 1620 $slug = bp_get_friends_slug(); 1621 1622 if ( empty( $slug ) ) 1623 $slug = 'friends'; 1624 1625 if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) 1709 } 1710 1711 if ( bp_is_user() && bp_is_forums_component() ) { 1626 1712 return true; 1713 } 1627 1714 1628 1715 return false; … … 1630 1717 1631 1718 /** 1632 * Is the current page a user's Groups activity stream? 1633 * 1634 * Eg http://example.com/members/joe/groups/ 1635 * 1636 * @return True if the current page is a user's Groups activity stream. 1637 */ 1638 function bp_is_user_groups_activity() { 1639 1640 if ( !bp_is_active( 'groups' ) ) 1641 return false; 1642 1643 $slug = bp_get_groups_slug(); 1644 1645 if ( empty( $slug ) ) 1646 $slug = 'groups'; 1647 1648 if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) 1719 * Is this a user's "Topics Started" page? 1720 * 1721 * Eg http://example.com/members/joe/forums/topics/. 1722 * 1723 * @since BuddyPress (1.5.0) 1724 * 1725 * @return bool True if the current page is a user's Topics Started page. 1726 */ 1727 function bp_is_user_forums_started() { 1728 return (bool) ( bp_is_user_forums() && bp_is_current_action( 'topics' ) ); 1729 } 1730 1731 /** 1732 * Is this a user's "Replied To" page? 1733 * 1734 * Eg http://example.com/members/joe/forums/replies/. 1735 * 1736 * @since BuddyPress (1.5.0) 1737 * 1738 * @return bool True if the current page is a user's Replied To forums page. 1739 */ 1740 function bp_is_user_forums_replied_to() { 1741 return (bool) ( bp_is_user_forums() && bp_is_current_action( 'replies' ) ); 1742 } 1743 1744 /** 1745 * Is the current page part of a user's Groups page? 1746 * 1747 * Eg http://example.com/members/joe/groups/ (or a subpage thereof). 1748 * 1749 * @return bool True if the current page is a user's Groups page. 1750 */ 1751 function bp_is_user_groups() { 1752 return (bool) ( bp_is_user() && bp_is_groups_component() ); 1753 } 1754 1755 /** 1756 * Is the current page part of a user's Blogs page? 1757 * 1758 * Eg http://example.com/members/joe/blogs/ (or a subpage thereof). 1759 * 1760 * @return bool True if the current page is a user's Blogs page. 1761 */ 1762 function bp_is_user_blogs() { 1763 return (bool) ( bp_is_user() && bp_is_blogs_component() ); 1764 } 1765 1766 /** 1767 * Is the current page a user's Recent Blog Posts page? 1768 * 1769 * Eg http://example.com/members/joe/blogs/recent-posts/. 1770 * 1771 * @return bool True if the current page is a user's Recent Blog Posts page. 1772 */ 1773 function bp_is_user_recent_posts() { 1774 return (bool) ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) ); 1775 } 1776 1777 /** 1778 * Is the current page a user's Recent Blog Comments page? 1779 * 1780 * Eg http://example.com/members/joe/blogs/recent-comments/. 1781 * 1782 * @return bool True if the current page is a user's Recent Blog Comments page. 1783 */ 1784 function bp_is_user_recent_commments() { 1785 return (bool) ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) ); 1786 } 1787 1788 /** 1789 * Is the current page a user's Friends page? 1790 * 1791 * Eg http://example.com/members/joe/blogs/friends/ (or a subpage thereof). 1792 * 1793 * @return bool True if the current page is a user's Friends page. 1794 */ 1795 function bp_is_user_friends() { 1796 return (bool) ( bp_is_user() && bp_is_friends_component() ); 1797 } 1798 1799 /** 1800 * Is the current page a user's Friend Requests page? 1801 * 1802 * Eg http://example.com/members/joe/friends/requests/. 1803 * 1804 * @return bool True if the current page is a user's Friends Requests page. 1805 */ 1806 function bp_is_user_friend_requests() { 1807 return (bool) ( bp_is_user_friends() && bp_is_current_action( 'requests' ) ); 1808 } 1809 1810 /** 1811 * Is this a user's notifications page? 1812 * 1813 * Eg http://example.com/members/joe/notifications/ (or a subpage thereof). 1814 * 1815 * @since BuddyPress (1.9.0) 1816 * 1817 * @return bool True if the current page is a user's Notifications page. 1818 */ 1819 function bp_is_user_notifications() { 1820 return (bool) ( bp_is_user() && bp_is_notifications_component() ); 1821 } 1822 1823 /** 1824 * Is this a user's settings page? 1825 * 1826 * Eg http://example.com/members/joe/settings/ (or a subpage thereof). 1827 * 1828 * @return bool True if the current page is a user's Settings page. 1829 */ 1830 function bp_is_user_settings() { 1831 return (bool) ( bp_is_user() && bp_is_settings_component() ); 1832 } 1833 1834 /** 1835 * Is this a user's General Settings page? 1836 * 1837 * Eg http://example.com/members/joe/settings/general/. 1838 * 1839 * @since BuddyPress (1.5.0) 1840 * 1841 * @return bool True if the current page is a user's General Settings page. 1842 */ 1843 function bp_is_user_settings_general() { 1844 return (bool) ( bp_is_user_settings() && bp_is_current_action( 'general' ) ); 1845 } 1846 1847 /** 1848 * Is this a user's Notification Settings page? 1849 * 1850 * Eg http://example.com/members/joe/settings/notifications/. 1851 * 1852 * @since BuddyPress (1.5.0) 1853 * 1854 * @return bool True if the current page is a user's Notification Settings page. 1855 */ 1856 function bp_is_user_settings_notifications() { 1857 return (bool) ( bp_is_user_settings() && bp_is_current_action( 'notifications' ) ); 1858 } 1859 1860 /** 1861 * Is this a user's Account Deletion page? 1862 * 1863 * Eg http://example.com/members/joe/settings/delete-account/. 1864 * 1865 * @since BuddyPress (1.5.0) 1866 * 1867 * @return bool True if the current page is a user's Delete Account page. 1868 */ 1869 function bp_is_user_settings_account_delete() { 1870 return (bool) ( bp_is_user_settings() && bp_is_current_action( 'delete-account' ) ); 1871 } 1872 1873 /** 1874 * Is this a user's profile settings? 1875 * 1876 * Eg http://example.com/members/joe/settings/profile/. 1877 * 1878 * @since BuddyPress (2.0.0) 1879 * 1880 * @return bool True if the current page is a user's Profile Settings page. 1881 */ 1882 function bp_is_user_settings_profile() { 1883 return (bool) ( bp_is_user_settings() && bp_is_current_action( 'profile' ) ); 1884 } 1885 1886 /** Groups ********************************************************************/ 1887 1888 /** 1889 * Is the current page the groups directory ? 1890 * 1891 * @since BuddyPress (2.0.0) 1892 * 1893 * @return True if the current page is the groups directory. 1894 */ 1895 function bp_is_groups_directory() { 1896 if ( bp_is_groups_component() && ! bp_current_action() && ! bp_current_item() ) { 1649 1897 return true; 1898 } 1650 1899 1651 1900 return false; … … 1653 1902 1654 1903 /** 1655 * Is the current page part of a user's extended profile?1656 *1657 * Eg http://example.com/members/joe/profile/ (or a subpage thereof).1658 *1659 * @return True if the current page is part of a user's extended profile.1660 */1661 function bp_is_user_profile() {1662 if ( bp_is_profile_component() || bp_is_current_component( 'profile' ) )1663 return true;1664 1665 return false;1666 }1667 1668 /**1669 * Is the current page part of a user's profile editing section?1670 *1671 * Eg http://example.com/members/joe/profile/edit/ (or a subpage thereof).1672 *1673 * @return True if the current page is a user's profile edit page.1674 */1675 function bp_is_user_profile_edit() {1676 if ( bp_is_profile_component() && bp_is_current_action( 'edit' ) )1677 return true;1678 1679 return false;1680 }1681 1682 function bp_is_user_change_avatar() {1683 if ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) )1684 return true;1685 1686 return false;1687 }1688 1689 /**1690 * Is this a user's forums page?1691 *1692 * Eg http://example.com/members/joe/forums/ (or a subpage thereof).1693 *1694 * @return bool True if the current page is a user's forums page.1695 */1696 function bp_is_user_forums() {1697 1698 if ( ! bp_is_active( 'forums' ) )1699 return false;1700 1701 if ( bp_is_user() && bp_is_forums_component() )1702 return true;1703 1704 return false;1705 }1706 1707 /**1708 * Is this a user's "Topics Started" page?1709 *1710 * Eg http://example.com/members/joe/forums/topics/.1711 *1712 * @since BuddyPress (1.5.0)1713 *1714 * @return bool True if the current page is a user's Topics Started page.1715 */1716 function bp_is_user_forums_started() {1717 if ( bp_is_user_forums() && bp_is_current_action( 'topics' ) )1718 return true;1719 1720 return false;1721 }1722 1723 /**1724 * Is this a user's "Replied To" page?1725 *1726 * Eg http://example.com/members/joe/forums/replies/.1727 *1728 * @since BuddyPress (1.5.0)1729 *1730 * @return bool True if the current page is a user's Replied To forums page.1731 */1732 function bp_is_user_forums_replied_to() {1733 if ( bp_is_user_forums() && bp_is_current_action( 'replies' ) )1734 return true;1735 1736 return false;1737 }1738 1739 /**1740 * Is the current page part of a user's Groups page?1741 *1742 * Eg http://example.com/members/joe/groups/ (or a subpage thereof).1743 *1744 * @return bool True if the current page is a user's Groups page.1745 */1746 function bp_is_user_groups() {1747 if ( bp_is_user() && bp_is_groups_component() )1748 return true;1749 1750 return false;1751 }1752 1753 /**1754 * Is the current page part of a user's Blogs page?1755 *1756 * Eg http://example.com/members/joe/blogs/ (or a subpage thereof).1757 *1758 * @return bool True if the current page is a user's Blogs page.1759 */1760 function bp_is_user_blogs() {1761 if ( bp_is_user() && bp_is_blogs_component() )1762 return true;1763 1764 return false;1765 }1766 1767 /**1768 * Is the current page a user's Recent Blog Posts page?1769 *1770 * Eg http://example.com/members/joe/blogs/recent-posts/.1771 *1772 * @return bool True if the current page is a user's Recent Blog Posts page.1773 */1774 function bp_is_user_recent_posts() {1775 if ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) )1776 return true;1777 1778 return false;1779 }1780 1781 /**1782 * Is the current page a user's Recent Blog Comments page?1783 *1784 * Eg http://example.com/members/joe/blogs/recent-comments/.1785 *1786 * @return bool True if the current page is a user's Recent Blog Comments page.1787 */1788 function bp_is_user_recent_commments() {1789 if ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) )1790 return true;1791 1792 return false;1793 }1794 1795 /**1796 * Is the current page a user's Friends page?1797 *1798 * Eg http://example.com/members/joe/blogs/friends/ (or a subpage thereof).1799 *1800 * @return bool True if the current page is a user's Friends page.1801 */1802 function bp_is_user_friends() {1803 if ( bp_is_user() && bp_is_friends_component() )1804 return true;1805 1806 return false;1807 }1808 1809 /**1810 * Is the current page a user's Friend Requests page?1811 *1812 * Eg http://example.com/members/joe/friends/requests/.1813 *1814 * @return bool True if the current page is a user's Friends Requests page.1815 */1816 function bp_is_user_friend_requests() {1817 if ( bp_is_user_friends() && bp_is_current_action( 'requests' ) )1818 return true;1819 1820 return false;1821 }1822 1823 /**1824 * Is this a user's notifications page?1825 *1826 * Eg http://example.com/members/joe/notifications/ (or a subpage thereof).1827 *1828 * @since BuddyPress (1.9.0)1829 *1830 * @return bool True if the current page is a user's Notifications page.1831 */1832 function bp_is_user_notifications() {1833 if ( bp_is_user() && bp_is_notifications_component() ) {1834 return true;1835 }1836 1837 return false;1838 }1839 1840 /**1841 * Is this a user's settings page?1842 *1843 * Eg http://example.com/members/joe/settings/ (or a subpage thereof).1844 *1845 * @return bool True if the current page is a user's Settings page.1846 */1847 function bp_is_user_settings() {1848 if ( bp_is_user() && bp_is_settings_component() )1849 return true;1850 1851 return false;1852 }1853 1854 /**1855 * Is this a user's General Settings page?1856 *1857 * Eg http://example.com/members/joe/settings/general/.1858 *1859 * @since BuddyPress (1.5.0)1860 *1861 * @return bool True if the current page is a user's General Settings page.1862 */1863 function bp_is_user_settings_general() {1864 if ( bp_is_user_settings() && bp_is_current_action( 'general' ) )1865 return true;1866 1867 return false;1868 }1869 1870 /**1871 * Is this a user's Notification Settings page?1872 *1873 * Eg http://example.com/members/joe/settings/notifications/.1874 *1875 * @since BuddyPress (1.5.0)1876 *1877 * @return bool True if the current page is a user's Notification Settings page.1878 */1879 function bp_is_user_settings_notifications() {1880 if ( bp_is_user_settings() && bp_is_current_action( 'notifications' ) )1881 return true;1882 1883 return false;1884 }1885 1886 /**1887 * Is this a user's Account Deletion page?1888 *1889 * Eg http://example.com/members/joe/settings/delete-account/.1890 *1891 * @since BuddyPress (1.5.0)1892 *1893 * @return bool True if the current page is a user's Delete Account page.1894 */1895 function bp_is_user_settings_account_delete() {1896 if ( bp_is_user_settings() && bp_is_current_action( 'delete-account' ) )1897 return true;1898 1899 return false;1900 }1901 1902 /**1903 * Is this a user's profile settings?1904 *1905 * Eg http://example.com/members/joe/settings/profile/.1906 *1907 * @since BuddyPress (2.0.0)1908 *1909 * @return bool True if the current page is a user's Profile Settings page.1910 */1911 function bp_is_user_settings_profile() {1912 if ( bp_is_user_settings() && bp_is_current_action( 'profile' ) )1913 return true;1914 1915 return false;1916 }1917 1918 /** Groups ********************************************************************/1919 1920 /**1921 * Is the current page the groups directory ?1922 *1923 * @since BuddyPress (2.0.0)1924 *1925 * @return True if the current page is the groups directory.1926 */1927 function bp_is_groups_directory() {1928 if ( bp_is_groups_component() && ! bp_current_action() && ! bp_current_item() )1929 return true;1930 1931 return false;1932 }1933 1934 /**1935 1904 * Does the current page belong to a single group? 1936 1905 * … … 1940 1909 */ 1941 1910 function bp_is_group() { 1942 global $bp; 1943 1944 if ( bp_is_groups_component() && isset( $bp->groups->current_group ) && $bp->groups->current_group ) 1945 return true; 1946 1947 return false; 1911 return (bool) ( bp_is_groups_component() && groups_get_current_group() ); 1948 1912 } 1949 1913 … … 1957 1921 */ 1958 1922 function bp_is_group_home() { 1959 if ( bp_is_single_item() && bp_is_groups_component() && ( ! bp_current_action() || bp_is_current_action( 'home' ) ) )1923 if ( bp_is_single_item() && bp_is_groups_component() && ( ! bp_current_action() || bp_is_current_action( 'home' ) ) ) { 1960 1924 return true; 1925 } 1961 1926 1962 1927 return false; … … 1969 1934 */ 1970 1935 function bp_is_group_create() { 1971 if ( bp_is_groups_component() && bp_is_current_action( 'create' ) ) 1972 return true; 1973 1974 return false; 1936 return (bool) ( bp_is_groups_component() && bp_is_current_action( 'create' ) ); 1975 1937 } 1976 1938 … … 1983 1945 */ 1984 1946 function bp_is_group_admin_page() { 1985 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) ) 1986 return true; 1987 1988 return false; 1947 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) ); 1989 1948 } 1990 1949 … … 2019 1978 */ 2020 1979 function bp_is_group_activity() { 2021 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) 1980 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ); 1981 } 1982 1983 /** 1984 * Is the current page a group forum topic? 1985 * 1986 * Only applies to legacy bbPress (1.x) forums. 1987 * 1988 * @return bool True if the current page is part of a group forum topic. 1989 */ 1990 function bp_is_group_forum_topic() { 1991 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) ); 1992 } 1993 1994 /** 1995 * Is the current page a group forum topic edit page? 1996 * 1997 * Only applies to legacy bbPress (1.x) forums. 1998 * 1999 * @return bool True if the current page is part of a group forum topic edit page. 2000 */ 2001 function bp_is_group_forum_topic_edit() { 2002 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_is_action_variable( 'edit', 2 ) ); 2003 } 2004 2005 /** 2006 * Is the current page a group's Members page? 2007 * 2008 * Eg http://example.com/groups/mygroup/members/. 2009 * 2010 * @return bool True if the current page is part of a group's Members page. 2011 */ 2012 function bp_is_group_members() { 2013 return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ); 2014 } 2015 2016 /** 2017 * Is the current page a group's Invites page? 2018 * 2019 * Eg http://example.com/groups/mygroup/send-invites/. 2020 * 2021 * @return bool True if the current page is a group's Send Invites page. 2022 */ 2023 function bp_is_group_invites() { 2024 return (bool) ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) ); 2025 } 2026 2027 /** 2028 * Is the current page a group's Request Membership page? 2029 * 2030 * Eg http://example.com/groups/mygroup/request-membership/. 2031 * 2032 * @return bool True if the current page is a group's Request Membership page. 2033 */ 2034 function bp_is_group_membership_request() { 2035 return (bool) ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) ); 2036 } 2037 2038 /** 2039 * Is the current page a leave group attempt? 2040 * 2041 * @return bool True if the current page is a Leave Group attempt. 2042 */ 2043 function bp_is_group_leave() { 2044 return (bool) ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) ); 2045 } 2046 2047 /** 2048 * Is the current page part of a single group? 2049 * 2050 * Not currently used by BuddyPress. 2051 * 2052 * @todo How is this functionally different from bp_is_group()? 2053 * 2054 * @return bool True if the current page is part of a single group. 2055 */ 2056 function bp_is_group_single() { 2057 return (bool) ( bp_is_groups_component() && bp_is_single_item() ); 2058 } 2059 2060 /** 2061 * Is the current page the Create a Blog page? 2062 * 2063 * Eg http://example.com/sites/create/. 2064 * 2065 * @return bool True if the current page is the Create a Blog page. 2066 */ 2067 function bp_is_create_blog() { 2068 return (bool) ( bp_is_blogs_component() && bp_is_current_action( 'create' ) ); 2069 } 2070 2071 /** 2072 * Is the current page the blogs directory ? 2073 * 2074 * @since BuddyPress (2.0.0) 2075 * 2076 * @return True if the current page is the blogs directory. 2077 */ 2078 function bp_is_blogs_directory() { 2079 if ( is_multisite() && bp_is_blogs_component() && ! bp_current_action() ) { 2022 2080 return true; 2081 } 2023 2082 2024 2083 return false; 2025 2084 } 2026 2085 2027 /** 2028 * Is the current page a group forum topic? 2029 * 2030 * Only applies to legacy bbPress (1.x) forums. 2031 * 2032 * @return bool True if the current page is part of a group forum topic. 2033 */ 2034 function bp_is_group_forum_topic() { 2035 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) ) 2086 /** Messages ******************************************************************/ 2087 2088 /** 2089 * Is the current page part of a user's Messages pages? 2090 * 2091 * Eg http://example.com/members/joe/messages/ (or a subpage thereof). 2092 * 2093 * @return bool True if the current page is part of a user's Messages pages. 2094 */ 2095 function bp_is_user_messages() { 2096 return (bool) ( bp_is_user() && bp_is_messages_component() ); 2097 } 2098 2099 /** 2100 * Is the current page a user's Messages Inbox? 2101 * 2102 * Eg http://example.com/members/joe/messages/inbox/. 2103 * 2104 * @return bool True if the current page is a user's Messages Inbox. 2105 */ 2106 function bp_is_messages_inbox() { 2107 if ( bp_is_user_messages() && ( ! bp_current_action() || bp_is_current_action( 'inbox' ) ) ) { 2036 2108 return true; 2109 } 2037 2110 2038 2111 return false; … … 2040 2113 2041 2114 /** 2042 * Is the current page a group forum topic edit page? 2043 * 2044 * Only applies to legacy bbPress (1.x) forums. 2045 * 2046 * @return bool True if the current page is part of a group forum topic edit page. 2047 */ 2048 function bp_is_group_forum_topic_edit() { 2049 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_is_action_variable( 'edit', 2 ) ) 2050 return true; 2051 2052 return false; 2053 } 2054 2055 /** 2056 * Is the current page a group's Members page? 2057 * 2058 * Eg http://example.com/groups/mygroup/members/. 2059 * 2060 * @return bool True if the current page is part of a group's Members page. 2061 */ 2062 function bp_is_group_members() { 2063 if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) 2064 return true; 2065 2066 return false; 2067 } 2068 2069 /** 2070 * Is the current page a group's Invites page? 2071 * 2072 * Eg http://example.com/groups/mygroup/send-invites/. 2073 * 2074 * @return bool True if the current page is a group's Send Invites page. 2075 */ 2076 function bp_is_group_invites() { 2077 if ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) ) 2078 return true; 2079 2080 return false; 2081 } 2082 2083 /** 2084 * Is the current page a group's Request Membership page? 2085 * 2086 * Eg http://example.com/groups/mygroup/request-membership/. 2087 * 2088 * @return bool True if the current page is a group's Request Membership page. 2089 */ 2090 function bp_is_group_membership_request() { 2091 if ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) ) 2092 return true; 2093 2094 return false; 2095 } 2096 2097 /** 2098 * Is the current page a leave group attempt? 2099 * 2100 * @return bool True if the current page is a Leave Group attempt. 2101 */ 2102 function bp_is_group_leave() { 2103 2104 if ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) ) 2105 return true; 2106 2107 return false; 2108 } 2109 2110 /** 2111 * Is the current page part of a single group? 2112 * 2115 * Is the current page a user's Messages Sentbox? 2116 * 2117 * Eg http://example.com/members/joe/messages/sentbox/. 2118 * 2119 * @return bool True if the current page is a user's Messages Sentbox. 2120 */ 2121 function bp_is_messages_sentbox() { 2122 return (bool) ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) ); 2123 } 2124 2125 /** 2126 * Is the current page a user's Messages Compose screen?? 2127 * 2128 * Eg http://example.com/members/joe/messages/compose/. 2129 * 2130 * @return bool True if the current page is a user's Messages Compose screen. 2131 */ 2132 function bp_is_messages_compose_screen() { 2133 return (bool) ( bp_is_user_messages() && bp_is_current_action( 'compose' ) ); 2134 } 2135 2136 /** 2137 * Is the current page the Notices screen? 2138 * 2139 * Eg http://example.com/members/joe/messages/notices/. 2140 * 2141 * @return bool True if the current page is the Notices screen. 2142 */ 2143 function bp_is_notices() { 2144 return (bool) ( bp_is_user_messages() && bp_is_current_action( 'notices' ) ); 2145 } 2146 2147 /** 2148 * Is the current page a single Messages conversation thread? 2149 * 2150 * @return bool True if the current page a single Messages conversation thread? 2151 */ 2152 function bp_is_messages_conversation() { 2153 return (bool) ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) ); 2154 } 2155 2156 /** 2113 2157 * Not currently used by BuddyPress. 2114 2158 * 2115 * @todo How is this functionally different from bp_is_group()?2116 *2117 * @return bool True if the current page is part of a single group.2118 */2119 function bp_is_group_single() {2120 if ( bp_is_groups_component() && bp_is_single_item() )2121 return true;2122 2123 return false;2124 }2125 2126 /**2127 * Is the current page the Create a Blog page?2128 *2129 * Eg http://example.com/sites/create/.2130 *2131 * @return bool True if the current page is the Create a Blog page.2132 */2133 function bp_is_create_blog() {2134 if ( bp_is_blogs_component() && bp_is_current_action( 'create' ) )2135 return true;2136 2137 return false;2138 }2139 2140 /**2141 * Is the current page the blogs directory ?2142 *2143 * @since BuddyPress (2.0.0)2144 *2145 * @return True if the current page is the blogs directory.2146 */2147 function bp_is_blogs_directory() {2148 if ( is_multisite() && bp_is_blogs_component() && ! bp_current_action() )2149 return true;2150 2151 return false;2152 }2153 2154 /** Messages ******************************************************************/2155 2156 /**2157 * Is the current page part of a user's Messages pages?2158 *2159 * Eg http://example.com/members/joe/messages/ (or a subpage thereof).2160 *2161 * @return bool True if the current page is part of a user's Messages pages.2162 */2163 function bp_is_user_messages() {2164 if ( bp_is_user() && bp_is_messages_component() )2165 return true;2166 2167 return false;2168 }2169 2170 /**2171 * Is the current page a user's Messages Inbox?2172 *2173 * Eg http://example.com/members/joe/messages/inbox/.2174 *2175 * @return bool True if the current page is a user's Messages Inbox.2176 */2177 function bp_is_messages_inbox() {2178 if ( bp_is_user_messages() && ( !bp_current_action() || bp_is_current_action( 'inbox' ) ) )2179 return true;2180 2181 return false;2182 }2183 2184 /**2185 * Is the current page a user's Messages Sentbox?2186 *2187 * Eg http://example.com/members/joe/messages/sentbox/.2188 *2189 * @return bool True if the current page is a user's Messages Sentbox.2190 */2191 function bp_is_messages_sentbox() {2192 if ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) )2193 return true;2194 2195 return false;2196 }2197 2198 /**2199 * Is the current page a user's Messages Compose screen??2200 *2201 * Eg http://example.com/members/joe/messages/compose/.2202 *2203 * @return bool True if the current page is a user's Messages Compose screen.2204 */2205 function bp_is_messages_compose_screen() {2206 if ( bp_is_user_messages() && bp_is_current_action( 'compose' ) )2207 return true;2208 2209 return false;2210 }2211 2212 /**2213 * Is the current page the Notices screen?2214 *2215 * Eg http://example.com/members/joe/messages/notices/.2216 *2217 * @return bool True if the current page is the Notices screen.2218 */2219 function bp_is_notices() {2220 if ( bp_is_user_messages() && bp_is_current_action( 'notices' ) )2221 return true;2222 2223 return false;2224 }2225 2226 /**2227 * Is the current page a single Messages conversation thread?2228 *2229 * @return bool True if the current page a single Messages conversation thread?2230 */2231 function bp_is_messages_conversation() {2232 if ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) )2233 return true;2234 2235 return false;2236 }2237 2238 /**2239 * Not currently used by BuddyPress.2240 *2241 2159 * @return bool 2242 2160 */ 2243 2161 function bp_is_single( $component, $callback ) { 2244 if ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) ) 2245 return true; 2246 2247 return false; 2162 return (bool) ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) ); 2248 2163 } 2249 2164 … … 2258 2173 */ 2259 2174 function bp_is_activation_page() { 2260 if ( bp_is_current_component( 'activate' ) ) 2261 return true; 2262 2263 return false; 2175 return (bool) bp_is_current_component( 'activate' ); 2264 2176 } 2265 2177 … … 2272 2184 */ 2273 2185 function bp_is_register_page() { 2274 if ( bp_is_current_component( 'register' ) ) 2275 return true; 2276 2277 return false; 2186 return (bool) bp_is_current_component( 'register' ); 2278 2187 } 2279 2188 … … 2296 2205 /** Pages *************************************************************/ 2297 2206 2298 if ( is_front_page() ) 2207 if ( is_front_page() ) { 2299 2208 $bp_classes[] = 'home-page'; 2300 2301 if ( bp_is_directory() ) 2209 } 2210 2211 if ( bp_is_directory() ) { 2302 2212 $bp_classes[] = 'directory'; 2303 2304 if ( bp_is_single_item() ) 2213 } 2214 2215 if ( bp_is_single_item() ) { 2305 2216 $bp_classes[] = 'single-item'; 2217 } 2306 2218 2307 2219 /** Components ********************************************************/ 2308 2220 2309 if ( ! bp_is_blog_page() ) :2310 if ( bp_is_user_profile() ) 2221 if ( ! bp_is_blog_page() ) { 2222 if ( bp_is_user_profile() ) { 2311 2223 $bp_classes[] = 'xprofile'; 2312 2313 if ( bp_is_activity_component() ) 2224 } 2225 2226 if ( bp_is_activity_component() ) { 2314 2227 $bp_classes[] = 'activity'; 2315 2316 if ( bp_is_blogs_component() ) 2228 } 2229 2230 if ( bp_is_blogs_component() ) { 2317 2231 $bp_classes[] = 'blogs'; 2318 2319 if ( bp_is_messages_component() ) 2232 } 2233 2234 if ( bp_is_messages_component() ) { 2320 2235 $bp_classes[] = 'messages'; 2321 2322 if ( bp_is_friends_component() ) 2236 } 2237 2238 if ( bp_is_friends_component() ) { 2323 2239 $bp_classes[] = 'friends'; 2324 2325 if ( bp_is_groups_component() ) 2240 } 2241 2242 if ( bp_is_groups_component() ) { 2326 2243 $bp_classes[] = 'groups'; 2327 2328 if ( bp_is_settings_component() ) 2244 } 2245 2246 if ( bp_is_settings_component() ) { 2329 2247 $bp_classes[] = 'settings'; 2330 endif; 2248 } 2249 } 2331 2250 2332 2251 /** User **************************************************************/ 2333 2252 2334 if ( bp_is_user() ) 2253 if ( bp_is_user() ) { 2335 2254 $bp_classes[] = 'bp-user'; 2336 2337 if ( !bp_is_directory() ) : 2338 if ( bp_is_user_blogs() ) 2255 } 2256 2257 if ( ! bp_is_directory() ) { 2258 if ( bp_is_user_blogs() ) { 2339 2259 $bp_classes[] = 'my-blogs'; 2340 2341 if ( bp_is_user_groups() ) 2260 } 2261 2262 if ( bp_is_user_groups() ) { 2342 2263 $bp_classes[] = 'my-groups'; 2343 2344 if ( bp_is_user_activity() ) 2264 } 2265 2266 if ( bp_is_user_activity() ) { 2345 2267 $bp_classes[] = 'my-activity'; 2346 endif; 2347 2348 if ( bp_is_my_profile() ) 2268 } 2269 } 2270 2271 if ( bp_is_my_profile() ) { 2349 2272 $bp_classes[] = 'my-account'; 2350 2351 if ( bp_is_user_profile() ) 2273 } 2274 2275 if ( bp_is_user_profile() ) { 2352 2276 $bp_classes[] = 'my-profile'; 2353 2354 if ( bp_is_user_friends() ) 2277 } 2278 2279 if ( bp_is_user_friends() ) { 2355 2280 $bp_classes[] = 'my-friends'; 2356 2357 if ( bp_is_user_messages() ) 2281 } 2282 2283 if ( bp_is_user_messages() ) { 2358 2284 $bp_classes[] = 'my-messages'; 2359 2360 if ( bp_is_user_recent_commments() ) 2285 } 2286 2287 if ( bp_is_user_recent_commments() ) { 2361 2288 $bp_classes[] = 'recent-comments'; 2362 2363 if ( bp_is_user_recent_posts() ) 2289 } 2290 2291 if ( bp_is_user_recent_posts() ) { 2364 2292 $bp_classes[] = 'recent-posts'; 2365 2366 if ( bp_is_user_change_avatar() ) 2293 } 2294 2295 if ( bp_is_user_change_avatar() ) { 2367 2296 $bp_classes[] = 'change-avatar'; 2368 2369 if ( bp_is_user_profile_edit() ) 2297 } 2298 2299 if ( bp_is_user_profile_edit() ) { 2370 2300 $bp_classes[] = 'profile-edit'; 2371 2372 if ( bp_is_user_friends_activity() ) 2301 } 2302 2303 if ( bp_is_user_friends_activity() ) { 2373 2304 $bp_classes[] = 'friends-activity'; 2374 2375 if ( bp_is_user_groups_activity() ) 2305 } 2306 2307 if ( bp_is_user_groups_activity() ) { 2376 2308 $bp_classes[] = 'groups-activity'; 2309 } 2377 2310 2378 2311 /** Messages **********************************************************/ 2379 2312 2380 if ( bp_is_messages_inbox() ) 2313 if ( bp_is_messages_inbox() ) { 2381 2314 $bp_classes[] = 'inbox'; 2382 2383 if ( bp_is_messages_sentbox() ) 2315 } 2316 2317 if ( bp_is_messages_sentbox() ) { 2384 2318 $bp_classes[] = 'sentbox'; 2385 2386 if ( bp_is_messages_compose_screen() ) 2319 } 2320 2321 if ( bp_is_messages_compose_screen() ) { 2387 2322 $bp_classes[] = 'compose'; 2388 2389 if ( bp_is_notices() ) 2323 } 2324 2325 if ( bp_is_notices() ) { 2390 2326 $bp_classes[] = 'notices'; 2391 2392 if ( bp_is_user_friend_requests() ) 2327 } 2328 2329 if ( bp_is_user_friend_requests() ) { 2393 2330 $bp_classes[] = 'friend-requests'; 2394 2395 if ( bp_is_create_blog() ) 2331 } 2332 2333 if ( bp_is_create_blog() ) { 2396 2334 $bp_classes[] = 'create-blog'; 2335 } 2397 2336 2398 2337 /** Groups ************************************************************/ 2399 2338 2400 if ( bp_is_group_leave() ) 2339 if ( bp_is_group_leave() ) { 2401 2340 $bp_classes[] = 'leave-group'; 2402 2403 if ( bp_is_group_invites() ) 2341 } 2342 2343 if ( bp_is_group_invites() ) { 2404 2344 $bp_classes[] = 'group-invites'; 2405 2406 if ( bp_is_group_members() ) 2345 } 2346 2347 if ( bp_is_group_members() ) { 2407 2348 $bp_classes[] = 'group-members'; 2408 2409 if ( bp_is_group_forum_topic() ) 2349 } 2350 2351 if ( bp_is_group_forum_topic() ) { 2410 2352 $bp_classes[] = 'group-forum-topic'; 2411 2412 if ( bp_is_group_forum_topic_edit() ) 2353 } 2354 2355 if ( bp_is_group_forum_topic_edit() ) { 2413 2356 $bp_classes[] = 'group-forum-topic-edit'; 2414 2415 if ( bp_is_group_forum() ) 2357 } 2358 2359 if ( bp_is_group_forum() ) { 2416 2360 $bp_classes[] = 'group-forum'; 2361 } 2417 2362 2418 2363 if ( bp_is_group_admin_page() ) { … … 2426 2371 } 2427 2372 2428 if ( bp_is_group_home() ) 2373 if ( bp_is_group_home() ) { 2429 2374 $bp_classes[] = 'group-home'; 2430 2431 if ( bp_is_single_activity() ) 2375 } 2376 2377 if ( bp_is_single_activity() ) { 2432 2378 $bp_classes[] = 'activity-permalink'; 2379 } 2433 2380 2434 2381 /** Registration ******************************************************/ 2435 2382 2436 if ( bp_is_register_page() ) 2383 if ( bp_is_register_page() ) { 2437 2384 $bp_classes[] = 'registration'; 2438 2439 if ( bp_is_activation_page() ) 2385 } 2386 2387 if ( bp_is_activation_page() ) { 2440 2388 $bp_classes[] = 'activation'; 2389 } 2441 2390 2442 2391 /** Current Component & Action ****************************************/ 2443 2392 2444 if ( ! bp_is_blog_page() ) {2393 if ( ! bp_is_blog_page() ) { 2445 2394 $bp_classes[] = bp_current_component(); 2446 2395 $bp_classes[] = bp_current_action(); … … 2537 2486 */ 2538 2487 function _bp_nav_menu_sort( $a, $b ) { 2539 if ( $a[ "position"] == $b["position"] )2488 if ( $a['position'] == $b['position'] ) { 2540 2489 return 0; 2541 2542 else if ( $a["position"] < $b["position"] ) 2490 } elseif ( $a['position'] < $b['position'] ) { 2543 2491 return -1; 2544 2545 else 2492 } else { 2546 2493 return 1; 2494 } 2547 2495 } 2548 2496 … … 2561 2509 2562 2510 // The root menu's ID is "xprofile", but the Profile submenus are using "profile". See BP_Core::setup_nav(). 2563 if ( 'profile' == $parent_menu )2511 if ( 'profile' === $parent_menu ) { 2564 2512 $parent_menu = 'xprofile'; 2513 } 2565 2514 2566 2515 // Sort the items in this menu's navigation by their position property … … 2572 2521 2573 2522 // Skip items we don't have access to 2574 if ( ! $sub_nav['user_has_access'] )2523 if ( empty( $sub_nav['user_has_access'] ) ) { 2575 2524 continue; 2525 } 2576 2526 2577 2527 // Add this menu … … 2601 2551 2602 2552 // Skip items marked as user-specific if you're not on your own profile 2603 if ( ! $nav['show_for_displayed_user'] && ! bp_core_can_edit_settings() )2553 if ( empty( $nav['show_for_displayed_user'] ) && ! bp_core_can_edit_settings() ) { 2604 2554 continue; 2555 } 2605 2556 2606 2557 // Get the correct menu link. See http://buddypress.trac.wordpress.org/ticket/4624 … … 2616 2567 2617 2568 // Check if we need to mark this menu as selected 2618 if ( in_array( $nav['css_id'], $selected_menus ) ) 2569 if ( in_array( $nav['css_id'], $selected_menus ) ) { 2619 2570 $menu->class[] = 'current-menu-parent'; 2571 } 2620 2572 2621 2573 $menus[] = $menu; … … 2688 2640 2689 2641 // Create custom walker if one wasn't set 2690 if ( empty( $args->walker ) ) 2642 if ( empty( $args->walker ) ) { 2691 2643 $args->walker = new BP_Walker_Nav_Menu; 2644 } 2692 2645 2693 2646 // Sanitise values for class and ID … … 2722 2675 // If a specific ID wasn't requested, and there are multiple menus on the same screen, make sure the autogenerated ID is unique 2723 2676 while ( in_array( $wrap_id, $menu_id_slugs ) ) { 2724 if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) 2677 if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) { 2725 2678 $wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id ); 2726 else2679 } else { 2727 2680 $wrap_id = $wrap_id . '-1'; 2681 } 2728 2682 } 2729 2683 } … … 2739 2693 2740 2694 // If we've wrapped the ul, close it 2741 if ( $show_container )2695 if ( ! empty( $show_container ) ) { 2742 2696 $nav_menu .= '</' . $args->container . '>'; 2697 } 2743 2698 2744 2699 // Final chance to modify output 2745 2700 $nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args ); 2746 2701 2747 if ( $args->echo )2702 if ( ! empty( $args->echo ) ) { 2748 2703 echo $nav_menu; 2749 else2704 } else { 2750 2705 return $nav_menu; 2751 } 2706 } 2707 }
Note: See TracChangeset
for help on using the changeset viewer.