admin管理员组文章数量:1289363
please how do I activate a plugin after a set period of time automatically. For example, let's say I want to activate Jetpack automatically after 3 weeks. Thanks
please how do I activate a plugin after a set period of time automatically. For example, let's say I want to activate Jetpack automatically after 3 weeks. Thanks
Share Improve this question asked Aug 13, 2021 at 15:40 Cinnia EntertainmentCinnia Entertainment 51 bronze badge 6 | Show 1 more comment1 Answer
Reset to default 0Add this to the functions.php
file of your active (child) theme-
add_action( 'init', 'wpse_393267_activate_plugin' );
function wpse_393267_activate_plugin() {
if( !function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugin_to_activate = 'jetpack/jetpack.php'; // plugin-dir/plugin-file.php
$date_to_activate = '2021-08-13'; // YYYY-MM-DD
if( is_plugin_active( $plugin_to_activate ) ) return;
if( time() >= strtotime( $date_to_activate ) ) {
activate_plugin( $plugin_to_activate );
}
}
Change the $plugin_to_activate
and $date_to_activate
as you want.
本文标签: Activate Plugin Automatically After Set Time
版权声明:本文标题:Activate Plugin Automatically After Set Time 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741390298a2376063.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
functions.php
file of your active (child) theme. Would that work for you? – mukto90 Commented Aug 13, 2021 at 16:03