首页 WP 免FTP和屏蔽更新的方法

WP 免FTP和屏蔽更新的方法

牛仔抄 2020-11-5 0 204

1,免FTP安装插件和主题:

在wp-config.php中加入以下代码:

/** 免FTP */

define("FS_METHOD", "direct");

define("FS_CHMOD_DIR", 0777);

define("FS_CHMOD_FILE", 0777);

# 停掉wp的自动任务脚本。

define( 'DISABLE_WP_CRON', true );

如果是用docker compose,在compose中加入如下服务:

# 在你的 docker-compose.yml 中追加一个超轻量的定时任务容器

 wp-cron:

   image: alpine

   container_name: wp-cron

   command: >

     sh -c "

     while true; do

       sleep 600;

       wget -q -O - --header="Host: a.xkelectronics.com" http://nginx/wp-cron.php?doing_wp_cron >/dev/null 2>&1;

     done

     "

   restart: always

   networks:

     - webnet

上面的nginx是compose中的服务名或者容器名。

2,屏蔽更新:

在相应主题的functions.php后面加入以下代码:

function remove_core_updates(){

   global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);

}

add_filter('pre_site_transient_update_core','remove_core_updates');  //WordPress核心

add_filter('pre_site_transient_update_plugins','remove_core_updates'); //WordPress插件

add_filter('pre_site_transient_update_themes','remove_core_updates'); //WordPress主题

作者: 牛仔抄
牛仔抄

迷途小书童,热衷于电脑与网络技术,自学多年,一事无成。

发表评论: