PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | minify/class-wp-optimize-minify-preloader.php +58 -18 3.2.7 → 4.7.0 View file →
@@ -1,8 +1,11 @@
1 1 <?php
2 2
3 3 if (!defined('ABSPATH')) die('No direct access allowed');
4 4
5 +if (!class_exists('WP_Optimize_Minify_Load_Url_Task')) {
6 + require_once(WPO_PLUGIN_MAIN_PATH . 'minify/class-wp-optimize-minify-load-url-task.php');
7 +}
5 8
6 9 class WP_Optimize_Minify_Preloader extends WP_Optimize_Preloader {
7 10
8 11 protected $preload_type = 'minify';
@@ -26,11 +29,11 @@
26 29 * @return bool
27 30 */
28 31 public function is_option_active() {
29 32 if (!function_exists('wp_optimize_minify_config')) {
30 - include_once WPO_PLUGIN_MAIN_PATH . '/minify/class-wp-optimize-minify-config.php';
33 + include_once WPO_PLUGIN_MAIN_PATH . 'minify/class-wp-optimize-minify-config.php';
31 34 }
32 - return wp_optimize_minify_config()->get('enabled');
35 + return (bool) wp_optimize_minify_config()->get('enabled');
33 36 }
34 37
35 38 /**
36 39 * Add intervals to cron schedules.
@@ -112,8 +115,13 @@
112 115 'error' => __('Probably minify preload is running already.', 'wp-optimize')
113 116 );
114 117 }
115 118
119 + /**
120 + * Returns preload data
121 + *
122 + * @return array
123 + */
116 124 protected function get_preload_data() {
117 125 $cache_path = WP_Optimize_Minify_Cache_Functions::cache_path();
118 126 $cache_dir = $cache_path['cachedir'];
119 127 $minify_cache_data = array();
@@ -120,41 +128,73 @@
120 128 $minify_cache_data['size'] = esc_html(WP_Optimize_Minify_Cache_Functions::get_cachestats($cache_dir));
121 129 $minify_cache_data['total_size'] = esc_html(WP_Optimize_Minify_Cache_Functions::get_cachestats(WPO_CACHE_MIN_FILES_DIR));
122 130 return $minify_cache_data;
123 131 }
124 -
125 - protected function get_preloading_message($minify_cache_data) {
132 +
133 + /**
134 + * Returns preloading message
135 + *
136 + * @param array $data
137 + *
138 + * @return array
139 + */
140 + protected function get_preloading_message($data) {
126 141 return array(
127 142 'done' => false,
128 143 'message' => __('Loading URLs...', 'wp-optimize'),
129 - 'size' => WP_Optimize()->format_size($minify_cache_data['size']),
130 - 'total_size' => $minify_cache_data['total_size']
144 + 'size' => WP_Optimize()->format_size($data['size']),
145 + 'total_size' => $data['total_size']
131 146 );
132 147 }
133 -
134 - protected function get_last_preload_message($minify_cache_data, $last_preload_time_str) {
148 +
149 + /**
150 + * Returns last preload message
151 + *
152 + * @param array $data
153 + * @param string $last_preload_time_str
154 + *
155 + * @return array
156 + */
157 + protected function get_last_preload_message($data, $last_preload_time_str) {
135 158 return array(
136 159 'done' => true,
160 + // translators: %s: last preload time
137 161 'message' => sprintf(__('Last preload finished at %s', 'wp-optimize'), $last_preload_time_str),
138 - 'size' => WP_Optimize()->format_size($minify_cache_data['size']),
139 - 'total_size' => $minify_cache_data['total_size']
162 + 'size' => WP_Optimize()->format_size($data['size']),
163 + 'total_size' => $data['total_size']
140 164 );
141 165 }
142 -
143 - protected function get_preload_success_message($minify_cache_data) {
166 +
167 + /**
168 + * Returns preload success message
169 + *
170 + * @param array $data
171 + *
172 + * @return array
173 + */
174 + protected function get_preload_success_message($data) {
144 175 return array(
145 176 'done' => true,
146 - 'size' => WP_Optimize()->format_size($minify_cache_data['size']),
147 - 'total_size' => $minify_cache_data['total_size']
177 + 'size' => WP_Optimize()->format_size($data['size']),
178 + 'total_size' => $data['total_size']
148 179 );
149 180 }
150 -
151 - protected function get_preload_progress_message($minify_cache_data, $preloaded_message, $preload_resuming_in) {
181 +
182 + /**
183 + * Returns preload progress message
184 + *
185 + * @param array $data
186 + * @param string $preloaded_message
187 + * @param int $preload_resuming_in
188 + *
189 + * @return array
190 + */
191 + protected function get_preload_progress_message($data, $preloaded_message, $preload_resuming_in) {
152 192 return array(
153 193 'done' => false,
154 194 'message' => $preloaded_message,
155 - 'size' => WP_Optimize()->format_size($minify_cache_data['size']),
156 - 'total_size' => $minify_cache_data['total_size'],
195 + 'size' => WP_Optimize()->format_size($data['size']),
196 + 'total_size' => $data['total_size'],
157 197 'resume_in' => $preload_resuming_in
158 198 );
159 199 }
160 200 }