PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
gutenberg / lib / compat / wordpress-7.2 / class-gutenberg-rest-view-config-controller-7-2.php

class-gutenberg-rest-view-config-controller-7-2.php in Gutenberg trunk, at lib/compat/wordpress-7.2/class-gutenberg-rest-view-config-controller-7-2.php

76 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * REST API: Gutenberg_REST_View_Config_Controller_7_2 class
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Controller which provides a REST endpoint for retrieving the default
10 * view configuration for a given entity type.
11 *
12 * Extends the 7.1 controller to describe the table column styles in the
13 * item schema and to add the `showPlaceholderIfEmpty` option of the panel
14 * form layout.
15 *
16 * @since 7.2.0
17 *
18 * @see Gutenberg_REST_View_Config_Controller_7_1
19 */
20 class Gutenberg_REST_View_Config_Controller_7_2 extends Gutenberg_REST_View_Config_Controller_7_1 {
21
22 /**
23 * Returns the schema for the ColumnStyle type.
24 *
25 * @since 7.2.0 Added descriptions to the column style properties.
26 *
27 * @return array Schema for a column style object.
28 */
29 protected function get_column_style_schema() {
30 $schema = parent::get_column_style_schema();
31
32 $schema['properties']['width']['description'] = __( 'The width of the column.', 'gutenberg' );
33 $schema['properties']['maxWidth']['description'] = __( 'The maximum width of the column.', 'gutenberg' );
34 $schema['properties']['minWidth']['description'] = __( 'The minimum width of the column.', 'gutenberg' );
35 $schema['properties']['align']['description'] = __( 'The horizontal alignment of the column content.', 'gutenberg' );
36
37 return $schema;
38 }
39
40 /**
41 * Returns the layout schema for table-type views (ViewTable, ViewPickerTable).
42 *
43 * @since 7.2.0 Added a description to the `styles` property.
44 *
45 * @return array Schema for a table layout object.
46 */
47 protected function get_table_layout_schema() {
48 $schema = parent::get_table_layout_schema();
49
50 $schema['properties']['styles']['description'] = __( 'Column styles keyed by field id, for the columns listed in the view fields. The primary column (title, media, and description fields) ignores these styles; in the table layout it takes the width left over by the other columns, or the last column does when there is no primary column.', 'gutenberg' );
51
52 return $schema;
53 }
54
55 /**
56 * Returns the schema for a form layout object.
57 *
58 * @since 7.2.0 Added the `showPlaceholderIfEmpty` property to the panel layout.
59 *
60 * @return array Schema for a form layout object.
61 */
62 protected function get_form_layout_schema() {
63 $schema = parent::get_form_layout_schema();
64
65 foreach ( $schema['oneOf'] as $index => $layout ) {
66 if ( array( 'panel' ) === $layout['properties']['type']['enum'] ) {
67 $schema['oneOf'][ $index ]['properties']['showPlaceholderIfEmpty'] = array(
68 'type' => 'boolean',
69 );
70 }
71 }
72
73 return $schema;
74 }
75 }
76