I have created custom Divi module and then convert it to the plugin. Divi page builder saves local storage variables so my module is not displaying in the modules list until I clears local storage.
I have added JS file that clears storage and its works fine.
but I want that js runs only at activation and deactivation.
Below is Plugin activation code
function angelleye_setup_For_paypal_divi_install()
{
// trigger our function that registers PayPal for Divi plugin.
angelleye_setup_for_paypal_divi();
}
register_activation_hook( __FILE__, 'angelleye_setup_For_paypal_divi_install' );
This is how I adding my js file in plugin.
function paypal_divi_clear_local_storage () {
wp_enqueue_script( 'paypal_divi_clear_local_storage', plugins_url('assets/js/clear_local_storage.js',__FILE__ ));
}
add_action( 'admin_enqueue_scripts', 'paypal_divi_clear_local_storage', 9999 );
Here add_action is not calling from the activation function.
2
Answers
I hope this may help you.
Please include these lines in your plugin file..
Create new function that add your custom option and call function on activation hook:
New Function
Set below code on time of init action this will work on activation time: