Skip to content

Commit

Permalink
✨ Auto delete DB table after uninstallation.
Browse files Browse the repository at this point in the history
  • Loading branch information
daomapsieucap committed Feb 10, 2022
1 parent ee5d591 commit 43011a0
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 63 deletions.
21 changes: 0 additions & 21 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
## Changelog

A complete listing of all notable changes to Lipsum Dynamo are documented
in [CHANGELOG.md](https://github.com/daomapsieucap/lipsum-dynamo/blob/master/CHANGELOG.md).
in [CHANGELOG.md](https://github.com/daomapsieucap/lipsum-dynamo/blob/master/changelog.txt).
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
== Changelog ==

= 2.1 =
*Release Date - 10 February 2022*

* Changed: Auto delete DB table after uninstallation.

= 2.0 =
*Release Date - 28 October 2021*

Expand Down
2 changes: 1 addition & 1 deletion includes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ function lipnamo_array_key_exists($key, $atts, $default = ''){

if(!function_exists('lipnamo_get_option')){
function lipnamo_get_option($key){
return lipnamo_array_key_exists($key, get_option('lipsum_dynamo'));
return lipnamo_array_key_exists($key, get_option('lipsum-dynamo-data'));
}
}
26 changes: 3 additions & 23 deletions includes/setting/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function lipnamo_admin_page(){

<?php settings_errors(); ?>

<form class="lipnamo" method="post" action="<?php echo get_admin_url() . 'options.php'; ?>">
<form class="lipnamo" method="post" action="options.php">
<?php
settings_fields('lipnamo_data_group');
do_settings_sections('lipsum-dynamo-data');
Expand All @@ -47,7 +47,7 @@ public function lipnamo_admin_page(){
public function lipnamo_data_page_init(){
register_setting(
'lipnamo_data_group',
'lipsum_dynamo_data',
'lipsum-dynamo-data',
array($this, 'sanitize_text_field')
);

Expand All @@ -65,14 +65,6 @@ public function lipnamo_data_page_init(){
'lipsum-dynamo-data', // page
'lipnamo_data_setting_section' // section
);

add_settings_field(
'setting_delete_data', // id
'Cleanup plugin data', // title
array($this, 'lipnamo_data_setting_delete'), // callback
'lipsum-dynamo-data', // page
'lipnamo_data_setting_section' // section
);
}

public function lipnamo_admin_section_info(){
Expand All @@ -82,24 +74,12 @@ public function lipnamo_data_setting_delete_generated(){
?>
<fieldset>
<label for="setting_delete_generated">
<input type="checkbox" name="lipsum_dynamo[setting_delete_generated]" id="setting_delete_generated"
<input type="checkbox" name="lipsum-dynamo-data[setting_delete_generated]" id="setting_delete_generated"
value="yes" <?php checked(esc_attr(lipnamo_get_option('setting_delete_generated')), 'yes'); ?> />
</label>
</fieldset>
<?php
}

public function lipnamo_data_setting_delete(){
?>
<fieldset>
<label for="setting_delete">
<input type="checkbox" name="lipsum_dynamo[setting_delete]" id="setting_delete"
value="yes" <?php checked(esc_attr(lipnamo_get_option('setting_delete')), 'yes'); ?> />
</label>
<p class="description"><?php echo __("This setting will the plugin database. It will keep your generated dummy data.", "lipsum-dynamo"); ?></p>
</fieldset>
<?php
}
}

new Lipsum_Dynamo_Data_Setting();
14 changes: 6 additions & 8 deletions lipsum-dynamo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Lipsum Dynamo
* Plugin URI: https://wordpress.org/plugins/lipsum-dynamo/
* Description: 🖨 Generate dummy content for demo purpose
* Version: 2.0
* Version: 2.1
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Dao
Expand All @@ -25,7 +25,7 @@
* Definitions
*/

define('LIPNAMO_VERSION', '2.0');
const LIPNAMO_VERSION = '2.1';
define("LIPNAMO_DIR", plugin_dir_path(__FILE__));
define("LIPNAMO_ASSETS_URL", plugin_dir_url(__FILE__) . 'assets/');

Expand Down Expand Up @@ -108,10 +108,8 @@ function lipnamo_uninstall(){
}
}

if(lipnamo_get_option('setting_delete')){
// Delete plugin data
$sql = "DROP TABLE IF EXISTS $table_name";
$wpdb->query($sql);
delete_option('lipsum_dynamo');
}
// Delete plugin data
$sql = "DROP TABLE IF EXISTS $table_name";
$wpdb->query($sql);
delete_option('lipsum_dynamo');
}
14 changes: 5 additions & 9 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: daomapsieucap
Tags: lorem ipsum, dummy text generator, lorem ipsum generator
Requires at least: 4.7
Tested up to: 5.8
Tested up to: 5.9
Requires PHP: 7.2
Stable tag: 2.0
Stable tag: 2.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -28,11 +28,7 @@ Generate dummy content for demo purpose

== Changelog ==

= 2.0 =
*Release Date - 28 October 2021*
= 2.1 =
*Release Date - 10 February 2022*

* New: New menu for Lipsum Dynamo.
* New: Cleanup tool to generate dummy items of specific post type.
* New: Default post author set to configured Administration Email Address in Site Settings.
* Changed: Exclude attachment post type in Lipsum Dynamo.
* Fixed: Missing one item when generating dummy.
* Changed: Auto delete DB table after uninstallation.

0 comments on commit 43011a0

Please sign in to comment.