Changeset 12797
- Timestamp:
- 11/19/2020 09:21:19 PM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r12791 r12797 3233 3233 } 3234 3234 } 3235 3236 if ( ! empty( $db_types[ $type_name ]->has_directory ) && empty( $db_types[ $type_name ]->directory_slug ) ) { 3237 $db_types[ $type_name ]->directory_slug = $term->slug; 3238 } 3235 3239 } 3236 3240 } -
trunk/src/bp-members/bp-members-functions.php
r12776 r12797 2719 2719 'bp_type_id_label' => _x( 'Member Type ID', 'BP Member type ID label', 'buddypress' ), 2720 2720 'bp_type_id_description' => _x( 'Enter a lower-case string without spaces or special characters (used internally to identify the member type).', 'BP Member type ID description', 'buddypress' ), 2721 'bp_type_show_in_list' => _x( 'Show on Member', 'BP Member type show in list', 'buddypress' ), 2721 2722 ) 2722 2723 ); … … 2763 2764 if ( bp_get_member_type_tax_name() === $taxonomy ) { 2764 2765 2765 // Directory 2766 // Directory. 2766 2767 if ( isset( $schema['bp_type_has_directory']['description'] ) ) { 2767 2768 $schema['bp_type_has_directory']['description'] = __( 'Make a list of members matching this type available on the members directory.', 'buddypress' ); 2768 2769 } 2769 2770 2770 // Slug 2771 // Slug. 2771 2772 if ( isset( $schema['bp_type_directory_slug']['description'] ) ) { 2772 2773 $schema['bp_type_directory_slug']['description'] = __( 'Enter if you want the type slug to be different from its ID.', 'buddypress' ); 2773 2774 } 2775 2776 // List. 2777 $schema['bp_type_show_in_list'] = array( 2778 'description' => __( 'Show where member types may be listed, like in the member header.', 'buddypress' ), 2779 'type' => 'boolean', 2780 'single' => true, 2781 'sanitize_callback' => 'absint', 2782 ); 2774 2783 } 2775 2784 … … 2811 2820 * Pass a string to customize the slug. Pass `false` to disable. 2812 2821 * Default: true. 2822 * @type bool $show_in_list Whether this member type should be shown in lists rendered by 2823 * bp_member_type_list(). Default: false. 2824 * @type bool $code Whether this member type is registered using code. Default: true. 2825 * @type int $db_id The member type term ID. Default: 0. 2813 2826 * } 2814 2827 * @return object|WP_Error Member type object on success, WP_Error object on failure. … … 2824 2837 'labels' => array(), 2825 2838 'has_directory' => true, 2839 'show_in_list' => false, 2826 2840 'code' => true, 2827 2841 'db_id' => 0, … … 2872 2886 $r['has_directory'] = false; 2873 2887 } 2888 2889 // Show the list of member types on front-end (member header, for now). 2890 $r['show_in_list'] = (bool) $r['show_in_list']; 2874 2891 2875 2892 $bp->members->types[ $member_type ] = $type = (object) $r; -
trunk/src/bp-members/bp-members-template.php
r12791 r12797 1693 1693 1694 1694 /* translators: %s: last activity timestamp (e.g. "Active 1 hour ago") */ 1695 $last_activity = bp_core_get_last_activity( bp_get_user_last_activity( $user_id ), __( 'Active %s', 'buddypress') );1695 $last_activity = bp_core_get_last_activity( bp_get_user_last_activity( $user_id ), __( 'Active %s', 'buddypress') ); 1696 1696 1697 1697 /** … … 2019 2019 */ 2020 2020 return apply_filters( 'bp_get_current_member_type_message', $message ); 2021 } 2022 2023 /** 2024 * Output member type directory link. 2025 * 2026 * @since 7.0.0 2027 * 2028 * @param string $member_type Unique member type identifier as used in bp_register_member_type(). 2029 */ 2030 function bp_member_type_directory_link( $member_type = '' ) { 2031 echo bp_get_member_type_directory_link( $member_type ); 2032 } 2033 /** 2034 * Return member type directory link. 2035 * 2036 * @since 7.0.0 2037 * 2038 * @param string $member_type Unique member type identifier as used in bp_register_member_type(). 2039 * @return string 2040 */ 2041 function bp_get_member_type_directory_link( $member_type = '' ) { 2042 if ( empty( $member_type ) ) { 2043 return ''; 2044 } 2045 2046 $member_type_object = bp_get_member_type_object( $member_type ); 2047 2048 if ( ! isset( $member_type_object->labels['name'] ) ) { 2049 return ''; 2050 } 2051 2052 $member_type_text = $member_type_object->labels['name']; 2053 if ( isset( $member_type_object->labels['singular_name'] ) && $member_type_object->labels['singular_name'] ) { 2054 $member_type_text = $member_type_object->labels['singular_name']; 2055 } 2056 2057 if ( empty( $member_type_object->has_directory ) ) { 2058 return esc_html( $member_type_text ); 2059 } 2060 2061 return sprintf( 2062 '<a href="%1$s">%2$s</a>', 2063 esc_url( bp_get_member_type_directory_permalink( $member_type ) ), 2064 esc_html( $member_type_text ) 2065 ); 2066 } 2067 2068 /** 2069 * Output a comma-delimited list of member types. 2070 * 2071 * @since 7.0.0 2072 * @see bp_get_member_type_list() For additional information on default arguments. 2073 * 2074 * @param int $user_id User ID. 2075 * @param array $r Optional. Member type list arguments. Default empty array. 2076 */ 2077 function bp_member_type_list( $user_id = 0, $r = array() ) { 2078 echo bp_get_member_type_list( $user_id, $r ); 2079 } 2080 /** 2081 * Return a comma-delimited list of member types. 2082 * 2083 * @since 7.0.0 2084 * 2085 * @param int $user_id User ID. Defaults to displayed user ID if on a member page. 2086 * @param array|string $r { 2087 * Array of parameters. All items are optional. 2088 * @type string $parent_element Element to wrap around the list. Defaults to 'p'. 2089 * @type array $parent_attr Element attributes for parent element. Defaults to 2090 * array( 'class' => 'bp-member-type-list' ). 2091 * @type array $label Plural and singular labels to use before the list. Defaults to 2092 * array( 'plural' => 'Member Types:', 'singular' => 'Member Type:' ). 2093 * @type string $label_element Element to wrap around the label. Defaults to 'strong'. 2094 * @type array $label_attr Element attributes for label element. Defaults to array(). 2095 * @type bool $show_all Whether to show all registered group types. Defaults to 'false'. If 2096 * 'false', only shows member types with the 'show_in_list' parameter set to 2097 * true. See bp_register_member_type() for more info. 2098 * @type string $list_element Element to wrap around the comma separated list of membet types. Defaults to ''. 2099 * @type string $list_element_attr Element attributes for list element. Defaults to array(). 2100 * } 2101 * @return string 2102 */ 2103 function bp_get_member_type_list( $user_id = 0, $r = array() ) { 2104 if ( empty( $user_id ) ) { 2105 $user_id = bp_displayed_user_id(); 2106 } 2107 2108 $r = bp_parse_args( 2109 $r, 2110 array( 2111 'parent_element' => 'p', 2112 'parent_attr' => array( 2113 'class' => 'bp-member-type-list', 2114 ), 2115 'label' => array(), 2116 'label_element' => 'strong', 2117 'label_attr' => array(), 2118 'show_all' => false, 2119 'list_element' => '', 2120 'list_element_attr' => array(), 2121 ), 2122 'member_type_list' 2123 ); 2124 2125 $labels = wp_parse_args( 2126 $r['label'], 2127 array( 2128 'plural' => __( 'Member Types:', 'buddypress' ), 2129 'singular' => __( 'Member Type:', 'buddypress' ), 2130 ) 2131 ); 2132 2133 $retval = ''; 2134 $types = bp_get_member_type( $user_id, false ); 2135 2136 if ( $types ) { 2137 // Make sure we can show the type in the list. 2138 if ( false === $r['show_all'] ) { 2139 $types = array_intersect( bp_get_member_types( array( 'show_in_list' => true ) ), $types ); 2140 if ( empty( $types ) ) { 2141 return $retval; 2142 } 2143 } 2144 2145 $before = $after = ''; 2146 $count = count( $types ); 2147 2148 if ( 1 === $count ) { 2149 $label_text = $labels['singular']; 2150 } else { 2151 $label_text = $labels['plural']; 2152 } 2153 2154 // Render parent element. 2155 if ( ! empty( $r['parent_element'] ) ) { 2156 $parent_elem = new BP_Core_HTML_Element( array( 2157 'element' => $r['parent_element'], 2158 'attr' => $r['parent_attr'] 2159 ) ); 2160 2161 // Set before and after. 2162 $before = $parent_elem->get( 'open_tag' ); 2163 $after = $parent_elem->get( 'close_tag' ); 2164 } 2165 2166 // Render label element. 2167 if ( ! empty( $r['label_element'] ) ) { 2168 $label = new BP_Core_HTML_Element( array( 2169 'element' => $r['label_element'], 2170 'attr' => $r['label_attr'], 2171 'inner_html' => esc_html( $label_text ) 2172 ) ); 2173 $label = $label->contents() . ' '; 2174 2175 // No element, just the label. 2176 } else { 2177 $label = esc_html( $label_text ); 2178 } 2179 2180 // The list of types. 2181 $list = implode( ', ', array_map( 'bp_get_member_type_directory_link', $types ) ); 2182 2183 // Render the list of types element. 2184 if ( ! empty( $r['list_element'] ) ) { 2185 $list_element = new BP_Core_HTML_Element( array( 2186 'element' => $r['list_element'], 2187 'attr' => $r['list_element_attr'], 2188 'inner_html' => $list, 2189 ) ); 2190 2191 $list = $list_element->contents(); 2192 } 2193 2194 // Comma-delimit each type into the group type directory link. 2195 $label .= $list; 2196 2197 // Retval time! 2198 $retval = $before . $label . $after; 2199 } 2200 2201 return $retval; 2021 2202 } 2022 2203 -
trunk/src/bp-templates/bp-nouveau/buddypress/members/single/cover-image-header.php
r12082 r12797 34 34 ) 35 35 ); 36 ?>36 ?> 37 37 38 38 <?php bp_nouveau_member_hook( 'before', 'header_meta' ); ?> … … 46 46 <?php endif; ?> 47 47 48 <?php 49 bp_member_type_list( 50 bp_displayed_user_id(), 51 array( 52 'label' => array( 53 'plural' => __( 'Member Types', 'buddypress' ), 54 'singular' => __( 'Member Type', 'buddypress' ), 55 ), 56 'list_element' => 'span', 57 ) 58 ); 59 ?> 60 48 61 </div><!-- #item-header-content --> 49 62 -
trunk/src/bp-templates/bp-nouveau/buddypress/members/single/member-header.php
r12082 r12797 32 32 <?php endif; ?> 33 33 34 <?php 35 bp_member_type_list( 36 bp_displayed_user_id(), 37 array( 38 'label' => array( 39 'plural' => __( 'Member Types', 'buddypress' ), 40 'singular' => __( 'Member Type', 'buddypress' ), 41 ), 42 'list_element' => 'span', 43 ) 44 ); 45 ?> 46 34 47 <?php bp_nouveau_member_header_buttons( array( 'container_classes' => array( 'member-header-actions' ) ) ); ?> 35 48 </div><!-- #item-header-content --> -
trunk/src/bp-templates/bp-nouveau/common-styles/_bp_user_header.scss
r12082 r12797 1 1 // BP Single User Specific Header Styles 2 // @version 3.0.0 2 // @since 3.0.0 3 // @version 7.0.0 3 4 4 .bp-user {5 body.buddypress.bp-user { 5 6 6 . users-header{7 .buddypress-wrap { 7 8 8 .user-nicename { 9 margin-bottom: $marg-xsml; 9 .users-header { 10 11 h2.user-nicename { 12 margin-top: 0; 13 margin-bottom: $marg-xsml; 14 } 15 16 .bp-member-type-list { 17 padding-bottom: 0.5em; 18 19 @include font-size(18); 20 margin: 0; 21 color: $black; 22 display: flex; 23 24 strong { 25 padding-right: $pad-med; 26 white-space: nowrap; 27 } 28 } 10 29 } 11 }12 30 13 .member-header-actions { 14 overflow: hidden; 31 .member-header-actions { 32 overflow: hidden; 33 padding-left: 0; 15 34 16 * > * { 17 display: block; 35 * > * { 36 display: block; 37 } 18 38 } 19 39 } -
trunk/src/bp-templates/bp-nouveau/css/buddypress-rtl.css
r12789 r12797 2405 2405 *----------------------------------------------------- 2406 2406 */ 2407 .bp-user .users-header .user-nicename { 2407 body.buddypress.bp-user .buddypress-wrap .users-header h2.user-nicename { 2408 margin-top: 0; 2408 2409 margin-bottom: 5px; 2409 2410 } 2410 2411 2411 .bp-user .member-header-actions { 2412 body.buddypress.bp-user .buddypress-wrap .users-header .bp-member-type-list { 2413 padding-bottom: 0.5em; 2414 font-size: 18px; 2415 margin: 0; 2416 color: #333; 2417 display: flex; 2418 } 2419 2420 body.buddypress.bp-user .buddypress-wrap .users-header .bp-member-type-list strong { 2421 padding-left: 1em; 2422 white-space: nowrap; 2423 } 2424 2425 body.buddypress.bp-user .buddypress-wrap .member-header-actions { 2412 2426 overflow: hidden; 2413 } 2414 2415 .bp-user .member-header-actions * > * { 2427 padding-right: 0; 2428 } 2429 2430 body.buddypress.bp-user .buddypress-wrap .member-header-actions * > * { 2416 2431 display: block; 2417 2432 } -
trunk/src/bp-templates/bp-nouveau/css/buddypress.css
r12789 r12797 2405 2405 *----------------------------------------------------- 2406 2406 */ 2407 .bp-user .users-header .user-nicename { 2407 body.buddypress.bp-user .buddypress-wrap .users-header h2.user-nicename { 2408 margin-top: 0; 2408 2409 margin-bottom: 5px; 2409 2410 } 2410 2411 2411 .bp-user .member-header-actions { 2412 body.buddypress.bp-user .buddypress-wrap .users-header .bp-member-type-list { 2413 padding-bottom: 0.5em; 2414 font-size: 18px; 2415 margin: 0; 2416 color: #333; 2417 display: flex; 2418 } 2419 2420 body.buddypress.bp-user .buddypress-wrap .users-header .bp-member-type-list strong { 2421 padding-right: 1em; 2422 white-space: nowrap; 2423 } 2424 2425 body.buddypress.bp-user .buddypress-wrap .member-header-actions { 2412 2426 overflow: hidden; 2413 } 2414 2415 .bp-user .member-header-actions * > * { 2427 padding-left: 0; 2428 } 2429 2430 body.buddypress.bp-user .buddypress-wrap .member-header-actions * > * { 2416 2431 display: block; 2417 2432 }
Note: See TracChangeset
for help on using the changeset viewer.