From 6e7e7cd87975846f0238a7efa4d23b19093b177c Mon Sep 17 00:00:00 2001 From: Beda Schmid Date: Thu, 9 Jun 2022 10:58:43 +0700 Subject: [PATCH] 9-06-2022 [Fixed] Plugin could not update itself. --- README.txt | 2 +- admin/class-cp-plgn-drctry-admin.php | 16 ++++++++++++++-- changelog.txt | 3 ++- readme.md | 3 ++- tukutoi-cp-directory-integration.php | 4 ++-- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index f6b9e60..0714b19 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Donate link: https://paypal.me/tukutoi Tags: directory, plugins Requires at least: 1.0.0 Tested up to: 4.9.15 -Stable tag: 1.1.2 +Stable tag: 1.1.3 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/admin/class-cp-plgn-drctry-admin.php b/admin/class-cp-plgn-drctry-admin.php index 8f9b239..0f65ff0 100644 --- a/admin/class-cp-plgn-drctry-admin.php +++ b/admin/class-cp-plgn-drctry-admin.php @@ -114,8 +114,11 @@ public function enqueue_scripts( $hook_suffix ) { /** * Install a Plugin. + * + * @since 1.1.3 Added overwrite_package argument + * @param bool $overwrite Whether to overwrite the plugin or not. Default False. */ - public function install_cp_plugin() { + public function install_cp_plugin( $overwrite = false ) { if ( ! isset( $_POST['nonce'] ) || empty( $_POST['nonce'] ) @@ -134,7 +137,7 @@ public function install_cp_plugin() { */ include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); $upgrader = new Plugin_Upgrader(); - $response = $upgrader->install( esc_url_raw( wp_unslash( $_POST['url'] ) ) ); + $response = $upgrader->install( esc_url_raw( wp_unslash( $_POST['url'] ) ), array( 'overwrite_package' => $overwrite ) ); wp_send_json( $response ); @@ -160,7 +163,16 @@ public function update_cp_plugin() { * selecting custom file URL. Only WP Can do that. * * Thus we need to manually deactivate, delete, and then install the plugin. + * We also need to make sure our own plugin can update itself. + * Since it would deactivate before deleting/updating, we need to re-intsall it instead. + * + * @since 1.0.0 Update Plugin + * @since 1.1.3 Update itself */ + if ( 'tukutoi-cp-directory-integration/tukutoi-cp-directory-integration.php' === $_POST['slug'] ) { + $this->install_cp_plugin( true ); + } + deactivate_plugins( sanitize_text_field( wp_unslash( $_POST['slug'] ) ), true ); delete_plugins( array( sanitize_text_field( wp_unslash( $_POST['slug'] ) ) ) ); $this->install_cp_plugin(); diff --git a/changelog.txt b/changelog.txt index b2a9d32..3284e65 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,5 @@ -= 1.1.2 = += 1.1.3 = +[Fixed] Plugin could not update itself. [Fixed] Request-URI Too Long when performing several searches without resetting the search. [Fixed] Unused third argument in AJAX operations removed. diff --git a/readme.md b/readme.md index 565dff7..d18c14c 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,8 @@ The plugin does not take any responsibility for Plugins downloaded from the Clas ## Changelog -### 1.1.2 +### 1.1.3 +[Fixed] Plugin could not update itself. [Fixed] Request-URI Too Long when performing several searches without resetting the search. [Fixed] Unused third argument in AJAX operations removed. diff --git a/tukutoi-cp-directory-integration.php b/tukutoi-cp-directory-integration.php index 0a58009..5087ee5 100644 --- a/tukutoi-cp-directory-integration.php +++ b/tukutoi-cp-directory-integration.php @@ -15,7 +15,7 @@ * Plugin Name: CP Plugin Directory * Plugin URI: https://www.tukutoi.com/ * Description: Integrates the ClassicPress Plugin Directory into the ClassicPress Admin Interface. - * Version: 1.1.2 + * Version: 1.1.3 * Author: bedas * Requires at least: 4.9.15 * Requires PHP: 7.0.0 @@ -37,7 +37,7 @@ * Start at version 1.0.0 and use SemVer - https://semver.org * Rename this for your plugin and update it as you release new versions. */ -define( 'CP_PLGN_DRCTRY_VERSION', '1.1.2' ); +define( 'CP_PLGN_DRCTRY_VERSION', '1.1.3' ); /** * Define the Plugin basename