admin管理员组文章数量:1204664
I have developed a wordpress plugin and I need to delete the options I am creating when uninstalling. What I did is I created a file called uninstall.php and included the following code:
<?php
function WCM_Setup_Demo_on_uninstall()
{
//if uninstall not called from WordPress exit
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit();
$video-thumbnail1 = 'video-thumbnail1';
// For Single site
if ( !is_multisite() )
{
delete_option( $video-thumbnail1 );
}
}
?>
And included this in my main plugin file:
register_uninstall_hook('uninstall.php', 'WCM_Setup_Demo_on_uninstall');
This is how i'm registering the option in my main plugin file:
register_setting( 'baw-settings-group', 'video-thumbnail1' );
When I deactivated and deleted the plugin from the dashboard, the plugin gets deactivated but not deleted. When one press delete a blank white page comes up.
I have developed a wordpress plugin and I need to delete the options I am creating when uninstalling. What I did is I created a file called uninstall.php and included the following code:
<?php
function WCM_Setup_Demo_on_uninstall()
{
//if uninstall not called from WordPress exit
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit();
$video-thumbnail1 = 'video-thumbnail1';
// For Single site
if ( !is_multisite() )
{
delete_option( $video-thumbnail1 );
}
}
?>
And included this in my main plugin file:
register_uninstall_hook('uninstall.php', 'WCM_Setup_Demo_on_uninstall');
This is how i'm registering the option in my main plugin file:
register_setting( 'baw-settings-group', 'video-thumbnail1' );
When I deactivated and deleted the plugin from the dashboard, the plugin gets deactivated but not deleted. When one press delete a blank white page comes up.
Share Improve this question asked May 21, 2014 at 18:43 user3492795user3492795 11 bronze badge 1- When developing, always turn on debug mode! – Sisir Commented May 22, 2014 at 10:40
2 Answers
Reset to default 0Blank/white page comes up probably due to wrong variable name. It should be $video_thumbnail1
instead of $video-thumbnail1
. No need to use a variable when you can directly use the option video-thumbnail1
.
Also deactivate and delete are two different functionalities. Please refer to the Codex for uninstallation hook.
Variable $video-thumbnail1
is defined incorrectly. You cant have -
in the variable. Change it to $video_thumbnail1
.
本文标签: Wordpress plugin options need to delete after deactivate amp uninstall
版权声明:本文标题:Wordpress plugin options need to delete after deactivate & uninstall 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738675752a2106250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论