Skip to content

Commit 988f4c0

Browse files
committed
Deploying version 2.6.9
1 parent 2cae02e commit 988f4c0

File tree

14 files changed

+587
-43
lines changed

14 files changed

+587
-43
lines changed

class/Common/FormData/FormData.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ public function form_data_compat($data)
101101

102102
$return = [
103103
'action' => $current_migration['intent'],
104-
'select_tables' => isset($current_migration['tables_selected']) ? $current_migration['tables_selected'] : '',
104+
'select_tables' => isset($current_migration['tables_selected']) ? $current_migration['tables_selected'] : [],
105105
'table_migrate_option' => isset($current_migration['tables_option']) ? $current_migration['tables_option'] : '',
106106
'create_backup' => isset($current_migration['backup_option']) && $current_migration['backup_option'] !== 'none' ? 1 : 0,
107107
'backup_option' => isset($current_migration['backup_option']) ? $current_migration['backup_option'] : '',
108-
'select_backup' => isset($current_migration['backup_tables_selected']) ? $current_migration['backup_tables_selected'] : '',
109-
'select_post_types' => isset($current_migration['post_types_selected']) ? $current_migration['post_types_selected'] : '',
108+
'select_backup' => isset($current_migration['backup_tables_selected']) ? $current_migration['backup_tables_selected'] : [],
109+
'select_post_types' => isset($current_migration['post_types_selected']) ? $current_migration['post_types_selected'] : [],
110110
'exclude_post_revisions' => in_array('exclude_post_revisions', $advanced_options) ? '1' : '0',
111111
'replace_guids' => in_array('replace_guids', $advanced_options) ? '1' : '0',
112112
'compatibility_older_mysql' => in_array('compatibility_older_mysql', $advanced_options) ? '1' : '0',

class/Common/MF/MediaFilesLocal.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ public function ajax_initiate_media_file_migration()
199199
// Push = get local files
200200
$abs_path = Files_Util::get_wp_uploads_dir();
201201
$abs_path = apply_filters('wpmdb_mf_local_uploads_folder', $abs_path, $state_data);
202-
$items = $this->plugin_helper->get_top_level_items($abs_path);
203-
204-
$file_list = $this->file_processor->get_local_files($items, $abs_path, $excludes, $state_data['stage'], $date, $timezone,'push');
202+
$file_list = $this->file_processor->get_local_files([$abs_path], $abs_path, $excludes, $state_data['stage'], $date, $timezone,'push');
205203
}
206204

