Так что у меня возникла небольшая проблема с выяснением того, как сравнить сегодняшнюю дату с одним из моих выборов.
Вот что я получил до сих пор!
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();
}
Вы можете сделать это таким образом.
Если текущее время больше пользовательской даты, отключите плагин.
$custom_date = "01/11/2017";
if (strtotime($custom_date) < time()){
deactivate_plugin();
}
Вы также можете указать дату и время, если хотите отключить плагин после определенной даты и времени
$ custom_date = «01.01.2017 23:59:59»;
Пожалуйста, дайте мне знать, если этот код поможет вам. Спасибо
Я рекомендую вам использовать функцию strtotime () для сравнения дат в PHP:
http://php.net/manual/en/function.strtotime.php
$custom_date = "01/11/2017";
if (strtotime("now") == strtotime($custom_date))
{
deactivate_plugin();
}