_wp_array_set example


    public static function migrate_experimental_duotone_support_flag( $settings$metadata ) {
        $duotone_support = _wp_array_get( $metadata, array( 'supports', 'color', '__experimentalDuotone' ), null );

        if ( ! isset( $settings['supports']['filter']['duotone'] ) && null !== $duotone_support ) {
            _wp_array_set( $settings, array( 'supports', 'filter', 'duotone' )(bool) $duotone_support );
        }

        return $settings;
    }

    /** * Gets the CSS filter property value from a preset. * * Exported for the deprecated function wp_get_duotone_filter_id(). * * @internal * * @since 6.3.0 * @deprecated 6.3.0 * * @param array $preset The duotone preset. * @return string The CSS filter property value. */
/* translators: 1: Block type, 2: Typography supports key, e.g: fontSize, lineHeight, etc. 3: block.json, 4: Old metadata key, 5: New metadata key. */
                    __( 'Block "%1$s" is declaring %2$s support in %3$s file under %4$s. %2$s support is now declared under %5$s.' ),
                    $metadata['name'],
                    "<code>$typography_key</code>",
                    '<code>block.json</code>',
                    "<code>supports.$typography_key</code>",
                    "<code>supports.typography.$typography_key</code>"
                ),
                '5.8.0'
            );

            _wp_array_set( $metadata['supports'], array( 'typography', $typography_key )$support_for_key );
            unset( $metadata['supports'][ $typography_key ] );
        }
    }

    return $metadata;
}

/** * Helper function that constructs a WP_Query args array from * a `Query` block properties. * * It's used in Query Loop, Query Pagination Numbers and Query Pagination Next blocks. * * @since 5.8.0 * @since 6.1.0 Added `query_loop_block_query_vars` filter and `parents` support in query. * * @param WP_Block $block Block instance. * @param int $page Current query's page. * * @return array Returns the constructed WP_Query arguments. */

    private static function rename_settings( &$settings$paths_to_rename ) {
        foreach ( $paths_to_rename as $original => $renamed ) {
            $original_path = explode( '.', $original );
            $renamed_path  = explode( '.', $renamed );
            $current_value = _wp_array_get( $settings$original_path, null );

            if ( null !== $current_value ) {
                _wp_array_set( $settings$renamed_path$current_value );
                self::unset_setting_by_path( $settings$original_path );
            }
        }
    }

    /** * Removes a property from within the provided settings by its path. * * @since 5.9.0 * * @param array $settings Reference to the current settings array. * @param array $path Path to the property to be removed. */
        $nodes = static::get_setting_nodes( $this->theme_json );
        foreach ( $nodes as $node ) {
            foreach ( static::PRESETS_METADATA as $preset_metadata ) {
                $path = $node['path'];
                foreach ( $preset_metadata['path'] as $subpath ) {
                    $path[] = $subpath;
                }
                $preset = _wp_array_get( $this->theme_json, $path, null );
                if ( null !== $preset ) {
                    // If the preset is not already keyed by origin.                     if ( isset( $preset[0] ) || empty( $preset ) ) {
                        _wp_array_set( $this->theme_json, $path, array( $origin => $preset ) );
                    }
                }
            }
        }
    }

    /** * Enables some opt-in settings if theme declared support. * * @since 5.9.0 * * @param array $theme_json A theme.json structure to modify. * @return array The modified theme.json structure. */
Home | Imprint | This part of the site doesn't use cookies.