Skip to content

Added uninstall.php file#4

Open
coder-karen wants to merge 2 commits into
wpmark:masterfrom
coder-karen:feat-uninstall
Open

Added uninstall.php file#4
coder-karen wants to merge 2 commits into
wpmark:masterfrom
coder-karen:feat-uninstall

Conversation

@coder-karen

Copy link
Copy Markdown

Added uninstall.php to make sure database is cleaned up after deactivating and deleting plugin.

Comment thread uninstall.php Outdated

/* If uninstall not called from WordPress, then exit. */
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
wp_die( sprintf( __( '%s should only be called when uninstalling the plugin.', 'wdp-plugin' ), '<code>' . __FILE__ . '</code>' ) );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coder-karen I am not sure the text domain is correct here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right it isn’t. I’ll submit a new commit to this pull request with an updated file.

Comment thread uninstall.php


/* Deleting FFPW widget option row in database */
delete_option('widget_FFPW_Flexible_Featured_Post');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coder-karen can you remind we what this is please?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (delete_option) removes the row in the wp_options table of the database with the name of ‘widget_ffpw_flexible_featured_post’. This option was remaining in the database after deactivation and deletion of the plugin.

Comment thread uninstall.php Outdated
/* Deleting post meta data added by plugin */
function delete_ffpw_meta() {

global $wpdb;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coder-karen is there a need to globalise this variable as it doesn't look as though it is used?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - since it isn’t actually needed to delete the post meta, there doesn’t seem to be a point in keeping it. In the wp-includes/post.php file delete_post_meta calls delete_metadata, which uses the global $wpdb variable, but it is defined in that file. So I will remove it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants