From 42393565c2dfc066c104c40ba301b2f516431f6d Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Mon, 12 Dec 2022 16:25:51 -0400 Subject: [PATCH 1/2] revert upload-release-asset --- .github/workflows/releases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 1b215e6a4..0938043e6 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -33,7 +33,7 @@ jobs: - name: Upload Release Asset id: upload-release-asset - uses: dream-encode/upload-release-asset-node16@v2 + uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From 9a2e35650e767b3c044dac4b38b78e347b35b381 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Mon, 12 Dec 2022 16:41:28 -0400 Subject: [PATCH 2/2] fix uninstall for Freemius --- CHANGES.md | 1 + src/Git_Updater/GU_Freemius.php | 21 +++++++++++++++++ uninstall.php | 41 --------------------------------- 3 files changed, 22 insertions(+), 41 deletions(-) delete mode 100644 uninstall.php diff --git a/CHANGES.md b/CHANGES.md index 7105ec5a0..19606ee74 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ * set Git Updater to auto-update with new `$db_version` * replace Appsero SDK with Freemius SDK * suspend Freemius plugin updating for Git Updater +* fix uninstall.php for Freemius #### 11.1.10 / 2022-11-05 * fix Appsero cron task from running more than scheduled diff --git a/src/Git_Updater/GU_Freemius.php b/src/Git_Updater/GU_Freemius.php index ffe5c5e06..3fbab96a2 100644 --- a/src/Git_Updater/GU_Freemius.php +++ b/src/Git_Updater/GU_Freemius.php @@ -91,6 +91,7 @@ function gu_fs() { $gu_fs->add_filter( 'plugin_icon', [ $this, 'add_icon' ] ); $gu_fs->add_filter( 'is_submenu_visible', [ $this, 'is_submenu_visible' ], 10, 2 ); $gu_fs->add_filter( 'permission_list', [ $this, 'permission_list' ] ); + gu_fs()->add_action( 'after_uninstall', [ $this, 'uninstall_cleanup' ] ); // $gu_fs->add_filter( 'show_deactivation_feedback_form', '__return_false' ); $this->remove_fs_plugin_updater_hooks( $gu_fs ); @@ -184,4 +185,24 @@ public function remove_fs_plugin_updater_hooks( \Freemius $gu_fs ) { ] ); } + + /** + * Uninstall. + * + * @return void + */ + public function uninstall_cleanup() { + $options = [ 'github_updater', 'github_updater_api_key', 'github_updater_remote_management', 'git_updater', 'git_updater_api_key', 'git_updater_additions' ]; + foreach ( $options as $option ) { + delete_option( $option ); + delete_site_option( $option ); + } + + global $wpdb; + $table = is_multisite() ? $wpdb->base_prefix . 'sitemeta' : $wpdb->base_prefix . 'options'; + $column = is_multisite() ? 'meta_key' : 'option_name'; + $delete_string = 'DELETE FROM ' . $table . ' WHERE ' . $column . ' LIKE %s LIMIT 1000'; + + $wpdb->query( $wpdb->prepare( $delete_string, [ '%ghu-%' ] ) ); // phpcs:ignore + } } diff --git a/uninstall.php b/uninstall.php deleted file mode 100644 index 15e8b26a5..000000000 --- a/uninstall.php +++ /dev/null @@ -1,41 +0,0 @@ -base_prefix . 'sitemeta' : $wpdb->base_prefix . 'options'; -$column = is_multisite() ? 'meta_key' : 'option_name'; -$delete_string = 'DELETE FROM ' . $table . ' WHERE ' . $column . ' LIKE %s LIMIT 1000'; - -$wpdb->query( $wpdb->prepare( $delete_string, [ '%ghu-%' ] ) ); // phpcs:ignore