Skip to content

Commit

Permalink
fix: use js deps from generated php assets file
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed May 24, 2024
1 parent 17d050a commit b4d18fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions includes/admin/feedzy-rss-feeds-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ public function enqueue_styles_admin() {
if ( ! wp_script_is( 'react-dom' ) ) {
wp_register_script( 'react-dom', 'https://unpkg.com/react-dom@18/umd/react-dom.production.min.js', array(), $this->version, true );
}
wp_enqueue_script( $this->plugin_name . '_action_popup', FEEDZY_ABSURL . 'js/build/action-popup.js', array( 'react', 'react-dom', 'wp-editor', 'wp-api', 'lodash' ), $this->version, true );

$asset_file = include FEEDZY_ABSPATH . '/js/build/action-popup.asset.php';
wp_enqueue_script( $this->plugin_name . '_action_popup', FEEDZY_ABSURL . 'js/build/action-popup.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api' ) ), $asset_file['version'], true );

wp_localize_script(
$this->plugin_name . '_action_popup',
Expand All @@ -206,8 +208,9 @@ public function enqueue_styles_admin() {

$this->register_survey();
}
if ( ! defined( 'TI_CYPRESS_TESTING' ) && ! defined( 'TI_TESTING' ) && ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type && feedzy_show_import_tour() ) ) {
wp_enqueue_script( $this->plugin_name . '_on_boarding', FEEDZY_ABSURL . 'js/build/import-onboarding.js', array( 'react', 'react-dom', 'wp-editor', 'wp-api', 'lodash' ), $this->version, true );
if ( ! defined( 'TI_CYPRESS_TESTING' ) && ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type && feedzy_show_import_tour() ) ) {
$asset_file = include FEEDZY_ABSPATH . '/js/build/import-onboarding.asset.php';
wp_enqueue_script( $this->plugin_name . '_on_boarding', FEEDZY_ABSURL . 'js/build/import-onboarding.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api' ) ), $asset_file['version'], true );
}

if ( ! in_array( $screen->base, $upsell_screens, true ) && strpos( $screen->id, 'feedzy' ) === false ) {
Expand All @@ -218,7 +221,8 @@ public function enqueue_styles_admin() {

$this->register_survey();

wp_enqueue_script( $this->plugin_name . '_feedback', FEEDZY_ABSURL . 'js/build/feedback.js', array( 'react', 'react-dom', 'wp-editor', 'wp-api', 'lodash' ), $this->version, true );
$asset_file = include FEEDZY_ABSPATH . '/js/build/feedback.asset.php';
wp_enqueue_script( $this->plugin_name . '_feedback', FEEDZY_ABSURL . 'js/build/feedback.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api', 'lodash' ) ), $asset_file['version'], true );
wp_enqueue_style( 'wp-block-editor' );

wp_localize_script(
Expand Down
4 changes: 3 additions & 1 deletion includes/gutenberg/feedzy-rss-feeds-gutenberg-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function feedzy_gutenberg_scripts() {
}

// Dependent WordPress core libraries.
$depends = array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-editor', 'wp-api', 'lodash', 'wp-hooks', 'jquery-ui-autocomplete' );
$asset_file = include FEEDZY_ABSPATH . '/js/build/block.asset.php';
$depends = array_merge( $asset_file['dependencies'], array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-editor', 'wp-api', 'lodash', 'wp-hooks', 'jquery-ui-autocomplete' ) );

// Remove "wp-editor" script for widget block.
if ( wp_script_is( 'wp-edit-widgets' ) && wp_use_widgets_block_editor() ) {
Expand All @@ -68,6 +69,7 @@ public function feedzy_gutenberg_scripts() {
}

// Enqueue the bundled block JS file

wp_enqueue_script( 'feedzy-gutenberg-block-js', FEEDZY_ABSURL . 'js/build/block.js', $depends, $version, true );

// Pass in REST URL
Expand Down

0 comments on commit b4d18fc

Please sign in to comment.