Skip to content

Commit

Permalink
Merge branch 'hotfix/dependency-installer-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Hemberger committed Nov 13, 2019
2 parents 282be24 + 3ab54e8 commit e011913
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.10.4.1 (11/13/19)
* Fixed: Hotfix for WPDI_Plugin_Installer_Skin dependency installer incompatibility with WordPress 5.3.

## 1.10.4 (5/6/19)
* Fixed: Forgot to update version number, sorry!

Expand Down
42 changes: 36 additions & 6 deletions lib/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,61 @@ function mai_update_first_version() {
function mai_update_database_version() {

// Get the version number saved in the db.
$option_db_version = get_option( 'mai_db_version' );
$option_db_version = (int) get_option( 'mai_db_version' );

// Bail if the saved version is the version is greater than or equal to the current version.
if ( $option_db_version >= MAI_THEME_ENGINE_DB_VERSION ) {
if ( $option_db_version >= (int) MAI_THEME_ENGINE_DB_VERSION ) {
return;
}

if ( $option_db_version < '1100' ) {
if ( $option_db_version < 1100 ) {
mai_upgrade_1100();
}

if ( $option_db_version < '1161' ) {
if ( $option_db_version < 1161 ) {
mai_upgrade_1161();
}

if ( $option_db_version < '1400' ) {
if ( $option_db_version < 1400 ) {
mai_upgrade_1400();
}

if ( $option_db_version < 1500 ) {
mai_upgrade_1500();
}

// Update the version number option.
update_option( 'mai_db_version', MAI_THEME_ENGINE_DB_VERSION );

}

/**
* Fix the WPDI_Plugin_Installer_Skin error in Mai Theme.
*
* @since 1.10.4.1
*/
function mai_upgrade_1500() {
// Our files with an incompatible method in WP 5.3.
$files = array(
get_stylesheet_directory() . '/includes/dependencies/wp-dependency-installer.php',
get_stylesheet_directory() . '/vendor/afragen/wp-dependency-installer/wp-dependency-installer.php',
);
foreach( $files as $file ) {
if ( ! file_exists( $file ) ) {
continue;
}
$contents = file_get_contents( $file );
// If $contents does not contain the incompatible method.
if ( false === strpos ( $contents, 'public function feedback( $string ) {}' ) ) {
return;
}
// Replace the method in the contents.
$contents = str_replace( 'public function feedback( $string ) {}', 'public function feedback( $string, ...$args ) {}', $contents );
// Update the file.
file_put_contents( $file, $contents );
}
}

/**
* Update new header_style setting.
*
Expand Down Expand Up @@ -237,7 +268,6 @@ function mai_upgrade_1100() {
}
}


// Maybe update.
if ( ! empty( $settings ) ) {
// Update settings.
Expand Down
6 changes: 3 additions & 3 deletions mai-theme-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://maitheme.com/
* Description: The Mai Theme Engine plugin
*
* Version: 1.10.4
* Version: 1.10.4.1
*
* GitHub URI: maithemewp/mai-theme-engine
*
Expand Down Expand Up @@ -89,10 +89,10 @@ public function __wakeup() {
private function setup_constants() {

// Plugin version.
define( 'MAI_THEME_ENGINE_VERSION', '1.10.4' );
define( 'MAI_THEME_ENGINE_VERSION', '1.10.4.1' );

// DB version.
define( 'MAI_THEME_ENGINE_DB_VERSION', '1400' );
define( 'MAI_THEME_ENGINE_DB_VERSION', '1500' );

// Plugin Folder Path.
define( 'MAI_THEME_ENGINE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
Expand Down

0 comments on commit e011913

Please sign in to comment.