So I am having a bit of an issue with figuring out how to compare today's date with one of my choosing.
Here is what I have gotten so far!
function deactivate_plugin() {
// Full path to WordPress from the root
$wordpress_path = 'http://mainstaycomputing.com/';
// Absolute path to plugins dir
$plugin_path = $wordpress_path.'wp-content/plugins/';
// Absolute path to your specific plugin
$my_plugin = $plugin_path.'dw-halloween/dw-halloween.php';
// Check to see if plugin is already active
if(is_plugin_active($my_plugin)) {
deactivate_plugins($my_plugin);
}
}
// trying to disable the plugin if past a certain date - in this case
// halloween
if ( date("Y/m/d") == date(2017-01-11)) {
deactivate_plugin();
}
I recommend to you use strtotime() function to compare dates in PHP: http://php.net/manual/en/function.strtotime.php
$custom_date = "01/11/2017";
if (strtotime("now") == strtotime($custom_date))
{
deactivate_plugin();
}
You can do it this way. If current time is greater than custom date then deactivate the plugin.
$custom_date = "01/11/2017";
if (strtotime($custom_date) < time()){
deactivate_plugin();
}
You can also specify date and time if you want to deactivate the plugin after specific date and time $custom_date = "01/11/2017 23:59:59";
Please let me know if this code helps you. Thanks