Make WordPress Core

Changeset 58326

Timestamp:
06/04/2024 10:21:11 AM (5 weeks ago)
Author:
ellatrix
Message:

REST API: Add post class list field.

See https://github.com/WordPress/gutenberg/pull/60642.
See https://github.com/WordPress/wordpress-develop/pull/6716.

Fixes #61360.

Props antonvlasenko, timothyblynjacobs, ellatrix, oandregal.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r58065 r58326  
    19981998                    $data['generated_slug'] = $sample_permalink[1];
    19991999                }
     2000
     2001
     2002
     2003
    20002004            }
    20012005        }
     
    23542358                'readonly'    => true,
    23552359            );
     2360
     2361
     2362
     2363
     2364
     2365
     2366
     2367
     2368
     2369
    23562370        }
    23572371
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r58130 r58326  
    16471647        $data       = $response->get_data();
    16481648        $properties = $data['schema']['properties'];
    1649         $this->assertCount( 28, $properties );
     1649        $this->assertCount( 2, $properties );
    16501650        $this->assertArrayHasKey( 'author', $properties );
    16511651        $this->assertArrayHasKey( 'alt_text', $properties );
     
    16821682        $this->assertArrayHasKey( 'missing_image_sizes', $properties );
    16831683        $this->assertArrayHasKey( 'featured_media', $properties );
     1684
    16841685    }
    16851686
  • trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php

    r56547 r58326  
    749749        $data       = $response->get_data();
    750750        $properties = $data['schema']['properties'];
    751         $this->assertCount( 24, $properties );
     751        $this->assertCount( 2, $properties );
    752752        $this->assertArrayHasKey( 'author', $properties );
    753753        $this->assertArrayHasKey( 'comment_status', $properties );
     
    774774        $this->assertArrayHasKey( 'title', $properties );
    775775        $this->assertArrayHasKey( 'type', $properties );
     776
    776777    }
    777778
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r58065 r58326  
    43634363        $data       = $response->get_data();
    43644364        $properties = $data['schema']['properties'];
    4365         $this->assertCount( 26, $properties );
     4365        $this->assertCount( 2, $properties );
    43664366        $this->assertArrayHasKey( 'author', $properties );
    43674367        $this->assertArrayHasKey( 'comment_status', $properties );
     
    43904390        $this->assertArrayHasKey( 'tags', $properties );
    43914391        $this->assertArrayHasKey( 'categories', $properties );
     4392
    43924393    }
    43934394
     
    44194420            'author',
    44204421            'categories',
     4422
    44214423            'comment_status',
    44224424            'content',
     
    44574459            'author',
    44584460            'categories',
     4461
    44594462            'comment_status',
    44604463            'content',
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r58097 r58326  
    760760        }
    761761
     762
     763
    762764        foreach ( $data as $key => $value ) {
    763             if ( is_string( $value ) && (
    764                 'date' === $key ||
    765                 'date_gmt' === $key ||
    766                 'modified' === $key ||
    767                 'modified_gmt' === $key
    768             ) ) {
    769                 $data[ $key ] = '2017-02-14T00:00:00';
    770             } else {
    771                 $data[ $key ] = $this->normalize_fixture( $value, "$path.$key" );
     765            if ( is_string( $value ) ) {
     766                if ( in_array( $key, $datetime_keys, true ) ) {
     767                    $data[ $key ] = '2017-02-14T00:00:00';
     768                    continue;
     769                }
     770
     771                if ( 1 === preg_match( '/^post-\d+$/', $value ) ) {
     772                    // Normalize the class value to ensure test stability.
     773                    $data[ $key ] = 'post-1073';
     774                    continue;
     775                }
    772776            }
     777
     778
    773779        }
    774780
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r58283 r58326  
    1232312323        ],
    1232412324        "tags": [],
     12325
     12326
     12327
     12328
     12329
     12330
     12331
     12332
     12333
    1232512334        "_links": {
    1232612335            "self": [
     
    1242212431        1
    1242312432    ],
    12424     "tags": []
     12433    "tags": [],
     12434    "class_list": [
     12435        "post-1073",
     12436        "post",
     12437        "type-post",
     12438        "status-publish",
     12439        "format-standard",
     12440        "hentry",
     12441        "category-uncategorized"
     12442    ]
    1242512443};
    1242612444
     
    1261412632            "meta_key": ""
    1261512633        },
     12634
     12635
     12636
     12637
     12638
     12639
     12640
    1261612641        "_links": {
    1261712642            "self": [
     
    1269712722    "meta": {
    1269812723        "meta_key": ""
    12699     }
     12724    },
     12725    "class_list": [
     12726        "post-1073",
     12727        "page",
     12728        "type-page",
     12729        "status-publish",
     12730        "hentry"
     12731    ]
    1270012732};
    1270112733
     
    1287912911            "meta_key": ""
    1288012912        },
     12913
     12914
     12915
     12916
     12917
     12918
     12919
    1288112920        "description": {
    1288212921            "rendered": "<p class=\"attachment\"><!-- <a...><img.../></a> --></p>"
     
    1294112980        "meta_key": ""
    1294212981    },
     12982
     12983
     12984
     12985
     12986
     12987
     12988
    1294312989    "description": {
    1294412990        "rendered": "<p class=\"attachment\"><!-- <a...><img.../></a> --></p>"
Note: See TracChangeset for help on using the changeset viewer.