Breeze – WordPress Cache Plugin - Version 1.2.4

Version Description

  • Add: Functionality to clear ALL cache via Command Line Interface (wp-cli).
    • Add: Functionality to clear Varnish cache via Command Line Interface (wp-cli).
    • Add: Functionality to clear Internal cache via Command Line Interface (wp-cli).
    • Add: While the file Permission is not correct, the warning message has been added.
    • Fix: Compatibility with Coming Soon Page, Maintenance Mode & Landing Pages by SeedProd.
    • Fix: improve the handling of warning undefine array key of delay JS script while enable debug mode.
Download this release

Release Info

Developer adeelkhan
Plugin Icon 128x128 Breeze – WordPress Cache Plugin
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

breeze.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Breeze
4
  * Description: Breeze is a WordPress cache plugin with extensive options to speed up your website. All the options including Varnish Cache are compatible with Cloudways hosting.
5
- * Version: 1.2.3
6
  * Text Domain: breeze
7
  * Domain Path: /languages
8
  * Author: Cloudways
@@ -37,7 +37,7 @@ if ( ! defined( 'BREEZE_PLUGIN_DIR' ) ) {
37
  define( 'BREEZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
38
  }
39
  if ( ! defined( 'BREEZE_VERSION' ) ) {
40
- define( 'BREEZE_VERSION', '1.2.3' );
41
  }
42
  if ( ! defined( 'BREEZE_SITEURL' ) ) {
43
  define( 'BREEZE_SITEURL', get_site_url() );
@@ -69,6 +69,8 @@ define( 'BREEZE_ROOT_DIR', str_replace( BREEZE_WP_CONTENT_NAME, '', WP_CONTENT_D
69
 
70
  // Compatibility checks
71
  require_once BREEZE_PLUGIN_DIR . 'inc/plugin-incompatibility/class-breeze-incompatibility-plugins.php';
 
 
72
 
73
  // Helper functions.
74
  require_once BREEZE_PLUGIN_DIR . 'inc/helpers.php';
2
  /**
3
  * Plugin Name: Breeze
4
  * Description: Breeze is a WordPress cache plugin with extensive options to speed up your website. All the options including Varnish Cache are compatible with Cloudways hosting.
5
+ * Version: 1.2.4
6
  * Text Domain: breeze
7
  * Domain Path: /languages
8
  * Author: Cloudways
37
  define( 'BREEZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
38
  }
39
  if ( ! defined( 'BREEZE_VERSION' ) ) {
40
+ define( 'BREEZE_VERSION', '1.2.4' );
41
  }
42
  if ( ! defined( 'BREEZE_SITEURL' ) ) {
43
  define( 'BREEZE_SITEURL', get_site_url() );
69
 
70
  // Compatibility checks
71
  require_once BREEZE_PLUGIN_DIR . 'inc/plugin-incompatibility/class-breeze-incompatibility-plugins.php';
72
+ // Check for if folder/files are writable.
73
+ require_once BREEZE_PLUGIN_DIR . 'inc/class-breeze-file-permissions.php';
74
 
75
  // Helper functions.
76
  require_once BREEZE_PLUGIN_DIR . 'inc/helpers.php';
inc/breeze-configuration.php CHANGED
@@ -41,6 +41,7 @@ class Breeze_Configuration {
41
  ) {
42
  $inherit_settings = ( 1 == $_REQUEST['inherit-settings'] ? '1' : '0' );
43
  update_option( 'breeze_inherit_settings', $inherit_settings );
 
44
 
45
  if ( ! isset( $_REQUEST['breeze_basic_action'], $_REQUEST['breeze_advanced_action'] ) ) {
46
  WP_Filesystem();
@@ -168,6 +169,7 @@ class Breeze_Configuration {
168
 
169
  WP_Filesystem();
170
  // Storage infomation to cache pages
 
171
  Breeze_ConfigCache::factory()->write_config_cache();
172
 
173
  //delete cache after settings
41
  ) {
42
  $inherit_settings = ( 1 == $_REQUEST['inherit-settings'] ? '1' : '0' );
43
  update_option( 'breeze_inherit_settings', $inherit_settings );
44
+ Breeze_ConfigCache::factory()->write();
45
 
46
  if ( ! isset( $_REQUEST['breeze_basic_action'], $_REQUEST['breeze_advanced_action'] ) ) {
47
  WP_Filesystem();
169
 
170
  WP_Filesystem();
171
  // Storage infomation to cache pages
172
+ Breeze_ConfigCache::factory()->write();
173
  Breeze_ConfigCache::factory()->write_config_cache();
174
 
175
  //delete cache after settings
inc/cache/config-cache.php CHANGED
@@ -30,6 +30,10 @@ class Breeze_ConfigCache {
30
  */
31
  public function write() {
32
  global $wp_filesystem;
 
 
 
 
33
 
34
  $file = trailingslashit( WP_CONTENT_DIR ) . '/advanced-cache.php';
35
 
@@ -49,14 +53,14 @@ class Breeze_ConfigCache {
49
  switch_to_blog( $blog_id );
50
  $config = breeze_get_option( 'basic_settings' );
51
  if ( ! empty( $config['breeze-active'] ) ) {
52
- $inherit_option = get_option( 'breeze_inherit_settings' );
53
-
54
- if ( '0' === $inherit_option ) {
55
  // Site uses own (custom) configuration.
56
  $cache_configs["breeze-config-{$blog_id}"] = preg_replace( '(^https?://)', '', site_url() );
57
  } else {
58
  // Site uses global configuration.
59
- $cache_configs['breeze-config'][] = preg_replace( '(^https?://)', '', site_url() );
60
  }
61
  }
62
  restore_current_blog();
@@ -85,7 +89,7 @@ class Breeze_ConfigCache {
85
  if ( 1 === count( $cache_configs ) ) {
86
  // Only 1 config file available.
87
  $blog_file = trailingslashit( WP_CONTENT_DIR ) . 'breeze-config/breeze-config.php';
88
- $file_string .= "\n\$config = '$blog_file';";
89
  } else {
90
  // Multiple configuration files, load appropriate one by comparing URLs.
91
  $file_string .= "\n\r" . '$domain = strtolower( stripslashes( $_SERVER[\'HTTP_HOST\'] ) );' .
@@ -113,15 +117,29 @@ class Breeze_ConfigCache {
113
  $urls = array( $urls );
114
  }
115
 
116
- if ( empty( $urls ) || empty( $urls[0] ) ) {
117
  continue;
118
  }
119
 
120
- foreach ( $urls as $site_url ) {
121
  $file_string .= "\n\tcase '$site_url':";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  }
123
- $file_string .= "\n\t\t\$config = '$blog_file';" .
124
- "\n\t\tbreak;";
125
  }
126
 
127
  $file_string .= "\n\t}";
@@ -133,8 +151,10 @@ class Breeze_ConfigCache {
133
  $file_string .= "\n" . '}';
134
  }
135
 
136
- $file_string .= "\nif ( empty( \$config ) || ! @file_exists( \$config ) ) { return; }" .
137
- "\n\$GLOBALS['breeze_config'] = include \$config;" .
 
 
138
  "\n" . 'if ( empty( $GLOBALS[\'breeze_config\'] ) || empty( $GLOBALS[\'breeze_config\'][\'cache_options\'][\'breeze-active\'] ) ) { return; }' .
139
  "\n" . 'if ( @file_exists( \'' . BREEZE_PLUGIN_DIR . 'inc/cache/execute-cache.php\' ) ) {' .
140
  "\n" . ' include_once \'' . BREEZE_PLUGIN_DIR . 'inc/cache/execute-cache.php\';' .
30
  */
31
  public function write() {
32
  global $wp_filesystem;
33
+ if ( empty( $wp_filesystem ) ) {
34
+ require_once( ABSPATH . '/wp-admin/includes/file.php' );
35
+ WP_Filesystem();
36
+ }
37
 
38
  $file = trailingslashit( WP_CONTENT_DIR ) . '/advanced-cache.php';
39
 
53
  switch_to_blog( $blog_id );
54
  $config = breeze_get_option( 'basic_settings' );
55
  if ( ! empty( $config['breeze-active'] ) ) {
56
+ $inherit_option = get_blog_option( $blog_id, 'breeze_inherit_settings', '0' );
57
+ $inherit_option = filter_var( $inherit_option, FILTER_VALIDATE_BOOLEAN );
58
+ if ( false === $inherit_option ) {
59
  // Site uses own (custom) configuration.
60
  $cache_configs["breeze-config-{$blog_id}"] = preg_replace( '(^https?://)', '', site_url() );
61
  } else {
62
  // Site uses global configuration.
63
+ $cache_configs['breeze-config'][ $blog_id ] = preg_replace( '(^https?://)', '', site_url() );
64
  }
65
  }
66
  restore_current_blog();
89
  if ( 1 === count( $cache_configs ) ) {
90
  // Only 1 config file available.
91
  $blog_file = trailingslashit( WP_CONTENT_DIR ) . 'breeze-config/breeze-config.php';
92
+ $file_string .= "\n\$config['config_path'] = '$blog_file';";
93
  } else {
94
  // Multiple configuration files, load appropriate one by comparing URLs.
95
  $file_string .= "\n\r" . '$domain = strtolower( stripslashes( $_SERVER[\'HTTP_HOST\'] ) );' .
117
  $urls = array( $urls );
118
  }
119
 
120
+ if ( empty( $urls ) ) {
121
  continue;
122
  }
123
 
124
+ foreach ( $urls as $the_blog_id => $site_url ) {
125
  $file_string .= "\n\tcase '$site_url':";
126
+
127
+ if ( is_multisite() ) {
128
+ if ( empty( $the_blog_id ) ) {
129
+ $e = explode( '-', $filename );
130
+ if ( isset( $e[2] ) ) {
131
+ $the_blog_id = (int) $e[2];
132
+ }
133
+
134
+ }
135
+
136
+ $define_blog_identity = "\n\t\t\$config['blog_id']={$the_blog_id};";
137
+ $file_string .= "\n\t\t\$config['config_path'] = '$blog_file';" . $define_blog_identity . "\n\t\tbreak;";
138
+ } else {
139
+ $file_string .= "\n\t\t\$config['config_path'] = '$blog_file';" . "\n\t\tbreak;";
140
+ }
141
+
142
  }
 
 
143
  }
144
 
145
  $file_string .= "\n\t}";
151
  $file_string .= "\n" . '}';
152
  }
153
 
154
+ $file_string .= "\nif ( empty( \$config ) || ! isset( \$config['config_path'] ) || ! @file_exists( \$config['config_path'] ) ) { return; }" .
155
+ "\n\$breeze_temp_config = include \$config['config_path'];" .
156
+ "\nif ( isset( \$config['blog_id'] ) ) { \$breeze_temp_config['blog_id'] = \$config['blog_id']; }" .
157
+ "\n\$GLOBALS['breeze_config'] = \$breeze_temp_config; unset( \$breeze_temp_config );" .
158
  "\n" . 'if ( empty( $GLOBALS[\'breeze_config\'] ) || empty( $GLOBALS[\'breeze_config\'][\'cache_options\'][\'breeze-active\'] ) ) { return; }' .
159
  "\n" . 'if ( @file_exists( \'' . BREEZE_PLUGIN_DIR . 'inc/cache/execute-cache.php\' ) ) {' .
160
  "\n" . ' include_once \'' . BREEZE_PLUGIN_DIR . 'inc/cache/execute-cache.php\';' .
inc/cache/purge-cache.php CHANGED
@@ -169,7 +169,8 @@ class Breeze_PurgeCache {
169
  }
170
 
171
  }
172
- $settings = breeze_get_option( 'basic_settings' );
173
- if ( isset( $settings['breeze-active'] ) && $settings['breeze-active'] ) {
 
174
  Breeze_PurgeCache::factory();
175
  }
169
  }
170
 
171
  }
172
+ $breez_basic_settings = breeze_get_option( 'basic_settings' );
173
+
174
+ if ( isset( $breez_basic_settings['breeze-active'] ) && $breez_basic_settings['breeze-active'] ) {
175
  Breeze_PurgeCache::factory();
176
  }
inc/class-breeze-file-permissions.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Breeze_File_Permissions {
4
+ /**
5
+ * @var null Hold the class instance.
6
+ */
7
+ private static $instance = null;
8
+
9
+ /**
10
+ * @var array All the errors found.
11
+ */
12
+ private static $errors = array();
13
+
14
+ function __construct() {
15
+
16
+ add_action( 'admin_notices', array( &$this, 'display_the_errors' ) );
17
+ add_action( 'network_admin_notices', array( &$this, 'display_the_errors' ) );
18
+ }
19
+
20
+ // The object is created from within the class itself
21
+ // only if the class has no instance.
22
+ public static function get_instance() {
23
+ if ( null === self::$instance ) {
24
+ self::$instance = new Breeze_File_Permissions();
25
+ }
26
+
27
+ return self::$instance;
28
+ }
29
+
30
+ public static function append_permission_error( $message = '' ) {
31
+ if ( ! empty( $message ) ) {
32
+ self::$errors[] = $message;
33
+ }
34
+
35
+ }
36
+
37
+ public function check_specific_files_folders() {
38
+
39
+ $cache_specific_folders = breeze_all_user_folders();
40
+ $assets_folders = array(
41
+ 'css',
42
+ 'js',
43
+ '',
44
+ );
45
+ $wp_content_dir = trailingslashit( WP_CONTENT_DIR );
46
+
47
+ /**
48
+ * Check global cache folders.
49
+ */
50
+
51
+ // Advanced cache file.
52
+ $file = $wp_content_dir . 'advanced-cache.php';
53
+
54
+ if ( ! is_writable( $file ) ) {
55
+ self::append_permission_error( $file . __( ' file is not writable.', 'breeze' ) );
56
+ }
57
+
58
+ $folder = $wp_content_dir . 'breeze-config/';
59
+
60
+ if ( is_dir( $folder ) && ! is_writable( $folder ) ) {
61
+ self::append_permission_error( $folder . __( ' folder is not writable.', 'breeze' ) );
62
+ }
63
+
64
+ $folder = $wp_content_dir . 'cache/';
65
+ if ( is_dir( $folder ) && ! is_writable( $folder ) ) {
66
+ self::append_permission_error( $folder . __( ' folder is not writable.', 'breeze' ) );
67
+ }
68
+
69
+ $folder = $wp_content_dir . 'cache/breeze/';
70
+ if ( is_dir( $folder ) && ! is_writable( $folder ) ) {
71
+ self::append_permission_error( $folder . __( ' folder is not writable.', 'breeze' ) );
72
+ }
73
+
74
+ /**
75
+ * Checking multisite specific folders.
76
+ */
77
+ if ( is_multisite() ) {
78
+ if ( is_network_admin() ) {
79
+ $file = $wp_content_dir . 'breeze-config/breeze-config.php';
80
+ if ( ! is_writable( $file ) ) {
81
+ self::append_permission_error( $file . __( ' file is not writable.', 'breeze' ) );
82
+ }
83
+
84
+ $folder_min = $wp_content_dir . 'cache/breeze-minification/';
85
+ if ( is_dir( $folder_min ) && ! is_writable( $folder_min ) ) {
86
+ self::append_permission_error( $folder_min . __( ' folder is not writable.', 'breeze' ) );
87
+ }
88
+
89
+ $blogs = get_sites();
90
+ if ( ! empty( $blogs ) ) {
91
+ foreach ( $blogs as $blog_data ) {
92
+ $blog_id = $blog_data->blog_id;
93
+ $folder = $wp_content_dir . 'cache/breeze/' . $blog_id . '/';
94
+ if ( is_dir( $folder ) && ! is_writable( $folder ) ) {
95
+ self::append_permission_error( $folder . __( ' folder is not writable.', 'breeze' ) );
96
+ }
97
+
98
+ $folder_min = $wp_content_dir . 'cache/breeze-minification/' . $blog_id . '/';
99
+
100
+ if ( ! empty( $cache_specific_folders ) && is_array( $cache_specific_folders ) ) {
101
+ foreach ( $cache_specific_folders as $item_folder ) {
102
+ foreach ( $assets_folders as $asset_folder ) {
103
+ $check_folder = trailingslashit( trailingslashit( $folder_min . $item_folder ) . $asset_folder );
104
+
105
+ if ( is_dir( $check_folder ) && ! is_writable( $check_folder ) ) {
106
+ self::append_permission_error( $check_folder . __( ' folder is not writable.', 'breeze' ) );
107
+ }
108
+ }
109
+ }
110
+ }// endif
111
+ }
112
+ }
113
+ } else {
114
+ $the_blog_id = get_current_blog_id();
115
+
116
+ $inherit_option = get_blog_option( $the_blog_id, 'breeze_inherit_settings' );
117
+ $inherit_option = filter_var( $inherit_option, FILTER_VALIDATE_BOOLEAN );
118
+
119
+ $folder_min = $wp_content_dir . 'cache/breeze-minification/';
120
+ if ( is_dir( $folder_min ) && ! is_writable( $folder_min ) ) {
121
+ self::append_permission_error( $folder_min . __( ' folder is not writable.', 'breeze' ) );
122
+ }
123
+
124
+
125
+ $file = $wp_content_dir . 'breeze-config/breeze-config-' . $the_blog_id . '.php';
126
+ if ( false === $inherit_option && file_exists( $file) && ! is_writable( $file ) ) {
127
+ self::append_permission_error( $file . __( ' file is not writable.', 'breeze' ) );
128
+ }
129
+
130
+ $folder = $wp_content_dir . 'cache/breeze/' . $the_blog_id . '/';
131
+ if ( is_dir( $folder ) && ! is_writable( $folder ) ) {
132
+ self::append_permission_error( $folder . __( ' folder is not writable.', 'breeze' ) );
133
+ }
134
+
135
+ $folder_min = $wp_content_dir . 'cache/breeze-minification/' . $the_blog_id . '/';
136
+
137
+ if ( ! empty( $cache_specific_folders ) && is_array( $cache_specific_folders ) ) {
138
+ foreach ( $cache_specific_folders as $item_folder ) {
139
+ foreach ( $assets_folders as $asset_folder ) {
140
+ $check_folder = trailingslashit( trailingslashit( $folder_min . $item_folder ) . $asset_folder );
141
+
142
+ if ( is_dir( $check_folder ) && ! is_writable( $check_folder ) ) {
143
+ self::append_permission_error( $check_folder . __( ' folder is not writable.', 'breeze' ) );
144
+ }
145
+ }
146
+ }
147
+ }// endif
148
+ }
149
+ } else {
150
+ $file = $wp_content_dir . 'breeze-config/breeze-config.php';
151
+ if ( ! is_writable( $file ) ) {
152
+ self::append_permission_error( $file . __( ' file is not writable.', 'breeze' ) );
153
+ }
154
+
155
+ /**
156
+ * Checking single site specific folders.
157
+ */
158
+ $folder_min = $wp_content_dir . 'cache/breeze-minification/';
159
+
160
+ if ( ! empty( $cache_specific_folders ) && is_array( $cache_specific_folders ) ) {
161
+ foreach ( $cache_specific_folders as $item_folder ) {
162
+
163
+ foreach ( $assets_folders as $asset_folder ) {
164
+ $check_folder = trailingslashit( trailingslashit( $folder_min . $item_folder ) . $asset_folder );
165
+
166
+ if ( is_dir( $check_folder ) && ! is_writable( $check_folder ) ) {
167
+ self::append_permission_error( $check_folder . __( ' folder is not writable.', 'breeze' ) );
168
+ }
169
+ }
170
+ }
171
+ }// endif
172
+ }
173
+
174
+ }
175
+
176
+ public function display_the_errors() {
177
+
178
+ $this->check_specific_files_folders();
179
+ if ( ! empty( self::$errors ) ) {
180
+ echo '<div class="notice notice-error is-dismissible">';
181
+ echo '<p><strong>' . __( 'Breeze settings will not reflect because there is file permission issue', 'breeze' ) . '</strong></p>';
182
+ foreach ( self::$errors as $message ) {
183
+ echo '<p>' . $message . '</p>';
184
+ }
185
+
186
+ echo '</div>';
187
+ }
188
+ }
189
+ }
190
+
191
+ add_action(
192
+ 'admin_init',
193
+ function () {
194
+ new Breeze_File_Permissions();
195
+ }
196
+ );
inc/helpers.php CHANGED
@@ -826,4 +826,4 @@ function breeze_is_delayjs_changed( $is_network = false, $blog_id = 0, $root = f
826
  }
827
 
828
  return true;
829
- }
826
  }
827
 
828
  return true;
829
+ }
inc/minification/breeze-minification-scripts.php CHANGED
@@ -250,6 +250,10 @@ class Breeze_MinificationScripts extends Breeze_MinificationBase {
250
  $this->custom_js_exclude[] = $jquery_local_path;
251
  }
