ties = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); // Everyone is allowed to exist. $capabilities['exist'] = true; // Nobody is allowed to do things they are not allowed to do. unset( $capabilities['do_not_allow'] ); // Must have ALL requested caps. foreach ( (array) $caps as $cap ) { if ( empty( $capabilities[ $cap ] ) ) { return false; } } return true; } /** * Converts numeric level to level capability name. * * Prepends 'level_' to level number. * * @since 2.0.0 * * @param int $level Level number, 1 to 10. * @return string */ public function translate_level_to_cap( $level ) { return 'level_' . $level; } /** * Sets the site to operate on. Defaults to the current site. * * @since 3.0.0 * @deprecated 4.9.0 Use WP_User::for_site() * * @param int $blog_id Optional. Site ID, defaults to current site. */ public function for_blog( $blog_id = '' ) { _deprecated_function( __METHOD__, '4.9.0', 'WP_User::for_site()' ); $this->for_site( $blog_id ); } /** * Sets the site to operate on. Defaults to the current site. * * @since 4.9.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param int $site_id Site ID to initialize user capabilities for. Default is the current site. */ public function for_site( $site_id = '' ) { global $wpdb; if ( ! empty( $site_id ) ) { $this->site_id = absint( $site_id ); } else { $this->site_id = get_current_blog_id(); } $this->cap_key = $wpdb->get_blog_prefix( $this->site_id ) . 'capabilities'; $this->caps = $this->get_caps_data(); $this->get_role_caps(); } /** * Gets the ID of the site for which the user's capabilities are currently initialized. * * @since 4.9.0 * * @return int Site ID. */ public function get_site_id() { return $this->site_id; } /** * Gets the available user capabilities data. * * @since 4.9.0 * * @return bool[] List of capabilities keyed by the capability name, * e.g. `array( 'edit_posts' => true, 'delete_posts' => false )`. */ private function get_caps_data() { $caps = get_user_meta( $this->ID, $this->cap_key, true ); if ( ! is_array( $caps ) ) { return array(); } return $caps; } } ), 'b' => base_convert( $match[3] . $match[3], 16, 10 ), ) ); $rgb['a'] = 1; return $rgb; } /* * The JS color picker considers the string "transparent" to be a hex value, * so we need to handle it here as a special case. */ if ( 'transparent' === $color_str ) { return array( 'r' => 0, 'g' => 0, 'b' => 0, 'a' => 0, ); } } /** * Returns the prefixed id for the duotone filter for use as a CSS id. * * @since 5.9.1 * @deprecated 6.3.0 * * @access private * * @param array $preset Duotone preset value as seen in theme.json. * @return string Duotone filter CSS id. */ function wp_get_duotone_filter_id( $preset ) { _deprecated_function( __FUNCTION__, '6.3.0' ); return WP_Duotone::get_filter_id_from_preset( $preset ); } /** * Returns the CSS filter property url to reference the rendered SVG. * * @since 5.9.0 * @since 6.1.0 Allow unset for preset colors. * @deprecated 6.3.0 * * @access private * * @param array $preset Duotone preset value as seen in theme.json. * @return string Duotone CSS filter property url value. */ function wp_get_duotone_filter_property( $preset ) { _deprecated_function( __FUNCTION__, '6.3.0' ); return WP_Duotone::get_filter_css_property_value_from_preset( $preset ); } /** * Returns the duotone filter SVG string for the preset. * * @since 5.9.1 * @deprecated 6.3.0 * * @access private * * @param array $preset Duotone preset value as seen in theme.json. * @return string Duotone SVG filter. */ function wp_get_duotone_filter_svg( $preset ) { _deprecated_function( __FUNCTION__, '6.3.0' ); return WP_Duotone::get_filter_svg_from_preset( $preset ); } /** * Registers the style and colors block attributes for block types that support it. * * @since 5.8.0 * @deprecated 6.3.0 Use WP_Duotone::register_duotone_support() instead. * * @access private * * @param WP_Block_Type $block_type Block Type. */ function wp_register_duotone_support( $block_type ) { _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::register_duotone_support()' ); return WP_Duotone::register_duotone_support( $block_type ); } /** * Renders out the duotone stylesheet and SVG. * * @since 5.8.0 * @since 6.1.0 Allow unset for preset colors. * @deprecated 6.3.0 Use WP_Duotone::render_duotone_support() instead. * * @access private * * @param string $block_content Rendered block content. * @param array $block Block object. * @return string Filtered block content. */ function wp_render_duotone_support( $block_content, $block ) { _deprecated_function( __FUNCTION__, '6.3.0', 'WP_Duotone::render_duotone_support()' ); $wp_block = new WP_Block( $block ); return WP_Duotone::render_duotone_support( $block_content, $block, $wp_block ); } /** * Returns a string containing the SVGs to be referenced as filters (duotone). * * @since 5.9.1 * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports. * * @return string */ function wp_get_global_styles_svg_filters() { _deprecated_function( __FUNCTION__, '6.3.0' ); /* * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme * developer's workflow. */ $can_use_cached = ! wp_is_development_mode( 'theme' ); $cache_group = 'theme_json'; $cache_key = 'wp_get_global_styles_svg_filters'; if ( $can_use_cached ) { $cached = wp_cache_get( $cache_key, $cache_group ); if ( $cached ) { return $cached; } } $supports_theme_json = wp_theme_has_theme_json(); $origins = array( 'default', 'theme', 'custom' ); if ( ! $supports_theme_json ) { $origins = array( 'default' ); } $tree = WP_Theme_JSON_Resolver::get_merged_data(); $svgs = $tree->get_svg_filters( $origins ); if ( $can_use_cached ) { wp_cache_set( $cache_key, $svgs, $cache_group ); } return $svgs; } /** * Renders the SVG filters supplied by theme.json. * * Note that this doesn't render the per-block user-defined * filters which are handled by wp_render_duotone_support, * but it should be rendered before the filtered content * in the body to satisfy Safari's rendering quirks. * * @since 5.9.1 * @deprecated 6.3.0 SVG generation is handled on a per-block basis in block supports. */ function wp_global_styles_render_svg_filters() { _deprecated_function( __FUNCTION__, '6.3.0' ); /* * When calling via the in_admin_header action, we only want to render the * SVGs on block editor pages. */ if ( is_admin() && ! get_current_screen()->is_block_editor() ) { return; } $filters = wp_get_global_styles_svg_filters(); if ( ! empty( $filters ) ) { echo $filters; } } /** * Build an array with CSS classes and inline styles defining the colors * which will be applied to the navigation markup in the front-end. * * @since 5.9.0 * @deprecated 6.3.0 This was removed from the Navigation Submenu block in favour of `wp_apply_colors_support()`. * `wp_apply_colors_support()` returns an array with similar class and style values, * but with different keys: `class` and `style`. * * @param array $context Navigation block context. * @param array $attributes Block attributes. * @param bool $is_sub_menu Whether the block is a sub-menu. * @return array Colors CSS classes and inline styles. */ function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) { _deprecated_function( __FUNCTION__, '6.3.0' ); $colors = array( 'css_classes' => array(), 'inline_styles' => '', ); // Text color. $named_text_color = null; $custom_text_color = null; if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) { $custom_text_color = $context['customOverlayTextColor']; } elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) { $named_text_color = $context['overlayTextColor']; } elseif ( array_key_exists( 'customTextColor', $context ) ) { $custom_text_color = $context['customTextColor']; } elseif ( array_key_exists( 'textColor', $context ) ) { $named_text_color = $context['textColor']; } elseif ( isset( $context['style']['color']['text'] ) ) { $custom_text_color = $context['style']['color']['text']; } // If has text color. if ( ! is_null( $named_text_color ) ) { // Add the color class. array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) ); } elseif ( ! is_null( $custom_text_color ) ) { // Add the custom color inline style. $colors['css_classes'][] = 'has-text-color'; $colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color ); } // Background color. $named_background_color = null; $custom_background_color = null; if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) { $custom_background_color = $context['customOverlayBackgroundColor']; } elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) { $named_background_color = $context['overlayBackgroundColor']; } elseif ( array_key_exists( 'customBackgroundColor', $context ) ) { $custom_background_color = $context['customBackgroundColor']; } elseif ( array_key_exists( 'backgroundColor', $context ) ) { $named_background_color = $context['backgroundColor']; } elseif ( isset( $context['style']['color']['background'] ) ) { $custom_background_color = $context['style']['color']['background']; } // If has background color. if ( ! is_null( $named_background_color ) ) { // Add the background-color class. array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) ); } elseif ( ! is_null( $custom_background_color ) ) { // Add the custom background-color inline style. $colors['css_classes'][] = 'has-background'; $colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color ); } return $colors; }