admin管理员组文章数量:1314480
I am using this code
add_action( 'wp_loaded', function()
{
global $pagenow;
// - - - - - - - - - - - - - - - - - - - - - -
// Turn on/off you Maintenance Mode (true/false)
define('IN_MAINTENANCE', true);
// - - - - - - - - - - - - - - - - - - - - - -
if(
defined( 'IN_MAINTENANCE' )
&& IN_MAINTENANCE
&& $pagenow !== 'wp-login.php'
&& ! is_user_logged_in()
) {
header('HTTP/1.1 503 Service Temporarily Unavailable');
header( 'Content-Type: text/html; charset=utf-8' );
if ( file_exists( get_template_directory() . '/maintenance.php' ) ) {
require_once( get_template_directory() . '/maintenance.php' );
}
die();
}
});
in a custom plugin to temporarily put the site in maintenance mode. It works fine but I use cron job with external call to the wp-cron.php file. Is there any way to bypass maintenance mode only for the wp-cron.php file? Maybe I'm all wrong but thanks to anyone for any input!
I am using this code
add_action( 'wp_loaded', function()
{
global $pagenow;
// - - - - - - - - - - - - - - - - - - - - - -
// Turn on/off you Maintenance Mode (true/false)
define('IN_MAINTENANCE', true);
// - - - - - - - - - - - - - - - - - - - - - -
if(
defined( 'IN_MAINTENANCE' )
&& IN_MAINTENANCE
&& $pagenow !== 'wp-login.php'
&& ! is_user_logged_in()
) {
header('HTTP/1.1 503 Service Temporarily Unavailable');
header( 'Content-Type: text/html; charset=utf-8' );
if ( file_exists( get_template_directory() . '/maintenance.php' ) ) {
require_once( get_template_directory() . '/maintenance.php' );
}
die();
}
});
in a custom plugin to temporarily put the site in maintenance mode. It works fine but I use cron job with external call to the wp-cron.php file. Is there any way to bypass maintenance mode only for the wp-cron.php file? Maybe I'm all wrong but thanks to anyone for any input!
Share Improve this question asked Nov 26, 2020 at 16:30 Daniele AsDaniele As 132 bronze badges1 Answer
Reset to default 1You can use the wp_doing_cron()
method to determine if the request comes from a cron request or not.
if(
defined( 'IN_MAINTENANCE' )
&& IN_MAINTENANCE
&& $pagenow !== 'wp-login.php'
&& ! is_user_logged_in()
&& ! wp_doing_cron()
) {
本文标签: Wp Maintenance mode and external cron job
版权声明:本文标题:Wp Maintenance mode and external cron job 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741961246a2407292.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论