WP_Theme_JSON::get_settings_slugs() – Similar to get_settings_values_by_slug, but doesn’t compute the value.

You appear to be a bot. Output may be restricted

Description

Similar to get_settings_values_by_slug, but doesn't compute the value.

Usage

$array = WP_Theme_JSON::get_settings_slugs( $settings, $preset_metadata, $origins );

Parameters

$settings
( array ) required – Settings to process.
$preset_metadata
( array ) required – One of the PRESETS_METADATA values.
$origins
( array ) optional – List of origins to process.

Returns

array Array of presets where the key and value are both the slug.

Source

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

1 to 21 of 21
  protected static function get_settings_slugs( $settings, $preset_metadata, $origins = null ) {
    if ( null === $origins ) {
      $origins = static::VALID_ORIGINS;
    }

    $preset_per_origin = _wp_array_get( $settings, $preset_metadata['path'], array() );

    $result = array();
    foreach ( $origins as $origin ) {
      if ( ! isset( $preset_per_origin[ $origin ] ) ) {
        continue;
      }
      foreach ( $preset_per_origin[ $origin ] as $preset ) {
        $slug = _wp_to_kebab_case( $preset['slug'] );

        // Use the array as a set so we don't get duplicates.
        $result[ $slug ] = $slug;
      }
    }
    return $result;
  }
 

 View on GitHub View on Trac