Changeset 12728 for trunk/src/bp-core/bp-core-functions.php
- Timestamp:
- 09/21/2020 01:09:16 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r12694 r12728 2938 2938 2939 2939 /** 2940 * Returns the BP Taxonomy common arguments. 2941 * 2942 * @since 7.0.0 2943 * 2944 * @return array The BP Taxonomy common arguments. 2945 */ 2946 function bp_get_taxonomy_common_args() { 2947 return array( 2948 'public' => false, 2949 'show_in_rest' => false, 2950 'query_var' => false, 2951 'rewrite' => false, 2952 'show_in_menu' => false, 2953 'show_tagcloud' => false, 2954 'show_ui' => bp_is_root_blog() && bp_current_user_can( 'bp_moderate' ), 2955 ); 2956 } 2957 2958 /** 2959 * Returns the BP Taxonomy common labels. 2960 * 2961 * @since 7.0.0 2962 * 2963 * @return array The BP Taxonomy common labels. 2964 */ 2965 function bp_get_taxonomy_common_labels() { 2966 return array( 2967 'bp_type_name' => _x( 'Name', 'BP Type name label', 'buddypress' ), 2968 'bp_type_singular_name' => _x( 'Singular name', 'BP Type singular name label', 'buddypress' ), 2969 'bp_type_has_directory' => _x( 'Add Type-Filtered Directory View', 'BP Type has directory checkbox label', 'buddypress' ), 2970 'bp_type_directory_slug' => _x( 'Custom type directory slug', 'BP Type slug label', 'buddypress' ), 2971 ); 2972 } 2973 2974 /** 2940 2975 * Output the name of the email type taxonomy. 2941 2976 * … … 2999 3034 } 3000 3035 3036 /** 3037 * Return arguments used by the email type taxonomy. 3038 * 3039 * @since 7.0.0 3040 * 3041 * @return array 3042 */ 3043 function bp_get_email_tax_type_args() { 3044 3045 /** 3046 * Filters emails type taxonomy args. 3047 * 3048 * @since 7.0.0 3049 * 3050 * @param array $value Associative array (key => arg). 3051 */ 3052 return apply_filters( 3053 'bp_register_email_tax_type', 3054 array_merge( 3055 array( 3056 'description' => _x( 'BuddyPress email types', 'email type taxonomy description', 'buddypress' ), 3057 'labels' => bp_get_email_tax_type_labels(), 3058 'meta_box_cb' => 'bp_email_tax_type_metabox', 3059 ), 3060 bp_get_taxonomy_common_args() 3061 ) 3062 ); 3063 } 3064 3065 /** 3066 * Returns the default BuddyPress type metadata schema. 3067 * 3068 * @since 7.0.0 3069 * 3070 * @param boolean $suppress_filters Whether to suppress filters. Default `false`. 3071 * @param string $type_taxonomy Optional. the Type's taxonomy name. 3072 * @return array The default BuddyPress type metadata schema. 3073 */ 3074 function bp_get_type_metadata_schema( $suppress_filters = false, $type_taxonomy = '' ) { 3075 $schema = array( 3076 'bp_type_name' => array( 3077 'description' => __( 'The name of your type, at the plural form.', 'buddypress' ), 3078 'type' => 'string', 3079 'single' => true, 3080 'sanitize_callback' => 'sanitize_text_field', 3081 ), 3082 'bp_type_singular_name' => array( 3083 'description' => __( 'The name of your type, at the singular form.', 'buddypress' ), 3084 'type' => 'string', 3085 'single' => true, 3086 'sanitize_callback' => 'sanitize_text_field', 3087 ), 3088 'bp_type_has_directory' => array( 3089 'description' => __( 'Add a list of members matching the member type available on the Members Directory page (e.g. site.url/members/type/teacher/).', 'buddypress' ), 3090 'type' => 'boolean', 3091 'single' => true, 3092 'sanitize_callback' => 'absint', 3093 ), 3094 'bp_type_directory_slug' => array( 3095 'label' => __( 'Custom type directory slug', 'buddypress' ), 3096 'description' => __( 'If you want to use a slug that is different from the Member Type ID above, enter it here.', 'buddypress' ), 3097 'type' => 'string', 3098 'single' => true, 3099 'sanitize_callback' => 'sanitize_title', 3100 ), 3101 ); 3102 3103 if ( true === $suppress_filters ) { 3104 return $schema; 3105 } 3106 3107 /** 3108 * Filter here to add new meta to the BuddyPress type metadata. 3109 * 3110 * @since 7.0.0 3111 * 3112 * @param array $schema Associative array (name => arguments). 3113 * @param string $type_taxonomy The Type's taxonomy name. 3114 */ 3115 return apply_filters( 'bp_get_type_metadata_schema', $schema, $type_taxonomy ); 3116 } 3117 3118 /** 3119 * Registers a meta key for BuddyPress types. 3120 * 3121 * @since 7.0.0 3122 * 3123 * @param string $type_tax The BuddyPress type taxonomy. 3124 * @param string $meta_key The meta key to register. 3125 * @param array $args Data used to describe the meta key when registered. See 3126 * {@see register_meta()} for a list of supported arguments. 3127 * @return bool True if the meta key was successfully registered, false if not. 3128 */ 3129 function bp_register_type_meta( $type_tax, $meta_key, array $args ) { 3130 $taxonomies = wp_list_pluck( bp_get_default_taxonomies(), 'component' ); 3131 3132 if ( ! isset( $taxonomies[ $type_tax ] ) ) { 3133 return false; 3134 } 3135 3136 // register_term_meta() was introduced in WP 4.9.8. 3137 if ( ! function_exists( 'register_term_meta' ) ) { 3138 $args['object_subtype'] = $type_tax; 3139 3140 return register_meta( 'term', $meta_key, $args ); 3141 } 3142 3143 return register_term_meta( $type_tax, $meta_key, $args ); 3144 } 3001 3145 3002 3146 /** Email *****************************************************************/
Note: See TracChangeset
for help on using the changeset viewer.