PluginProbe
Gutenberg / 23.2.0
Gutenberg v23.2.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 12.6.0 All 403 releases
gutenberg / lib / experimental / dashboard-widgets / default-layout-seed.php
lib/experimental/dashboard-widgets
class-wp-rest-widget-modules-controller.php 7.6 KB 3 months ago class-wp-widget-type-registry.php 5.1 KB 3 months ago class-wp-widget-type.php 2.2 KB 3 months ago dashboard-layout.php 5.2 KB 3 months ago default-layout-seed.php 1.6 KB 3 months ago load.php 821 B 3 months ago widget-types.php 3.6 KB 3 months ago

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

50 lines 1.6 KB 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 `core/hello-world` instance to the default layout
15 * unless something earlier in the filter chain already added it.
16 *
17 * Only contributes to the bundled `gutenberg_dashboard` surface; 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 surface
23 * receiving 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-hello-world-widget-instance', $uuids, true ) ) {
34 return $dashboard_layout;
35 }
36
37 $dashboard_layout[] = array(
38 'uuid' => 'default-hello-world-widget-instance',
39 'type' => 'core/hello-world',
40 'placement' => array(
41 'width' => 2,
42 'height' => 1,
43 ),
44 );
45
46 return $dashboard_layout;
47 }
48
49 add_filter( 'gutenberg_dashboard_default_layout', 'gutenberg_seed_default_dashboard_layout', 10, 2 );
50