From 0d054567c0ab6eaaed6dd7727d094bc35dd1d7c1 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Wed, 31 Aug 2022 11:02:07 -0700 Subject: [PATCH] fix rename_on_activation for move_dir Fixes https://github.com/afragen/git-updater/issues/999 --- CHANGES.md | 3 +++ git-updater.php | 2 +- src/Git_Updater/Bootstrap.php | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e416ef634..84395447e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ #### [unreleased] +#### 11.0.6 / 2022-08-31 +* fix `rename_on_activation` with `move_dir` + #### 11.0.5 / 2022-08-29 * now requires WP 5.9 for readme parser `str_contains()` polyfill diff --git a/git-updater.php b/git-updater.php index 4af24027a..0ef4b2245 100644 --- a/git-updater.php +++ b/git-updater.php @@ -12,7 +12,7 @@ * Plugin Name: Git Updater * Plugin URI: https://git-updater.com * Description: A plugin to automatically update GitHub hosted plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist. - * Version: 11.0.5 + * Version: 11.0.6 * Author: Andy Fragen * License: MIT * Domain Path: /languages diff --git a/src/Git_Updater/Bootstrap.php b/src/Git_Updater/Bootstrap.php index e6ace0b2c..d28b67b8d 100644 --- a/src/Git_Updater/Bootstrap.php +++ b/src/Git_Updater/Bootstrap.php @@ -159,8 +159,16 @@ public function rename_on_activation() { update_site_option( 'git_updater', array_merge( $options, [ 'current_branch_git-updater' => 'develop' ] ) ); } + require_once __DIR__ . '/Shim.php'; if ( $slug && 'git-updater/git-updater.php' !== $slug ) { - move_dir( $plugin_dir . dirname( $slug ), $plugin_dir . 'git-updater' ); + if ( function_exists( 'move_dir' ) ) { + $result = \move_dir( $plugin_dir . dirname( $slug ), $plugin_dir . 'git-updater' ); + } else { + $result = move_dir( $plugin_dir . dirname( $slug ), $plugin_dir . 'git-updater' ); + } + if ( \is_wp_error( $result ) ) { + return $result; + } } } }