Cache Enabler – WordPress Cache - Version 1.5.1

Version Description

  • Fix getting settings file
Download this release

Release Info

Developer keycdn
Plugin Icon 128x128 Cache Enabler – WordPress Cache
Version 1.5.1
Comparing to
See all releases

Code changes from version 1.5.0 to 1.5.1

cache-enabler.php CHANGED
@@ -6,7 +6,7 @@ Description: Simple and fast WordPress caching plugin.
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
- Version: 1.5.0
10
  */
11
 
12
  /*
@@ -32,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
32
  }
33
 
34
  // constants
35
- define( 'CE_VERSION', '1.5.0' );
36
  define( 'CE_MIN_WP', '5.1' );
37
  define( 'CE_FILE', __FILE__ );
38
  define( 'CE_BASE', plugin_basename( __FILE__ ) );
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
+ Version: 1.5.1
10
  */
11
 
12
  /*
32
  }
33
 
34
  // constants
35
+ define( 'CE_VERSION', '1.5.1' );
36
  define( 'CE_MIN_WP', '5.1' );
37
  define( 'CE_FILE', __FILE__ );
38
  define( 'CE_BASE', plugin_basename( __FILE__ ) );
inc/cache_enabler_disk.class.php CHANGED
@@ -132,7 +132,7 @@ final class Cache_Enabler_Disk {
132
  * check if cached page expired
133
  *
134
  * @since 1.0.1
135
- * @change 1.5.0
136
  *
137
  * @return boolean true if cached page expired, false otherwise
138
  */
@@ -145,7 +145,7 @@ final class Cache_Enabler_Disk {
145
  }
146
 
147
  $now = time();
148
- $expires_seconds = HOUR_IN_SECONDS * Cache_Enabler_Engine::$settings['cache_expiry_time'];
149
 
150
  // check if cached page has expired