207205
if (is_wp_error($file_list)) {

class/Common/Plugin/PluginManagerBase.php

Lines changed: 98 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
class PluginManagerBase
2929
{
3030

31+
const DBRAINS_URL = 'https://deliciousbrains.com';
32+
const WPE_URL = 'https://wpengine.com';
33+
3134
/**
3235
* @var Properties
3336
*/
@@ -251,7 +254,7 @@ public function maybe_schema_update()
251254
$schema_version = 3.2;
252255
}
253256

254-
if($schema_version < 3.6) {
257+
if ($schema_version < 3.6) {
255258
$this->update_profiles();
256259

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

280-
<div class="updated" style="border-left: 4px solid #ffba00;">
281-
<p><?php echo esc_html($message); ?></p>
282-
</div> <?php
283+
<div class="updated" style="border-left: 4px solid #ffba00;">
284+
<p><?php echo esc_html($message); ?></p>
285+
</div> <?php
283286

284-
delete_transient('wp_migrate_db_deactivated_notice_id');
287+
delete_transient('wp_migrate_db_deactivated_notice_id');
285288
}
286289
}
287290

@@ -304,7 +307,7 @@ function admin_head_connection_info()
304307

305308
$data = $site_details_extended;
306309

307-
if(Util::isPro()) {
310+
if (Util::isPro()) {
308311
$data = apply_filters('wpmdb_data', $site_details_extended);
309312
}
310313

@@ -398,14 +401,14 @@ private function update_profiles()
398401

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

401-
if(is_wp_error($loaded_profile)) {
404+
if (is_wp_error($loaded_profile)) {
402405
continue;
403406
}
404407

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

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

@@ -414,47 +417,51 @@ private function update_profiles()
414417
}
415418

416419
if (property_exists($profile_data, 'theme_plugin_files')) {
417-
if ( ! property_exists($profile_data->theme_plugin_files, 'themes_option')) {
420+
if (!property_exists($profile_data->theme_plugin_files, 'themes_option')) {
418421
$profile_data->theme_plugin_files->themes_option = $profile_data->theme_plugin_files->themes_selected ? 'selected' : 'all';
419422
}
420-
if ( ! property_exists($profile_data->theme_plugin_files, 'plugins_option')) {
421-
$profile_data->theme_plugin_files->plugins_option = $profile_data->theme_plugin_files->plugins_selected ? 'selected': 'all';
423+
if (!property_exists($profile_data->theme_plugin_files, 'plugins_option')) {
424+
$profile_data->theme_plugin_files->plugins_option = $profile_data->theme_plugin_files->plugins_selected ? 'selected' : 'all';
422425
}
423-
if ( ! property_exists($profile_data->theme_plugin_files, 'themes_excluded')) {
426+
if (!property_exists($profile_data->theme_plugin_files, 'themes_excluded')) {
424427
$profile_data->theme_plugin_files->themes_excluded = [];
425428
}
426-
if ( ! property_exists($profile_data->theme_plugin_files, 'plugins_excluded')) {
429+
if (!property_exists($profile_data->theme_plugin_files, 'plugins_excluded')) {
427430
$profile_data->theme_plugin_files->plugins_excluded = [];
428431
}
429-
if ( ! property_exists($profile_data->theme_plugin_files, 'plugins_excludes')) {
432+
if (!property_exists($profile_data->theme_plugin_files, 'plugins_excludes')) {
430433
$profile_data->theme_plugin_files->plugins_excludes = property_exists($profile_data->theme_plugin_files, 'excludes')
431434
? $profile_data->theme_plugin_files->excludes
432435
: '';
433436
}
434-
if ( ! property_exists($profile_data->theme_plugin_files, 'themes_excludes')) {
437+
if (!property_exists($profile_data->theme_plugin_files, 'themes_excludes')) {
435438
$profile_data->theme_plugin_files->themes_excludes = property_exists($profile_data->theme_plugin_files, 'excludes')
436439
? $profile_data->theme_plugin_files->excludes
437440
: '';
438441
}
439442

440443
//updates for others and muplugins added 2.3.4
441-
if ( ! property_exists($profile_data->theme_plugin_files, 'other_files')) {
444+
if (!property_exists($profile_data->theme_plugin_files, 'other_files')) {
442445
$profile_data->theme_plugin_files->other_files = ['enabled' => false];
443446
$profile_data->theme_plugin_files->others_option = 'selected';
444447
$profile_data->theme_plugin_files->others_selected = [];
445448
$profile_data->theme_plugin_files->others_excludes = '';
446449
}
447-
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {
450+
if (!property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {
448451
$profile_data->theme_plugin_files->muplugin_files = ['enabled' => false];
449452
$profile_data->theme_plugin_files->muplugins_option = 'selected';
450453
$profile_data->theme_plugin_files->muplugins_selected = [];
451454
$profile_data->theme_plugin_files->muplugins_excludes = '';
452455
}
453456

454-
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {}
455-
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugins_option')) {}
456-
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugins_selected')) {}
457-
if ( ! property_exists($profile_data->theme_plugin_files, 'muplugins_excludes')) {}
457+
if (!property_exists($profile_data->theme_plugin_files, 'muplugin_files')) {
458+
}
459+
if (!property_exists($profile_data->theme_plugin_files, 'muplugins_option')) {
460+
}
461+
if (!property_exists($profile_data->theme_plugin_files, 'muplugins_selected')) {
462+
}
463+
if (!property_exists($profile_data->theme_plugin_files, 'muplugins_excludes')) {
464+
}
458465
}
459466
//gonna need to update the profiles
460467

@@ -464,4 +471,74 @@ private function update_profiles()
464471
}
465472
}
466473
}
474+
475+
/**
476+
* Filter admin footer text for Migrate pages
477+
*
478+
* @param string $text
479+
* @param string $product_link
480+
* @param string $wpe_link
481+
* @return type
482+
* @handles admin_footer_text
483+
**/
484+
public function generate_admin_footer_text($text, $product_link, $wpe_link)
485+
{
486+
if (empty($product_link) || empty($wpe_link)) {
487+
return $text;
488+
}
489+
return sprintf(
490+
/* translators: %1$s is a link to WP Migrate's website, and %2$s is a link to WP Engine's website. */
491+
__('%1$s is developed and maintained by %2$s.', 'wp-migrate-db'),
492+
$product_link,
493+
$wpe_link
494+
);
495+
}
496+
497+
/**
498+
* Generate Delicious Brains site URL with correct UTM tags.
499+
*
500+
* @param string $path
501+
* @param array $args
502+
* @param string $hash
503+
*
504+
* @return string
505+
*/
506+
public static function delicious_brains_url( $path, $args = array(), $hash = '' ) {
507+
$args = wp_parse_args( $args, array(
508+
'utm_medium' => 'insideplugin'
509+
) );
510+
$args = array_map( 'urlencode', $args );
511+
$url = trailingslashit( self::DBRAINS_URL ) . ltrim( $path, '/' );
512+
$url = add_query_arg( $args, $url );
513+
if ( $hash ) {
514+
$url .= '#' . $hash;
515+
}
516+
return $url;
517+
}
518+
519+
/**
520+
* Generate WP Engine site URL with correct UTM tags.
521+
*
522+
* @param string $path
523+
* @param array $args
524+
* @param string $hash
525+
*
526+
* @return string
527+
*/
528+
public static function wpe_url($path = '', $args = array(), $hash = '')
529+
{
530+
$args = wp_parse_args($args, [
531+
'utm_medium' => 'referral',
532+
'utm_campaign' => 'bx_prod_referral'
533+
]);
534+
$args = array_map('urlencode', $args);
535+
$url = trailingslashit(self::WPE_URL) . ltrim($path, '/');
536+
$url = add_query_arg($args, $url);
537+
538+
if ($hash) {
539+
$url .= '#' . $hash;
540+
}
541+
542+
return $url;
543+
}
467544
}

class/Common/Util/Util.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,4 +1440,16 @@ public static function get_wpe_cookie() {
14401440
public static function is_dev_environment() {
14411441
return isset($_ENV['MDB_IS_DEV']) && (bool) $_ENV['MDB_IS_DEV'];
14421442
}
1443+
1444+
/**
1445+
* Create an external link for given URL.
1446+
*
1447+
* @param string $url
1448+
* @param string $text
1449+
*
1450+
* @return string
1451+
*/
1452+
public static function external_link( $url, $text ) {
1453+
return sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $url ), esc_html( $text ) );
1454+
}
14431455
}

class/Free/Plugin/PluginManager.php

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public function register()
3232

3333
add_filter('plugin_action_links_' . $this->props->plugin_basename, array($this, 'plugin_action_links'));
3434
add_filter('network_admin_plugin_action_links_' . $this->props->plugin_basename, array($this, 'plugin_action_links'));
35+
36+
add_filter('admin_footer_text', [$this, 'admin_footer_text']);
37+
38+
add_filter( 'update_footer', [$this, 'update_footer'], 20 );
3539
}
3640

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

5458
return $start_links + $links + $end_links;
5559
}
60+
61+
/**
62+
* Get the plugin title
63+
*
64+
* @return string
65+
**/
66+
public function get_plugin_title()
67+
{
68+
return __('WP Migrate Lite', 'wp-migrate-db');
69+
}
70+
71+
/**
72+
* Get the plugin version
73+
*
74+
* @return string
75+
**/
76+
public function get_plugin_version()
77+
{
78+
if (!isset($GLOBALS['wpmdb_meta']['wp-migrate-db']['version'])) {
79+
return '0';
80+
}
81+
return $GLOBALS['wpmdb_meta']['wp-migrate-db']['version'];
82+
}
83+
84+
/**
85+
* Get the plugin page url
86+
*
87+
* @return string
88+
**/
89+
public static function plugin_page_url()
90+
{
91+
if(is_multisite()) {
92+
return menu_page_url('tools_page_wp-migrate-db');
93+
}
94+
return menu_page_url('settings_page_wp-migrate-db-network');
95+
}
96+
97+
/**
98+
* Filter admin footer text for Migrate pages
99+
*
100+
* @param string $text
101+
* @return string
102+
* @handles admin_footer_text
103+
**/
104+
public function admin_footer_text($text)
105+
{
106+
if (!$this->util->isMDBPage()) {
107+
return $text;
108+
}
109+
$product_link = Util::external_link(
110+
static::delicious_brains_url(
111+
'/wp-migrate-db-pro/',
112+
[
113+
'utm_source' => 'migrate_lite',
114+
'utm_medium' => 'insideplugin',
115+
'utm_campaign' => 'plugin_footer',
116+
'utm_content' => 'footer_colophon'
117+
]
118+
),
119+
$this->get_plugin_title()
120+
);
121+
$wpe_link = Util::external_link(
122+
static::wpe_url(
123+
'',
124+
[
125+
'utm_source' => 'migrate_plugin',
126+
'utm_content' => 'migrate_free_plugin_footer_text'
127+
]
128+
),
129+
'WP Engine'
130+
);
131+
return $this->generate_admin_footer_text($text, $product_link, $wpe_link);
132+
}
133+
134+
/**
135+
* Filter update footer text for Migrate pages
136+
*
137+
* @param string $content
138+
* @return string
139+
* @handles update_footer
140+
**/
141+
public function update_footer($content)
142+
{
143+
if (!$this->util->isMDBPage()) {
144+
return $content;
145+
}
146+
$utm_params = [
147+
'utm_source' => 'MDB%2BFree',
148+
'utm_campaign' => 'plugin_footer',
149+
'utm_content' => 'footer_navigation'
150+
];
151+
152+
$links[] = Util::external_link(
153+
static::delicious_brains_url(
154+
'/wp-migrate-db-pro/docs/',
155+
$utm_params
156+
),
157+
__('Documentation', 'wp-migrate-db')
158+
);
159+
160+
$links[] = '<a href="' . static::plugin_page_url() . '#help">' . __( 'Support', 'wp-migrate-db' ) . '</a>';
161+
162+
$links[] = Util::external_link(
163+
static::delicious_brains_url(
164+
'/wp-migrate-db-pro/feedback/',
165+
$utm_params
166+
),
167+
__('Feedback', 'wp-migrate-db')
168+
);
169+
170+
$links[] = Util::external_link(
171+
static::delicious_brains_url(
172+
'/wp-migrate-db-pro/whats-new/',
173+
$utm_params
174+
),
175+
$this->get_plugin_title() . ' ' . $this->get_plugin_version(),
176+
'whats-new'
177+
);
178+
return join( ' &#8729; ', $links );
179+
}
56180
}

0 commit comments

Comments
 (0)