欢迎光临
我们一直在努力

wordpress打开elementor插件最近很慢解决办法

以前用wordpress用elementor插件做的网站,最近打开elementor编辑页面时速度非常慢,很多时候都提示打不开,加载不了,要刷新好多次。现在(2022年3月29日)解决的办法如下:(推荐方法3)

方法1、替换elementor编辑器加载的JS文件,现在已打不开了。将\wp-content\plugins\elementor\core\editor\editor.php,文件429,438行网址https://cdnjs.cloudflare.com/替换为https://cdnjs.loli.net/。

		wp_register_script(
			'ace',
			'https://cdnjs.loli.net/ajax/libs/ace/1.2.5/ace.js',
			[],
			'1.2.5',
			true
		);

		wp_register_script(
			'ace-language-tools',
			'https://cdnjs.loli.net/ajax/libs/ace/1.2.5/ext-language_tools.js',
			[
				'ace',
			],
			'1.2.5',
			true
		);

以后升级elementor后如果速度慢还得手动更改。

参考:来源

以上地址也可以采用七牛的静态地址搜索对应的文件地址进行替换,http://www.staticfile.org/,或者将上面的文件下载回来保存在wordpress的本机目录下。

方法2、安装wp-china-yes插件,将谷歌字体和js文件国内化,并设置为全局模式,替换掉wordpress及插件的字体和js文件。

设置后,基本上elementor都一次能打开,不用刷新很多次了。

方法3、安装耗子大佬写的插件替换掉网址,后面有下载地址,插件内容如下。

<?php /** * Plugin Name: Super-Static * Description: 一个简单的插件,将插件/主题中的国外前端资源替换为国内的加速服务 * Author: 耗子 * Author URI:https://hzbk.net/ * Version: 1.3.0 * Network: True * License: GPLv3 or later * License URI: http://www.gnu.org/licenses/gpl-3.0.html */ defined( 'ABSPATH' ) || exit; if ( ! class_exists( 'SUPER_STATIC' ) ) { class SUPER_STATIC { public function init() { /** * 替换CDNJS为WePublish维护的加速节点 */ $this->page_str_replace( 'str_replace', [
					'cdnjs.cloudflare.com/ajax/libs',
					'cdnjs.cdn.wepublish.cn'
				], 1 );
				/**
				 * 替换Google前端库为极客族维护的加速节点
				 */
				$this->page_str_replace( 'str_replace', [
					'ajax.googleapis.com',
					'gapis.geekzu.org/ajax'
				], 1 );
				/**
				 * 替换字体文件(Google Fonts)为极客族维护的加速节点
				 */
				$this->page_str_replace( 'str_replace', [
					'fonts.googleapis.com',
					'fonts.geekzu.org'
				], 1 );
				$this->page_str_replace( 'str_replace', [
					'fonts.gstatic.com',
					'gapis.geekzu.org/g-fonts'
				], 1 );
				$this->page_str_replace( 'str_replace', [
					'themes.googleusercontent.com',
					'gapis.geekzu.org/g-themes'
				], 1 );
		}

		/**
		 * @param $replace_func string 要调用的字符串关键字替换函数
		 * @param $param array 传递给字符串替换函数的参数
		 * @param $level int 替换级别:1.全局替换 3.前台替换 4.后台替换
		 */
		private function page_str_replace( $replace_func, $param, $level ) {
			if ( $level == 3 && is_admin() ) {
				return;
			} elseif ( $level == 4 && ! is_admin() ) {
				return;
			}

			add_action( 'init', function () use ( $replace_func, $param ) {
				ob_start( function ( $buffer ) use ( $replace_func, $param ) {
					$param[] = $buffer;

					return call_user_func_array( $replace_func, $param );
				} );
			} );
		}
	}

	( new SUPER_STATIC )->init();
}

super-static-1.3.0

更新于:2022年4月2日

赞(0) 打赏
未经允许不得转载:刘旭的人个博客 » wordpress打开elementor插件最近很慢解决办法
分享到: 更多 (0)
标签:

评论 抢沙发

评论前必须登录!

 

QQ :13945502电话:13913571631

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

×
订阅图标按钮