Contact Form 7 503 ajax response in maintenance mode (hardcode fix included)
-
I’ve created my custom
wp-content/wp-maintenance-mode.php
template, which I saw is supported in
init()
function, because in code it looks for this file over at wp-content. SO I added
wp_head();
before end of </head>
and before end of </body> added_wp_footer_scripts();
to load all necessary js for CF7. After lots of reading, debugging var_dumping, hard-coding I found a hardcode fix. But I would appreciate a long term solution. Because my fix could be removed any update if not looked into, or it should be added to
wp-content/plugins/wp-maintenance-mode/includes/classes/wp-maintenance-mode.php
. So here is the fix:
Find init() function on last mentioned file. In my case line: 419.
At the end or beginning, up to your preferences, of if statement add this validation rule:
&& !intval($_POST[‘_wpcf7_is_ajax_call’]), it can be as well !isset, or !empty, but I found that $_POST[‘_wpcf7_is_ajax_call’] value is always 1, so probably it is like that for a reason, so I left intval validation. As conclusion: this should prevents from loading 503 header and returningmaintenance.php or wp-content/wp-maintenance-mode.php html.
P.S. After changes if statement in init() function should look something like that:
……public function init() { /** * CHECKS */ if ( (!$this->check_user_role()) && !strstr($_SERVER['PHP_SELF'], 'wp-cron.php') && !strstr($_SERVER['PHP_SELF'], 'wp-login.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/') && !strstr($_SERVER['PHP_SELF'], 'async-upload.php') && !(strstr($_SERVER['PHP_SELF'], 'upgrade.php') && $this->check_user_role()) && !strstr($_SERVER['PHP_SELF'], '/plugins/') && !strstr($_SERVER['PHP_SELF'], '/xmlrpc.php') && !$this->check_exclude() && !$this->check_search_bots() && !intval($_POST['_wpcf7_is_ajax_call']) ) { // HEADER STUFF
……
- The topic ‘Contact Form 7 503 ajax response in maintenance mode (hardcode fix included)’ is closed to new replies.