2828class 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}
0 commit comments