plugin operation launch every time i click on page

admin2025-06-03  2

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 .

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748889916a314570.html

最新回复(0)