252
 
 
 
 
 
253
  foreach ( $matches[0] as $tag ) {
254
  // only consider aggregation whitelisted in should_aggregate-function
255
  if ( ! $this->should_aggregate( $tag ) ) {
@@ -1086,4 +1090,58 @@ class Breeze_MinificationScripts extends Breeze_MinificationBase {
1086
 
1087
  return false;
1088
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1089
  }
250
  $this->custom_js_exclude[] = $jquery_local_path;
251
  }
252
 
253
+ if ( isset( $matches[0] ) && ! empty( $matches[0] ) ) {
254
+ $matches[0] = $this->delay_script_loading( $matches[0] );
255
+ }
256
+
257
  foreach ( $matches[0] as $tag ) {
258
  // only consider aggregation whitelisted in should_aggregate-function
259
  if ( ! $this->should_aggregate( $tag ) ) {
1090
 
1091
  return false;
1092
  }
1093
+
1094
+ /**
1095
+ * This is an exception for bad written plugins.
1096
+ * Where they use jQuery but do not load their script with jQuery dependency.
1097
+ * We will delay these scripts. But if jQuery is not loaded the issue will still persist.
1098
+ *
1099
+ * @since 1.2.4
1100
+ * @access private
1101
+ */
1102
+ private function delay_script_loading( $scripts = array() ) {
1103
+
1104
+ if ( ! is_array( $scripts ) || empty( $scripts ) ) {
1105
+ return $scripts;
1106
+ }
1107
+
1108
+ $to_move_last = apply_filters(
1109
+ 'breeze_delay_bag_scripts',
1110
+ array(
1111
+ 'sp-scripts.min.js',
1112
+ 'js/tubular.js',
1113
+ )
1114
+ );
1115
+
1116
+ $return_scripts = array();
1117
+ $add_last = array();
1118
+
1119
+ foreach ( $scripts as $index => $script ) {
1120
+ $add_return = false;
1121
+ $add_later = false;
1122
+ foreach ( $to_move_last as $script_to_delay ) {
1123
+ if ( false === strpos( $script, $script_to_delay ) ) {
1124
+ $add_return = true;
1125
+ break;
1126
+ } else {
1127
+ $add_later = true;
1128
+ }
1129
+ }
1130
+
1131
+ if ( false === $add_later && true === $add_return ) {
1132
+ $return_scripts[] = $script;
1133
+ } else if ( true === $add_later ) {
1134
+ $add_last[] = $script;
1135
+ }
1136
+ }
1137
+
1138
+ if ( ! empty( $add_last ) ) {
1139
+ foreach ( $add_last as $delayed_js_script ) {
1140
+ $return_scripts[] = $delayed_js_script;
1141
+ }
1142
+ }
1143
+
1144
+ return $return_scripts;
1145
+
1146
+ }
1147
  }
inc/minification/breeze-minify-main.php CHANGED
@@ -26,7 +26,7 @@ class Breeze_Minify {
26
  //check disable cache for page
27
  $http_host_breeze = ( isset( $_SERVER['HTTP_HOST'] ) ) ? $_SERVER['HTTP_HOST'] : '';
28
  $domain = ( ( ( isset( $_SERVER['HTTPS'] ) && ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] !== 'off' ) || ( ! empty( $_SERVER['SERVER_PORT'] ) && $_SERVER['SERVER_PORT'] == 443 ) ) ? 'https://' : 'http://' ) . $http_host_breeze;
29
- $current_url = $domain . $_SERVER['REQUEST_URI'];
30
 
31
  $check_url = $this->check_exclude_url( $current_url );
32
 
@@ -184,7 +184,7 @@ class Breeze_Minify {
184
  $minify['breeze-enable-js-delay'] = '0';
185
  }
186
 
187
- $cdn_url = '';
188
  if ( $cdn_data ) {
189
  if ( '1' === $cdn_data['cdn-active'] ) {
190
  $cdn_url = $cdn_data['cdn-url'];
@@ -198,7 +198,11 @@ class Breeze_Minify {
198
  } elseif (
199
  ! empty( $minify['breeze-defer-js'] ) ||
200
  ! empty( $minify['breeze-move-to-footer-js'] ) ||
201
- ( ! empty( $minify['breeze-delay-js-scripts'] ) && true === filter_var( $minify['breeze-enable-js-delay'], FILTER_VALIDATE_BOOLEAN ) )
 
 
 
 
202
  ) {
203
  $classes[] = 'Breeze_Js_Deferred_Loading';
204
  }
@@ -242,7 +246,7 @@ class Breeze_Minify {
242
  'custom_js_exclude' => $minify['breeze-exclude-js'],
243
  'move_to_footer_js' => $minify['breeze-move-to-footer-js'],
244
  'defer_js' => $minify['breeze-defer-js'],
245
- 'delay_inline_js' => $minify['breeze-delay-js-scripts'],
246
  ),
247
  'Breeze_MinificationStyles' => array(
248
  'justhead' => false,
@@ -265,7 +269,7 @@ class Breeze_Minify {
265
  'Breeze_Js_Deferred_Loading' => array(
266
  'move_to_footer_js' => $minify['breeze-move-to-footer-js'],
267
  'defer_js' => $minify['breeze-defer-js'],
268
- 'delay_inline_js' => $minify['breeze-delay-js-scripts'],
269
  'cdn_url' => $cdn_url,
270
  ),
271
  );
@@ -360,20 +364,31 @@ class Breeze_Minify {
360
  foreach ( $opts_config['breeze-exclude-urls'] as $v ) {
361
  // Clear blank character
362
  $v = trim( $v );
 
 
 
 
363
  if ( preg_match( '/(\&?\/?\(\.?\*\)|\/\*|\*)$/', $v, $matches ) ) {
364
- // End of rules is *, /*, [&][/](*) , [&][/](.*)
365
- $pattent = substr( $v, 0, strpos( $v, $matches[0] ) );
366
- if ( $v[0] == '/' ) {
367
- // A path of exclude url with regex
368
- if ( ( @preg_match( '@' . $pattent . '@', $current_url, $matches ) > 0 ) ) {
369
- return true;
370
- }
371
- } else {
372
- // Full exclude url with regex
373
- if ( strpos( $current_url, $pattent ) !== false ) {
374
- return true;
 
 
 
 
 
 
375
  }
376
  }
 
377
  } else {
378
 
379
  $test_url = rtrim( $v, '/' );
26
  //check disable cache for page
27
  $http_host_breeze = ( isset( $_SERVER['HTTP_HOST'] ) ) ? $_SERVER['HTTP_HOST'] : '';
28
  $domain = ( ( ( isset( $_SERVER['HTTPS'] ) && ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] !== 'off' ) || ( ! empty( $_SERVER['SERVER_PORT'] ) && $_SERVER['SERVER_PORT'] == 443 ) ) ? 'https://' : 'http://' ) . $http_host_breeze;
29
+ $current_url = $domain . $_SERVER['REQUEST_URI'];
30
 
31
  $check_url = $this->check_exclude_url( $current_url );
32
 
184
  $minify['breeze-enable-js-delay'] = '0';
185
  }
186
 
187
+ $cdn_url = '';
188
  if ( $cdn_data ) {
189
  if ( '1' === $cdn_data['cdn-active'] ) {
190
  $cdn_url = $cdn_data['cdn-url'];
198
  } elseif (
199
  ! empty( $minify['breeze-defer-js'] ) ||
200
  ! empty( $minify['breeze-move-to-footer-js'] ) ||
201
+ (
202
+ isset( $minify['breeze-delay-js-scripts'] ) &&
203
+ ! empty( $minify['breeze-delay-js-scripts'] ) &&
204
+ true === filter_var( $minify['breeze-enable-js-delay'], FILTER_VALIDATE_BOOLEAN )
205
+ )
206
  ) {
207
  $classes[] = 'Breeze_Js_Deferred_Loading';
208
  }
246
  'custom_js_exclude' => $minify['breeze-exclude-js'],
247
  'move_to_footer_js' => $minify['breeze-move-to-footer-js'],
248
  'defer_js' => $minify['breeze-defer-js'],
249
+ 'delay_inline_js' => ( isset( $minify['breeze-delay-js-scripts'] ) ? $minify['breeze-delay-js-scripts'] : array() ),
250
  ),
251
  'Breeze_MinificationStyles' => array(
252
  'justhead' => false,
269
  'Breeze_Js_Deferred_Loading' => array(
270
  'move_to_footer_js' => $minify['breeze-move-to-footer-js'],
271
  'defer_js' => $minify['breeze-defer-js'],
272
+ 'delay_inline_js' => ( isset( $minify['breeze-delay-js-scripts'] ) ? $minify['breeze-delay-js-scripts'] : array() ),
273
  'cdn_url' => $cdn_url,
274
  ),
275
  );
364
  foreach ( $opts_config['breeze-exclude-urls'] as $v ) {
365
  // Clear blank character
366
  $v = trim( $v );
367
+ if ( empty( $v ) ) {
368
+ continue;
369
+ }
370
+
371
  if ( preg_match( '/(\&?\/?\(\.?\*\)|\/\*|\*)$/', $v, $matches ) ) {
372
+
373
+ if ( isset( $matches[0] ) && ! empty( $matches[0] ) ) {
374
+ // End of rules is *, /*, [&][/](*) , [&][/](.*)
375
+ $pattent = substr( $v, 0, strpos( $v, $matches[0] ) );
376
+ if ( $v[0] == '/' ) {
377
+ // A path of exclude url with regex
378
+ if ( ( @preg_match( '@' . $pattent . '@', $current_url, $matches ) > 0 ) ) {
379
+ return true;
380
+ }
381
+ } else {
382
+ // Full exclude url with regex
383
+ if ( ! empty( $pattent ) ) {
384
+ if ( strpos( $current_url, $pattent ) !== false ) {
385
+ return true;
386
+ }
387
+ }
388
+
389
  }
390
  }
391
+
392
  } else {
393
 
394
  $test_url = rtrim( $v, '/' );
inc/wp-cli/class-breeze-cli-helpers.php CHANGED
@@ -56,4 +56,14 @@ class Breeze_Cli_Helpers {
56
  }
57
 
58
  }
 
 
 
 
 
 
 
 
 
 
59
  }
56
  }
57
 
58
  }
59
+
60
+ public static function cache_helper_display(){
61
+ WP_CLI::line( '---' );
62
+ WP_CLI::line( WP_CLI::colorize( '%Ywp breeze purge --cache=<all|varnish|local>%n is the full command:' ) );
63
+ WP_CLI::line( WP_CLI::colorize( '%Y--cache=%n%Gall%n will clear local cache and varnish cache.' ) );
64
+ WP_CLI::line( WP_CLI::colorize( '%Y--cache=%n%Gvarnish%n will clear varnish cache only.' ) );
65
+ WP_CLI::line( WP_CLI::colorize( '%Y--cache=%n%Glocal%n will clear local cache only.' ) );
66
+ WP_CLI::line( WP_CLI::colorize( '%Y--level=%n%GblogID|network%n will clear cache for the specified blogID or at network level(all sub-sites).' ) );
67
+ WP_CLI::line( '---' );
68
+ }
69
  }
inc/wp-cli/class-breeze-wp-cli-core.php CHANGED
@@ -11,6 +11,13 @@ if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) {
11
  class Breeze_WP_Cli_Core extends \WP_CLI_Command {
12
 
13
  function help( $args, $assoc_args ) {
 
 
 
 
 
 
 
14
 
15
  WP_CLI::line( '---' );
16
  WP_CLI::line( WP_CLI::colorize( 'Command to export settings %Ywp breeze export --file-path=/path/to/folder --level=<network|blogID>%n ' ) );
@@ -27,6 +34,141 @@ class Breeze_WP_Cli_Core extends \WP_CLI_Command {
27
  return;
28
  }
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  /**
31
  * Export settings to file using WP-CLI.
32
  *
11
  class Breeze_WP_Cli_Core extends \WP_CLI_Command {
12
 
13
  function help( $args, $assoc_args ) {
14
+ WP_CLI::line( '---' );
15
+ WP_CLI::line( WP_CLI::colorize( 'Command to purge cache %Ywp breeze purge --cache=<all|varnish|local>%n:' ) );
16
+ WP_CLI::line( WP_CLI::colorize( '%Y--cache=%n%Gall%n will clear local cache and varnish cache.' ) );
17
+ WP_CLI::line( WP_CLI::colorize( '%Y--cache=%n%Gvarnish%n will clear varnish cache only.' ) );
18
+ WP_CLI::line( WP_CLI::colorize( '%Y--cache=%n%Glocal%n will clear local cache only.' ) );
19
+ WP_CLI::line( WP_CLI::colorize( '%Y--level=%n%G<blogID|network>%n (%Moptional multisite only%n) Will clear cache for the specified blogID or at network level(all sub-sites). If not specified then the default is network level.' ) );
20
+ WP_CLI::line( '---' );
21
 
22
  WP_CLI::line( '---' );
23
  WP_CLI::line( WP_CLI::colorize( 'Command to export settings %Ywp breeze export --file-path=/path/to/folder --level=<network|blogID>%n ' ) );
34
  return;
35
  }
36
 
37
+ function purge( $args, $assoc_args ) {
38
+ $level = ( isset( $assoc_args['level'] ) && ! empty( $assoc_args['level'] ) ) ? trim( $assoc_args['level'] ) : '';
39
+
40
+ if ( is_numeric( $level ) ) {
41
+ $level = absint( $level );
42
+ }
43
+
44
+ if ( isset( $assoc_args ) && ! empty( $assoc_args ) && isset( $assoc_args['cache'] ) ) {
45
+
46
+ if ( empty( $assoc_args['cache'] ) ) {
47
+ WP_CLI::error(
48
+ __( 'Specify a value for parameter --cache=<all|varnish|local>', 'breeze' )
49
+ );
50
+
51
+ return;
52
+ }
53
+
54
+ $assoc_args['cache'] = strtolower( $assoc_args['cache'] );
55
+
56
+ if ( 'help' === $assoc_args['cache'] ) {
57
+ Breeze_Cli_Helpers::cache_helper_display();
58
+
59
+ return;
60
+ }
61
+
62
+ if ( 'all' === $assoc_args['cache'] ) {
63
+
64
+ // Clear all cache at network level.
65
+ if ( is_multisite() && empty( $level ) || 'network' === $level ) {
66
+
67
+ $sites = get_sites();
68
+ foreach ( $sites as $site ) {
69
+ switch_to_blog( $site->blog_id );
70
+ do_action( 'breeze_clear_all_cache' );
71
+ restore_current_blog();
72
+ }
73
+ WP_CLI::success(
74
+ __( 'Breeze all cache has been purged on network level', 'breeze' )
75
+ );
76
+ } else {
77
+ if ( ! empty( $level ) ) {
78
+ switch_to_blog( $level );
79
+ }
80
+
81
+ do_action( 'breeze_clear_all_cache' );
82
+
83
+ if ( ! empty( $level ) ) {
84
+ restore_current_blog();
85
+ }
86
+
87
+ WP_CLI::success(
88
+ __( 'Breeze all cache has been purged.', 'breeze' )
89
+ );
90
+ }
91
+
92
+ }
93
+
94
+ if ( 'varnish' === $assoc_args['cache'] ) {
95
+ // Clear varnish at network level.
96
+ if ( is_multisite() && empty( $level ) || 'network' === $level ) {
97
+ $sites = get_sites();
98
+ foreach ( $sites as $site ) {
99
+ switch_to_blog( $site->blog_id );
100
+ do_action( 'breeze_clear_varnish' );
101
+ restore_current_blog();
102
+ }
103
+
104
+ WP_CLI::success(
105
+ __( 'Breeze Varnish cache has been purged on network level.', 'breeze' )
106
+ );
107
+ } else {
108
+ if ( ! empty( $level ) ) {
109
+ switch_to_blog( $level );
110
+ }
111
+
112
+ do_action( 'breeze_clear_varnish' );
113
+
114
+ if ( ! empty( $level ) ) {
115
+ restore_current_blog();
116
+ }
117
+
118
+ WP_CLI::success(
119
+ __( 'Breeze Varnish cache has been purged.', 'breeze' )
120
+ );
121
+ }
122
+
123
+
124
+ }
125
+
126
+ if ( 'local' === $assoc_args['cache'] ) {
127
+ // Clear local cache at network level.
128
+ if ( is_multisite() && empty( $level ) || 'network' === $level ) {
129
+ $sites = get_sites();
130
+ foreach ( $sites as $site ) {
131
+ switch_to_blog( $site->blog_id );
132
+ //delete minify
133
+ Breeze_MinificationCache::clear_minification();
134
+ //clear normal cache
135
+ Breeze_PurgeCache::breeze_cache_flush();
136
+ restore_current_blog();
137
+ }
138
+
139
+ WP_CLI::success(
140
+ __( 'Breeze local cache has been purged on network level', 'breeze' )
141
+ );
142
+ } else {
143
+ if ( ! empty( $level ) ) {
144
+ switch_to_blog( $level );
145
+ }
146
+ //delete minify
147
+ Breeze_MinificationCache::clear_minification();
148
+ //clear normal cache
149
+ Breeze_PurgeCache::breeze_cache_flush();
150
+
151
+ if ( ! empty( $level ) ) {
152
+ restore_current_blog();
153
+ }
154
+
155
+ WP_CLI::success(
156
+ __( 'Breeze local cache has been purged.', 'breeze' )
157
+ );
158
+ }
159
+
160
+ }
161
+
162
+
163
+ } else {
164
+ Breeze_Cli_Helpers::cache_helper_display();
165
+ WP_CLI::error(
166
+ __( 'Parameter --cache=<all|varnish|local> is missing', 'breeze' )
167
+ );
168
+
169
+ }
170
+ }
171
+
172
  /**
173
  * Export settings to file using WP-CLI.
174
  *
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Cloudways
3
  Tags: cache,caching, performance, wp-cache, cdn, combine, compress, speed plugin, database cache,gzip, http compression, js cache, minify, optimize, page cache, performance, speed, expire headers
4
  Requires at least: 4.5
5
  Tested up to: 5.8
6
- Stable tag: 1.2.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -145,6 +145,16 @@ Using Gzip, Breeze compresses the request files, further reducing the size of th
145
 
146
  == Changelog ==
147
 
 
 
 
 
 
 
 
 
 
 
148
 
149
 
150
  = 1.2.3 =
3
  Tags: cache,caching, performance, wp-cache, cdn, combine, compress, speed plugin, database cache,gzip, http compression, js cache, minify, optimize, page cache, performance, speed, expire headers
4
  Requires at least: 4.5
5
  Tested up to: 5.8
6
+ Stable tag: 1.2.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
145
 
146
  == Changelog ==
147
 
148
+ = 1.2.4 =
149
+
150
+
151
+ * Add: Functionality to clear ALL cache via Command Line Interface (wp-cli).
152
+ * Add: Functionality to clear Varnish cache via Command Line Interface (wp-cli).
153
+ * Add: Functionality to clear Internal cache via Command Line Interface (wp-cli).
154
+ * Add: While the file Permission is not correct, the warning message has been added.
155
+ * Fix: Compatibility with Coming Soon Page, Maintenance Mode & Landing Pages by SeedProd.
156
+ * Fix: improve the handling of warning undefine array key of delay JS script while enable debug mode.
157
+
158
 
159
 
160
  = 1.2.3 =