151
  if ( ( filemtime( self::cache_file_html() ) + $expires_seconds ) <= $now ) {
@@ -631,30 +631,29 @@ final class Cache_Enabler_Disk {
631
  * get settings file
632
  *
633
  * @since 1.4.0
634
- * @change 1.5.0
635
  *
636
- * @param boolean $fallback whether or not to provide fallback settings file path
637
- * @return string $settings_file settings file path
 
638
  */
639
 
640
- private static function get_settings_file( $fallback = false ) {
641
 
642
- // single site not in subdirectory, any site of subdomain network, or main site of subdirectory network (fallback)
643
  $blog_path = '';
644
 
645
- // get URL path from home or request URL
646
- if ( ! $fallback ) {
647
  if ( function_exists( 'home_url' ) ) {
648
  $url_path = parse_url( home_url( '/' ), PHP_URL_PATH ); // trailing slash required
649
  } else {
650
  $url_path = $_SERVER['REQUEST_URI'];
651
  }
652
 
653
- // get subdirectory network blog path or subdirectory installation path
654
  $url_path_pieces = explode( '/', $url_path, 3 );
655
  $blog_path = $url_path_pieces[1];
656
 
657
- // subdirectory network or installation
658
  if ( ! empty( $blog_path ) ) {
659
  $blog_path = '.' . $blog_path;
660
  }
@@ -675,7 +674,7 @@ final class Cache_Enabler_Disk {
675
  * get settings from settings file
676
  *
677
  * @since 1.5.0
678
- * @change 1.5.0
679
  *
680
  * @return array $settings current settings from settings file
681
  */
@@ -684,20 +683,24 @@ final class Cache_Enabler_Disk {
684
 
685
  // get settings file
686
  $settings_file = self::get_settings_file();
 
687
 
688
  // include existing settings file
689
  if ( file_exists( $settings_file ) ) {
690
  $settings = include_once $settings_file;
691
- // if settings file does not exist try to get fallback settings file when network with subdirectory configuration
692
- } elseif ( is_multisite() && defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL ) {
693
- $fallback = true;
694
- $fallback_settings_file = self::get_settings_file( $fallback );
 
 
 
 
 
695
  // include existing fallback settings file
696
  if ( file_exists( $fallback_settings_file ) ) {
697
  $settings = include_once $fallback_settings_file;
698
  }
699
- } else {
700
- $settings = array();
701
  }
702
 
703
  return $settings;
132
  * check if cached page expired
133
  *
134
  * @since 1.0.1
135
+ * @change 1.5.1
136
  *
137
  * @return boolean true if cached page expired, false otherwise
138
  */
145
  }
146
 
147
  $now = time();
148
+ $expires_seconds = 60 * 60 * Cache_Enabler_Engine::$settings['cache_expiry_time'];
149
 
150
  // check if cached page has expired
151
  if ( ( filemtime( self::cache_file_html() ) + $expires_seconds ) <= $now ) {
631
  * get settings file
632
  *
633
  * @since 1.4.0
634
+ * @change 1.5.1
635
  *
636
+ * @param boolean $fallback_for_sub_install return fallback settings file path for subdirectory installations
637
+ * @param boolean $fallback_for_sub_network return fallback settings file path for subdirectory networks
638
+ * @return string $settings_file settings file path
639
  */
640
 
641
+ private static function get_settings_file( $fallback_for_sub_install = false, $fallback_for_sub_network = false ) {
642
 
643
+ // single site not in a subdirectory, any site of subdomain network, or main site of subdirectory network (fallback)
644
  $blog_path = '';
645
 
646
+ // subdirectory network or subdirectory installation (fallback)
647
+ if ( $fallback_for_sub_install || is_multisite() && defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL && ! $fallback_for_sub_network ) {
648
  if ( function_exists( 'home_url' ) ) {
649
  $url_path = parse_url( home_url( '/' ), PHP_URL_PATH ); // trailing slash required
650
  } else {
651
  $url_path = $_SERVER['REQUEST_URI'];
652
  }
653
 
 
654
  $url_path_pieces = explode( '/', $url_path, 3 );
655
  $blog_path = $url_path_pieces[1];
656
 
 
657
  if ( ! empty( $blog_path ) ) {
658
  $blog_path = '.' . $blog_path;
659
  }
674
  * get settings from settings file
675
  *
676
  * @since 1.5.0
677
+ * @change 1.5.1
678
  *
679
  * @return array $settings current settings from settings file
680
  */
683
 
684
  // get settings file
685
  $settings_file = self::get_settings_file();
686
+ $settings = array();
687
 
688
  // include existing settings file
689
  if ( file_exists( $settings_file ) ) {
690
  $settings = include_once $settings_file;
691
+ // if settings file does not exist try to get fallback settings file
692
+ } else {
693
+ if ( is_multisite() && defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL ) {
694
+ $fallback_for_sub_network = true;
695
+ $fallback_settings_file = self::get_settings_file( $fallback_for_sub_network );
696
+ } else {
697
+ $fallback_for_sub_install = true;
698
+ $fallback_settings_file = self::get_settings_file( $fallback_for_sub_install );
699
+ }
700
  // include existing fallback settings file
701
  if ( file_exists( $fallback_settings_file ) ) {
702
  $settings = include_once $fallback_settings_file;
703
  }
 
 
704
  }
705
 
706
  return $settings;
readme.txt CHANGED
@@ -80,6 +80,10 @@ When combined with Optimus, the WordPress Cache Enabler allows you to easily del
80
 
81
  == Changelog ==
82
 
 
 
 
 
83
  = 1.5.0 =
84
  * Update settings file type to PHP instead of JSON (#147)
85
  * Update settings file(s) storage location (#147)
80
 
81
  == Changelog ==
82
 
83
+ = 1.5.1 =
84
+
85
+ * Fix getting settings file
86
+
87
  = 1.5.0 =
88
  * Update settings file type to PHP instead of JSON (#147)
89
  * Update settings file(s) storage location (#147)