Version Description
- Update advanced cache to prevent potential errors (#161)
- Update getting settings to create settings file if cache exists but settings file does not (#159)
- Fix getting settings file edge cases (#158)
- Fix cache expiry
Download this release
Release Info
| Developer | keycdn |
| Plugin | |
| Version | 1.5.5 |
| Comparing to | |
| See all releases | |
Code changes from version 1.5.4 to 1.5.5
- advanced-cache.php +11 -5
- cache-enabler.php +2 -2
- inc/cache_enabler.class.php +2 -2
- inc/cache_enabler_disk.class.php +113 -39
- inc/cache_enabler_engine.class.php +4 -4
- js/post.js +0 -47
- readme.txt +7 -0
advanced-cache.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Cache Enabler advanced cache
|
| 4 |
*
|
| 5 |
* @since 1.2.0
|
| 6 |
-
* @change 1.5.
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
|
@@ -11,9 +11,15 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
| 11 |
}
|
| 12 |
|
| 13 |
$ce_dir = ( ( defined( 'WP_PLUGIN_DIR' ) ) ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins' ) . '/cache-enabler';
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
require_once $
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
Cache_Enabler_Engine
|
| 19 |
-
Cache_Enabler_Engine::
|
|
|
|
|
|
| 3 |
* Cache Enabler advanced cache
|
| 4 |
*
|
| 5 |
* @since 1.2.0
|
| 6 |
+
* @change 1.5.5
|
| 7 |
*/
|
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 11 |
}
|
| 12 |
|
| 13 |
$ce_dir = ( ( defined( 'WP_PLUGIN_DIR' ) ) ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins' ) . '/cache-enabler';
|
| 14 |
+
$ce_engine_file = $ce_dir . '/inc/cache_enabler_engine.class.php';
|
| 15 |
+
$ce_disk_file = $ce_dir . '/inc/cache_enabler_disk.class.php';
|
| 16 |
|
| 17 |
+
if ( file_exists( $ce_engine_file ) && file_exists( $ce_disk_file ) ) {
|
| 18 |
+
require_once $ce_engine_file;
|
| 19 |
+
require_once $ce_disk_file;
|
| 20 |
+
}
|
| 21 |
|
| 22 |
+
if ( class_exists( 'Cache_Enabler_Engine' ) ) {
|
| 23 |
+
Cache_Enabler_Engine::start();
|
| 24 |
+
Cache_Enabler_Engine::deliver_cache();
|
| 25 |
+
}
|
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.
|
| 10 |
*/
|
| 11 |
|
| 12 |
/*
|
|
@@ -32,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
| 32 |
}
|
| 33 |
|
| 34 |
// constants
|
| 35 |
-
define( 'CE_VERSION', '1.5.
|
| 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.5
|
| 10 |
*/
|
| 11 |
|
| 12 |
/*
|
| 32 |
}
|
| 33 |
|
| 34 |
// constants
|
| 35 |
+
define( 'CE_VERSION', '1.5.5' );
|
| 36 |
define( 'CE_MIN_WP', '5.1' );
|
| 37 |
define( 'CE_FILE', __FILE__ );
|
| 38 |
define( 'CE_BASE', plugin_basename( __FILE__ ) );
|
inc/cache_enabler.class.php
CHANGED
|
@@ -532,8 +532,8 @@ final class Cache_Enabler {
|
|
| 532 |
* @since 1.5.0
|
| 533 |
* @change 1.5.0
|
| 534 |
*
|
| 535 |
-
* @param integer
|
| 536 |
-
* @return string
|
| 537 |
*/
|
| 538 |
|
| 539 |
private static function get_cache_size_transient_name( $blog_id = null ) {
|
| 532 |
* @since 1.5.0
|
| 533 |
* @change 1.5.0
|
| 534 |
*
|
| 535 |
+
* @param integer $blog_id blog ID
|
| 536 |
+
* @return string $transient_name transient name
|
| 537 |
*/
|
| 538 |
|
| 539 |
private static function get_cache_size_transient_name( $blog_id = null ) {
|
inc/cache_enabler_disk.class.php
CHANGED
|
@@ -629,42 +629,115 @@ final class Cache_Enabler_Disk {
|
|
| 629 |
* get settings file
|
| 630 |
*
|
| 631 |
* @since 1.4.0
|
| 632 |
-
* @change 1.5.
|
| 633 |
*
|
| 634 |
-
* @param boolean $
|
| 635 |
-
* @
|
| 636 |
-
* @return string $settings_file settings file path
|
| 637 |
*/
|
| 638 |
|
| 639 |
-
private static function get_settings_file( $
|
| 640 |
|
| 641 |
-
|
| 642 |
-
|
|
|
|
|
|
|
|
|
|
| 643 |
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 650 |
}
|
| 651 |
|
| 652 |
-
$
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
|
| 655 |
-
|
| 656 |
-
$blog_path = '.' . $blog_path;
|
| 657 |
}
|
| 658 |
}
|
| 659 |
|
| 660 |
-
|
| 661 |
-
$settings_file = sprintf(
|
| 662 |
-
'%s/%s.php',
|
| 663 |
-
self::$settings_dir,
|
| 664 |
-
parse_url( ( function_exists( 'home_url' ) ) ? home_url() : 'http://' . strtolower( $_SERVER['HTTP_HOST'] ), PHP_URL_HOST ) . $blog_path
|
| 665 |
-
);
|
| 666 |
-
|
| 667 |
-
return $settings_file;
|
| 668 |
}
|
| 669 |
|
| 670 |
|
|
@@ -672,35 +745,36 @@ final class Cache_Enabler_Disk {
|
|
| 672 |
* get settings from settings file
|
| 673 |
*
|
| 674 |
* @since 1.5.0
|
| 675 |
-
* @change 1.5.
|
| 676 |
*
|
| 677 |
* @return array $settings current settings from settings file
|
| 678 |
*/
|
| 679 |
|
| 680 |
public static function get_settings() {
|
| 681 |
|
|
|
|
|
|
|
| 682 |
// get settings file
|
| 683 |
$settings_file = self::get_settings_file();
|
| 684 |
-
$settings = array();
|
| 685 |
|
| 686 |
-
// include
|
| 687 |
-
if (
|
| 688 |
$settings = include_once $settings_file;
|
| 689 |
-
//
|
| 690 |
} else {
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
$fallback_for_sub_install = true;
|
| 696 |
-
$fallback_settings_file = self::get_settings_file( $fallback_for_sub_install );
|
| 697 |
-
}
|
| 698 |
-
// include existing fallback settings file
|
| 699 |
-
if ( file_exists( $fallback_settings_file ) ) {
|
| 700 |
$settings = include_once $fallback_settings_file;
|
| 701 |
}
|
| 702 |
}
|
| 703 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 704 |
return $settings;
|
| 705 |
}
|
| 706 |
|
| 629 |
* get settings file
|
| 630 |
*
|
| 631 |
* @since 1.4.0
|
| 632 |
+
* @change 1.5.5
|
| 633 |
*
|
| 634 |
+
* @param boolean $fallback whether or not fallback settings file should be returned
|
| 635 |
+
* @return string $settings_file file path to settings file
|
|
|
|
| 636 |
*/
|
| 637 |
|
| 638 |
+
private static function get_settings_file( $fallback = false ) {
|
| 639 |
|
| 640 |
+
$settings_file = sprintf(
|
| 641 |
+
'%s/%s',
|
| 642 |
+
self::$settings_dir,
|
| 643 |
+
self::get_settings_file_name( $fallback )
|
| 644 |
+
);
|
| 645 |
|
| 646 |
+
return $settings_file;
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
/**
|
| 651 |
+
* get settings file name
|
| 652 |
+
*
|
| 653 |
+
* @since 1.5.5
|
| 654 |
+
* @change 1.5.5
|
| 655 |
+
*
|
| 656 |
+
* @param boolean $fallback whether or not fallback settings file name should be returned
|
| 657 |
+
* @param boolean $skip_blog_path whether or not blog path should be included in settings file name
|
| 658 |
+
* @return string $settings_file_name file name for settings file
|
| 659 |
+
*/
|
| 660 |
+
|
| 661 |
+
private static function get_settings_file_name( $fallback = false, $skip_blog_path = false ) {
|
| 662 |
+
|
| 663 |
+
$settings_file_name = '';
|
| 664 |
+
|
| 665 |
+
// if creating or deleting settings file
|
| 666 |
+
if ( function_exists( 'home_url' ) ) {
|
| 667 |
+
$settings_file_name = parse_url( home_url(), PHP_URL_HOST );
|
| 668 |
+
|
| 669 |
+
// subdirectory network
|
| 670 |
+
if ( is_multisite() && defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL ) {
|
| 671 |
+
$url_path = parse_url( home_url(), PHP_URL_PATH );
|
| 672 |
+
$url_path = rtrim( $url_path, '/' ); // remove trailing slash if there happens to be one
|
| 673 |
+
$url_path_pieces = explode( '/', $url_path );
|
| 674 |
+
$blog_path = ( ! empty( end( $url_path_pieces ) ) ) ? end( $url_path_pieces ) : ''; // get last piece in case installation is in a subdirectory
|
| 675 |
+
$settings_file_name .= ( ! empty( $blog_path ) ) ? '.' . $blog_path : '';
|
| 676 |
}
|
| 677 |
|
| 678 |
+
$settings_file_name .= '.php';
|
| 679 |
+
// if getting settings from settings file
|
| 680 |
+
} elseif ( is_dir( self::$settings_dir ) ) {
|
| 681 |
+
if ( $fallback ) {
|
| 682 |
+
$settings_files = self::get_dir_objects( self::$settings_dir );
|
| 683 |
+
$settings_file_regex = '/\.php$/';
|
| 684 |
+
|
| 685 |
+
if ( is_multisite() ) {
|
| 686 |
+
$settings_file_regex = '/^' . parse_url( 'http://' . strtolower( $_SERVER['HTTP_HOST'] ), PHP_URL_HOST );
|
| 687 |
+
$settings_file_regex = str_replace( '.', '\.', $settings_file_regex );
|
| 688 |
+
|
| 689 |
+
// subdirectory network
|
| 690 |
+
if ( defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL && ! $skip_blog_path ) {
|
| 691 |
+
$url_path = $_SERVER['REQUEST_URI'];
|
| 692 |
+
$url_path = trim( $url_path, '/'); // remove leading and trailing slash(es)
|
| 693 |
+
|
| 694 |
+
if ( ! empty( $url_path ) ) {
|
| 695 |
+
$url_path_regex = str_replace( '/', '|', $url_path );
|
| 696 |
+
$url_path_regex = '\.(' . $url_path_regex . ')';
|
| 697 |
+
$settings_file_regex .= $url_path_regex;
|
| 698 |
+
}
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
$settings_file_regex .= '\.php$/';
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
$filtered_settings_files = preg_grep( $settings_file_regex, $settings_files );
|
| 705 |
+
|
| 706 |
+
if ( ! empty( $filtered_settings_files ) ) {
|
| 707 |
+
$settings_file_name = current( $filtered_settings_files );
|
| 708 |
+
} elseif ( is_multisite() && defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL && ! $skip_blog_path ) {
|
| 709 |
+
$fallback = true;
|
| 710 |
+
$skip_blog_path = true;
|
| 711 |
+
$settings_file_name = self::get_settings_file_name( $fallback, $skip_blog_path );
|
| 712 |
+
}
|
| 713 |
+
} else {
|
| 714 |
+
$settings_file_name = parse_url( 'http://' . strtolower( $_SERVER['HTTP_HOST'] ), PHP_URL_HOST );
|
| 715 |
+
|
| 716 |
+
// subdirectory network
|
| 717 |
+
if ( is_multisite() && defined( 'SUBDOMAIN_INSTALL' ) && ! SUBDOMAIN_INSTALL && ! $skip_blog_path ) {
|
| 718 |
+
$url_path = $_SERVER['REQUEST_URI'];
|
| 719 |
+
$url_path_pieces = explode( '/', $url_path, 3 );
|
| 720 |
+
$blog_path = $url_path_pieces[1];
|
| 721 |
+
|
| 722 |
+
if ( ! empty( $blog_path ) ) {
|
| 723 |
+
$settings_file_name .= '.' . $blog_path;
|
| 724 |
+
}
|
| 725 |
+
|
| 726 |
+
$settings_file_name .= '.php';
|
| 727 |
+
|
| 728 |
+
// check if main site
|
| 729 |
+
if ( ! is_file( self::$settings_dir . '/' . $settings_file_name ) ) {
|
| 730 |
+
$fallback = false;
|
| 731 |
+
$skip_blog_path = true;
|
| 732 |
+
$settings_file_name = self::get_settings_file_name( $fallback, $skip_blog_path );
|
| 733 |
+
}
|
| 734 |
+
}
|
| 735 |
|
| 736 |
+
$settings_file_name .= ( strpos( $settings_file_name, '.php' ) === false ) ? '.php' : '';
|
|
|
|
| 737 |
}
|
| 738 |
}
|
| 739 |
|
| 740 |
+
return $settings_file_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 741 |
}
|
| 742 |
|
| 743 |
|
| 745 |
* get settings from settings file
|
| 746 |
*
|
| 747 |
* @since 1.5.0
|
| 748 |
+
* @change 1.5.5
|
| 749 |
*
|
| 750 |
* @return array $settings current settings from settings file
|
| 751 |
*/
|
| 752 |
|
| 753 |
public static function get_settings() {
|
| 754 |
|
| 755 |
+
$settings = array();
|
| 756 |
+
|
| 757 |
// get settings file
|
| 758 |
$settings_file = self::get_settings_file();
|
|
|
|
| 759 |
|
| 760 |
+
// include settings file if it exists
|
| 761 |
+
if ( is_file( $settings_file ) ) {
|
| 762 |
$settings = include_once $settings_file;
|
| 763 |
+
// try to get fallback settings file otherwise
|
| 764 |
} else {
|
| 765 |
+
$fallback = true;
|
| 766 |
+
$fallback_settings_file = self::get_settings_file( $fallback );
|
| 767 |
+
|
| 768 |
+
if ( is_file( $fallback_settings_file ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
$settings = include_once $fallback_settings_file;
|
| 770 |
}
|
| 771 |
}
|
| 772 |
|
| 773 |
+
// create settings file if cache exists but settings file does not
|
| 774 |
+
if ( empty( $settings ) && class_exists( 'Cache_Enabler' ) ) {
|
| 775 |
+
self::create_settings_file( Cache_Enabler::get_settings() );
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
return $settings;
|
| 779 |
}
|
| 780 |
|
inc/cache_enabler_engine.class.php
CHANGED
|
@@ -58,10 +58,10 @@ final class Cache_Enabler_Engine {
|
|
| 58 |
|
| 59 |
public function __construct() {
|
| 60 |
|
| 61 |
-
// get settings from disk
|
| 62 |
if ( Cache_Enabler_Disk::cache_exists() ) {
|
| 63 |
self::$settings = Cache_Enabler_Disk::get_settings();
|
| 64 |
-
// get settings from database
|
| 65 |
} elseif ( class_exists( 'Cache_Enabler' ) ) {
|
| 66 |
self::$settings = Cache_Enabler::get_settings();
|
| 67 |
// set deprecated settings
|
|
@@ -397,12 +397,12 @@ final class Cache_Enabler_Engine {
|
|
| 397 |
* deliver cache
|
| 398 |
*
|
| 399 |
* @since 1.5.0
|
| 400 |
-
* @change 1.5.
|
| 401 |
*/
|
| 402 |
|
| 403 |
public static function deliver_cache() {
|
| 404 |
|
| 405 |
-
if ( ! self::$started || self::bypass_cache() ) {
|
| 406 |
return;
|
| 407 |
}
|
| 408 |
|
| 58 |
|
| 59 |
public function __construct() {
|
| 60 |
|
| 61 |
+
// get settings from disk if cache exists
|
| 62 |
if ( Cache_Enabler_Disk::cache_exists() ) {
|
| 63 |
self::$settings = Cache_Enabler_Disk::get_settings();
|
| 64 |
+
// get settings from database otherwise
|
| 65 |
} elseif ( class_exists( 'Cache_Enabler' ) ) {
|
| 66 |
self::$settings = Cache_Enabler::get_settings();
|
| 67 |
// set deprecated settings
|
| 397 |
* deliver cache
|
| 398 |
*
|
| 399 |
* @since 1.5.0
|
| 400 |
+
* @change 1.5.5
|
| 401 |
*/
|
| 402 |
|
| 403 |
public static function deliver_cache() {
|
| 404 |
|
| 405 |
+
if ( ! self::$started || Cache_Enabler_Disk::cache_expired() || self::bypass_cache() ) {
|
| 406 |
return;
|
| 407 |
}
|
| 408 |
|
js/post.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
jQuery( document ).ready(
|
| 2 |
-
function( $ ) {
|
| 3 |
-
|
| 4 |
-
$( '.edit-cache-action', '#misc-publishing-actions' ).click(
|
| 5 |
-
function( e ) {
|
| 6 |
-
|
| 7 |
-
$( this )
|
| 8 |
-
.next( ':hidden' )
|
| 9 |
-
.slideDown( 'fast' )
|
| 10 |
-
.end()
|
| 11 |
-
.hide();
|
| 12 |
-
|
| 13 |
-
e.preventDefault();
|
| 14 |
-
}
|
| 15 |
-
);
|
| 16 |
-
|
| 17 |
-
$( '.save-cache-action', '#misc-publishing-actions' ).click(
|
| 18 |
-
function( e ) {
|
| 19 |
-
|
| 20 |
-
$( this )
|
| 21 |
-
.parent()
|
| 22 |
-
.slideUp( 'fast' )
|
| 23 |
-
.prev( ':hidden' )
|
| 24 |
-
.show();
|
| 25 |
-
|
| 26 |
-
$( '#output-cache-action' ).text(
|
| 27 |
-
$( '#cache_action' ).children( 'option:selected' ).text()
|
| 28 |
-
);
|
| 29 |
-
|
| 30 |
-
e.preventDefault();
|
| 31 |
-
}
|
| 32 |
-
);
|
| 33 |
-
|
| 34 |
-
$( '.cancel-cache-action', '#misc-publishing-actions' ).click(
|
| 35 |
-
function( e ) {
|
| 36 |
-
|
| 37 |
-
$( this )
|
| 38 |
-
.parent()
|
| 39 |
-
.slideUp( 'fast' )
|
| 40 |
-
.prev( ':hidden' )
|
| 41 |
-
.show();
|
| 42 |
-
|
| 43 |
-
e.preventDefault();
|
| 44 |
-
}
|
| 45 |
-
);
|
| 46 |
-
}
|
| 47 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
|
@@ -80,6 +80,13 @@ When combined with Optimus, the WordPress Cache Enabler allows you to easily del
|
|
| 80 |
|
| 81 |
== Changelog ==
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
= 1.5.4 =
|
| 84 |
|
| 85 |
* Update default query string exclusion (#155)
|
| 80 |
|
| 81 |
== Changelog ==
|
| 82 |
|
| 83 |
+
= 1.5.5 =
|
| 84 |
+
|
| 85 |
+
* Update advanced cache to prevent potential errors (#161)
|
| 86 |
+
* Update getting settings to create settings file if cache exists but settings file does not (#159)
|
| 87 |
+
* Fix getting settings file edge cases (#158)
|
| 88 |
+
* Fix cache expiry
|
| 89 |
+
|
| 90 |
= 1.5.4 =
|
| 91 |
|
| 92 |
* Update default query string exclusion (#155)
|
