Make WordPress Core


Ignore:
Timestamp:
07/24/2024 12:24:31 AM (17 months ago)
Author:
noisysocks
Message:

Block themes: Enable block-level background image styles

Allows defining background images for blocks in theme.json.

Syncs PHP changes from https://github.com/WordPress/gutenberg/pull/60100.

Props ramonopoly, aaronrobertshaw.
Fixes #61588.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php

    r58466 r58797  
    12581258     * @covers WP_Theme_JSON_Resolver::resolve_theme_file_uris
    12591259     * @ticket 61273
     1260     * @ticket 61588
    12601261     */
    12611262    public function test_resolve_theme_file_uris() {
     
    12671268                        'backgroundImage' => array(
    12681269                            'url' => 'file:./assets/image.png',
     1270                        ),
     1271                    ),
     1272                    'blocks'     => array(
     1273                        'core/quote' => array(
     1274                            'background' => array(
     1275                                'backgroundImage' => array(
     1276                                    'url' => 'file:./assets/quote.png',
     1277                                ),
     1278                            ),
     1279                        ),
     1280                        'core/verse' => array(
     1281                            'background' => array(
     1282                                'backgroundImage' => array(
     1283                                    'url' => 'file:./assets/verse.png',
     1284                                ),
     1285                            ),
    12691286                        ),
    12701287                    ),
     
    12811298                    ),
    12821299                ),
     1300                'blocks'     => array(
     1301                    'core/quote' => array(
     1302                        'background' => array(
     1303                            'backgroundImage' => array(
     1304                                'url' => 'https://example.org/wp-content/themes/example-theme/assets/quote.png',
     1305                            ),
     1306                        ),
     1307                    ),
     1308                    'core/verse' => array(
     1309                        'background' => array(
     1310                            'backgroundImage' => array(
     1311                                'url' => 'https://example.org/wp-content/themes/example-theme/assets/verse.png',
     1312                            ),
     1313                        ),
     1314                    ),
     1315                ),
    12831316            ),
    12841317        );
     
    12941327     * @covers WP_Theme_JSON_Resolver::get_resolved_theme_uris
    12951328     * @ticket 61273
     1329     * @ticket 61588
    12961330     */
    12971331    public function test_get_resolved_theme_uris() {
     
    13051339                        ),
    13061340                    ),
     1341                    'blocks'     => array(
     1342                        'core/quote' => array(
     1343                            'background' => array(
     1344                                'backgroundImage' => array(
     1345                                    'url' => 'file:./assets/quote.jpg',
     1346                                ),
     1347                            ),
     1348                        ),
     1349                        'core/verse' => array(
     1350                            'background' => array(
     1351                                'backgroundImage' => array(
     1352                                    'url' => 'file:./assets/verse.gif',
     1353                                ),
     1354                            ),
     1355                        ),
     1356                    ),
    13071357                ),
    13081358            )
     
    13151365                'target' => 'styles.background.backgroundImage.url',
    13161366                'type'   => 'image/png',
     1367            ),
     1368            array(
     1369                'name'   => 'file:./assets/quote.jpg',
     1370                'href'   => 'https://example.org/wp-content/themes/example-theme/assets/quote.jpg',
     1371                'target' => 'styles.blocks.core/quote.background.backgroundImage.url',
     1372                'type'   => 'image/jpeg',
     1373            ),
     1374            array(
     1375                'name'   => 'file:./assets/verse.gif',
     1376                'href'   => 'https://example.org/wp-content/themes/example-theme/assets/verse.gif',
     1377                'target' => 'styles.blocks.core/verse.background.backgroundImage.url',
     1378                'type'   => 'image/gif',
    13171379            ),
    13181380        );
Note: See TracChangeset for help on using the changeset viewer.