-
Notifications
You must be signed in to change notification settings - Fork 869
Forms: Load wp-build dashboard independently of Gutenberg plugin #47035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: patch | ||
| Type: fixed | ||
|
|
||
| Load the wp-build dashboard independently of the Gutenberg plugin. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @use "sass:meta"; | ||
| @include meta.load-css("@wordpress/dataviews/build-style/style.css"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,16 +21,25 @@ | |
| * Handles the Jetpack Forms dashboard. | ||
| */ | ||
| class Dashboard { | ||
|
|
||
| /** | ||
| * Load wp-build generated files if available. | ||
| * This is for the new DataViews-based responses list. | ||
| */ | ||
| public static function load_wp_build() { | ||
| if ( self::get_admin_query_page() === self::FORMS_WPBUILD_ADMIN_SLUG ) { | ||
| $wp_build_index = dirname( __DIR__, 2 ) . '/build/build.php'; | ||
|
|
||
| if ( file_exists( $wp_build_index ) ) { | ||
| require_once $wp_build_index; | ||
|
|
||
| // Re-add core's registration only when Gutenberg isn't providing it | ||
| if ( ! defined( 'IS_GUTENBERG_PLUGIN' ) || ! IS_GUTENBERG_PLUGIN ) { | ||
| // `wp-build` currently removes `wp_default_script_modules` from `wp_default_scripts`. | ||
| // Re-add the core hook so script modules work in vanilla wp-admin (no Gutenberg plugin). | ||
| if ( function_exists( 'wp_default_script_modules' ) ) { | ||
| add_action( 'wp_default_scripts', 'wp_default_script_modules', 0 ); | ||
| } | ||
dhasilva marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+37
to
+41
|
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -65,17 +74,15 @@ public static function load_wp_build() { | |
| * Initialize the dashboard. | ||
| */ | ||
| public function init() { | ||
| add_action( 'admin_menu', array( $this, 'add_new_admin_submenu' ), self::MENU_PRIORITY ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this MENU_PRIORITY anymore for WP Build?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, we don't. |
||
|
|
||
| // Flag to enable the wp-build-based dashboard. | ||
| $is_wp_build_enabled = apply_filters( 'jetpack_forms_alpha', false ); | ||
|
|
||
| if ( $is_wp_build_enabled ) { | ||
| // Load wp-build generated files for the new DataViews-based UI. | ||
| self::load_wp_build(); | ||
| } | ||
|
|
||
| add_action( 'admin_menu', array( $this, 'add_new_admin_submenu' ), self::MENU_PRIORITY ); | ||
|
|
||
| if ( $is_wp_build_enabled ) { | ||
| add_action( 'admin_menu', array( $this, 'add_forms_wpbuild_submenu' ), self::MENU_PRIORITY ); | ||
| add_action( 'admin_menu', array( $this, 'add_forms_wpbuild_submenu' ) ); | ||
| } | ||
|
|
||
| add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds weird to me why are we doing this in wp-build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a simple test repo:
https://github.com/dhasilva/minimal-wp-build-test
This fix is applied there, but commented.