Hello @ricard76rr,
You can update wpmm_settings option and set status to 1. But you also have to clear the cache (programmatically) if you have a cache plugin installed and activated (example for W3 Total Cache and WP Super Cache).
Here you can see the default content of wpmm_settings option: github repo
So you need something like this:
function wpmm_custom_trigger($status) {
if (!in_array($status, array(0, 1))) {
return;
}
if (!class_exists('WP_Maintenance_Mode')) {
return;
}
// get settings
$settings = WP_Maintenance_Mode::get_instance()->get_plugin_settings();
// set status
$settings['general']['status'] = $status;
$settings['general']['status_date'] = date('Y-m-d H:i:s');
// save settings
update_option('wpmm_settings', $settings);
// here must be a clear cache mechanism if you have a cache plugin installed and activated...
}
wpmm_custom_trigger(1); // to enable
wpmm_custom_trigger(0); // to disable
Thanks.
-
This reply was modified 8 years, 10 months ago by
George J.
-
This reply was modified 8 years, 10 months ago by
George J.
-
This reply was modified 8 years, 10 months ago by
George J.
-
This reply was modified 8 years, 10 months ago by
George J.
Hello George, you’re gorgeous :).
This works perfectly.
Thanks for your help, you do a great job,
Best regards,
Ricard.