Skip to content

Commit

Permalink
Deploying version 2.6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
philwp committed Aug 29, 2023
1 parent 2cae02e commit 988f4c0
Show file tree
Hide file tree
Showing 14 changed files with 587 additions and 43 deletions.
6 changes: 3 additions & 3 deletions class/Common/FormData/FormData.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ public function form_data_compat($data)

$return = [
'action' => $current_migration['intent'],
'select_tables' => isset($current_migration['tables_selected']) ? $current_migration['tables_selected'] : '',
'select_tables' => isset($current_migration['tables_selected']) ? $current_migration['tables_selected'] : [],
'table_migrate_option' => isset($current_migration['tables_option']) ? $current_migration['tables_option'] : '',
'create_backup' => isset($current_migration['backup_option']) && $current_migration['backup_option'] !== 'none' ? 1 : 0,
'backup_option' => isset($current_migration['backup_option']) ? $current_migration['backup_option'] : '',
'select_backup' => isset($current_migration['backup_tables_selected']) ? $current_migration['backup_tables_selected'] : '',
'select_post_types' => isset($current_migration['post_types_selected']) ? $current_migration['post_types_selected'] : '',
'select_backup' => isset($current_migration['backup_tables_selected']) ? $current_migration['backup_tables_selected'] : [],
'select_post_types' => isset($current_migration['post_types_selected']) ? $current_migration['post_types_selected'] : [],
'exclude_post_revisions' => in_array('exclude_post_revisions', $advanced_options) ? '1' : '0',
'replace_guids' => in_array('replace_guids', $advanced_options) ? '1' : '0',
'compatibility_older_mysql' => in_array('compatibility_older_mysql', $advanced_options) ? '1' : '0',
Expand Down
4 changes: 1 addition & 3 deletions class/Common/MF/MediaFilesLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ public function ajax_initiate_media_file_migration()
// Push = get local files
$abs_path = Files_Util::get_wp_uploads_dir();
$abs_path = apply_filters('wpmdb_mf_local_uploads_folder', $abs_path, $state_data);
$items = $this->plugin_helper->get_top_level_items($abs_path);

$file_list = $this->file_processor->get_local_files($items, $abs_path, $excludes, $state_data['stage'], $date, $timezone,'push');
$file_list = $this->file_processor->get_local_files([$abs_path], $abs_path, $excludes, $state_data['stage'], $date, $timezone,'push');
}

if (is_wp_error($file_list)) {
Expand Down
119 changes: 98 additions & 21 deletions class/Common/Plugin/PluginManagerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
class PluginManagerBase
{

const DBRAINS_URL = 'https://deliciousbrains.com';
const WPE_URL = 'https://wpengine.com';

/**
* @var Properties
*/
Expand Down Expand Up @@ -251,7 +254,7 @@ public function maybe_schema_update()
$schema_version = 3.2;
}

if($schema_version < 3.6) {
if ($schema_version < 3.6) {
$this->update_profiles();

$update_schema = true;
Expand All @@ -277,11 +280,11 @@ function plugin_deactivated_notice()
$message = __("WP Migrate Lite and WP Migrate cannot both be active. We've automatically deactivated WP Migrate.", 'wp-migrate-db');
} ?>

<div class="updated" style="border-left: 4px solid #ffba00;">
<p><?php echo esc_html($message); ?></p>
</div> <?php
<div class="updated" style="border-left: 4px solid #ffba00;">
<p><?php echo esc_html($message); ?></p>
</div> <?php

delete_transient('wp_migrate_db_deactivated_notice_id');
delete_transient('wp_migrate_db_deactivated_notice_id');
}
}

Expand All @@ -304,7 +307,7 @@ function admin_head_connection_info()

$data = $site_details_extended;

