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
← All changes | lib/experimental/dashboard-widgets/dashboard-layout.php +13 -13 23.2.1 → trunk View file →
@@ -10,9 +10,9 @@
10 10 */
11 11
12 12 /**
13 13 * Preferences scope under which the dashboard layout is stored.
14 - * Mirrors the scope read by the JS surface.
14 + * Mirrors the scope read by the dashboard's JS layer.
15 15 */
16 16 const GUTENBERG_DASHBOARD_LAYOUT_SCOPE = 'core/dashboard';
17 17
18 18 /**
@@ -21,12 +21,12 @@
21 21 */
22 22 const GUTENBERG_DASHBOARD_LAYOUT_KEY = 'dashboardLayout';
23 23
24 24 /**
25 - * Identifier of the bundled dashboard surface, formatted as
26 - * `<plugin>_<page>` to match the underscore form produced by the
27 - * wp-build pipeline (mirrors the `{{PREFIX}}_{{PAGE_SLUG_UNDERSCORE}}`
28 - * pair used in generated page templates).
25 + * Identifier of the bundled dashboard, formatted as `<plugin>_<page>`
26 + * to match the underscore form produced by the wp-build pipeline
27 + * (mirrors the `{{PREFIX}}_{{PAGE_SLUG_UNDERSCORE}}` pair used in
28 + * generated page templates).
29 29 *
30 30 * Passed as context to `gutenberg_dashboard_default_layout` and used
31 31 * as the `{name}` segment of the REST default-layout route.
32 32 */
@@ -36,12 +36,14 @@
36 36 * Injects a registered default dashboard layout into the user's
37 37 * `persisted_preferences` read when the stored layout is empty.
38 38 *
39 39 * Hooks into `get_user_metadata` so the default propagates through
40 - * the same persistence layer the dashboard's JS surface reads from.
40 + * the same persistence layer the dashboard's JS layer reads from.
41 41 * The JS side stays oblivious: a default and a user-saved layout
42 42 * look identical at the preferences-store boundary.
43 43 *
44 + * @global wpdb $wpdb WordPress database abstraction object.
45 + *
44 46 * @param mixed $value The pre-fetched value, or null to let the
45 47 * meta API resolve normally.
46 48 * @param int $user_id User ID.
47 49 * @param string $meta_key Meta key being read.
@@ -64,11 +66,9 @@
64 66 if ( ! is_array( $base ) ) {
65 67 $base = array();
66 68 }
67 69
68 - $committed = isset( $base[ GUTENBERG_DASHBOARD_LAYOUT_SCOPE ][ GUTENBERG_DASHBOARD_LAYOUT_KEY ] )
69 - ? $base[ GUTENBERG_DASHBOARD_LAYOUT_SCOPE ][ GUTENBERG_DASHBOARD_LAYOUT_KEY ]
70 - : array();
70 + $committed = $base[ GUTENBERG_DASHBOARD_LAYOUT_SCOPE ][ GUTENBERG_DASHBOARD_LAYOUT_KEY ] ?? array();
71 71
72 72 if ( ! empty( $committed ) ) {
73 73 return $value;
74 74 }
@@ -80,9 +80,9 @@
80 80 * Each entry should match the dashboard's widget instance shape:
81 81 * `uuid`, `type`, optional `attributes`, optional `placement`.
82 82 *
83 83 * @param array $default_layout Default array of widget instances.
84 - * @param string $dashboard_name Identifier of the dashboard surface
84 + * @param string $dashboard_name Identifier of the dashboard
85 85 * receiving the default. Callbacks
86 86 * targeting a specific dashboard
87 87 * should switch on this value.
88 88 */
@@ -103,14 +103,14 @@
103 103
104 104 add_filter( 'get_user_metadata', 'gutenberg_inject_dashboard_default_layout', 99, 3 );
105 105
106 106 /**
107 - * Returns the default layout registered for a dashboard surface.
107 + * Returns the default layout registered for a dashboard.
108 108 *
109 109 * Resolves `gutenberg_dashboard_default_layout` for the supplied
110 110 * dashboard name, returning a fresh evaluation of the filter chain
111 - * each call. Used by the JS surface to back a "reset to default"
112 - * action without depending on the user-meta hydration path.
111 + * each call. Used by the dashboard's JS layer to back a "reset to
112 + * default" action without depending on the user-meta hydration path.
113 113 *
114 114 * @param WP_REST_Request $request REST request carrying the
115 115 * dashboard name segment.
116 116 * @return WP_REST_Response Response wrapping the default layout