Is there an option to execute javascript file only on plugin deactivation

I'm creating a custom plugin for WordPress and I'm trying to execute javascript file only on plugin deactivati

I'm creating a custom plugin for WordPress and I'm trying to execute javascript file only on plugin deactivation.

I'm using register_deactivation_hook() and wp_enqueue_script() to execute file only on plugin deactivation.

There are no errors in the code since the javascript code works well if it is called outside the register_deactivation_hook()

This is what I've tried so far:

register_deactivation_hook( __FILE__, 'deactivation' );
function deactivation() {
    function delete_rest_api() {
        wp_enqueue_script('deactivation_data_api', plugins_url('assets/js/deactivation_data_api.js', __FILE__));
    }
    add_action( 'admin_enqueue_scripts', 'delete_rest_api' );
}

In the end, the plugin needs to execute that javascript file only during plugin deactivation.

Thanks in advance.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745286235a4620577.html

相关推荐

  • Is there an option to execute javascript file only on plugin deactivation

    I'm creating a custom plugin for WordPress and I'm trying to execute javascript file only on plugin deactivati

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信