if(Util::isPro()) {
if (Util::isPro()) {
$data = apply_filters('wpmdb_data', $site_details_extended);
}

Expand Down Expand Up @@ -398,14 +401,14 @@ private function update_profiles()

$loaded_profile = $this->profile_manager->get_profile_by_id($profile_type === 'wpmdb_recent_migrations' ? 'unsaved' : $profile_type, $profile['id']);

if(is_wp_error($loaded_profile)) {
if (is_wp_error($loaded_profile)) {
continue;
}

$profile_data = json_decode($loaded_profile['value']);

//Enable database migration by default for pre 2.3 profiles
if(!property_exists($profile_data->current_migration, 'databaseEnabled')) {
if (!property_exists($profile_data->current_migration, 'databaseEnabled')) {
$profile_data->current_migration->databaseEnabled = true;
}

Expand All @@ -414,47 +417,51 @@ private function update_profiles()
}

if (property_exists($profile_data, 'theme_plugin_files')) {
if ( ! property_exists($profile_data->theme_plugin_files, 'themes_option')) {
if (!property_exists($profile_data->theme_plugin_files, 'themes_option')) {
$profile_data->theme_plugin_files->themes_option = $profile_data->theme_plugin_files->themes_selected ? 'selected' : 'all';
}
if ( ! property_exists($profile_data->theme_plugin_files, 'plugins_option')) {
$profile_data->theme_plugin_files->plugins_option = $profile_data->theme_plugin_files->plugins_selected ? 'selected': 'all';
if (!property_exists($profile_data->theme_plugin_files, 'plugins_option')) {
$profile_data->theme_plugin_files->plugins_option = $profile_data->theme_plugin_files->plugins_selected ? 'selected' : 'all';
}
if ( ! property_exists($profile_data->theme_plugin_files, 'themes_excluded')) {
if (!property_exists($profile_data->theme_plugin_files, 'themes_excluded')) {
$profile_data->theme_plugin_files->themes_excluded = [];
}
if ( ! property_exists($profile_data->theme_plugin_files, 'plugins_excluded')) {
if (!property_exists($profile_data->theme_plugin_files, 'plugins_excluded')) {
$profile_data->theme_plugin_files->plugins_excluded = [];
}
if ( ! property_exists($profile_data->theme_plugin_files, 'plugins_excludes')) {
if (!property_exists($profile_data->theme_plugin_files, 'plugins_excludes')) {
$profile_data->theme_plugin_files->plugins_excludes = property_exists($profile_data->theme_plugin_files, 'excludes')
? $profile_data->theme_plugin_files->excludes
: '';
}
if ( ! property_exists($profile_data->theme_plugin_files, 'themes_excludes')) {
if (!property_exists($profile_data->theme_plugin_files, 'themes_excludes')) {
$profile_data->theme_plugin_files->themes_excludes = property_exists($profile_data->theme_plugin_files, 'excludes')
? $profile_data->theme_plugin_files->excludes
: '';
}

//updates for others and muplugins added 2.3.4
if ( ! property_exists($profile_data->theme_plugin_files, 'other_files')) {
if (!property_exists($profile_data->theme_plugin_files, 'other_files')) {
$profile_data->theme_plugin_files->other_files = ['enabled' => false];
$profile_data->theme_plugin_files->others_option = 'selected';
$profile_data->theme_plugin_files->others_selected = [];
$profile_data->theme_plugin_files->others_excludes = '';
}
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {
if (!property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {
$profile_data->theme_plugin_files->muplugin_files = ['enabled' => false];
$profile_data->theme_plugin_files->muplugins_option = 'selected';
$profile_data->theme_plugin_files->muplugins_selected = [];
$profile_data->theme_plugin_files->muplugins_excludes = '';
}

if ( ! property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {}
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugins_option')) {}
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugins_selected')) {}
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugins_excludes')) {}
if (!property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {
}
if (!property_exists($profile_data->theme_plugin_files, 'muplugins_option')) {
}
if (!property_exists($profile_data->theme_plugin_files, 'muplugins_selected')) {
}
if (!property_exists($profile_data->theme_plugin_files, 'muplugins_excludes')) {
}
}
//gonna need to update the profiles

Expand All @@ -464,4 +471,74 @@ private function update_profiles()
}
}
}

/**
* Filter admin footer text for Migrate pages
*
* @param string $text
* @param string $product_link
* @param string $wpe_link
* @return type
* @handles admin_footer_text
**/
public function generate_admin_footer_text($text, $product_link, $wpe_link)
{
if (empty($product_link) || empty($wpe_link)) {
return $text;
}
return sprintf(
/* translators: %1$s is a link to WP Migrate's website, and %2$s is a link to WP Engine's website. */
__('%1$s is developed and maintained by %2$s.', 'wp-migrate-db'),
$product_link,
$wpe_link
);
}

/**
* Generate Delicious Brains site URL with correct UTM tags.
*
* @param string $path
* @param array $args
* @param string $hash
*
* @return string
*/
public static function delicious_brains_url( $path, $args = array(), $hash = '' ) {
$args = wp_parse_args( $args, array(
'utm_medium' => 'insideplugin'
) );
$args = array_map( 'urlencode', $args );
$url = trailingslashit( self::DBRAINS_URL ) . ltrim( $path, '/' );
$url = add_query_arg( $args, $url );
if ( $hash ) {
$url .= '#' . $hash;
}
return $url;
}

/**
* Generate WP Engine site URL with correct UTM tags.
*
* @param string $path
* @param array $args
* @param string $hash
*
* @return string
*/
public static function wpe_url($path = '', $args = array(), $hash = '')
{
$args = wp_parse_args($args, [
'utm_medium' => 'referral',
'utm_campaign' => 'bx_prod_referral'
]);
$args = array_map('urlencode', $args);
$url = trailingslashit(self::WPE_URL) . ltrim($path, '/');
$url = add_query_arg($args, $url);

if ($hash) {
$url .= '#' . $hash;
}

return $url;
}
}
12 changes: 12 additions & 0 deletions class/Common/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1440,4 +1440,16 @@ public static function get_wpe_cookie() {
public static function is_dev_environment() {
return isset($_ENV['MDB_IS_DEV']) && (bool) $_ENV['MDB_IS_DEV'];
}

/**
* Create an external link for given URL.
*
* @param string $url
* @param string $text
*
* @return string
*/
public static function external_link( $url, $text ) {
return sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $url ), esc_html( $text ) );
}
}
124 changes: 124 additions & 0 deletions class/Free/Plugin/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function register()

add_filter('plugin_action_links_' . $this->props->plugin_basename, array($this, 'plugin_action_links'));
add_filter('network_admin_plugin_action_links_' . $this->props->plugin_basename, array($this, 'plugin_action_links'));

add_filter('admin_footer_text', [$this, 'admin_footer_text']);

add_filter( 'update_footer', [$this, 'update_footer'], 20 );
}

/**
Expand All @@ -53,4 +57,124 @@ public function plugin_action_links($links)

return $start_links + $links + $end_links;
}

/**
* Get the plugin title
*
* @return string
**/
public function get_plugin_title()
{
return __('WP Migrate Lite', 'wp-migrate-db');
}

/**
* Get the plugin version
*
* @return string
**/
public function get_plugin_version()
{
if (!isset($GLOBALS['wpmdb_meta']['wp-migrate-db']['version'])) {
return '0';
}
return $GLOBALS['wpmdb_meta']['wp-migrate-db']['version'];
}

/**
* Get the plugin page url
*
* @return string
**/
public static function plugin_page_url()
{
if(is_multisite()) {
return menu_page_url('tools_page_wp-migrate-db');
}
return menu_page_url('settings_page_wp-migrate-db-network');
}

/**
* Filter admin footer text for Migrate pages
*
* @param string $text
* @return string
* @handles admin_footer_text
**/
public function admin_footer_text($text)
{
if (!$this->util->isMDBPage()) {
return $text;
}
$product_link = Util::external_link(
static::delicious_brains_url(
'/wp-migrate-db-pro/',
[
'utm_source' => 'migrate_lite',
'utm_medium' => 'insideplugin',
'utm_campaign' => 'plugin_footer',
'utm_content' => 'footer_colophon'
]
),
$this->get_plugin_title()
);
$wpe_link = Util::external_link(
static::wpe_url(
'',
[
'utm_source' => 'migrate_plugin',
'utm_content' => 'migrate_free_plugin_footer_text'
]
),
'WP Engine'
);
return $this->generate_admin_footer_text($text, $product_link, $wpe_link);
}

/**
* Filter update footer text for Migrate pages
*
* @param string $content
* @return string
* @handles update_footer
**/
public function update_footer($content)
{
if (!$this->util->isMDBPage()) {
return $content;
}
$utm_params = [
'utm_source' => 'MDB%2BFree',
'utm_campaign' => 'plugin_footer',
'utm_content' => 'footer_navigation'
];

$links[] = Util::external_link(
static::delicious_brains_url(
'/wp-migrate-db-pro/docs/',
$utm_params
),
__('Documentation', 'wp-migrate-db')
);

$links[] = '<a href="' . static::plugin_page_url() . '#help">' . __( 'Support', 'wp-migrate-db' ) . '</a>';

$links[] = Util::external_link(
static::delicious_brains_url(
'/wp-migrate-db-pro/feedback/',
$utm_params
),
__('Feedback', 'wp-migrate-db')
);

$links[] = Util::external_link(
static::delicious_brains_url(
'/wp-migrate-db-pro/whats-new/',
$utm_params
),
$this->get_plugin_title() . ' ' . $this->get_plugin_version(),
'whats-new'
);
return join( ' &#8729; ', $links );
}
}
Loading

0 comments on commit 988f4c0

Please sign in to comment.