Title: WP_Duotone::get_selector
Published: August 8, 2023
Last modified: August 20, 2026

---

# WP_Duotone::get_selector( WP_Block_Type $block_type ): string|null

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#changelog)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Get the CSS selector for a block type.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#description)󠁿

This handles selectors defined in `color.__experimentalDuotone` support if `filter.
duotone` support is not defined.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#parameters)󠁿

 `$block_type`[WP_Block_Type](https://developer.wordpress.org/reference/classes/wp_block_type/)
required

Block type to check for support.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#return)󠁿

 string|null The CSS selector or null if there is no support.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#source)󠁿

    ```php
    private static function get_selector( $block_type ) {
    	if ( ! ( $block_type instanceof WP_Block_Type ) ) {
    		return null;
    	}

    	/*
    	 * Backward compatibility with `supports.color.__experimentalDuotone`
    	 * is provided via the `block_type_metadata_settings` filter. If
    	 * `supports.filter.duotone` has not been set and the experimental
    	 * property has been, the experimental property value is copied into
    	 * `supports.filter.duotone`.
    	 */
    	$duotone_support = block_has_support( $block_type, array( 'filter', 'duotone' ) );
    	if ( ! $duotone_support ) {
    		return null;
    	}

    	/*
    	 * If the experimental duotone support was set, that value is to be
    	 * treated as a selector and requires scoping.
    	 */
    	$experimental_duotone = $block_type->supports['color']['__experimentalDuotone'] ?? false;
    	if ( $experimental_duotone ) {
    		$root_selector = wp_get_block_css_selector( $block_type );
    		return is_string( $experimental_duotone )
    			? WP_Theme_JSON::scope_selector( $root_selector, $experimental_duotone )
    			: $root_selector;
    	}

    	// Regular filter.duotone support uses filter.duotone selectors with fallbacks.
    	return wp_get_block_css_selector( $block_type, array( 'filter', 'duotone' ), true );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-duotone.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-duotone.php#L962)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-duotone.php#L962-L993)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_block_css_selector()](https://developer.wordpress.org/reference/functions/wp_get_block_css_selector/)`wp-includes/global-styles-and-settings.php` |

Determines the CSS selector for the block type and property provided, returning it if available.

  | 
| [WP_Theme_JSON::scope_selector()](https://developer.wordpress.org/reference/classes/wp_theme_json/scope_selector/)`wp-includes/class-wp-theme-json.php` |

Function that scopes a selector with another one. This works a bit like SCSS nesting except the `&amp;` operator isn’t supported.

  | 
| [block_has_support()](https://developer.wordpress.org/reference/functions/block_has_support/)`wp-includes/blocks.php` |

Checks whether the current block type supports the feature requested.

  |

| Used by | Description | 
| [WP_Duotone::render_duotone_support()](https://developer.wordpress.org/reference/classes/wp_duotone/render_duotone_support/)`wp-includes/class-wp-duotone.php` |

Render out the duotone CSS styles and SVG.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_duotone/get_selector/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_duotone%2Fget_selector%2F)
before being able to contribute a note or feedback.