Skip to content

Commit

Permalink
9-06-2022
Browse files Browse the repository at this point in the history
[Fixed] Plugin could not update itself.
  • Loading branch information
smileBeda committed Jun 9, 2022
1 parent 1948509 commit 6e7e7cd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 14 additions & 2 deletions admin/class-cp-plgn-drctry-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] )
Expand All @@ -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 );

Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions tukutoi-cp-directory-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6e7e7cd

Please sign in to comment.