Skip to content

Commit

Permalink
Rename wp:theme-file-uris to wp:theme-file
Browse files Browse the repository at this point in the history
Rename utils file
  • Loading branch information
ramonjd committed May 20, 2024
1 parent 7fecf34 commit 5d3ba0b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/class-wp-rest-global-styles-controller-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public function prepare_item_for_response( $post, $request ) { // phpcs:ignore V
if ( $theme_json ) {
$resolved_theme_uris = WP_Theme_JSON_Resolver_Gutenberg::get_resolved_theme_uris( $theme_json );
if ( ! empty( $resolved_theme_uris ) ) {
$links['https://api.w.org/theme-file-uris'] = $resolved_theme_uris;
$links['https://api.w.org/theme-file'] = $resolved_theme_uris;
}
}
$response->add_links( $links );
Expand Down Expand Up @@ -643,7 +643,7 @@ public function get_theme_item( $request ) {
);
$resolved_theme_uris = WP_Theme_JSON_Resolver_Gutenberg::get_resolved_theme_uris( $theme );
if ( ! empty( $resolved_theme_uris ) ) {
$links['https://api.w.org/theme-file-uris'] = $resolved_theme_uris;
$links['https://api.w.org/theme-file'] = $resolved_theme_uris;
}

$response->add_links( $links );
Expand Down Expand Up @@ -712,7 +712,7 @@ public function get_theme_items( $request ) {
if ( ! empty( $resolved_theme_uris ) ) {
$data->add_links(
array(
'https://api.w.org/theme-file-uris' => $resolved_theme_uris,
'https://api.w.org/theme-file' => $resolved_theme_uris,
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function prepare_item_for_response( $post, $request ) {
$links = array();
$resolved_theme_uris = WP_Theme_JSON_Resolver_Gutenberg::get_resolved_theme_uris( $theme_json );
if ( ! empty( $resolved_theme_uris ) ) {
$links['https://api.w.org/theme-file-uris'] = $resolved_theme_uris;
$links['https://api.w.org/theme-file'] = $resolved_theme_uris;
}
$response->add_links( $links );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { setImmutably } from '../../utils/object';
import MediaReplaceFlow from '../media-replace-flow';
import { store as blockEditorStore } from '../../store';
import { getResolvedThemeFilePath } from './set-theme-file-uris';
import { getResolvedThemeFilePath } from './theme-file-uri-utils';

const IMAGE_BACKGROUND_TYPE = 'image';
const DEFAULT_CONTROLS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* Internal dependencies
*/
import setThemeFileUris, {
import {
setThemeFileUris,
getResolvedThemeFilePath,
} from '../set-theme-file-uris';
} from '../theme-file-uri-utils';

const themeFileURIs = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function setMutably( object, path, value ) {
* @param {Array<Object>} themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.
* @return {Object} Returns mutated object.
*/
export default function setThemeFileUris( themeJson, themeFileURIs ) {
export function setThemeFileUris( themeJson, themeFileURIs ) {
if ( ! themeJson?.styles || ! themeFileURIs ) {
return themeJson;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { LAYOUT_DEFINITIONS } from '../../layouts/definitions';
import { getValueFromObjectPath, setImmutably } from '../../utils/object';
import BlockContext from '../block-context';
import { unlock } from '../../lock-unlock';
import setThemeFileUris from './set-theme-file-uris';
import { setThemeFileUris } from './theme-file-uri-utils';

// List of block support features that can have their related styles
// generated under their own feature level selector rather than the block's.
Expand Down Expand Up @@ -1220,7 +1220,7 @@ export function useGlobalStylesOutputWithConfig( mergedConfig = {} ) {
const [ blockGap ] = useGlobalSetting( 'spacing.blockGap' );
mergedConfig = setThemeFileUris(
mergedConfig,
mergedConfig?._links?.[ 'wp:theme-file-uris' ]
mergedConfig?._links?.[ 'wp:theme-file' ]
);
const hasBlockGapSupport = blockGap !== null;
const hasFallbackGapSupport = ! hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function BackgroundPanel() {
headerLabel={ __( 'Image' ) }
defaultValues={ BACKGROUND_DEFAULT_VALUES }
defaultControls={ defaultControls }
themeFileURIs={ _links?.[ 'wp:theme-file-uris' ] }
themeFileURIs={ _links?.[ 'wp:theme-file' ] }
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ public function test_get_theme_items() {
$expected = array(
array(
'_links' => array(
'curies' => array(
'curies' => array(
array(
'name' => 'wp',
'href' => 'https://api.w.org/{rel}',
'templated' => true,
),
),
'wp:theme-file-uris' => array(
'wp:theme-file' => array(
array(
'href' => 'http://localhost:8889/wp-content/themes/emptytheme/img/1024x768_emptytheme_test_image.jpg',
'name' => 'file:./img/1024x768_emptytheme_test_image.jpg',
Expand Down

0 comments on commit 5d3ba0b

Please sign in to comment.