Changeset 5815
- Timestamp:
- 07/13/2015 01:13:46 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/users/template.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/template.php
r5770 r5815 354 354 355 355 // Allow early overriding of the profile URL to cut down on processing 356 $early_profile_url = apply_filters( 'bbp_pre_get_user_profile_url', (int)$user_id );356 $early_profile_url = apply_filters( 'bbp_pre_get_user_profile_url', $user_id ); 357 357 if ( is_string( $early_profile_url ) ) { 358 358 return $early_profile_url; … … 361 361 // Pretty permalinks 362 362 if ( $wp_rewrite->using_permalinks() ) { 363 $url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%';364 363 365 364 // Get username if not passed … … 368 367 } 369 368 370 $url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url ); 371 $url = home_url( user_trailingslashit( $url ) ); 369 $url = trailingslashit( $wp_rewrite->root . bbp_get_user_slug() ) . $user_nicename; 370 $url = user_trailingslashit( $url ); 371 $url = home_url( $url ); 372 372 373 373 // Unpretty permalinks 374 374 } else { 375 $url = add_query_arg( array( bbp_get_user_rewrite_id() => $user_id ), home_url( '/' ) ); 375 $url = add_query_arg( array( 376 bbp_get_user_rewrite_id() => $user_id 377 ), home_url( '/' ) ); 376 378 } 377 379 … … 436 438 * @param string $user_nicename Optional. User nicename 437 439 * @uses bbp_get_user_id() To get user id 440 * @uses bbp_get_user_profile_url() To get the user profile url 438 441 * @uses WP_Rewrite::using_permalinks() To check if the blog is using 439 442 * permalinks … … 447 450 global $wp_rewrite; 448 451 449 $bbp = bbpress();450 452 $user_id = bbp_get_user_id( $user_id ); 451 453 if ( empty( $user_id ) ) { … … 453 455 } 454 456 457 // Allow early overriding of the profile edit URL to cut down on processing 458 $early_profile_url = apply_filters( 'bbp_pre_get_user_profile_edit_url', $user_id ); 459 if ( is_string( $early_profile_url ) ) { 460 return $early_profile_url; 461 } 462 463 // Get user profile URL 464 $profile_url = bbp_get_user_profile_url( $user_id, $user_nicename ); 465 455 466 // Pretty permalinks 456 467 if ( $wp_rewrite->using_permalinks() ) { 457 $url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . $bbp->user_id . '%/' . $bbp->edit_id; 458 459 // Get username if not passed 460 if ( empty( $user_nicename ) ) { 461 $user = get_userdata( $user_id ); 462 if ( ! empty( $user->user_nicename ) ) { 463 $user_nicename = $user->user_nicename; 464 } 465 } 466 467 $url = str_replace( '%' . $bbp->user_id . '%', $user_nicename, $url ); 468 $url = home_url( user_trailingslashit( $url ) ); 468 $url = trailingslashit( $profile_url ) . 'edit'; 469 $url = user_trailingslashit( $url ); 470 $url = home_url( $url ); 469 471 470 472 // Unpretty permalinks 471 473 } else { 472 $url = add_query_arg( array( $bbp->user_id => $user_id, $bbp->edit_id => '1' ), home_url( '/' ) ); 474 $url = add_query_arg( array( 475 bbp_get_edit_rewrite_id() => '1' 476 ), $profile_url ); 473 477 } 474 478 … … 825 829 826 830 // Allow early overriding of the profile URL to cut down on processing 827 $early_profile_url = apply_filters( 'bbp_pre_get_favorites_permalink', (int)$user_id );831 $early_profile_url = apply_filters( 'bbp_pre_get_favorites_permalink', $user_id ); 828 832 if ( is_string( $early_profile_url ) ) { 829 833 return $early_profile_url; 830 834 } 831 835 836 // Get user profile URL 837 $profile_url = bbp_get_user_profile_url( $user_id ); 838 832 839 // Pretty permalinks 833 840 if ( $wp_rewrite->using_permalinks() ) { 834 $url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/%' . bbp_get_user_favorites_rewrite_id() . '%'; 835 $user = get_userdata( $user_id ); 836 if ( ! empty( $user->user_nicename ) ) { 837 $user_nicename = $user->user_nicename; 838 } else { 839 $user_nicename = $user->user_login; 840 } 841 $url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url ); 842 $url = str_replace( '%' . bbp_get_user_favorites_rewrite_id() . '%', bbp_get_user_favorites_slug(), $url ); 843 $url = home_url( user_trailingslashit( $url ) ); 841 $url = trailingslashit( $profile_url ) . bbp_get_user_favorites_rewrite_id(); 842 $url = user_trailingslashit( $url ); 843 $url = home_url( $url ); 844 844 845 845 // Unpretty permalinks 846 846 } else { 847 847 $url = add_query_arg( array( 848 bbp_get_user_rewrite_id() => $user_id,849 848 bbp_get_user_favorites_rewrite_id() => bbp_get_user_favorites_slug(), 850 ), home_url( '/' ));849 ), $profile_url ); 851 850 } 852 851 … … 919 918 920 919 // No link if you can't edit yourself 921 if ( ! current_user_can( 'edit_user', (int)$user_id ) ) {920 if ( ! current_user_can( 'edit_user', $user_id ) ) { 922 921 return false; 923 922 } … … 990 989 991 990 // Allow early overriding of the profile URL to cut down on processing 992 $early_profile_url = apply_filters( 'bbp_pre_get_subscriptions_permalink', (int)$user_id );991 $early_profile_url = apply_filters( 'bbp_pre_get_subscriptions_permalink', $user_id ); 993 992 if ( is_string( $early_profile_url ) ) { 994 993 return $early_profile_url; 995 994 } 996 995 996 // Get user profile URL 997 $profile_url = bbp_get_user_profile_url( $user_id ); 998 997 999 // Pretty permalinks 998 1000 if ( $wp_rewrite->using_permalinks() ) { 999 $url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/%' . bbp_get_user_subscriptions_rewrite_id() . '%'; 1000 $user = get_userdata( $user_id ); 1001 if ( ! empty( $user->user_nicename ) ) { 1002 $user_nicename = $user->user_nicename; 1003 } else { 1004 $user_nicename = $user->user_login; 1005 } 1006 $url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url ); 1007 $url = str_replace( '%' . bbp_get_user_subscriptions_rewrite_id() . '%', bbp_get_user_subscriptions_slug(), $url ); 1008 $url = home_url( user_trailingslashit( $url ) ); 1001 $url = trailingslashit( $profile_url ) . bbp_get_user_subscriptions_slug(); 1002 $url = user_trailingslashit( $url ); 1003 $url = home_url( $url ); 1009 1004 1010 1005 // Unpretty permalinks 1011 1006 } else { 1012 1007 $url = add_query_arg( array( 1013 bbp_get_user_rewrite_id() => $user_id,1014 1008 bbp_get_user_subscriptions_rewrite_id() => bbp_get_user_subscriptions_slug(), 1015 ), home_url( '/' ));1009 ), $profile_url ); 1016 1010 } 1017 1011 … … 1087 1081 1088 1082 // No link if you can't edit yourself 1089 if ( ! current_user_can( 'edit_user', (int)$user_id ) ) {1083 if ( ! current_user_can( 'edit_user', $user_id ) ) { 1090 1084 return false; 1091 1085 } … … 1436 1430 1437 1431 // Allow early overriding of the profile URL to cut down on processing 1438 $early_url = apply_filters( 'bbp_pre_get_user_topics_created_url', (int)$user_id );1432 $early_url = apply_filters( 'bbp_pre_get_user_topics_created_url', $user_id ); 1439 1433 if ( is_string( $early_url ) ) { 1440 1434 return $early_url; 1441 1435 } 1442 1436 1437 // Get user profile URL 1438 $profile_url = bbp_get_user_profile_url( $user_id ); 1439 1443 1440 // Pretty permalinks 1444 1441 if ( $wp_rewrite->using_permalinks() ) { 1445 $url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/' . bbp_get_topic_archive_slug(); 1446 $user = get_userdata( $user_id ); 1447 if ( ! empty( $user->user_nicename ) ) { 1448 $user_nicename = $user->user_nicename; 1449 } else { 1450 $user_nicename = $user->user_login; 1451 } 1452 $url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url ); 1453 $url = home_url( user_trailingslashit( $url ) ); 1442 $url = trailingslashit( $profile_url ) . bbp_get_topic_archive_slug(); 1443 $url = user_trailingslashit( $url ); 1444 $url = home_url( $url ); 1454 1445 1455 1446 // Unpretty permalinks 1456 1447 } else { 1457 1448 $url = add_query_arg( array( 1458 bbp_get_user_rewrite_id() => $user_id,1459 1449 bbp_get_user_topics_rewrite_id() => '1', 1460 ), home_url( '/' ));1450 ), $profile_url ); 1461 1451 } 1462 1452 … … 1498 1488 1499 1489 // Allow early overriding of the profile URL to cut down on processing 1500 $early_url = apply_filters( 'bbp_pre_get_user_replies_created_url', (int)$user_id );1490 $early_url = apply_filters( 'bbp_pre_get_user_replies_created_url', $user_id ); 1501 1491 if ( is_string( $early_url ) ) { 1502 1492 return $early_url; 1503 1493 } 1504 1494 1495 // Get user profile URL 1496 $profile_url = bbp_get_user_profile_url( $user_id ); 1497 1505 1498 // Pretty permalinks 1506 1499 if ( $wp_rewrite->using_permalinks() ) { 1507 $url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%/' . bbp_get_reply_archive_slug(); 1508 $user = get_userdata( $user_id ); 1509 if ( ! empty( $user->user_nicename ) ) { 1510 $user_nicename = $user->user_nicename; 1511 } else { 1512 $user_nicename = $user->user_login; 1513 } 1514 $url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_nicename, $url ); 1515 $url = home_url( user_trailingslashit( $url ) ); 1500 $url = trailingslashit( $profile_url ) . bbp_get_reply_archive_slug(); 1501 $url = user_trailingslashit( $url ); 1502 $url = home_url( $url ); 1516 1503 1517 1504 // Unpretty permalinks 1518 1505 } else { 1519 1506 $url = add_query_arg( array( 1520 bbp_get_user_rewrite_id() => $user_id,1521 1507 bbp_get_user_replies_rewrite_id() => '1', 1522 ), home_url( '/' ));1508 ), $profile_url ); 1523 1509 } 1524 1510
Note: See TracChangeset
for help on using the changeset viewer.