Skip to content
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

Use get_asset_info to get dependencies and version of script file for wp_enqueue_script function #608

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/Classifai/Blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function blocks_styles() {
'recommended-content-block-style',
CLASSIFAI_PLUGIN_URL . 'dist/recommended-content-block-frontend.css',
[],
CLASSIFAI_PLUGIN_VERSION
get_asset_info( 'recommended-content-block-frontend', 'version' )
);

wp_enqueue_script(
Expand Down
8 changes: 5 additions & 3 deletions includes/Classifai/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,24 @@ public function add_privacy_policy_content() {

/**
* Enqueue the admin scripts.
*
* @since 2.4.0 Use get_asset_info to get the asset version and dependencies.
*/
public function enqueue_admin_assets() {

wp_enqueue_style(
'classifai-admin-style',
CLASSIFAI_PLUGIN_URL . 'dist/admin.css',
array(),
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'admin', 'version' ),
'all'
);

wp_enqueue_script(
'classifai-admin-script',
CLASSIFAI_PLUGIN_URL . 'dist/admin.js',
[],
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'admin', 'dependencies' ),
get_asset_info( 'admin', 'version' ),
true
);

Expand Down
4 changes: 3 additions & 1 deletion includes/Classifai/Providers/Azure/TextToSpeech.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public function __construct( $service ) {

/**
* Enqueue the editor scripts.
*
* @since 2.4.0 Use get_asset_info to get the asset version and dependencies.
*/
public function enqueue_editor_assets() {
$post = get_post();
Expand All @@ -103,7 +105,7 @@ public function enqueue_editor_assets() {
'classifai-gutenberg-plugin',
CLASSIFAI_PLUGIN_URL . 'dist/gutenberg-plugin.js',
array_merge( get_asset_info( 'gutenberg-plugin', 'dependencies' ), array( 'lodash' ) ),
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'gutenberg-plugin', 'version' ),
true
);

Expand Down
8 changes: 4 additions & 4 deletions includes/Classifai/Providers/OpenAI/ChatGPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function enqueue_editor_assets() {
'classifai-content-resizing-plugin-css',
CLASSIFAI_PLUGIN_URL . 'dist/content-resizing-plugin.css',
[],
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'content-resizing-plugin', 'version' ),
'all'
);
}
Expand Down Expand Up @@ -245,7 +245,7 @@ public function enqueue_admin_assets( $hook_suffix = '' ) {
'classifai-generate-title-classic-css',
CLASSIFAI_PLUGIN_URL . 'dist/generate-title-classic.css',
[],
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'generate-title-classic', 'version' ),
'all'
);

Expand Down Expand Up @@ -275,7 +275,7 @@ public function enqueue_admin_assets( $hook_suffix = '' ) {
'classifai-generate-title-classic-css',
CLASSIFAI_PLUGIN_URL . 'dist/generate-title-classic.css',
[],
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'generate-title-classic', 'version' ),
'all'
);

Expand Down Expand Up @@ -308,7 +308,7 @@ public function enqueue_admin_assets( $hook_suffix = '' ) {
'classifai-language-processing-style',
CLASSIFAI_PLUGIN_URL . 'dist/language-processing.css',
[],
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'language-processing', 'version' ),
'all'
);
}
Expand Down
8 changes: 5 additions & 3 deletions includes/Classifai/Providers/OpenAI/DallE.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public function register_generate_media_page() {
/**
* Enqueue the admin scripts.
*
* @since 2.4.0 Use get_asset_info to get the asset version and dependencies.
*
* @param string $hook_suffix The current admin page.
*/
public function enqueue_admin_scripts( $hook_suffix = '' ) {
Expand All @@ -100,14 +102,14 @@ public function enqueue_admin_scripts( $hook_suffix = '' ) {
'classifai-image-processing-style',
CLASSIFAI_PLUGIN_URL . 'dist/media-modal.css',
[],
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'media-modal', 'version' ),
'all'
);

wp_enqueue_script(
'classifai-generate-images',
CLASSIFAI_PLUGIN_URL . 'dist/media-modal.js',
[ 'jquery', 'wp-api', 'wp-media-utils', 'wp-url' ],
array_merge( get_asset_info( 'media-modal', 'dependencies' ), array( 'jquery', 'wp-api' ) ),
get_asset_info( 'media-modal', 'version' ),
true
);
Expand Down Expand Up @@ -158,7 +160,7 @@ public function enqueue_admin_scripts( $hook_suffix = '' ) {
wp_enqueue_script(
'classifai-generate-images-media-upload',
CLASSIFAI_PLUGIN_URL . 'dist/generate-image-media-upload.js',
[ 'jquery' ],
array_merge( get_asset_info( 'generate-image-media-upload', 'dependencies' ), array( 'jquery' ) ),
get_asset_info( 'classifai-generate-images-media-upload', 'version' ),
true
);
Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Providers/Watson/NLU.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function enqueue_admin_assets() {
'classifai-language-processing-style',
CLASSIFAI_PLUGIN_URL . 'dist/language-processing.css',
array(),
CLASSIFAI_PLUGIN_VERSION,
get_asset_info( 'language-processing', 'version' ),
'all'
);
}
Expand Down
4 changes: 3 additions & 1 deletion includes/Classifai/Services/ImageProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ public function init() {

/**
* Enqueue the script for the media modal.
*
* @since 2.4.0 Use get_asset_info to get the asset version and dependencies.
*/
public function enqueue_media_scripts() {
wp_enqueue_script(
'classifai-media-script',
CLASSIFAI_PLUGIN_URL . 'dist/media.js',
array( 'jquery', 'media-editor', 'lodash', 'wp-i18n' ),
array_merge( get_asset_info( 'media', 'dependencies' ), array( 'jquery', 'media-editor', 'lodash' ) ),
get_asset_info( 'media', 'version' ),
true
);
Expand Down
Loading