Skip to content

Commit

Permalink
Fixed enqueue helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Mar 27, 2022
1 parent c1617d6 commit 063667d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
9 changes: 8 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,20 @@ gulp.task( 'build:php:frontend', function () {
.pipe( gulp.dest( 'dist/frontend/' ) );
} );

gulp.task( 'build:php:helpers', function () {
return gulp
.src( [ 'src/php/helpers/**/*.php' ] )
.pipe( gulp.dest( 'dist/helpers/' ) );
} );

gulp.task(
'build:php',
gulp.parallel(
'build:php:admin',
'build:php:base',
'build:php:exceptions',
'build:php:frontend'
'build:php:frontend',
'build:php:helpers'
)
);

Expand Down
10 changes: 6 additions & 4 deletions src/php/helpers/class-script-and-style-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class Script_And_Style_Helpers {
* @return void
*/
public static function register_script( $handle, $src, $deps = array() ) {
$file = plugin_dir_path( __FILE__ ) . $src;
wp_register_script( $handle, plugin_dir_url( __FILE__ ) . $src, $deps, file_exists( $file ) ? strval( filemtime( $file ) ) : false, true );
$path = plugin_dir_path( dirname( __FILE__ ) ) . $src;
$url = plugin_dir_url( dirname( __FILE__ ) ) . $src;
wp_register_script( $handle, $url, $deps, file_exists( $path ) ? strval( filemtime( $path ) ) : false, true );
}

/**
Expand All @@ -39,8 +40,9 @@ public static function register_script( $handle, $src, $deps = array() ) {
* @return void
*/
public static function register_style( $handle, $src, $deps = array() ) {
$file = plugin_dir_path( __FILE__ ) . $src;
wp_register_style( $handle, plugin_dir_url( __FILE__ ) . $src, $deps, file_exists( $file ) ? strval( filemtime( $file ) ) : false );
$path = plugin_dir_path( dirname( __FILE__ ) ) . $src;
$url = plugin_dir_url( dirname( __FILE__ ) ) . $src;
wp_register_style( $handle, $url, $deps, file_exists( $path ) ? strval( filemtime( $path ) ) : false );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/php/skaut-google-drive-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
require_once __DIR__ . '/exceptions/class-root-not-found-exception.php';
require_once __DIR__ . '/exceptions/class-unsupported-value-exception.php';

require_once __DIR__ . '/helpers/class-get-helpers.php';
require_once __DIR__ . '/helpers/class-script-and-style-helpers.php';

require_once __DIR__ . '/frontend/interface-pagination-helper-interface.php';
require_once __DIR__ . '/frontend/class-api-fields.php';
require_once __DIR__ . '/frontend/class-block.php';
Expand All @@ -84,9 +87,6 @@
require_once __DIR__ . '/admin/class-settings-pages.php';
require_once __DIR__ . '/admin/class-tinymce-plugin.php';

require_once __DIR__ . '/helpers/class-get-helpers.php';
require_once __DIR__ . '/helpers/class-script-and-style-helpers.php';

/**
* Initializes the plugin
*
Expand Down

0 comments on commit 063667d

Please sign in to comment.