hlashbrooke / WordPress-Plugin-Template

A robust code template for creating a standards-compliant WordPress plugin.
https://hughlashbrooke.com/
GNU General Public License v2.0
1.03k stars 329 forks source link

proposal for a universal uninstall script to clean up after plugin is deleted #72

Open alekseyn1 opened 5 years ago

alekseyn1 commented 5 years ago

Hello, I would like to propose the following uninstall.php

if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    exit;
}

//change your plugin prefix here
delete_options_prefixed( 'test_' );

function delete_options_prefixed( $prefix ) {
    global $wpdb;
    $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$prefix}%'" );
}
jonathanbossenger commented 5 years ago

Hey @alekseyn1 thanks for this.

Are you able to open a pull request with these changes. I can't guarantee I will be able to merge it very soon, but if it's open I can at least try and prioritise it.

alekseyn1 commented 5 years ago

Done :-)