Make WordPress Core


Ignore:
Timestamp:
02/17/2022 05:29:04 PM (2 years ago)
Author:
audrasjb
Message:

Editor: Backport Duotone fixes for 5.9.1.

This changeset is a backport for the following Gutenberg PRs:

Props oandregal, scruffian, Mamaduka.
Merges [52757] to the 5.9 branch.
See #55179.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-includes/class-wp-theme-json.php

    r52758 r52759  
    133133            'override'          => true,
    134134            'use_default_names' => false,
    135             'value_func'        => 'wp_render_duotone_filter_preset',
     135            'value_func'        => 'wp_get_duotone_filter_property',
    136136            'css_vars'          => '--wp--preset--duotone--$slug',
    137137            'classes'           => array(),
     
    15881588
    15891589    /**
     1590     * Converts all filter (duotone) presets into SVGs.
     1591     *
     1592     * @since 5.9.1
     1593     *
     1594     * @param array $origins List of origins to process.
     1595     * @return string SVG filters.
     1596     */
     1597    public function get_svg_filters( $origins ) {
     1598        $blocks_metadata = static::get_blocks_metadata();
     1599        $setting_nodes   = static::get_setting_nodes( $this->theme_json, $blocks_metadata );
     1600
     1601        foreach ( $setting_nodes as $metadata ) {
     1602            $node = _wp_array_get( $this->theme_json, $metadata['path'], array() );
     1603            if ( empty( $node['color']['duotone'] ) ) {
     1604                continue;
     1605            }
     1606
     1607            $duotone_presets = $node['color']['duotone'];
     1608
     1609            $filters = '';
     1610            foreach ( $origins as $origin ) {
     1611                if ( ! isset( $duotone_presets[ $origin ] ) ) {
     1612                    continue;
     1613                }
     1614                foreach ( $duotone_presets[ $origin ] as $duotone_preset ) {
     1615                    $filters .= wp_get_duotone_filter_svg( $duotone_preset );
     1616                }
     1617            }
     1618        }
     1619
     1620        return $filters;
     1621    }
     1622
     1623    /**
    15901624     * Returns whether a presets should be overridden or not.
    15911625     *
Note: See TracChangeset for help on using the changeset viewer.