2016-03-29 67 views
1

我想調用一個js文件,該文件具有可以調用我的api的功能。我的代碼是..如何在關閉wordpress插件時調用java腳本

<?php 
. 
. // rest all code................................. 
. 
. 

/* Runs on plugin deactivation*/ 
register_deactivation_hook(__FILE__, 'Pushbiz_remove'); 

function Pushbiz_remove() { 
/* Deletes the database field */ 

delete_option('PushBIZ_firstCreation'); 
delete_option('VarPushBIZapikey'); 
delete_option('PushBIZRegUrl'); 

wp_register_script('DeactivationJS', plugins_url('/admin/js/deactivation.js', __FILE__)); 
wp_enqueue_script('DeactivationJS'); 

} 
?> 

我無法在停用插件時調用deactivation.js。如何在停用事件時調用此Java腳本。

回答

0

請問您可以檢查下面的代碼嗎?

/* Runs on plugin deactivation*/ 
register_deactivation_hook(__FILE__, 'Pushbiz_remove'); 

function Pushbiz_remove() { 
/* Deletes the database field */ 

    delete_option('PushBIZ_firstCreation'); 
    delete_option('VarPushBIZapikey'); 
    delete_option('PushBIZRegUrl'); 

    add_action('wp_enqueue_scripts', 'DeactivationJS_scripts'); 
} 
function DeactivationJS_scripts(){ 
    wp_enqueue_script('DeactivationJS', plugin_dir_url(__FILE__) .'/admin/js/deactivation.js'); 
}