Skip to content

Commit 9379c55

Browse files
committed
use plugin version instead of filemtime() for resources (#326)
Resources of the same version should be the same, no matter if the files are touched or the plugin is re-installed. There are even scenarios where the modification time is not reliable. Reduce overhead of accessing the file system and simply add the plugin's version to scripts and styles.
1 parent ec45066 commit 9379c55

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cachify.php

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
define( 'CACHIFY_DIR', __DIR__ );
4242
define( 'CACHIFY_BASE', plugin_basename( __FILE__ ) );
4343
define( 'CACHIFY_CACHE_DIR', WP_CONTENT_DIR . '/cache/cachify' );
44+
define( 'CACHIFY_VERSION', '2.4.1' );
4445

4546

4647
/* Hooks */

inc/class-cachify.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,15 @@ public static function register_styles() {
340340
'cachify-dashboard',
341341
plugins_url( 'css/dashboard.min.css', CACHIFY_FILE ),
342342
array(),
343-
filemtime( plugin_dir_path( CACHIFY_FILE ) . 'css/dashboard.min.css' )
343+
CACHIFY_VERSION
344344
);
345345

346346
/* Register admin bar flush CSS */
347347
wp_register_style(
348348
'cachify-admin-bar-flush',
349349
plugins_url( 'css/admin-bar-flush.min.css', CACHIFY_FILE ),
350350
array(),
351-
filemtime( plugin_dir_path( CACHIFY_FILE ) . 'css/admin-bar-flush.min.css' )
351+
CACHIFY_VERSION
352352
);
353353
}
354354

@@ -363,7 +363,7 @@ public static function register_scripts() {
363363
'cachify-admin-bar-flush',
364364
plugins_url( 'js/admin-bar-flush.min.js', CACHIFY_FILE ),
365365
array(),
366-
filemtime( plugin_dir_path( CACHIFY_FILE ) . 'js/admin-bar-flush.min.js' ),
366+
CACHIFY_VERSION,
367367
true
368368
);
369369
}

0 commit comments

Comments
 (0)