← All changes
|
lib/experimental/dashboard-widgets/default-layout-seed.php
+62
-15
23.2.1
→
trunk
View file →
| @@ -10,18 +10,18 @@ | ||
| 10 | 10 | * @package gutenberg |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Appends the bundled `core/hello-world` instance to the default layout | |
| 15 | - * unless something earlier in the filter chain already added it. | |
| 14 | + * Appends the bundled widget instances to the default layout unless an | |
| 15 | + * earlier callback in the filter chain already added them. | |
| 16 | 16 | * |
| 17 | - * Only contributes to the bundled `gutenberg_dashboard` surface; other | |
| 17 | + * Only contributes to the bundled `gutenberg_dashboard`; other | |
| 18 | 18 | * dashboards are left untouched. |
| 19 | 19 | * |
| 20 | 20 | * @param array $dashboard_layout Default layout produced by previous |
| 21 | 21 | * callbacks on `gutenberg_dashboard_default_layout`. |
| 22 | - * @param string $dashboard_name Identifier of the dashboard surface | |
| 23 | - * receiving the default. | |
| 22 | + * @param string $dashboard_name Identifier of the dashboard receiving | |
| 23 | + * the default. | |
| 24 | 24 | * @return array The layout extended with the bundled widget instance. |
| 25 | 25 | */ |
| 26 | 26 | function gutenberg_seed_default_dashboard_layout( $dashboard_layout, $dashboard_name = '' ) { |
| 27 | 27 | if ( 'gutenberg_dashboard' !== $dashboard_name ) { |
| @@ -29,20 +29,67 @@ | ||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $uuids = array_column( $dashboard_layout, 'uuid' ); |
| 32 | 32 | |
| 33 | - if ( in_array( 'default-hello-world-widget-instance', $uuids, true ) ) { | |
| 34 | - return $dashboard_layout; | |
| 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 | + ); | |
| 35 | 43 | } |
| 36 | 44 | |
| 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 | + 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 | + } | |
| 45 | 92 | |
| 46 | 93 | return $dashboard_layout; |
| 47 | 94 | } |
| 48 | 95 | |