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
| 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 |