Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
69b6154
BP: Duotone: Limit SVG filter output to used filters #49103
MaggieCabrera Jun 15, 2023
26ee6d3
wrong place for the included file
MaggieCabrera Jun 15, 2023
4615585
BP: Duotone: Remove Safari rerender hack (#49232)
MaggieCabrera Jun 15, 2023
984486c
BP: Replace regex with tag processor for duotone class render #49212
MaggieCabrera Jun 15, 2023
72f6355
BP: Duotone: Pass filters to the Post Editor #49239
MaggieCabrera Jun 15, 2023
cb980d0
BP: Port colord to PHP #49700
MaggieCabrera Jun 15, 2023
b6f01c6
BP:Deprecate remaining global duotone functions
MaggieCabrera Jun 15, 2023
035a100
BP - partially: Selectors API: Fix for global styles hook, style vari…
MaggieCabrera Jun 15, 2023
83e3c2a
BP - partially: Selectors API: Make duotone selectors fallback and be…
MaggieCabrera Jun 15, 2023
3777e20
BP: Group duotone outputs and refactor rendering #49705
MaggieCabrera Jun 15, 2023
3471457
BP: Polish duotone rendering code #49706
MaggieCabrera Jun 15, 2023
e82e5da
BP: Better error message when theme.json styles use a duotone preset …
MaggieCabrera Jun 15, 2023
89d1c7a
BP: Clarify error message if duotone color values is incorrect #51397
MaggieCabrera Jun 15, 2023
8efbc43
run linter
MaggieCabrera Jun 15, 2023
8dc7158
Add duotone hooks
Jun 15, 2023
9774f6c
Fix comments to reference core versions of functions
Jun 15, 2023
ee7741c
Fix more comments to reference core versions of functions
Jun 15, 2023
4d1d9aa
Use core versions of classes/functions
Jun 15, 2023
9ebb0d3
Remove gutenberg translation domains
Jun 15, 2023
2a90a43
added docs or fixed them
MaggieCabrera Jun 16, 2023
2fd1bf9
Fixed more docblocks
MaggieCabrera Jun 21, 2023
d2306db
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
fb75344
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
f78d01b
Update tests/phpunit/tests/block-supports/duotone.php
MaggieCabrera Jun 26, 2023
7106f33
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
4530c53
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
071e093
fix docblocks for tests
MaggieCabrera Jun 26, 2023
eb1c12e
fix multiline comments
MaggieCabrera Jun 26, 2023
956e65c
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
6dad8db
fix colord functions docblocks
MaggieCabrera Jun 26, 2023
f1c26ea
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
49f0630
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
7d296b4
Update src/wp-includes/class-wp-duotone.php
MaggieCabrera Jun 26, 2023
e18f0ae
moved deprecated functions to the correct file
MaggieCabrera Jun 26, 2023
ae122da
Mark private and new deprecated methods as internal
ajlende Jun 26, 2023
6a91d93
Format line wrapping in comment
ajlende Jun 26, 2023
5141c6a
Update deprecated function docblock link and order
ajlende Jun 26, 2023
ec248c2
Fix trailing space
ajlende Jun 26, 2023
375ce41
Add more description to the WP_Duotone methods
ajlende Jun 26, 2023
895363a
Deprecate wp_global_styles_render_svg_filters and wp_get_global_style…
ajlende Jun 27, 2023
5347e2c
Remove tests for deprecated functions
ajlende Jun 27, 2023
1476cff
Move newly deprecated functions to deprecated.php
ajlende Jun 27, 2023
d74a917
Add changelog to PRESETS_METADATA
ajlende Jun 27, 2023
710858d
Add @since 6.3.0 to all duotone methods
ajlende Jun 27, 2023
a114db1
Mark class WP_Duotone as @access private
ajlende Jun 27, 2023
105bd9e
Fix theme json test string
tellthemachines Jun 28, 2023
2541786
Fix lint error
tellthemachines Jun 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mark private and new deprecated methods as internal
  • Loading branch information
ajlende authored and tellthemachines committed Jun 29, 2023
commit ae122dafb097640a49e88f690a7f6a52367933a0
91 changes: 91 additions & 0 deletions src/wp-includes/class-wp-duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class WP_Duotone {
* …
* ]
*
* @internal
*
* @var array
*/
private static $global_styles_block_names = array();
Expand All @@ -68,6 +70,8 @@ class WP_Duotone {
* …
* ]
*
* @internal
*
* @var array
*/
private static $global_styles_presets = array();
Expand All @@ -85,6 +89,8 @@ class WP_Duotone {
* …
* ]
*
* @internal
*
* @var array
*/
private static $used_global_styles_presets = array();
Expand All @@ -106,6 +112,8 @@ class WP_Duotone {
* …
* ]
*
* @internal
*
* @var array
*/
private static $used_svg_filter_data = array();
Expand All @@ -124,15 +132,21 @@ class WP_Duotone {
* …
* ]
*
* @internal
*
* @var array
*/
private static $block_css_declarations = array();

/**
* Clamps a value between an upper and lower bound.
*
* Direct port of colord's clamp function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/helpers.ts#L23 Sourced from colord.
*
* @internal
*
* @param float $number The number to clamp.
* @param float $min The minimum value.
* @param float $max The maximum value.
Expand All @@ -145,8 +159,12 @@ private static function colord_clamp( $number, $min = 0, $max = 1 ) {
/**
* Processes and clamps a degree (angle) value properly.
*
* Direct port of colord's clampHue function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/helpers.ts#L32 Sourced from colord.
*
* @internal
*
* @param float $degrees The hue to clamp.
* @return float The clamped hue.
*/
Expand All @@ -158,8 +176,12 @@ private static function colord_clamp_hue( $degrees ) {
/**
* Converts a hue value to degrees from 0 to 360 inclusive.
*
* Direct port of colord's parseHue function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/helpers.ts#L40 Sourced from colord.
*
* @internal
*
* @param float $value The hue value to parse.
* @param string $unit The unit of the hue value.
* @return float The parsed hue value.
Expand All @@ -182,8 +204,12 @@ private static function colord_parse_hue( $value, $unit = 'deg' ) {
/**
* Parses any valid Hex3, Hex4, Hex6 or Hex8 string and converts it to an RGBA object
*
* Direct port of colord's parseHex function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/hex.ts#L8 Sourced from colord.
*
* @internal
*
* @param string $hex The hex string to parse.
* @return array|null An array of RGBA values or null if the hex string is invalid.
*/
Expand Down Expand Up @@ -224,8 +250,12 @@ private static function colord_parse_hex( $hex ) {
/**
* Clamps an array of RGBA values.
*
* Direct port of colord's clampRgba function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/rgb.ts#L5 Sourced from colord.
*
* @internal
*
* @param array $rgba The RGBA array to clamp.
* @return array The clamped RGBA array.
*/
Expand All @@ -241,8 +271,12 @@ private static function colord_clamp_rgba( $rgba ) {
/**
* Parses a valid RGB[A] CSS color function/string
*
* Direct port of colord's parseRgbaString function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/rgbString.ts#L18 Sourced from colord.
*
* @internal
*
* @param string $input The RGBA string to parse.
* @return array|null An array of RGBA values or null if the RGB string is invalid.
*/
Expand Down Expand Up @@ -294,8 +328,12 @@ private static function colord_parse_rgba_string( $input ) {
/**
* Clamps an array of HSLA values.
*
* Direct port of colord's clampHsla function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/hsl.ts#L6 Sourced from colord.
*
* @internal
*
* @param array $hsla The HSLA array to clamp.
* @return array The clamped HSLA array.
*/
Expand All @@ -311,8 +349,12 @@ private static function colord_clamp_hsla( $hsla ) {
/**
* Converts an HSVA array to RGBA.
*
* Direct port of colord's hsvaToRgba function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/hsv.ts#L52 Sourced from colord.
*
* @internal
*
* @param array $hsva The HSVA array to convert.
* @return array The RGBA array.
*/
Expand All @@ -339,8 +381,12 @@ private static function colord_hsva_to_rgba( $hsva ) {
/**
* Converts an HSLA array to HSVA.
*
* Direct port of colord's hslaToHsva function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/hsl.ts#L33 Sourced from colord.
*
* @internal
*
* @param array $hsla The HSLA array to convert.
* @return array The HSVA array.
*/
Expand All @@ -363,8 +409,12 @@ private static function colord_hsla_to_hsva( $hsla ) {
/**
* Converts an HSLA array to RGBA.
*
* Direct port of colord's hslaToRgba function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/hsl.ts#L55 Sourced from colord.
*
* @internal
*
* @param array $hsla The HSLA array to convert.
* @return array The RGBA array.
*/
Expand All @@ -375,8 +425,12 @@ private static function colord_hsla_to_rgba( $hsla ) {
/**
* Parses a valid HSL[A] CSS color function/string.
*
* Direct port of colord's parseHslaString function.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/colorModels/hslString.ts#L17 Sourced from colord.
*
* @internal
*
* @param string $input The HSLA string to parse.
* @return array|null An array of RGBA values or null if the RGB string is invalid.
*/
Expand Down Expand Up @@ -426,8 +480,13 @@ private static function colord_parse_hsla_string( $input ) {
/**
* Tries to convert an incoming string into RGBA values.
*
* Direct port of colord's parse function simplified for our use case. This
* version only supports string parsing and only returns RGBA values.
*
* @link https://github.com/omgovich/colord/blob/3f859e03b0ca622eb15480f611371a0f15c9427f/src/parse.ts#L37 Sourced from colord.
*
* @internal
*
* @param string $input The string to parse.
* @return array|null An array of RGBA values or null if the string is invalid.
*/
Expand All @@ -452,6 +511,8 @@ private static function colord_parse( $input ) {
* var:preset|duotone|blue-orange
* var(--wp--preset--duotone--blue-orange)
*
* @internal
*
* @param string $duotone_attr The duotone attribute from a block.
* @return string The slug of the duotone preset or an empty string if no slug is found.
*/
Expand All @@ -465,6 +526,8 @@ private static function get_slug_from_attribute( $duotone_attr ) {
/**
* Checks if we have a valid duotone preset.
*
* @internal
*
* @param string $duotone_attr The duotone attribute from a block.
* @return bool True if the duotone preset present and valid.
*/
Expand All @@ -478,6 +541,8 @@ private static function is_preset( $duotone_attr ) {
/**
* Gets the CSS variable name for a duotone preset.
*
* @internal
*
* @param string $slug The slug of the duotone preset.
* @return string The CSS variable name.
*/
Expand All @@ -488,6 +553,8 @@ private static function get_css_custom_property_name( $slug ) {
/**
* Get the ID of the duotone filter.
*
* @internal
*
* @param string $slug The slug of the duotone preset.
* @return string The ID of the duotone filter.
*/
Expand All @@ -498,6 +565,8 @@ private static function get_filter_id( $slug ) {
/**
* Get the CSS variable for a duotone preset.
*
* @internal
*
* @param string $slug The slug of the duotone preset.
* @return string The CSS variable.
*/
Expand All @@ -509,6 +578,8 @@ private static function get_css_var( $slug ) {
/**
* Get the URL for a duotone filter.
*
* @internal
*
* @param string $filter_id The ID of the filter.
* @return string The URL for the duotone filter.
*/
Expand All @@ -519,6 +590,8 @@ private static function get_filter_url( $filter_id ) {
/**
* Gets the SVG for the duotone filter definition.
*
* @internal
*
* @param string $filter_id The ID of the filter.
* @param array $colors An array of color strings.
* @return string An SVG with a duotone filter definition.
Expand Down Expand Up @@ -604,6 +677,8 @@ private static function get_filter_svg( $filter_id, $colors ) {
*
* Exported for the deprecated function wp_get_duotone_filter_id().
*
* @internal
*
* @since 6.3.0
* @deprecated 6.3.0
*
Expand All @@ -625,6 +700,8 @@ public static function get_filter_id_from_preset( $preset ) {
*
* Exported for the deprecated function wp_get_duotone_filter_property().
*
* @internal
*
* @since 6.3.0
* @deprecated 6.3.0
*
Expand All @@ -644,6 +721,8 @@ public static function get_filter_svg_from_preset( $preset ) {
* Example output:
* <svg><defs><filter id="wp-duotone-blue-orange">…</filter></defs></svg><svg>…</svg>
*
* @internal
*
* @param array $sources The duotone presets.
* @return string The SVGs for the duotone filters.
*/
Expand All @@ -662,6 +741,8 @@ private static function get_svg_definitions( $sources ) {
* Example output:
* body{--wp--preset--duotone--blue-orange:url('#wp-duotone-blue-orange');}
*
* @internal
*
* @param array $sources The duotone presets.
* @return string The CSS for global styles.
*/
Expand All @@ -681,6 +762,8 @@ private static function get_global_styles_presets( $sources ) {
/**
* Enqueue a block CSS declaration for the page.
*
* @internal
*
* @param string $filter_id The filter ID. e.g. 'wp-duotone-000000-ffffff-2'.
* @param string $duotone_selector The block's duotone selector. e.g. '.wp-block-image img'.
* @param string $filter_value The filter CSS value. e.g. 'url(#wp-duotone-000000-ffffff-2)' or 'unset'.
Expand Down Expand Up @@ -714,6 +797,8 @@ private static function enqueue_block_css( $filter_id, $duotone_selector, $filte
*
* Includes an SVG filter and block CSS declaration.
*
* @internal
*
* @param string $filter_id The filter ID. e.g. 'wp-duotone-000000-ffffff-2'.
* @param string $duotone_selector The block's duotone selector. e.g. '.wp-block-image img'.
* @param string $filter_value The filter CSS value. e.g. 'url(#wp-duotone-000000-ffffff-2)' or 'unset'.
Expand All @@ -729,6 +814,8 @@ private static function enqueue_custom_filter( $filter_id, $duotone_selector, $f
*
* Includes a CSS custom property, SVG filter, and block CSS declaration.
*
* @internal
*
* @param string $filter_id The filter ID. e.g. 'wp-duotone-blue-orange'.
* @param string $duotone_selector The block's duotone selector. e.g. '.wp-block-image img'.
* @param string $filter_value The filter CSS value. e.g. 'url(#wp-duotone-blue-orange)' or 'unset'.
Expand Down Expand Up @@ -782,6 +869,8 @@ public static function register_duotone_support( $block_type ) {
*
* @param string $block_name The block name.
*
* @internal
*
* @return string The CSS selector or null if there is no support.
*/
private static function get_selector( $block_name ) {
Expand Down Expand Up @@ -1066,6 +1155,8 @@ public static function migrate_experimental_duotone_support_flag( $settings, $me
*
* Exported for the deprecated function wp_get_duotone_filter_id().
*
* @internal
*
* @since 6.3.0
* @deprecated 6.3.0
*
Expand Down