PluginProbe
Gutenberg / 23.7.2
Gutenberg v23.7.2
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 12.6.0 7.4.0 All 402 releases
gutenberg / lib / experimental / dashboard-widgets / default-layout-seed.php

default-layout-seed.php in Gutenberg 23.7.2, at lib/experimental/dashboard-widgets/default-layout-seed.php

97 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Dashboard Layout: starter content shipped with the experiment.
4 *
5 * Registers a small default layout under `gutenberg_dashboard_default_layout`
6 * so the dashboard renders something meaningful the first time a user opens
7 * it. Plugins and themes can layer their own callback on top of the same
8 * filter to extend or replace this set.
9 *
10 * @package gutenberg
11 */
12
13 /**
14 * Appends the bundled widget instances to the default layout unless an
15 * earlier callback in the filter chain already added them.
16 *
17 * Only contributes to the bundled `gutenberg_dashboard`; other
18 * dashboards are left untouched.
19 *
20 * @param array $dashboard_layout Default layout produced by previous
21 * callbacks on `gutenberg_dashboard_default_layout`.
22 * @param string $dashboard_name Identifier of the dashboard receiving
23 * the default.
24 * @return array The layout extended with the bundled widget instance.
25 */
26 function gutenberg_seed_default_dashboard_layout( $dashboard_layout, $dashboard_name = '' ) {
27 if ( 'gutenberg_dashboard' !== $dashboard_name ) {
28 return $dashboard_layout;
29 }
30
31 $uuids = array_column( $dashboard_layout, 'uuid' );
32
33 if ( ! in_array( 'default-welcome-widget-instance', $uuids, true ) ) {
34 $dashboard_layout[] = array(
35 'uuid' => 'default-welcome-widget-instance',
36 'type' => 'core/welcome',
37 'placement' => array(
38 'width' => 'full',
39 'height' => 3,
40 'order' => 0,
41 ),
42 );
43 }
44
45 if ( ! in_array( 'default-activity-widget-instance', $uuids, true ) ) {
46 $dashboard_layout[] = array(
47 'uuid' => 'default-activity-widget-instance',
48 'type' => 'core/activity',
49 'placement' => array(
50 'width' => 3,
51 'height' => 3,
52 'order' => 1,
53 ),
54 );
55 }
56
57 if ( ! in_array( 'default-quick-draft-widget-instance', $uuids, true ) ) {
58 $dashboard_layout[] = array(
59 'uuid' => 'default-quick-draft-widget-instance',
60 'type' => 'core/quick-draft',
61 'placement' => array(
62 'width' => 4,
63 'height' => 3,
64 'order' => 2,
65 ),
66 );
67 }
68
69 if ( ! in_array( 'default-site-health-widget-instance', $uuids, true ) ) {
70 $dashboard_layout[] = array(
71 'uuid' => 'default-site-health-widget-instance',
72 'type' => 'core/site-health',
73 'placement' => array(
74 'width' => 2,
75 'height' => 2,
76 'order' => 3,
77 ),
78 );
79 }
80
81 if ( ! in_array( 'default-preview-widget-instance', $uuids, true ) ) {
82 $dashboard_layout[] = array(
83 'uuid' => 'default-preview-widget-instance',
84 'type' => 'core/site-preview',
85 'placement' => array(
86 'width' => 2,
87 'height' => 3,
88 'order' => 4,
89 ),
90 );
91 }
92
93 return $dashboard_layout;
94 }
95
96 add_filter( 'gutenberg_dashboard_default_layout', 'gutenberg_seed_default_dashboard_layout', 10, 2 );
97