WP_Theme_JSON::get_svg_filters() – Converts all filter (duotone) presets into SVGs.

You appear to be a bot. Output may be restricted

Description

Converts all filter (duotone) presets into SVGs.

Usage

$string = WP_Theme_JSON::get_svg_filters( $origins );

Parameters

$origins
( array ) required – List of origins to process.

Returns

string SVG filters.

Source

File name: wordpress/wp-includes/class-wp-theme-json.php
Lines:

1 to 25 of 25
  public function get_svg_filters( $origins ) {
    $blocks_metadata = static::get_blocks_metadata();
    $setting_nodes   = static::get_setting_nodes( $this->theme_json, $blocks_metadata );

    $filters = '';
    foreach ( $setting_nodes as $metadata ) {
      $node = _wp_array_get( $this->theme_json, $metadata['path'], array() );
      if ( empty( $node['color']['duotone'] ) ) {
        continue;
      }

      $duotone_presets = $node['color']['duotone'];

      foreach ( $origins as $origin ) {
        if ( ! isset( $duotone_presets[ $origin ] ) ) {
          continue;
        }
        foreach ( $duotone_presets[ $origin ] as $duotone_preset ) {
          $filters .= wp_get_duotone_filter_svg( $duotone_preset );
        }
      }
    }

    return $filters;
  }
 

 View on GitHub View on Trac