WP_Theme_JSON::get_svg_filters() WordPress Method

The WP_Theme_JSON::get_svg_filters() function is used to return an array of all available SVG filters.

WP_Theme_JSON::get_svg_filters( array $origins ) #

Converts all filter (duotone) presets into SVGs.


Parameters

$origins

(array)(Required)List of origins to process.


Top ↑

Return

(string) SVG filters.


Top ↑

Source

File: wp-includes/class-wp-theme-json.php

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.1Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.