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