Changeset 10403 for trunk/src/bp-core/bp-core-template.php
- Timestamp:
- 12/13/2015 04:54:45 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-template.php
r10356 r10403 2780 2780 function bp_is_register_page() { 2781 2781 return (bool) bp_is_current_component( 'register' ); 2782 } 2783 2784 /** 2785 * Get the title parts of the BuddyPress displayed page 2786 * 2787 * @since 2.4.3 2788 * 2789 * @param string $seplocation 2790 * @return array the title parts 2791 */ 2792 function bp_get_title_parts( $seplocation = 'right' ) { 2793 $bp = buddypress(); 2794 2795 // Defaults to an empty array 2796 $bp_title_parts = array(); 2797 2798 // If this is not a BP page, return the empty array. 2799 if ( bp_is_blog_page() ) { 2800 return $bp_title_parts; 2801 } 2802 2803 // If this is a 404, return the empty array. 2804 if ( is_404() ) { 2805 return $bp_title_parts; 2806 } 2807 2808 // If this is the front page of the site, return the empty array. 2809 if ( is_front_page() || is_home() ) { 2810 return $bp_title_parts; 2811 } 2812 2813 // Return the empty array if not a BuddyPress page. 2814 if ( ! is_buddypress() ) { 2815 return $bp_title_parts; 2816 } 2817 2818 // Now we can build the BP Title Parts 2819 // Is there a displayed user, and do they have a name? 2820 $displayed_user_name = bp_get_displayed_user_fullname(); 2821 2822 // Displayed user. 2823 if ( ! empty( $displayed_user_name ) && ! is_404() ) { 2824 2825 // Get the component's ID to try and get its name. 2826 $component_id = $component_name = bp_current_component(); 2827 2828 // Set empty subnav name. 2829 $component_subnav_name = ''; 2830 2831 // Use the component nav name. 2832 if ( ! empty( $bp->bp_nav[$component_id] ) ) { 2833 $component_name = _bp_strip_spans_from_title( $bp->bp_nav[ $component_id ]['name'] ); 2834 2835 // Fall back on the component ID. 2836 } elseif ( ! empty( $bp->{$component_id}->id ) ) { 2837 $component_name = ucwords( $bp->{$component_id}->id ); 2838 } 2839 2840 // Append action name if we're on a member component sub-page. 2841 if ( ! empty( $bp->bp_options_nav[ $component_id ] ) && ! empty( $bp->canonical_stack['action'] ) ) { 2842 $component_subnav_name = wp_filter_object_list( $bp->bp_options_nav[ $component_id ], array( 'slug' => bp_current_action() ), 'and', 'name' ); 2843 2844 if ( ! empty( $component_subnav_name ) ) { 2845 $component_subnav_name = array_shift( $component_subnav_name ); 2846 } 2847 } 2848 2849 // If on the user profile's landing page, just use the fullname. 2850 if ( bp_is_current_component( $bp->default_component ) && ( bp_get_requested_url() === bp_displayed_user_domain() ) ) { 2851 $bp_title_parts[] = $displayed_user_name; 2852 2853 // Use component name on member pages. 2854 } else { 2855 $bp_title_parts = array_merge( $bp_title_parts, array_map( 'strip_tags', array( 2856 $displayed_user_name, 2857 $component_name, 2858 ) ) ); 2859 2860 // If we have a subnav name, add it separately for localization. 2861 if ( ! empty( $component_subnav_name ) ) { 2862 $bp_title_parts[] = strip_tags( $component_subnav_name ); 2863 } 2864 } 2865 2866 // A single group. 2867 } elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) { 2868 $subnav = isset( $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] ) ? $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] : ''; 2869 $bp_title_parts = array( $bp->bp_options_title, $subnav ); 2870 2871 // A single item from a component other than groups. 2872 } elseif ( bp_is_single_item() ) { 2873 $bp_title_parts = array( $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'] ); 2874 2875 // An index or directory. 2876 } elseif ( bp_is_directory() ) { 2877 $current_component = bp_current_component(); 2878 2879 // No current component (when does this happen?). 2880 $bp_title_parts = array( _x( 'Directory', 'component directory title', 'buddypress' ) ); 2881 2882 if ( ! empty( $current_component ) ) { 2883 $bp_title_parts = array( bp_get_directory_title( $current_component ) ); 2884 } 2885 2886 // Sign up page. 2887 } elseif ( bp_is_register_page() ) { 2888 $bp_title_parts = array( __( 'Create an Account', 'buddypress' ) ); 2889 2890 // Activation page. 2891 } elseif ( bp_is_activation_page() ) { 2892 $bp_title_parts = array( __( 'Activate Your Account', 'buddypress' ) ); 2893 2894 // Group creation page. 2895 } elseif ( bp_is_group_create() ) { 2896 $bp_title_parts = array( __( 'Create a Group', 'buddypress' ) ); 2897 2898 // Blog creation page. 2899 } elseif ( bp_is_create_blog() ) { 2900 $bp_title_parts = array( __( 'Create a Site', 'buddypress' ) ); 2901 } 2902 2903 // Strip spans. 2904 $bp_title_parts = array_map( '_bp_strip_spans_from_title', $bp_title_parts ); 2905 2906 // Sep on right, so reverse the order. 2907 if ( 'right' === $seplocation ) { 2908 $bp_title_parts = array_reverse( $bp_title_parts ); 2909 } 2910 2911 /** 2912 * Filter BuddyPress title parts before joining. 2913 * 2914 * @since 2.4.3 2915 * 2916 * @param array $bp_title_parts Current BuddyPress title parts 2917 * @return array 2918 */ 2919 return (array) apply_filters( 'bp_get_title_parts', $bp_title_parts ); 2782 2920 } 2783 2921
Note: See TracChangeset
for help on using the changeset viewer.