Make WordPress Core


Ignore:
Timestamp:
02/17/2022 04:16:59 PM (5 years ago)
Author:
audrasjb
Message:

Editor: Backport Duotone fixes for 5.9.1.

This changeset is a backport for the following Gutenberg PRs:

  • Fix duotone theme cache gutenberg#36236
  • Fix duotone render in non-fse themes gutenberg#37954
  • Duotone: Allow users to specify custom filters gutenberg#38442

Props oandregal, scruffian, Mamaduka.
See #55179.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r52744 r52757  
    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.