WP_Duotone
- Source
wp-includes/class-wp-duotone.php:40
Manages duotone block supports and global styles.
Compatibility
- WordPress
- core
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Properties · 5
$global_styles_block_names?arrayprivate static- Block names from global, theme, and custom styles that use duotone presets and the slug of the preset they are using.
$global_styles_presets?arrayprivate static- An array of duotone filter data from global, theme, and custom presets.
$used_global_styles_presetsarrayprivate static- All of the duotone filter data from presets for CSS custom properties on the page.
$used_svg_filter_dataarrayprivate static- All of the duotone filter data for SVGs on the page. Includes both presets and custom filters.
$block_css_declarationsarrayprivate static- All of the block CSS declarations for styles on the page.
Methods · 38
- colord_clamp()Clamps a value between an upper and lower bound.
- colord_clamp_hue()Processes and clamps a degree (angle) value properly.
- colord_parse_hue()Converts a hue value to degrees from 0 to 360 inclusive.
- colord_parse_hex()Parses any valid Hex3, Hex4, Hex6 or Hex8 string and converts it to an RGBA object.
- colord_clamp_rgba()Clamps an array of RGBA values.
- colord_parse_rgba_string()Parses a valid RGB[A] CSS color function/string.
- colord_clamp_hsla()Clamps an array of HSLA values.
- colord_hsva_to_rgba()Converts an HSVA array to RGBA.
- colord_hsla_to_hsva()Converts an HSLA array to HSVA.
- colord_hsla_to_rgba()Converts an HSLA array to RGBA.
- colord_parse_hsla_string()Parses a valid HSL[A] CSS color function/string.
- colord_parse()Tries to convert an incoming string into RGBA values.
- get_slug_from_attribute()Takes the inline CSS duotone variable from a block and return the slug.
- is_preset()Checks if we have a valid duotone preset.
- get_css_custom_property_name()Gets the CSS variable name for a duotone preset.
- get_filter_id()Get the ID of the duotone filter.
- get_css_var()Get the CSS variable for a duotone preset.
- get_filter_url()Get the URL for a duotone filter.
- get_filter_svg()Gets the SVG for the duotone filter definition.
- get_filter_id_from_preset()Returns the prefixed id for the duotone filter for use as a CSS id.
- get_filter_svg_from_preset()Gets the SVG for the duotone filter definition from a preset.
- get_svg_definitions()Get the SVGs for the duotone filters.
- get_global_styles_presets()Get the CSS for global styles.
- enqueue_block_css()Enqueue a block CSS declaration for the page.
- enqueue_custom_filter()Enqueue custom filter assets for the page.
- enqueue_global_styles_preset()Enqueue preset assets for the page.
- register_duotone_support()Registers the style and colors block attributes for block types that support it.
- get_selector()Get the CSS selector for a block type.
- get_all_global_styles_presets()Scrape all possible duotone presets from global and theme styles and store them in self::$global_styles_presets.
- get_all_global_style_block_names()Scrape all block names from global styles and store in self::$global_styles_block_names.
- render_duotone_support()Render out the duotone CSS styles and SVG.
- restore_image_outer_container()Fixes the issue with our generated class name not being added to the block's outer container in classic themes due to gutenberg_restore_image_outer_container from layout block supports.
- output_block_styles()Appends the used block duotone filter declarations to the inline block supports CSS.
- output_global_styles()Appends the used global style duotone filter presets (CSS custom properties) to the inline global styles CSS.
- output_footer_assets()Outputs all necessary SVG for duotone filters, CSS for classic themes.
- add_editor_settings()Adds the duotone SVGs and CSS custom properties to the editor settings.
- migrate_experimental_duotone_support_flag()Migrates the experimental duotone support flag to the stabilized location.
- get_filter_css_property_value_from_preset()Gets the CSS filter property value from a preset.
Source code
class WP_Duotone { /** * Block names from global, theme, and custom styles that use duotone presets and the slug of * the preset they are using. * * Example: * [ * 'core/featured-image' => 'blue-orange', * … * ] * * @internal * * @since 6.3.0 * * @var ?array */ private static $global_styles_block_names; /** * An array of duotone filter data from global, theme, and custom presets. * * Example: * [ * 'wp-duotone-blue-orange' => [ * 'slug' => 'blue-orange', * 'colors' => [ '#0000ff', '#ffcc00' ], * ], * 'wp-duotone-red-yellow' => [ * 'slug' => 'red-yellow', * 'colors' => [ '#cc0000', '#ffff33' ], * ], * … * ] * * @internal * * @since 6.3.0 * * @var ?array */ private static $global_styles_presets; /** * All of the duotone filter data from presets for CSS custom properties on * the page. * * Example: * [ * 'wp-duotone-blue-orange' => [ * 'slug' => 'blue-orange', * 'colors' => [ '#0000ff', '#ffcc00' ], * ], * … * ] * * @internal * * @since 6.3.0 * * @var array */ private static $used_global_styles_presets = array(); /** * All of the duotone filter data for SVGs on the page. Includes both * presets and custom filters. * * Example: * [ * 'wp-duotone-blue-orange' => [ * 'slug' => 'blue-orange', * 'colors' => [ '#0000ff', '#ffcc00' ], * ], * 'wp-duotone-000000-ffffff-2' => [ * 'slug' => '000000-ffffff-2', * 'colors' => [ '#000000', '#ffffff' ], * ], * … * ]Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-duotone.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.