-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a4d1ab
commit 9faaa89
Showing
476 changed files
with
59,230 additions
and
0 deletions.
There are no files selected for viewing
610 changes: 610 additions & 0 deletions
610
wp-content/plugins/wp-migrate-db-pro/class/ClassMap.php
Large diffs are not rendered by default.
Oops, something went wrong.
210 changes: 210 additions & 0 deletions
210
wp-content/plugins/wp-migrate-db-pro/class/Common/Addon/Addon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
<?php | ||
|
||
namespace DeliciousBrains\WPMDB\Common\Addon; | ||
|
||
use DeliciousBrains\WPMDB\Common\Error\ErrorLog; | ||
use DeliciousBrains\WPMDB\Common\Helpers; | ||
use DeliciousBrains\WPMDB\Common\Properties\Properties; | ||
use DeliciousBrains\WPMDB\Common\Settings\Settings; | ||
use DeliciousBrains\WPMDB\Common\Util\Util; | ||
use DeliciousBrains\WPMDB\Pro\Api; | ||
use DeliciousBrains\WPMDB\WPMDBDI; | ||
|
||
/** | ||
* Class Addon | ||
* | ||
* Manages addon compatibility and versioning/downloading addons | ||
* | ||
* @package DeliciousBrains\WPMDB\Pro | ||
*/ | ||
class Addon | ||
{ | ||
|
||
/** | ||
* @var ErrorLog | ||
*/ | ||
private $log; | ||
/** | ||
* @var Settings | ||
*/ | ||
private $settings; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
public $addons; | ||
|
||
/** | ||
* @var Properties | ||
*/ | ||
protected $props; | ||
|
||
public function __construct( | ||
ErrorLog $log, | ||
Settings $settings, | ||
Properties $properties | ||
) { | ||
$this->props = $properties; | ||
$this->log = $log; | ||
$this->settings = $settings; | ||
|
||
$this->setAddons(); | ||
} | ||
|
||
public function getAddons() | ||
{ | ||
return $this->addons; | ||
} | ||
|
||
/** | ||
* Set versions of Addons required for this version of WP Migrate DB Pro | ||
*/ | ||
public function setAddons() | ||
{ | ||
$this->addons = array( | ||
'wp-migrate-db-pro-media-files/wp-migrate-db-pro-media-files.php' => array( | ||
'name' => 'Media Files', | ||
'required_version' => '1.4.18', | ||
), | ||
'wp-migrate-db-pro-cli/wp-migrate-db-pro-cli.php' => array( | ||
'name' => 'CLI', | ||
'required_version' => '1.3.6', | ||
), | ||
'wp-migrate-db-pro-multisite-tools/wp-migrate-db-pro-multisite-tools.php' => array( | ||
'name' => 'Multisite Tools', | ||
'required_version' => '1.2.7', | ||
), | ||
'wp-migrate-db-pro-theme-plugin-files/wp-migrate-db-pro-theme-plugin-files.php' => array( | ||
'name' => 'Theme & Plugin Files', | ||
'required_version' => '1.0.6', | ||
), | ||
); | ||
} | ||
|
||
public function register() | ||
{ | ||
$this->setAddons(); | ||
|
||
// allow developers to change the temporary prefix applied to the tables | ||
$this->props->temp_prefix = apply_filters('wpmdb_temporary_prefix', $this->props->temp_prefix); | ||
} | ||
|
||
public function is_addon_outdated($addon_basename) | ||
{ | ||
$addon_slug = current(explode('/', $addon_basename)); | ||
|
||
// If pre-1.1.2 version of Media Files addon, then it is outdated | ||
if (!isset($GLOBALS['wpmdb_meta'][$addon_slug]['version'])) { | ||
return true; | ||
} | ||
|
||
$installed_version = $GLOBALS['wpmdb_meta'][$addon_slug]['version']; | ||
$required_version = $this->addons[$addon_basename]['required_version']; | ||
|
||
return version_compare($installed_version, $required_version, '<'); | ||
} | ||
|
||
public function get_plugin_name($plugin = false) | ||
{ | ||
if (!is_admin()) { | ||
return false; | ||
} | ||
|
||
$plugin_basename = (false !== $plugin ? $plugin : $this->props->plugin_basename); | ||
|
||
$plugins = get_plugins(); | ||
|
||
if (!isset($plugins[$plugin_basename]['Name'])) { | ||
return false; | ||
} | ||
|
||
return $plugins[$plugin_basename]['Name']; | ||
} | ||
|
||
public function get_latest_version($slug) | ||
{ | ||
if ( ! Util::isPro()) { | ||
return false; | ||
} | ||
|
||
$data = $this->get_upgrade_data(); | ||
|
||
if (!isset($data[$slug])) { | ||
return false; | ||
} | ||
|
||
$latest_version = empty ($data[$slug]['version']) ? false : $data[$slug]['version']; | ||
|
||
if (!isset($data[$slug]['beta_version'])) { | ||
// No beta version available | ||
return $latest_version; | ||
} | ||
|
||
if (version_compare($data[$slug]['version'], $data[$slug]['beta_version'], '>')) { | ||
// Stable version greater than the beta | ||
return $latest_version; | ||
} | ||
|
||
if (\DeliciousBrains\WPMDB\Pro\Beta\BetaManager::is_rolling_back_plugins()) { | ||
// We are in the process of rolling back to stable versions | ||
return $latest_version; | ||
} | ||
|
||
//Reload the settings to get fresh beta optin value | ||
$this->settings->load_settings(); | ||
|
||
if (!\DeliciousBrains\WPMDB\Pro\Beta\BetaManager::has_beta_optin($this->settings->get_settings())) { | ||
// Not opted in to beta updates | ||
// The required version isn't a beta version | ||
return $latest_version; | ||
} | ||
|
||
return $data[$slug]['beta_version']; | ||
} | ||
|
||
public function get_upgrade_data() | ||
{ | ||
$api = WPMDBDI::getInstance()->get('api'); | ||
$info = get_site_transient('wpmdb_upgrade_data'); | ||
|
||
if (isset($info['version'])) { | ||
delete_site_transient( Helpers::get_licence_response_transient_key() ); | ||
delete_site_transient('wpmdb_upgrade_data'); | ||
$info = false; | ||
} | ||
|
||
if ($info) { | ||
return $info; | ||
} | ||
|
||
$data = $api->dbrains_api_request('upgrade_data'); | ||
|
||
$data = json_decode($data, true); | ||
|
||
/* | ||
We need to set the transient even when there's an error, | ||
otherwise we'll end up making API requests over and over again | ||
and slowing things down big time. | ||
*/ | ||
$default_upgrade_data = array('wp-migrate-db-pro' => array('version' => $GLOBALS['wpmdb_meta'][$this->props->core_slug]['version'])); | ||
|
||
if (!$data) { | ||
set_site_transient('wpmdb_upgrade_data', $default_upgrade_data, $this->props->transient_retry_timeout); | ||
$this->log->log_error('Error trying to decode JSON upgrade data.'); | ||
|
||
return false; | ||
} | ||
|
||
if (isset($data['errors'])) { | ||
set_site_transient('wpmdb_upgrade_data', $default_upgrade_data, $this->props->transient_retry_timeout); | ||
$this->log->log_error('Error trying to get upgrade data.', $data['errors']); | ||
|
||
return false; | ||
} | ||
|
||
set_site_transient('wpmdb_upgrade_data', $data, $this->props->transient_timeout); | ||
|
||
return $data; | ||
} | ||
|
||
} |
136 changes: 136 additions & 0 deletions
136
wp-content/plugins/wp-migrate-db-pro/class/Common/Addon/AddonAbstract.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?php | ||
|
||
namespace DeliciousBrains\WPMDB\Common\Addon; | ||
|
||
use DeliciousBrains\WPMDB\Common\Properties\DynamicProperties; | ||
use DeliciousBrains\WPMDB\Common\Properties\Properties; | ||
|
||
abstract class AddonAbstract | ||
{ | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $version_required; | ||
/** | ||
* @var Properties | ||
*/ | ||
protected $properties; | ||
/** | ||
* @var Addon | ||
*/ | ||
protected $addon; | ||
/** | ||
* @var DynamicProperties | ||
*/ | ||
protected $dynamic_properties; | ||
/** | ||
* @var | ||
*/ | ||
protected $plugin_slug; | ||
/** | ||
* @var | ||
*/ | ||
protected $plugin_version; | ||
/** | ||
* @var | ||
*/ | ||
protected $addon_name; | ||
|
||
protected $plugin_basename = false; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
protected $licensed = false; | ||
|
||
function __construct( | ||
Addon $addon, | ||
Properties $properties | ||
) { | ||
$this->addon = $addon; | ||
$this->properties = $properties; | ||
$this->dynamic_properties = DynamicProperties::getInstance(); | ||
$this->dynamic_properties->is_addon = true; | ||
} | ||
|
||
function meets_version_requirements($version_required) | ||
{ | ||
$wpmdb_pro_version = $GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['version']; | ||
$result = version_compare($wpmdb_pro_version, $version_required, '>='); | ||
$this->version_required = $version_required; | ||
|
||
|
||
if ($result) { | ||
// If pre-1.1.2 version of Media Files addon, | ||
// then it's not supported by this version of core | ||
if (empty($this->properties->plugin_version)) { | ||
$result = false; | ||
} else { // Check that this version of core supports the addon version | ||
$plugin_basename = sprintf('%1$s/%1$s.php', $this->plugin_slug); | ||
$this->plugin_basename = $plugin_basename; | ||
$required_addon_version = $this->addon->getAddons()[$plugin_basename]['required_version']; | ||
$result = version_compare($this->properties->plugin_version, $required_addon_version, '>='); | ||
} | ||
} | ||
|
||
if (false == $result) { | ||
$this->hook_version_requirement_actions(); | ||
|
||
} | ||
|
||
return $result; | ||
} | ||
|
||
function hook_version_requirement_actions() | ||
{ | ||
add_filter('wpmdb_notification_strings', array($this, 'version_requirement_actions')); | ||
} | ||
|
||
function version_requirement_actions($notifications) | ||
{ | ||
$addon_requirement_check = get_site_option('wpmdb_addon_requirement_check', array()); | ||
|
||
// we only want to delete the transients once, here we keep track of which versions we've checked | ||
if (!isset($addon_requirement_check[$this->properties->plugin_slug]) || $addon_requirement_check[$this->properties->plugin_slug] != $GLOBALS['wpmdb_meta'][$this->properties->plugin_slug]['version']) { | ||
delete_site_transient('wpmdb_upgrade_data'); | ||
delete_site_transient('update_plugins'); | ||
$addon_requirement_check[$this->properties->plugin_slug] = $GLOBALS['wpmdb_meta'][$this->properties->plugin_slug]['version']; | ||
update_site_option('wpmdb_addon_requirement_check', $addon_requirement_check); | ||
} | ||
|
||
$notice_id = $this->plugin_basename . '-notice'; | ||
|
||
$notifications[$notice_id] = [ | ||
'message' => $this->version_requirement_warning(), | ||
'link' => false, | ||
'id' => $notice_id, | ||
]; | ||
|
||
return $notifications; | ||
} | ||
|
||
function version_requirement_warning() | ||
{ | ||
$str = '<strong>Update Required</strong> — '; | ||
|
||
$addon_name = $this->addon_name; | ||
$required = $this->version_required; | ||
$installed = $GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['version']; | ||
$wpmdb_basename = sprintf('%s/%s.php', $GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['folder'], 'wp-migrate-db'); | ||
$update = wp_nonce_url(network_admin_url('update.php?action=upgrade-plugin&plugin=' . urlencode($wpmdb_basename)), 'upgrade-plugin_' . $wpmdb_basename); | ||
$str .= sprintf(__('The version of %1$s you have installed requires version %2$s of WP Migrate. You currently have %3$s installed. <strong><a href="%4$s">Update Now</a></strong>', 'wp-migrate-db'), $addon_name, $required, $installed, $update); | ||
|
||
return $str; | ||
} | ||
|
||
|
||
/** | ||
* @param bool $is_licensed | ||
**/ | ||
public function set_licensed($is_licensed) | ||
{ | ||
$this->licensed = $is_licensed; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
wp-content/plugins/wp-migrate-db-pro/class/Common/Addon/AddonManagerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace DeliciousBrains\WPMDB\Common\Addon; | ||
|
||
interface AddonManagerInterface { | ||
public function register($licensed); | ||
public function get_license_response_key(); | ||
} |
Oops, something went wrong.