Ticket #2086: 2086.03.patch
File 2086.03.patch, 14.4 KB (added by , 13 years ago) |
---|
-
bp-activity/bp-activity-actions.php
diff --git bp-activity/bp-activity-actions.php bp-activity/bp-activity-actions.php index 509d2bd..f73e579 100644
add_action( 'bp_actions', 'bp_activity_action_mentions_feed' ); 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 ) )580 if ( !bp_is_user_activity() || !bp_is_current_action( bp_get_activity_favorites_slug() ) || !bp_is_action_variable( 'feed', 0 ) ) 581 581 return false; 582 582 583 583 $wp_query->is_404 = false; -
bp-activity/bp-activity-loader.php
diff --git bp-activity/bp-activity-loader.php bp-activity/bp-activity-loader.php index 700fb72..9ec08f6 100644
class BP_Activity_Component extends BP_Component { 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 'root_slug' => array( 82 'slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG, 83 'description' => sprintf( __( 'Used to construct top-level activity URLs, e.g. %1$s/<strong>%2$s</strong>/', 'buddypress' ), bp_get_root_domain(), isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG ) 84 ), 85 'slug' => array( 86 'slug' => BP_ACTIVITY_SLUG, 87 'description' => sprintf( __( 'Used to construct mid-level URLs, e.g. %1$s<strong>%2$s</strong>/', 'buddypress' ), bp_get_root_domain() . '/members/username/', BP_ACTIVITY_SLUG ) // Activity component loaded too early to use bp_loggedin_user_domain() 88 ), 89 'just-me' => array( 90 'slug' => 'just-me', 91 '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' ) 92 ), 93 'favorites' => array( 94 'slug' => 'favorites', 95 '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' ) 96 ), 97 'mentions' => array( 98 'slug' => 'mentions', 99 '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' ) 100 ) 101 ); 79 102 80 103 // Global tables for activity component 81 104 $global_tables = array( … … class BP_Activity_Component extends BP_Component { 87 110 // Note that global_tables is included in this array. 88 111 $globals = array( 89 112 'path' => BP_PLUGIN_DIR, 90 'slug' => BP_ACTIVITY_SLUG, 91 'root_slug' => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG, 113 'slugs' => $slugs, 114 'slug' => $slugs['slug']['slug'], 115 'root_slug' => $slugs['root_slug']['slug'], 92 116 'has_directory' => true, 93 117 'search_string' => __( 'Search Activity...', 'buddypress' ), 94 118 'global_tables' => $global_tables, … … class BP_Activity_Component extends BP_Component { 118 142 'slug' => $this->slug, 119 143 'position' => 10, 120 144 'screen_function' => 'bp_activity_screen_my_activity', 121 'default_subnav_slug' => 'just-me',145 'default_subnav_slug' => $this->slugs['just-me']['slug'], 122 146 'item_css_id' => $this->id 123 147 ); 124 148 … … class BP_Activity_Component extends BP_Component { 140 164 // Add the subnav items to the activity nav item if we are using a theme that supports this 141 165 $sub_nav[] = array( 142 166 'name' => __( 'Personal', 'buddypress' ), 143 'slug' => 'just-me',167 'slug' => $this->slugs['just-me']['slug'], 144 168 'parent_url' => $activity_link, 145 169 'parent_slug' => $this->slug, 146 170 'screen_function' => 'bp_activity_screen_my_activity', … … class BP_Activity_Component extends BP_Component { 150 174 // @ mentions 151 175 $sub_nav[] = array( 152 176 'name' => __( 'Mentions', 'buddypress' ), 153 'slug' => 'mentions',177 'slug' => $this->slugs['mentions']['slug'], 154 178 'parent_url' => $activity_link, 155 179 'parent_slug' => $this->slug, 156 180 'screen_function' => 'bp_activity_screen_mentions', … … class BP_Activity_Component extends BP_Component { 161 185 // Favorite activity items 162 186 $sub_nav[] = array( 163 187 'name' => __( 'Favorites', 'buddypress' ), 164 'slug' => 'favorites',188 'slug' => $this->slugs['favorites']['slug'], 165 189 'parent_url' => $activity_link, 166 190 'parent_slug' => $this->slug, 167 191 'screen_function' => 'bp_activity_screen_favorites', … … class BP_Activity_Component extends BP_Component { 245 269 'parent' => 'my-account-' . $this->id, 246 270 'id' => 'my-account-' . $this->id . '-mentions', 247 271 'title' => $title, 248 'href' => trailingslashit( $activity_link . 'mentions')272 'href' => trailingslashit( $activity_link . bp_get_activity_mentions_slug() ) 249 273 ); 250 274 251 275 // Personal … … class BP_Activity_Component extends BP_Component { 261 285 'parent' => 'my-account-' . $this->id, 262 286 'id' => 'my-account-' . $this->id . '-favorites', 263 287 'title' => __( 'Favorites', 'buddypress' ), 264 'href' => trailingslashit( $activity_link . 'favorites')288 'href' => trailingslashit( $activity_link . bp_get_activity_favorites_slug() ) 265 289 ); 266 290 267 291 // Friends? -
bp-activity/bp-activity-template.php
diff --git bp-activity/bp-activity-template.php bp-activity/bp-activity-template.php index 049d347..2d1b827 100644
function bp_activity_slug() { 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() { 32 global $bp; 33 return apply_filters( 'bp_get_activity_slug', $bp->activity->slug ); 31 return apply_filters( 'bp_get_activity_slug', bp_get_slug( 'activity', 'slug' ) ); 34 32 } 35 33 36 34 /** … … function bp_activity_root_slug() { 48 46 * 49 47 * @since 1.5.0 50 48 * 51 * @global object $bp BuddyPress global settings52 49 * @uses apply_filters() To call the 'bp_get_activity_root_slug' hook 53 50 */ 54 51 function bp_get_activity_root_slug() { 55 global $bp; 56 return apply_filters( 'bp_get_activity_root_slug', $bp->activity->root_slug ); 52 return apply_filters( 'bp_get_activity_root_slug', bp_get_slug( 'activity', 'root_slug' ) ); 53 } 54 55 /** 56 * Output the activity component 'just-me' slug 57 * 58 * @since 1.6 59 * 60 * @uses bp_get_activity_justme_slug() 61 */ 62 function bp_activity_justme_slug() { 63 echo bp_get_activity_justme_slug(); 64 } 65 /** 66 * Return the activity component 'just-me' slug 67 * 68 * @since 1.6 69 * 70 * @uses apply_filters() To call the 'bp_get_activity_justme_slug' hook 71 */ 72 function bp_get_activity_justme_slug() { 73 return apply_filters( 'bp_get_activity_justme_slug', bp_get_slug( 'activity', 'just-me' ) ); 74 } 75 76 /** 77 * Output the activity component 'favorites' slug 78 * 79 * @since 1.6 80 * 81 * @uses bp_get_activity_favorites_slug() 82 */ 83 function bp_activity_favorites_slug() { 84 echo bp_get_activity_favorites_slug(); 85 } 86 /** 87 * Return the activity component 'favorites' slug 88 * 89 * @since 1.6 90 * 91 * @uses apply_filters() To call the 'bp_get_activity_favorites_slug' hook 92 */ 93 function bp_get_activity_favorites_slug() { 94 return apply_filters( 'bp_get_activity_favorites_slug', bp_get_slug( 'activity', 'favorites' ) ); 95 } 96 97 /** 98 * Output the activity component 'mentions' slug 99 * 100 * @since 1.6 101 * 102 * @uses bp_get_activity_mentions_slug() 103 */ 104 function bp_activity_mentions_slug() { 105 echo bp_get_activity_mentions_slug(); 106 } 107 /** 108 * Return the activity component 'mentions' slug 109 * 110 * @since 1.6 111 * 112 * @uses apply_filters() To call the 'bp_get_activity_mentions_slug' hook 113 */ 114 function bp_get_activity_mentions_slug() { 115 return apply_filters( 'bp_get_activity_mentions_slug', bp_get_slug( 'activity', 'mentions' ) ); 57 116 } 58 117 59 118 /** … … function bp_has_activities( $args = '' ) { 279 338 // The default scope should recognize custom slugs 280 339 if ( array_key_exists( $bp->current_action, (array)$bp->loaded_components ) ) { 281 340 $scope = $bp->loaded_components[$bp->current_action]; 282 } 283 else 341 } else if ( $slug_index = array_search( bp_current_action(), $bp->activity->slugs ) ) { 342 $scope = $slug_index; 343 } else { 284 344 $scope = bp_current_action(); 345 } 285 346 286 347 // Support for permalinks on single item pages: /groups/my-group/activity/124/ 287 348 if ( bp_is_current_action( bp_get_activity_slug() ) ) … … function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link 2486 2547 function bp_get_member_activity_feed_link() { 2487 2548 global $bp; 2488 2549 2489 if ( bp_is_profile_component() || bp_is_current_action( 'just-me') )2550 if ( bp_is_profile_component() || bp_is_current_action( bp_get_activity_justme_slug() ) ) 2490 2551 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/'; 2491 2552 elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) 2492 2553 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/'; 2493 elseif ( bp_is_active( 'groups' 2554 elseif ( bp_is_active( 'groups' ) && bp_is_current_action( bp_get_groups_slug() ) ) 2494 2555 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/'; 2495 elseif ( 'favorites' == $bp->current_action)2496 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/ favorites/feed/';2497 elseif ( 'mentions' == $bp->current_action)2498 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';2556 elseif ( bp_is_current_action( bp_get_activity_favorites_slug() ) ) 2557 $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_activity_favorites_slug() . '/feed/'; 2558 elseif ( bp_is_current_action( bp_get_activity_mentions_slug() ) ) 2559 $link = bp_displayed_user_domain() . bp_get_activity_slug() . bp_get_activity_mentions_slug() . '/feed/'; 2499 2560 else 2500 2561 $link = ''; 2501 2562 -
bp-core/bp-core-component.php
diff --git bp-core/bp-core-component.php bp-core/bp-core-component.php index b857b24..93e2f5e 100644
class BP_Component { 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 $slugs; 31 36 32 37 /** 33 38 * @var string Unique slug (used in query string and permalinks) … … class BP_Component { 106 111 /** Slugs *************************************************************/ 107 112 108 113 $defaults = array( 114 'slugs' => array(), 109 115 'slug' => $this->id, 110 116 'root_slug' => '', 111 117 'has_directory' => false, … … class BP_Component { 115 121 ); 116 122 $r = wp_parse_args( $args, $defaults ); 117 123 124 // Component slugs 125 $this->slugs = apply_filters( 'bp_' . $this->id . '_slugs', bp_parse_component_slugs( $this->id, $r['slugs'] ) ); 126 118 127 // Slug used for permalink URI chunk after root 119 128 $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] ); 120 129 -
bp-core/bp-core-functions.php
diff --git bp-core/bp-core-functions.php bp-core/bp-core-functions.php index 2eec774..189b30c 100644
function bp_core_get_root_options() { 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', … … function bp_update_is_item_mod( $is_item_mod = false, $component = '' ) { 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 $return 'slugonly' to get the slug only, 'array' to get the slug + description array 1595 */ 1596 function bp_get_slug( $component_id = '', $slug_name = '', $return = 'slugonly' ) { 1597 global $bp; 1598 1599 $slug = ''; 1600 1601 if ( $component_id && $slug_name ) { 1602 if ( isset( $bp->{$component_id}->slugs[$slug_name] ) ) { 1603 $slug = 'slugonly' == $return ? $bp->{$component_id}->slugs[$slug_name]['slug'] : $bp->{$component_id}->slugs[$slug_name]; 1604 } 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 The default slugs passed along from the component loader 1621 */ 1622 function bp_parse_component_slugs( $component_id = '', $slugs = array() ) { 1623 global $bp; 1624 1625 $parsed_slugs = array(); 1626 $saved_slugs = (array)bp_get_option( 'bp-slugs' ); 1627 1628 // Get a full list of slug names, in case there is a mismatch 1629 if ( !empty( $saved_slugs[$component_id] ) ) { 1630 $slug_indexes = array_unique( array_merge( array_keys( $saved_slugs[$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 = isset( $saved_slugs[$component_id][$slug_index] ) ? $saved_slugs[$component_id][$slug_index] : array(); 1637 $default_data = isset( $slugs[$slug_index] ) ? $slugs[$slug_index] : array(); 1638 $parsed_slugs[$slug_index] = wp_parse_args( (array)$saved_data, (array)$default_data ); 1639 } 1640 1641 return apply_filters( 'bp_parse_component_slugs', $parsed_slugs, $component_id, $slugs ); 1642 } 1643 1644 /** 1587 1645 * Trigger a 404 1588 1646 * 1589 1647 * @global object $bp Global BuddyPress settings object