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

Move assets to the folder assets #272

Merged
merged 1 commit into from
Oct 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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '77ee83c4ea5024b59278');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'ba69da201e2be1442d0d');
File renamed without changes.
1 change: 1 addition & 0 deletions assets/admin/settings.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion build/admin/settings.js

This file was deleted.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
"uglify-js": "^3.17.4"
},
"scripts": {
"build": "wp-scripts build src/js/frontend/woocommerce-blocks.js --output-path=build/frontend",
"build": "wp-scripts build src/js/frontend/woocommerce-blocks.js --output-path=assets/frontend",
"build:assets": "npm run clean:assets && npm run build:js && npm run copy:images",
"build:js": "npm run uglify:woocommerce && npm run uglify:woocommerce-checkout && npm run uglify:edd && npm run uglify:edd-checkout && npm run uglify:cf7",
"clean:assets": "del assets",
"i18n:textdomain": "wpi18n addtextdomain",
"i18n:pot": "wp i18n make-pot ./ languages/gtm-kit.pot",
"change-version": "./bin/change-version.sh $npm_package_version",
"zip-package": "./bin/zip-package.sh",
"uglify:woocommerce": "mkdirp assets/js && uglifyjs src/js/woocommerce.js --compress --mangle --output assets/js/woocommerce.js",
"uglify:woocommerce-checkout": "mkdirp assets/js && uglifyjs src/js/woocommerce-checkout.js --compress --mangle --output assets/js/woocommerce-checkout.js",
"uglify:edd": "mkdirp assets/js && uglifyjs src/js/edd.js --compress --mangle --output assets/js/edd.js",
"uglify:edd-checkout": "mkdirp assets/js && uglifyjs src/js/edd-checkout.js --compress --mangle --output assets/js/edd-checkout.js",
"uglify:cf7": "mkdirp assets/js && uglifyjs src/js/contact-form-7.js --compress --mangle --output assets/js/contact-form-7.js",
"uglify:woocommerce": "mkdirp assets/integration && uglifyjs src/js/woocommerce.js --compress --mangle --output assets/integration/woocommerce.js",
"uglify:woocommerce-checkout": "mkdirp assets/integration && uglifyjs src/js/woocommerce-checkout.js --compress --mangle --output assets/integration/woocommerce-checkout.js",
"uglify:edd": "mkdirp assets/integration && uglifyjs src/js/edd.js --compress --mangle --output assets/integration/edd.js",
"uglify:edd-checkout": "mkdirp assets/integration && uglifyjs src/js/edd-checkout.js --compress --mangle --output assets/integration/edd-checkout.js",
"uglify:cf7": "mkdirp assets/integration && uglifyjs src/js/contact-form-7.js --compress --mangle --output assets/integration/contact-form-7.js",
"copy:images": "node ./bin/copy-images.js",
"format": "wp-scripts format",
"lint:css": "wp-scripts lint-style",
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/AbstractOptionsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ abstract public function enqueue_page_assets( string $hook ): void;
*/
protected function enqueue_assets( string $page_slug, string $script_handle, string $path = GTMKIT_PATH, string $url = GTMKIT_URL ) {

$deps_file = $path . 'build/admin/' . $script_handle . '.asset.php';
$deps_file = $path . 'assets/admin/' . $script_handle . '.asset.php';
$dependency = [];
$version = false;

Expand All @@ -168,9 +168,9 @@ protected function enqueue_assets( string $page_slug, string $script_handle, str
$version = $deps_file['version'];
}

\wp_enqueue_style( 'gtmkit-' . $script_handle . '-style', $url . 'build/admin/' . $script_handle . '.css', array( 'wp-components' ), $version );
\wp_enqueue_style( 'gtmkit-' . $script_handle . '-style', $url . 'assets/admin/' . $script_handle . '.css', array( 'wp-components' ), $version );

\wp_enqueue_script( 'gtmkit-' . $script_handle . '-script', $url . 'build/admin/' . $script_handle . '.js', $dependency, $version, true );
\wp_enqueue_script( 'gtmkit-' . $script_handle . '-script', $url . 'assets/admin/' . $script_handle . '.js', $dependency, $version, true );

$this->localize_script( $page_slug, $script_handle );
}
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/SetupWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,17 @@ public function enqueue_assets( string $hook ) {
return;
}

$deps_file = GTMKIT_PATH . 'build/admin/wizard.asset.php';
$deps_file = GTMKIT_PATH . 'assets/admin/wizard.asset.php';
$dependency = [];
if ( file_exists( $deps_file ) ) {
$deps_file = require $deps_file;
$dependency = $deps_file['dependencies'];
$version = $deps_file['version'];
}

wp_enqueue_style( 'gtmkit-wizard-style', GTMKIT_URL . 'build/admin/wizard.css', array( 'wp-components' ), $version );
wp_enqueue_style( 'gtmkit-wizard-style', GTMKIT_URL . 'assets/admin/wizard.css', array( 'wp-components' ), $version );

wp_enqueue_script( 'gtmkit-wizard-script', GTMKIT_URL . 'build/admin/wizard.js', $dependency, $version, true );
wp_enqueue_script( 'gtmkit-wizard-script', GTMKIT_URL . 'assets/admin/wizard.js', $dependency, $version, true );

wp_localize_script(
'gtmkit-wizard-script',
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function get_plugin_version(): string {
*/
public function enqueue_script( string $handle, string $script ): void {

$deps_file = GTMKIT_PATH . 'build/' . $script . '.asset.php';
$deps_file = GTMKIT_PATH . 'assets/' . $script . '.asset.php';

$dependency = [];
$version = false;
Expand All @@ -225,6 +225,6 @@ public function enqueue_script( string $handle, string $script ): void {
$version = $deps_file['version'];
}

\wp_enqueue_script( $handle, GTMKIT_URL . 'build/' . $script . '.js', $dependency, $version, true );
\wp_enqueue_script( $handle, GTMKIT_URL . 'assets/' . $script . '.js', $dependency, $version, true );
}
}
2 changes: 1 addition & 1 deletion src/Integration/ContactForm7.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function enqueue_scripts(): void {

wp_enqueue_script(
'gtmkit-cf7',
GTMKIT_URL . 'assets/js/contact-form-7.js',
GTMKIT_URL . 'assets/integration/contact-form-7.js',
[],
$this->util->get_plugin_version(),
true
Expand Down
4 changes: 2 additions & 2 deletions src/Integration/EasyDigitalDownloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function enqueue_scripts(): void {
if ( ! edd_is_checkout() ) {
wp_enqueue_script(
'gtmkit-edd',
GTMKIT_URL . 'assets/js/edd.js',
GTMKIT_URL . 'assets/integration/edd.js',
[ 'jquery' ],
$this->util->get_plugin_version(),
true
Expand All @@ -93,7 +93,7 @@ public function enqueue_scripts(): void {
if ( edd_is_checkout() ) {
wp_enqueue_script(
'gtmkit-edd-checkout',
GTMKIT_URL . 'assets/js/edd-checkout.js',
GTMKIT_URL . 'assets/integration/edd-checkout.js',
[ 'jquery' ],
$this->util->get_plugin_version(),
true
Expand Down
4 changes: 2 additions & 2 deletions src/Integration/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function enqueue_scripts(): void {

wp_enqueue_script(
'gtmkit-woocommerce',
GTMKIT_URL . 'assets/js/woocommerce.js',
GTMKIT_URL . 'assets/integration/woocommerce.js',
[],
$this->util->get_plugin_version(),
true
Expand All @@ -218,7 +218,7 @@ public function enqueue_scripts(): void {
} else {
wp_enqueue_script(
'gtmkit-woocommerce-checkout',
GTMKIT_URL . 'assets/js/woocommerce-checkout.js',
GTMKIT_URL . 'assets/integration/woocommerce-checkout.js',
[ 'gtmkit-woocommerce' ],
$this->util->get_plugin_version(),
true
Expand Down
Loading