mirror of
https://github.com/WenPai-org/wp-china-yes.git
synced 2025-08-03 11:11:30 +08:00
fix: cli判断
This commit is contained in:
parent
73f4d6eba5
commit
7f1b9a5672
2 changed files with 11 additions and 11 deletions
|
@ -147,7 +147,7 @@ class Super {
|
|||
global $concatenate_scripts;
|
||||
$concatenate_scripts = false;
|
||||
|
||||
$this->page_str_replace( 'preg_replace', [
|
||||
$this->page_str_replace( 'init', 'preg_replace', [
|
||||
'~' . home_url( '/' ) . '(wp-admin|wp-includes)/(css|js)/~',
|
||||
sprintf( 'https://wpstatic.admincdn.com/%s/$1/$2/', $GLOBALS['wp_version'] )
|
||||
] );
|
||||
|
@ -159,7 +159,7 @@ class Super {
|
|||
* 前台静态加速
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['frontend'] ) ) {
|
||||
$this->page_str_replace( 'preg_replace', [
|
||||
$this->page_str_replace( 'template_redirect', 'preg_replace', [
|
||||
'#(?<=[(\"\'])(?:' . quotemeta( home_url() ) . ')?/(?:((?:wp-content|wp-includes)[^\"\')]+\.(css|js)[^\"\')]+))(?=[\"\')])#',
|
||||
'https://public.admincdn.com/$0'
|
||||
] );
|
||||
|
@ -169,7 +169,7 @@ class Super {
|
|||
* Google 字体替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['googlefonts'] ) ) {
|
||||
$this->page_str_replace( 'str_replace', [
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'fonts.googleapis.com',
|
||||
'googlefonts.admincdn.com'
|
||||
] );
|
||||
|
@ -179,7 +179,7 @@ class Super {
|
|||
* Google 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['googleajax'] ) ) {
|
||||
$this->page_str_replace( 'str_replace', [
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'ajax.googleapis.com',
|
||||
'googleajax.admincdn.com'
|
||||
] );
|
||||
|
@ -189,7 +189,7 @@ class Super {
|
|||
* CDNJS 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['cdnjs'] ) ) {
|
||||
$this->page_str_replace( 'str_replace', [
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'cdnjs.cloudflare.com/ajax/libs',
|
||||
'cdnjs.admincdn.com'
|
||||
] );
|
||||
|
@ -199,7 +199,7 @@ class Super {
|
|||
* jsDelivr 前端公共库替换
|
||||
*/
|
||||
if ( ! empty( $this->settings['admincdn']['jsdelivr'] ) ) {
|
||||
$this->page_str_replace( 'str_replace', [
|
||||
$this->page_str_replace( 'init', 'str_replace', [
|
||||
'cdn.jsdelivr.net',
|
||||
'jsd.admincdn.com'
|
||||
] );
|
||||
|
@ -330,12 +330,12 @@ class Super {
|
|||
* @param $replace_func string 要调用的字符串关键字替换函数
|
||||
* @param $param array 传递给字符串替换函数的参数
|
||||
*/
|
||||
private function page_str_replace( $replace_func, $param ) {
|
||||
private function page_str_replace( $hook, $replace_func, $param ) {
|
||||
// CLI 下返回,防止影响缓冲区
|
||||
if ( class_exists( 'WP_CLI' ) ) {
|
||||
if ( php_sapi_name() == 'cli' ) {
|
||||
return;
|
||||
}
|
||||
add_action( 'template_redirect', function () use ( $replace_func, $param ) {
|
||||
add_action( $hook, function () use ( $replace_func, $param ) {
|
||||
ob_start( function ( $buffer ) use ( $replace_func, $param ) {
|
||||
$param[] = $buffer;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Description: 文派叶子 🍃(WP-China-Yes)是中国 WordPress 生态基础设施软件,犹如落叶新芽,生生不息。
|
||||
* Author: 文派开源
|
||||
* Author URI: https://wp-china-yes.com
|
||||
* Version: 3.6.4
|
||||
* Version: 3.6.5
|
||||
* License: GPLv3 or later
|
||||
* Text Domain: wp-china-yes
|
||||
* Domain Path: /languages
|
||||
|
@ -19,7 +19,7 @@ namespace WenPai\ChinaYes;
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
define( 'CHINA_YES_VERSION', '3.6.4' );
|
||||
define( 'CHINA_YES_VERSION', '3.6.5' );
|
||||
define( 'CHINA_YES_PLUGIN_FILE', __FILE__ );
|
||||
define( 'CHINA_YES_PLUGIN_URL', plugin_dir_url( CHINA_YES_PLUGIN_FILE ) );
|
||||
define( 'CHINA_YES_PLUGIN_PATH', plugin_dir_path( CHINA_YES_PLUGIN_FILE ) );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue