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
.