PluginProbe
Autoptimize / trunk
Autoptimize vtrunk
3.1.16 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 All 108 releases
← All changes | classes/autoptimizeVersionUpdatesHandler.php +67 -19 2.5.1 → trunk View file →
@@ -27,9 +27,8 @@
27 27 */
28 28 public function run_needed_major_upgrades()
29 29 {
30 30 $major_update = false;
31 -
32 31 switch ( $this->current_major_version ) {
33 32 case '1.6':
34 33 $this->upgrade_from_1_6();
35 34 $major_update = true;
@@ -46,14 +45,31 @@
46 45 $this->upgrade_from_2_2();
47 46 $major_update = true;
48 47 // No break, intentionally, so all upgrades are ran during a single request...
49 48 case '2.4':
50 - if ( get_option( 'autoptimize_version', 'none' ) == '2.4.2' ) {
49 + if ( autoptimizeOptionWrapper::get_option( 'autoptimize_version', 'none' ) == '2.4.2' ) {
51 50 $this->upgrade_from_2_4_2();
52 51 }
53 52 $this->upgrade_from_2_4();
54 53 $major_update = false;
55 54 // No break, intentionally, so all upgrades are ran during a single request...
55 + case '2.7':
56 + $this->upgrade_from_2_7();
57 + $major_update = true;
58 + // No break, intentionally, so all upgrades are ran during a single request...
59 + case '2.8':
60 + // nothing.
61 + case '2.9':
62 + if ( version_compare( autoptimizeOptionWrapper::get_option( 'autoptimize_version', 'none' ), '2.9.999', 'lt' ) ) {
63 + $this->upgrade_from_2_9_before_compatibility();
64 + }
65 + $major_update = false;
66 + // No break, intentionally, so all upgrades are ran during a single request...
67 + case '3.0':
68 + // nothing.
69 + case '3.1':
70 + $this->upgrade_from_3_1();
71 + $major_update = false;
56 72 }
57 73
58 74 if ( true === $major_update ) {
59 75 $this->on_major_version_update();
@@ -68,9 +84,9 @@
68 84 * @param string $target Target version to check against (ie., the currently running one).
69 85 */
70 86 public static function check_installed_and_update( $target )
71 87 {
72 - $db_version = get_option( 'autoptimize_version', 'none' );
88 + $db_version = autoptimizeOptionWrapper::get_option( 'autoptimize_version', 'none' );
73 89 if ( $db_version !== $target ) {
74 90 if ( 'none' === $db_version ) {
75 91 add_action( 'admin_notices', 'autoptimizeMain::notice_installed' );
76 92 } else {
@@ -78,9 +94,9 @@
78 94 $updater->run_needed_major_upgrades();
79 95 }
80 96
81 97 // Versions differed, upgrades happened if needed, store the new version.
82 - update_option( 'autoptimize_version', $target );
98 + autoptimizeOptionWrapper::update_option( 'autoptimize_version', $target );
83 99 }
84 100 }
85 101
86 102 /**
@@ -102,9 +118,9 @@
102 118 */
103 119 private function upgrade_from_1_6()
104 120 {
105 121 // If user was on version 1.6.x, force advanced options to be shown by default.
106 - update_option( 'autoptimize_show_adv', '1' );
122 + autoptimizeOptionWrapper::update_option( 'autoptimize_show_adv', '1' );
107 123
108 124 // And remove old options.
109 125 $to_delete_options = array(
110 126 'autoptimize_cdn_css',
@@ -127,15 +143,15 @@
127 143 */
128 144 private function upgrade_from_1_7()
129 145 {
130 146 if ( ! is_multisite() ) {
131 - $css_exclude = get_option( 'autoptimize_css_exclude' );
147 + $css_exclude = autoptimizeOptionWrapper::get_option( 'autoptimize_css_exclude' );
132 148 if ( empty( $css_exclude ) ) {
133 149 $css_exclude = 'admin-bar.min.css, dashicons.min.css';
134 150 } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) {
135 151 $css_exclude .= ', dashicons.min.css';
136 152 }
137 - update_option( 'autoptimize_css_exclude', $css_exclude );
153 + autoptimizeOptionWrapper::update_option( 'autoptimize_css_exclude', $css_exclude );
138 154 } else {
139 155 global $wpdb;
140 156 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
141 157 $original_blog_id = get_current_blog_id();
@@ -140,15 +156,15 @@
140 156 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
141 157 $original_blog_id = get_current_blog_id();
142 158 foreach ( $blog_ids as $blog_id ) {
143 159 switch_to_blog( $blog_id );
144 - $css_exclude = get_option( 'autoptimize_css_exclude' );
160 + $css_exclude = autoptimizeOptionWrapper::get_option( 'autoptimize_css_exclude' );
145 161 if ( empty( $css_exclude ) ) {
146 162 $css_exclude = 'admin-bar.min.css, dashicons.min.css';
147 163 } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) {
148 164 $css_exclude .= ', dashicons.min.css';
149 165 }
150 - update_option( 'autoptimize_css_exclude', $css_exclude );
166 + autoptimizeOptionWrapper::update_option( 'autoptimize_css_exclude', $css_exclude );
151 167 }
152 168 switch_to_blog( $original_blog_id );
153 169 }
154 170 }
@@ -161,10 +177,10 @@
161 177 */
162 178 private function upgrade_from_1_9()
163 179 {
164 180 if ( ! is_multisite() ) {
165 - update_option( 'autoptimize_css_include_inline', 'on' );
166 - update_option( 'autoptimize_js_include_inline', 'on' );
181 + autoptimizeOptionWrapper::update_option( 'autoptimize_css_include_inline', 'on' );
182 + autoptimizeOptionWrapper::update_option( 'autoptimize_js_include_inline', 'on' );
167 183 } else {
168 184 global $wpdb;
169 185 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
170 186 $original_blog_id = get_current_blog_id();
@@ -169,10 +185,10 @@
169 185 $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
170 186 $original_blog_id = get_current_blog_id();
171 187 foreach ( $blog_ids as $blog_id ) {
172 188 switch_to_blog( $blog_id );
173 - update_option( 'autoptimize_css_include_inline', 'on' );
174 - update_option( 'autoptimize_js_include_inline', 'on' );
189 + autoptimizeOptionWrapper::update_option( 'autoptimize_css_include_inline', 'on' );
190 + autoptimizeOptionWrapper::update_option( 'autoptimize_js_include_inline', 'on' );
175 191 }
176 192 switch_to_blog( $original_blog_id );
177 193 }
178 194 }
@@ -202,12 +218,12 @@
202 218 * Helper for 2.2 autoptimize_extra_settings upgrade to avoid duplicate code
203 219 */
204 220 private function do_2_2_settings_update()
205 221 {
206 - $nogooglefont = get_option( 'autoptimize_css_nogooglefont', '' );
207 - $ao_extrasetting = get_option( 'autoptimize_extra_settings', '' );
222 + $nogooglefont = autoptimizeOptionWrapper::get_option( 'autoptimize_css_nogooglefont', '' );
223 + $ao_extrasetting = autoptimizeOptionWrapper::get_option( 'autoptimize_extra_settings', '' );
208 224 if ( ( $nogooglefont ) && ( empty( $ao_extrasetting ) ) ) {
209 - update_option( 'autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options() );
225 + autoptimizeOptionWrapper::update_option( 'autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options() );
210 226 }
211 227 delete_option( 'autoptimize_css_nogooglefont' );
212 228 }
213 229
@@ -235,10 +251,10 @@
235 251 /**
236 252 * Migrate imgopt options from autoptimize_extra_settings to autoptimize_imgopt_settings
237 253 */
238 254 private function upgrade_from_2_4() {
239 - $extra_settings = get_option( 'autoptimize_extra_settings', '' );
240 - $imgopt_settings = get_option( 'autoptimize_imgopt_settings', '' );
255 + $extra_settings = autoptimizeOptionWrapper::get_option( 'autoptimize_extra_settings', '' );
256 + $imgopt_settings = autoptimizeOptionWrapper::get_option( 'autoptimize_imgopt_settings', '' );
241 257 if ( empty( $imgopt_settings ) && ! empty( $extra_settings ) ) {
242 258 $imgopt_settings = autoptimizeConfig::get_ao_imgopt_default_options();
243 259 if ( array_key_exists( 'autoptimize_extra_checkbox_field_5', $extra_settings ) ) {
244 260 $imgopt_settings['autoptimize_imgopt_checkbox_field_1'] = $extra_settings['autoptimize_extra_checkbox_field_5'];
@@ -245,8 +261,40 @@
245 261 }
246 262 if ( array_key_exists( 'autoptimize_extra_select_field_6', $extra_settings ) ) {
247 263 $imgopt_settings['autoptimize_imgopt_select_field_2'] = $extra_settings['autoptimize_extra_select_field_6'];
248 264 }
249 - update_option( 'autoptimize_imgopt_settings', $imgopt_settings );
265 + autoptimizeOptionWrapper::update_option( 'autoptimize_imgopt_settings', $imgopt_settings );
266 + }
267 + }
268 +
269 + /**
270 + * Remove CCSS request limit option + update jquery exclusion to include WordPress 5.6 jquery.min.js.
271 + */
272 + private function upgrade_from_2_7() {
273 + delete_option( 'autoptimize_ccss_rlimit' );
274 + $js_exclusions = get_option( 'autoptimize_js_exclude', '' );
275 + if ( strpos( $js_exclusions, 'js/jquery/jquery.js' ) !== false && strpos( $js_exclusions, 'js/jquery/jquery.min.js' ) === false ) {
276 + $js_exclusions .= ', js/jquery/jquery.min.js';
277 + autoptimizeOptionWrapper::update_option( 'autoptimize_js_exclude', $js_exclusions );
278 + }
279 + }
280 +
281 + /**
282 + * Set an option to indicate the AO installation predates the compatibility logic, this way we
283 + * can avoid adding compatibility code that is likely not needed and maybe not wanted as it
284 + * can introduce performance regressions.
285 + */
286 + private function upgrade_from_2_9_before_compatibility() {
287 + autoptimizeOptionWrapper::update_option( 'autoptimize_installed_before_compatibility', true );
288 + }
289 +
290 + /**
291 + * If the 404 handler is active, delete the current PHP-file so it can be re-created to fix the double underscore bug.
292 + */
293 + private function upgrade_from_3_1() {
294 + $_version_from_db = autoptimizeOptionWrapper::get_option( 'autoptimize_version', 'none' );
295 + if ( autoptimizeCache::do_fallback() && 'none' !== $_version_from_db && version_compare( $_version_from_db, '3.1.2', 'lt' ) ) {
296 + $_fallback_php = trailingslashit( WP_CONTENT_DIR ) . 'autoptimize_404_handler.php';
297 + @unlink( $_fallback_php ); // @codingStandardsIgnoreLine
250 298 }
251 299 }
252 300 }