$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugin operation launch every time i click on page|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugin operation launch every time i click on page

matteradmin8PV0评论

I created a plugin for specific heavy batch operation but it seems that every time I click on any other place (list posts , list page , ....) the heavy operation is launched again, so I want to know how i can launch the plugin operation only when I activate him like singleton.

bellow the code I use to avoid this kind of behavior but it doesn't work:

register_activation_hook( __FILE__, 'my_plugin_activation' );
function my_plugin_activation() {
  add_option( 'my_plugin_activation','just-activated' );
}

add_action( 'admin_init','my_plugin_initialize' );
function my_plugin_initialize() {
    if( is_admin() && get_option( 'my_plugin_activation' ) == 'just-activated' ) {
    delete_option( 'my_plugin_activation' );
        flush_rewrite_rules();
    }
}

Could you help .

Post a comment

comment list (0)

  1. No comments so far