Make WordPress Core


Ignore:
Timestamp:
06/04/2024 10:21:11 AM (12 months 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.

File:
1 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            if ( rest_is_field_included( 'class_list', $fields ) ) {
     2003                $data['class_list'] = get_post_class( array(), $post->ID );
    20002004            }
    20012005        }
     
    23542358                'readonly'    => true,
    23552359            );
     2360
     2361            $schema['properties']['class_list'] = array(
     2362                'description' => __( 'An array of the class names for the post container element.' ),
     2363                'type'        => 'array',
     2364                'context'     => array( 'view', 'edit' ),
     2365                'readonly'    => true,
     2366                'items'       => array(
     2367                    'type' => 'string',
     2368                ),
     2369            );
    23562370        }
    23572371
Note: See TracChangeset for help on using the changeset viewer.