Ticket #2086: 2086.04.patch
File 2086.04.patch, 13.4 KB (added by , 13 years ago) |
---|
-
bp-activity/bp-activity-actions.php
549 549 function bp_activity_action_mentions_feed() { 550 550 global $bp, $wp_query; 551 551 552 if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions') || !bp_is_action_variable( 'feed', 0 ) )552 if ( !bp_is_user_activity() || !bp_is_current_action( bp_get_activity_mentions_slug() ) || !bp_is_action_variable( 'feed', 0 ) ) 553 553 return false; 554 554 555 555 $wp_query->is_404 = false; … … 577 577 function bp_activity_action_favorites_feed() { 578 578 global $bp, $wp_query; 579 579 580 if ( !bp_is_user_activity() || !bp_is_current_action( 'favorites' ) || !bp_is_action_variable( 'feed', 0 ) ) 581 No newline at end of file 580 if ( !bp_is_user_activity() || !bp_is_current_action( bp_get_activity_favorites_slug() ) || !bp_is_action_variable( 'feed', 0 ) ) 582 581 return false; 583 582 584 583 $wp_query->is_404 = false; -
bp-activity/bp-activity-loader.php
71 71 * @global object $bp BuddyPress global settings 72 72 */ 73 73 function setup_globals() { 74 global $bp ;74 global $bp, $current_user; 75 75 76 76 // Define a slug, if necessary 77 77 if ( !defined( 'BP_ACTIVITY_SLUG' ) ) 78 78 define( 'BP_ACTIVITY_SLUG', $this->id ); 79 80 $slugs = array( 81 'just-me' => array( 82 'slug' => 'just-me', 83 'description' => sprintf( __( 'Used to construct URL for a user\'s personal activity, e.g. %1$s<strong>%2$s</strong>/', 'buddypress' ), bp_get_root_domain() . '/members/username/' . BP_ACTIVITY_SLUG . '/', 'just-me' ) 84 ), 85 'favorites' => array( 86 'slug' => 'favorites', 87 'description' => sprintf( __( 'Used to construct URL for a user\'s favorite activity items, e.g. %1$s<strong>%2$s</strong>/', 'buddypress' ), bp_get_root_domain() . '/members/username/' . BP_ACTIVITY_SLUG . '/', 'favorites' ) 88 ), 89 'mentions' => array( 90 'slug' => 'mentions', 91 'description' => sprintf( __( 'Used to construct URL for a user\'s public @-mentions, e.g. %1$s<strong>%2$s</strong>/', 'buddypress' ), bp_get_root_domain() . '/members/username/' . BP_ACTIVITY_SLUG . '/', 'mentions' ) 92 ) 93 ); 79 94 80 95 // Global tables for activity component 81 96 $global_tables = array( … … 89 104 'path' => BP_PLUGIN_DIR, 90 105 'slug' => BP_ACTIVITY_SLUG, 91 106 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG, 107 'action_slugs' => $slugs, 92 108 'has_directory' => true, 93 109 'search_string' => __( 'Search Activity...', 'buddypress' ), 94 110 'global_tables' => $global_tables, … … 118 134 'slug' => $this->slug, 119 135 'position' => 10, 120 136 'screen_function' => 'bp_activity_screen_my_activity', 121 'default_subnav_slug' => 'just-me',137 'default_subnav_slug' => $this->slugs['just-me']['slug'], 122 138 'item_css_id' => $this->id 123 139 ); 124 140 … … 140 156 // Add the subnav items to the activity nav item if we are using a theme that supports this 141 157 $sub_nav[] = array( 142 158 'name' => __( 'Personal', 'buddypress' ), 143 'slug' => 'just-me',159 'slug' => $this->slugs['just-me']['slug'], 144 160 'parent_url' => $activity_link, 145 161 'parent_slug' => $this->slug, 146 162 'screen_function' => 'bp_activity_screen_my_activity', … … 150 166 // @ mentions 151 167 $sub_nav[] = array( 152 168 'name' => __( 'Mentions', 'buddypress' ), 153 'slug' => 'mentions',169 'slug' => $this->slugs['mentions']['slug'], 154 170 'parent_url' => $activity_link, 155 171 'parent_slug' => $this->slug, 156 172 'screen_function' => 'bp_activity_screen_mentions', … … 161 177 // Favorite activity items 162 178 $sub_nav[] = array( 163 179 'name' => __( 'Favorites', 'buddypress' ), 164 'slug' => 'favorites',180 'slug' => $this->slugs['favorites']['slug'], 165 181 'parent_url' => $activity_link, 166 182 'parent_slug' => $this->slug, 167 183 'screen_function' => 'bp_activity_screen_favorites', … … 245 261 'parent' => 'my-account-' . $this->id, 246 262 'id' => 'my-account-' . $this->id . '-mentions', 247 263 'title' => $title, 248 'href' => trailingslashit( $activity_link . 'mentions')264 'href' => trailingslashit( $activity_link . bp_get_activity_mentions_slug() ) 249 265 ); 250 266 251 267 // Personal … … 261 277 'parent' => 'my-account-' . $this->id, 262 278 'id' => 'my-account-' . $this->id . '-favorites', 263 279 'title' => __( 'Favorites', 'buddypress' ), 264 'href' => trailingslashit( $activity_link . 'favorites' ) 265 No newline at end of file 280 'href' => trailingslashit( $activity_link . bp_get_activity_favorites_slug() ) 266 281 ); 267 282 268 283 // Friends? -
bp-activity/bp-activity-template.php
25 25 * 26 26 * @since 1.5.0 27 27 * 28 * @global object $bp BuddyPress global settings29 28 * @uses apply_filters() To call the 'bp_get_activity_slug' hook 30 29 */ 31 30 function bp_get_activity_slug() { … … 48 47 * 49 48 * @since 1.5.0 50 49 * 51 * @global object $bp BuddyPress global settings52 50 * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook 53 51 */ 54 52 function bp_get_activity_root_slug() { … … 57 55 } 58 56 59 57 /** 58 * Output the activity component 'just-me' slug 59 * 60 * @since 1.6 61 * 62 * @uses bp_get_activity_justme_slug() 63 */ 64 function bp_activity_justme_slug() { 65 echo bp_get_activity_justme_slug(); 66 } 67 /** 68 * Return the activity component 'just-me' slug 69 * 70 * @since 1.6 71 * 72 * @uses apply_filters() To call the 'bp_get_activity_justme_slug' hook 73 */ 74 function bp_get_activity_justme_slug() { 75 return apply_filters( 'bp_get_activity_justme_slug', bp_get_slug( 'activity', 'just-me' ) ); 76 } 77 78 /** 79 * Output the activity component 'favorites' slug 80 * 81 * @since 1.6 82 * 83 * @uses bp_get_activity_favorites_slug() 84 */ 85 function bp_activity_favorites_slug() { 86 echo bp_get_activity_favorites_slug(); 87 } 88 /** 89 * Return the activity component 'favorites' slug 90 * 91 * @since 1.6 92 * 93 * @uses apply_filters() To call the 'bp_get_activity_favorites_slug' hook 94 */ 95 function bp_get_activity_favorites_slug() { 96 return apply_filters( 'bp_get_activity_favorites_slug', bp_get_slug( 'activity', 'favorites' ) ); 97 } 98 99 /** 100 * Output the activity component 'mentions' slug 101 * 102 * @since 1.6 103 * 104 * @uses bp_get_activity_mentions_slug() 105 */ 106 function bp_activity_mentions_slug() { 107 echo bp_get_activity_mentions_slug(); 108 } 109 /** 110 * Return the activity component 'mentions' slug 111 * 112 * @since 1.6 113 * 114 * @uses apply_filters() To call the 'bp_get_activity_mentions_slug' hook 115 */ 116 function bp_get_activity_mentions_slug() { 117 return apply_filters( 'bp_get_activity_mentions_slug', bp_get_slug( 'activity', 'mentions' ) ); 118 } 119 120 /** 60 121 * Output member directory permalink 61 122 * 62 123 * @since 1.5.0 … … 279 340 // The default scope should recognize custom slugs 280 341 if ( array_key_exists( $bp->current_action, (array)$bp->loaded_components ) ) { 281 342 $scope = $bp->loaded_components[$bp->current_action]; 282 } 283 else 343 } else if ( $slug_index = array_search( bp_current_action(), $bp->activity->action_slugs ) ) { 344 $scope = $slug_index; 345 } else { 284 346 $scope = bp_current_action(); 347 } 285 348 286 349 // Support for permalinks on single item pages: /groups/my-group/activity/124/ 287 350 if ( bp_is_current_action( bp_get_activity_slug() ) ) … … 2483 2546 * @uses bp_get_groups_slug() 2484 2547 * @uses apply_filters() To call the 'bp_get_activities_member_rss_link' hook 2485 2548 * 2549 * @todo use bp_get_slug() here 2550 * 2486 2551 * @return string $link The member activity feed link 2487 2552 */ 2488 2553 function bp_get_member_activity_feed_link() { 2489 2554 global $bp; 2490 2555 2491 if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) 2556 $link = ''; 2557 2558 // User's activity root 2559 if ( bp_is_profile_component() || bp_is_current_action( bp_get_activity_justme_slug() ) ) 2492 2560 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/'; 2561 2562 // User's Friends 2493 2563 elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) 2494 2564 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/'; 2495 elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) 2565 2566 // User's Groups 2567 elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) 2496 2568 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/'; 2497 elseif ( 'favorites' == $bp->current_action )2498 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';2499 elseif ( 'mentions' == $bp->current_action )2500 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';2501 else2502 $link = '';2503 2569 2570 // User's favorites 2571 elseif ( bp_is_current_action( bp_get_activity_favorites_slug() ) ) 2572 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_activity_favorites_slug() . '/feed/'; 2573 2574 // User's mentions 2575 elseif ( bp_is_current_action( bp_get_activity_mentions_slug() ) ) 2576 $link = bp_displayed_user_domain() . bp_get_activity_slug() . bp_get_activity_mentions_slug() . '/feed/'; 2577 2504 2578 return apply_filters( 'bp_get_activities_member_rss_link', $link ); 2505 2579 } 2506 2580 -
bp-core/bp-core-component.php
28 28 * @var Unique ID (normally for custom post type) 29 29 */ 30 30 var $id; 31 32 /** 33 * @var array Slugs for this component (used to construct permalinks) 34 */ 35 var $action_slugs; 31 36 32 37 /** 33 38 * @var string Unique slug (used in query string and permalinks) … … 108 113 $defaults = array( 109 114 'slug' => $this->id, 110 115 'root_slug' => '', 116 'action_slugs' => array(), 111 117 'has_directory' => false, 112 118 'notification_callback' => '', 113 119 'search_string' => '', … … 121 127 // Slug used for root directory 122 128 $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] ); 123 129 130 // Action slugs 131 $this->action_slugs = apply_filters( 'bp_' . $this->id . '_action_slugs', bp_parse_component_slugs( $this->id, $r['action_slugs'] ) ); 132 124 133 // Does this component have a top-level directory? 125 134 $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] ); 126 135 -
bp-core/bp-core-functions.php
1116 1116 // BuddyPress core settings 1117 1117 'bp-deactivated-components' => serialize( array( ) ), 1118 1118 'bp-blogs-first-install' => '0', 1119 'bp-disable-blogforum-comments' => '0',1119 'bp-disable-blogforum-comments' => '0', 1120 1120 'bp-xprofile-base-group-name' => 'Base', 1121 1121 'bp-xprofile-fullname-field-name' => 'Name', 1122 1122 'bp-disable-profile-sync' => '0', … … 1584 1584 } 1585 1585 1586 1586 /** 1587 * Fetch a slug from the $bp global 1588 * 1589 * @since 1.6 1590 * @global obj $bp 1591 * 1592 * @param str $component_id The id of the component that the slug belongs to 1593 * @param str $slug_name The name of the slug you're fetching 1594 * @param str Optional|$default The default slug if none is found 1595 * @param str Optional|$return 'slugonly' to get the slug only, 'array' to get the slug + description array 1596 */ 1597 function bp_get_slug( $component_id, $slug_name, $default = '', $return = 'slugonly' ) { 1598 global $bp; 1599 1600 // Default slug 1601 $slug = !empty( $default ) ? $default : $slug_name; 1602 1603 if ( !empty( $bp->{$component_id}->slugs[$slug_name] ) ) { 1604 $slug = ( 'slugonly' == $return ) ? $bp->{$component_id}->slugs[$slug_name]['slug'] : $bp->{$component_id}->slugs[$slug_name]; 1605 } 1606 1607 return apply_filters( 'bp_get_slug', $slug, $component_id, $slug_name ); 1608 } 1609 1610 /** 1611 * Parse a component's default slugs with the custom slugs saved to the database by the user 1612 * 1613 * Custom components should pass their slugs through this function in their setup_globals() method 1614 * so that they can be customized by site admins. 1615 * 1616 * @since 1.6 1617 * @global obj $bp 1618 * 1619 * @param str $component_id The id of the component the slugs belong to 1620 * @param array $slugs Slugs passed along (from the component loader) 1621 */ 1622 function bp_parse_component_slugs( $component_id, $slugs = array() ) { 1623 global $bp; 1624 1625 $parsed = array(); 1626 $saved = (array) bp_get_option( 'bp-slugs' ); // should be separate options 1627 1628 // Get a full list of slug names, in case there is a mismatch 1629 if ( !empty( $saved[$component_id] ) ) { 1630 $slug_indexes = array_unique( array_merge( array_keys( $saved[$component_id] ), array_keys( $slugs ) ) ); 1631 } else { 1632 $slug_indexes = array_unique( array_keys( $slugs ) ); 1633 } 1634 1635 foreach( $slug_indexes as $slug_index ) { 1636 $saved_data = !empty( $saved[$component_id][$slug_index] ) ? $saved[$component_id][$slug_index] : array(); 1637 $default_data = !empty( $slugs[$slug_index] ) ? $slugs[$slug_index] : array(); 1638 $parsed[$slug_index] = wp_parse_args( (array) $saved_data, (array) $default_data ); 1639 } 1640 1641 return apply_filters( 'bp_parse_component_slugs', $parsed, $component_id, $slugs ); 1642 } 1643 1644 /** 1587 1645 * Trigger a 404 1588 1646 * 1589 1647 * @global object $bp Global BuddyPress settings object