手里有个网站一直在使用知更鸟博客的 Autoptimize 插件优化版,用来整合并压缩 CSS 和 JavaScript 代码,今天启用插件后,在设置中启用压缩 CSS,发现网站显示报错: Array and string offset access syntax with curly braces is no longer support /wp-content/plugins/autoptimize/classes/autoptimizeStyles.php on line 605报错原因,应该是因为这款根据老 Autoptimize 修改的优化版插件不兼容新版的 PHP8。 最新版 Autoptimize 2.7.6 如何优化?我自己修改了最新版的 Autoptimize 插件,主要删除了插件设置界面右侧的 Feed 模块和优化更多,用来优化插件设置页面的加载速度。 打开 Autoptimize 插件下目录文件:autoptimize/classes/autoptimizeConfig.php,删除掉文件中的第507行至第544行即可,删除内容如下: <div id="autoptimize_admin_feed"><?php if ( apply_filters( 'autoptimize_filter_show_partner_tabs', true ) ) { ?><div class="autoptimize_banner hidden"><ul><?phpif ( $this->settings_screen_do_remote_http ) {$ao_banner = get_transient( 'autoptimize_banner' );if ( empty( $ao_banner ) ) {$banner_resp = wp_remote_get( 'https://misc.optimizingmatters.com/autoptimize_news.html?ao_ver=' . AUTOPTIMIZE_PLUGIN_VERSION );if ( ! is_wp_error( $banner_resp ) ) {if ( '200' == wp_remote_retrieve_response_code( $banner_resp ) ) {$ao_banner = wp_kses_post( wp_remote_retrieve_body( $banner_resp ) );set_transient( 'autoptimize_banner', $ao_banner, WEEK_IN_SECONDS );}}}echo $ao_banner;}?><li><?php _e( "Need help? <a href='https://wordpress.org/plugins/autoptimize/faq/'>Check out the FAQ here</a>.", 'autoptimize' ); ?></li><li><?php _e( 'Happy with Autoptimize?', 'autoptimize' ); ?><br /><a href="<?php echo network_admin_url(); ?>plugin-install.php?tab=search&type=author&s=optimizingmatters"><?php _e( 'Try my other plugins!', 'autoptimize' ); ?></a></li></ul></div><?php } ?><div style="margin-left:10px;margin-top:-5px;"><h2><?php _e( 'Autoptimize news', 'autoptimize' ); ?></h2><div id="futtta_feed"><div id="autoptimizefeed"></div></div></div><?php if ( apply_filters( 'autoptimize_filter_show_partner_tabs', true ) ) { ?><div style="float:right;margin:50px 15px;"><a href="https://blog.futtta.be/2013/10/21/do-not-donate-to-me/" target="_blank"><img width="100px" height="85px" src="<?php echo plugins_url() . '/' . plugin_basename( dirname( __FILE__ ) ) . '/external/do_not_donate_smallest.png'; ?>" title="<?php _e( 'Do not donate for this plugin!', 'autoptimize' ); ?>"></a></div><?php } ?></div>下一步就是删掉优化更多菜单,删除掉 autoptimizePartners.php 文件中的第142行至第150行即可。不过优化更多菜单还在,点击进去显示空白页面,如果全部清空了 autoptimizePartners.php,会显示报错。 <script>document.title = "Autoptimize: <?php _e( 'Optimize More!', 'autoptimize' ); ?> " + document.title;</script><div class="wrap"><h1><?php apply_filters( 'autoptimize_filter_settings_is_pro', false ) ? _e( 'Autoptimize Pro Settings', 'autoptimize' ) : _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1><?php echo autoptimizeConfig::ao_admin_tabs(); ?><?php echo '<h2>' . __( "These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize' ) . '</h2>'; ?><div><?php echo $this->get_ao_partner_feed_markup(); ?></div></div>
|