use admin name instead of the wordpress.
need to load a new copy of the database also for this to work as headway has a lot of serialized arrays
stored that will have the incorrect url.
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
-require('./wordpress/wp-blog-header.php' );
+require('./admin/wp-blog-header.php' );
*
* @package WordPress
*/
-define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/www.petoskeyrobotics.org/wordpress');
+define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/www.petoskeyrobotics.org/admin');
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME'].'/www.petoskeyrobotics.org');
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/www.petoskeyrobotics.org/wp-content');
define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/www.petoskeyrobotics.org/wp-content');
--- /dev/null
+#wpmdb-main {
+ width: 742px;
+ position: relative;
+ min-height: 950px;
+}
+
+#overlay {
+ background-color: rgba(255, 255, 255, 0.9);
+}
+
+.wpmdb {
+ /* =============================================================================
+ Common & Global
+ ========================================================================== */
+ /* =============================================================================
+ Migrate Tab
+ ========================================================================== */
+ /* Misc */
+ /* Tabs */
+ /* Saved migration profile selection */
+ /* Output Selection */
+ /* Find and Replace */
+ /* Select Tables */
+ /* Advanced Options */
+ /* Save migration profile */
+ /* Action buttons */
+ /* =============================================================================
+ Settings Tab
+ ========================================================================== */
+ /* =============================================================================
+ Help Tab
+ ========================================================================== */
+ /* =============================================================================
+ Addons Tab
+ ========================================================================== */
+}
+.wpmdb .updated {
+ clear: both;
+}
+.wpmdb div.updated.warning {
+ max-width: 742px;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ margin: 10px 0;
+}
+.wpmdb div.updated.warning p {
+ font-size: 13px;
+ margin: 0.5em 0;
+}
+.wpmdb a {
+ text-decoration: none;
+}
+.wpmdb li {
+ margin-bottom: 5px;
+ position: relative;
+}
+.wpmdb ul {
+ margin: 0;
+}
+.wpmdb input[type=checkbox],
+.wpmdb input[type=radio] {
+ margin-right: 5px;
+ vertical-align: baseline;
+ margin-top: 0;
+}
+.wpmdb input[type=text],
+.wpmdb input[type=password] {
+ padding: 5px;
+}
+.wpmdb input[disabled=disabled] {
+ cursor: default;
+}
+.wpmdb label.disabled {
+ color: #888;
+ cursor: default;
+}
+.wpmdb .option-section {
+ border-bottom: 1px solid #ccc;
+ padding-bottom: 20px;
+ margin-bottom: 20px;
+}
+.wpmdb .option-section h3 {
+ font-size: 18px;
+ font-weight: normal;
+}
+.wpmdb p.migrate-db {
+ overflow: hidden;
+}
+.wpmdb p.migrate-db input {
+ float: left;
+}
+.wpmdb p.migrate-db img {
+ float: left;
+ margin: 3px 0 0 5px;
+}
+.wpmdb p.migrate-db .save-settings-button {
+ margin-left: 10px;
+ display: none;
+}
+.wpmdb .indent-wrap {
+ margin-left: 24px;
+}
+.wpmdb .expandable-content {
+ display: none;
+ margin-top: 10px;
+}
+.wpmdb .expandable-content li:last-child {
+ margin-bottom: 0px;
+}
+.wpmdb .header-wrapper {
+ margin-bottom: 10px;
+}
+.wpmdb .header-expand-collapse {
+ cursor: pointer;
+ display: inline-block;
+}
+.wpmdb .option-description {
+ font-size: 12px;
+ color: #999;
+ margin-left: 8px;
+ font-weight: normal;
+}
+.wpmdb .option-group li:last-child {
+ margin-bottom: 0;
+}
+.wpmdb .connection-status {
+ display: none;
+ overflow: auto;
+}
+.wpmdb .connection-status.error {
+ color: #9D1818;
+}
+.wpmdb .ajax-spinner {
+ left: 6px;
+ position: relative;
+ top: 3px;
+}
+.wpmdb div.message {
+ margin: 15px 0 0;
+}
+.wpmdb .licence-wrap h3 {
+ margin: 0 0 10px 0;
+}
+.wpmdb .licence-input {
+ clear: both;
+ display: block;
+ font-family: Consolas, Monaco, monospace;
+ font-size: 14px;
+ margin-bottom: 7px;
+ padding: 10px;
+ width: 418px;
+}
+.wpmdb .register-licence {
+ float: left;
+ outline: none;
+}
+.wpmdb .licence-status {
+ color: #A21B1B;
+ font-weight: bold;
+ clear: both;
+ padding-top: 0.5em;
+ margin: 0;
+}
+.wpmdb .licence-status.success {
+ color: #333;
+}
+.wpmdb .register-licence-ajax-spinner {
+ margin: 4px 0 0 8px;
+}
+.wpmdb .return-to-profile-selection {
+ margin-bottom: 15px;
+ display: inline-block;
+}
+.wpmdb .return-to-profile-selection.bottom {
+ margin-top: 10px;
+}
+.wpmdb h2.nav-tab-wrapper {
+ margin-top: 10px;
+ margin-bottom: 20px;
+ padding-left: 5px;
+}
+.wpmdb h2.nav-tab-wrapper a.nav-tab-active {
+ color: #464646;
+ cursor: default;
+}
+.wpmdb label {
+ display: inline-block;
+ clear: both;
+}
+.wpmdb .migration-profile-options li {
+ position: relative;
+ width: 520px;
+}
+.wpmdb .migration-profile-options li a {
+ padding: 5px 10px;
+ width: 500px;
+ border: 1px solid #ddd;
+ margin: 0px 0px 7px;
+ display: block;
+ font-size: 14px;
+ color: #333;
+}
+.wpmdb .migration-profile-options li a:hover {
+ border-color: #bbb;
+}
+.wpmdb .main-list-delete-profile-link {
+ color: #999999;
+ font-family: "Times New Roman", serif;
+ font-size: 26px;
+ font-weight: 200;
+ position: absolute;
+ right: 7px;
+ top: 6px;
+ cursor: pointer;
+}
+.wpmdb .main-list-delete-profile-link:hover {
+ color: #444;
+}
+.wpmdb .option-group li {
+ margin-bottom: 5px;
+}
+.wpmdb .option-group > li {
+ margin-bottom: 8px;
+}
+.wpmdb .option-group li > label {
+ font-size: 14px;
+ font-weight: bold;
+}
+.wpmdb .option-group ul {
+ display: none;
+ margin: 10px 0px 10px 25px;
+}
+.wpmdb .option-group ul label {
+ font-size: 12px;
+ font-weight: normal;
+}
+.wpmdb .option-heading, .wpmdb .checkbox-label {
+ font-size: 14px;
+ font-weight: bold;
+}
+.wpmdb .checkbox-label input[type=checkbox] {
+ margin-right: 7px;
+ position: relative;
+ top: -1px;
+}
+.wpmdb .expand-collapse-arrow {
+ margin-right: 9px;
+}
+.wpmdb .migrate-connection-info {
+ min-width: 675px;
+ margin: 0;
+}
+.wpmdb .migrate-tab .pull-push-connection-info {
+ width: 418px;
+ height: 65px;
+ color: #333;
+ font-family: Consolas, Monaco, monospace;
+ font-size: 15px;
+ line-height: 21px;
+ padding: 10px;
+}
+.wpmdb .basic-access-auth-wrapper {
+ display: none;
+ margin-bottom: 5px;
+}
+.wpmdb .auth-username, .wpmdb .auth-password {
+ width: 206px;
+ margin-top: 3px;
+}
+.wpmdb .auth-password {
+ width: 207px;
+}
+.wpmdb .connection-info-wrapper {
+ display: none;
+ width: 670px;
+}
+.wpmdb .connect-button {
+ margin-top: 2px;
+}
+.wpmdb .temp-disabled {
+ background-color: #EEEEEE;
+ color: #888888;
+ font-family: Consolas, Monaco, monospace;
+ text-shadow: 0 1px 0 #FFFFFF;
+}
+.wpmdb .push-list ul {
+ margin-bottom: 0px;
+}
+.wpmdb .find-heading, .wpmdb .replace-heading {
+ float: left;
+}
+.wpmdb .find-heading {
+ width: 400px;
+}
+.wpmdb .replace-fields {
+ border-collapse: collapse;
+ border-spacing: 0px;
+}
+.wpmdb .replace-fields input {
+ width: 295px;
+}
+.wpmdb .replace-fields tr td {
+ padding-bottom: 7px;
+}
+.wpmdb .replace-fields tr:last-child td {
+ padding-bottom: 0px;
+}
+.wpmdb .arrow-col {
+ width: 93px;
+ text-align: center;
+ vertical-align: middle;
+}
+.wpmdb .right-arrow {
+ font-size: 36px;
+ color: #aaa;
+ font-family: arial, sans-serif;
+}
+.wpmdb .replace-right-col span {
+ border-radius: 50%;
+ border: 1px solid #ccc;
+ background-color: #eee;
+ width: 16px;
+ height: 16px;
+ display: inline-block;
+ position: relative;
+ top: 4px;
+ cursor: pointer;
+}
+.wpmdb .replace-right-col span:hover {
+ border-color: #aaa;
+}
+.wpmdb .pin .sort-handle-col {
+ opacity: 0.5;
+ cursor: default;
+}
+.wpmdb .pin .sort-handle {
+ cursor: default !important;
+}
+.wpmdb .sort-handle-col {
+ width: 20px;
+ cursor: -webkit-grab;
+ cursor: -moz-grab;
+}
+.wpmdb .sort-handle:before {
+ content: "\f214";
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 16px/1 'dashicons';
+ vertical-align: top;
+ color: #aaa;
+ background-color: transparent !important;
+}
+.wpmdb .original-repeatable-field {
+ display: none;
+}
+.wpmdb .no-replaces-message {
+ display: none;
+ margin-bottom: 0px;
+}
+.wpmdb .inline-message.missing-replace {
+ margin-top: 15px;
+ display: none;
+}
+.wpmdb #new-path-missing-warning {
+ margin-top: 5px;
+}
+.wpmdb .tables-header {
+ display: inline-block;
+}
+.wpmdb .expand-collapse-arrow {
+ display: inline-block;
+ position: relative;
+ top: -2px;
+ font-size: 11px;
+}
+.wpmdb .collapsed {
+ -moz-transform: scale(1) rotate(-90deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg);
+ -webkit-transform: scale(1) rotate(-90deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg);
+ -o-transform: scale(1) rotate(-90deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg);
+ -ms-transform: scale(1) rotate(-90deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg);
+ transform: scale(1) rotate(-90deg) translateX(0px) translateY(0px) skewX(0deg) skewY(0deg);
+}
+.wpmdb .select-deselect-divider {
+ margin: 0 6px;
+}
+.wpmdb .select-wrap {
+ display: none;
+ margin-top: 12px;
+}
+.wpmdb .select-post-types-wrap {
+ display: block;
+}
+.wpmdb .multiselect {
+ min-width: 420px;
+ min-height: 180px;
+ margin-bottom: 10px;
+}
+.wpmdb .table-migrate-options li label {
+ font-size: 12px;
+ font-weight: normal;
+}
+.wpmdb .table-migrate-options li {
+ margin-bottom: 5px;
+}
+.wpmdb .general-helper {
+ border-radius: 50%;
+ border: 1px solid #ccc;
+ background-color: #eee;
+ width: 15px;
+ height: 15px;
+ display: inline-block;
+ position: relative;
+ top: 4px;
+ margin-top: -4px;
+ cursor: pointer;
+ margin-left: 2px;
+}
+.wpmdb .general-helper:hover {
+ border-color: #aaa;
+}
+.wpmdb .general-helper:after {
+ content: "?";
+ color: #999999;
+ font-size: 10px;
+ font-weight: bold;
+ left: 4px;
+ position: absolute;
+ top: -1px;
+}
+.wpmdb .helper-message {
+ padding: 10px;
+ border: 1px solid #ccc;
+ border-radius: 3px;
+ background-color: #fff;
+ position: absolute;
+ width: 500px;
+ z-index: 9999;
+ display: none;
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
+}
+.wpmdb .inline-message {
+ padding: 10px;
+ border-radius: 3px;
+ margin-top: 5px;
+}
+.wpmdb .inline-message.error {
+ border: 1px solid #CC0000;
+ background-color: #FFEBE8;
+}
+.wpmdb .inline-message.warning {
+ background-color: #FFFFE0;
+ border: 1px solid #E6DB55;
+}
+.wpmdb .helper-message:before {
+ content: '';
+ border-bottom: 8px solid transparent;
+ border-right: 8px solid #aaa;
+ border-top: 8px solid transparent;
+ display: block;
+ height: 0;
+ left: -8px;
+ position: absolute;
+ top: 11px;
+ width: 0;
+}
+.wpmdb .helper-message:after {
+ content: '';
+ border-bottom: 8px solid transparent;
+ border-right: 8px solid #fff;
+ border-top: 8px solid transparent;
+ display: block;
+ height: 0;
+ left: -7px;
+ position: absolute;
+ top: 11px;
+ width: 0;
+}
+.wpmdb .helper-message.bottom:before {
+ content: '';
+ border-left: 8px solid transparent;
+ border-right: 8px solid transparent;
+ border-bottom: 8px solid #aaa;
+ border-top: 0;
+ display: block;
+ height: 0;
+ left: 50%;
+ margin-left: -8px;
+ position: absolute;
+ top: -9px;
+ width: 0;
+}
+.wpmdb .helper-message.bottom:after {
+ content: '';
+ border-left: 8px solid transparent;
+ border-right: 8px solid transparent;
+ border-bottom: 8px solid #fff;
+ border-top: 0;
+ display: block;
+ height: 0;
+ left: 50%;
+ margin-left: -8px;
+ position: absolute;
+ top: -8px;
+ width: 0;
+}
+.wpmdb .label-disabled {
+ color: #888;
+}
+.wpmdb .prefix-notice, .wpmdb .ssl-notice, .wpmdb .different-plugin-version-notice, .wpmdb .directory-permission-notice {
+ background-color: #FFFFE0;
+ border: 1px solid #E6DB55;
+ padding: 15px;
+ border-radius: 3px;
+ margin-bottom: 15px;
+ display: none;
+}
+.wpmdb .prefix-notice p, .wpmdb .ssl-notice p, .wpmdb .different-plugin-version-notice p, .wpmdb .directory-permission-notice p {
+ margin-top: 0px;
+}
+.wpmdb .prefix-notice p:last-child, .wpmdb .ssl-notice p:last-child, .wpmdb .different-plugin-version-notice p:last-child, .wpmdb .directory-permission-notice p:last-child {
+ margin: 0px;
+}
+.wpmdb .different-plugin-version-notice, .wpmdb .directory-permission-notice {
+ background-color: #FFEBE8;
+ border-color: #CC0000;
+}
+.wpmdb .different-plugin-version-notice a, .wpmdb .directory-permission-notice a {
+ color: #CC0000;
+ text-decoration: underline;
+}
+.wpmdb .save-migration-profile-wrap li label {
+ font-size: 12px;
+ font-weight: normal;
+}
+.wpmdb .save-migration-profile-wrap li {
+ margin-bottom: 5px;
+ padding-left: 25px;
+}
+.wpmdb .save-migration-profile-wrap .indent-wrap {
+ margin-left: 0px;
+}
+.wpmdb .create-new-label {
+ margin-right: 8px;
+}
+.wpmdb .create-new-profile {
+ position: absolute;
+ top: -5px;
+}
+.wpmdb .replace-remove-row,
+.wpmdb .delete-profile {
+ background-color: #eee;
+ border: 1px solid #ccc;
+ border-radius: 50% 50% 50% 50%;
+ cursor: pointer;
+ height: 11px;
+ left: 5px;
+ margin-left: 2px;
+ position: absolute;
+ margin-top: -6px;
+ top: 50%;
+ width: 11px;
+ display: none;
+ background-position: 50% 50%;
+ background-size: 6px 6px;
+ background-repeat: no-repeat;
+}
+.wpmdb .replace-remove-row:after,
+.wpmdb .delete-profile:after {
+ content: "\00d7";
+ left: 2px;
+ position: absolute;
+ top: -3px;
+ color: #aaa;
+ font-size: 12px;
+}
+.wpmdb .replace-remove-row:after {
+ position: relative;
+}
+.wpmdb .replace-remove-row:hover,
+.wpmdb .delete-profile:hover {
+ border-color: #aaa;
+}
+.wpmdb .migrate-db .ajax-success-msg {
+ font-weight: bold;
+ margin: 3px 0 0 9px;
+ display: inline-block;
+}
+.wpmdb p img.save-profile-ajax-spinner {
+ margin-left: 10px;
+}
+.wpmdb .backup-description {
+ left: 20px;
+ position: relative;
+}
+.wpmdb .backup-option-disabled {
+ margin-bottom: 0px !important;
+}
+.wpmdb .settings-tab {
+ display: none;
+}
+.wpmdb .settings-tab .slider {
+ max-width: 416px;
+}
+.wpmdb .settings-tab .slider-label {
+ display: block;
+ margin-bottom: 10px;
+ float: left;
+ width: 50%;
+}
+.wpmdb .settings-tab .slider-label-wrapper {
+ max-width: 416px;
+ width: 100%;
+ position: relative;
+}
+.wpmdb .settings-tab .amount {
+ width: 50%;
+ text-align: right;
+ display: block;
+ text-align: right;
+ float: left;
+}
+.wpmdb .settings-tab .slider-spinner {
+ position: absolute;
+ right: -35px;
+ bottom: -13px;
+}
+.wpmdb .settings-tab .slider-success-msg {
+ display: none;
+ right: -53px;
+ bottom: -13px;
+ position: absolute;
+ font-weight: bold;
+}
+.wpmdb .settings-tab .ui-slider {
+ border: 1px solid #dfdfdf;
+ height: 10px;
+ border-radius: 2px;
+ position: relative;
+}
+.wpmdb .settings-tab .ui-slider-handle {
+ width: 7px;
+ height: 20px;
+ background-color: #aaa;
+ display: block;
+ position: absolute;
+ top: -5px;
+ outline: none;
+}
+.wpmdb .settings-tab .ui-slider-handle:active {
+ background-color: #999;
+}
+.wpmdb .settings-tab .ui-slider-range {
+ background-color: #eee;
+ height: 100%;
+}
+.wpmdb .settings-tab .option-section li label {
+ font-size: 12px;
+ font-weight: normal;
+ position: relative;
+}
+.wpmdb .settings-tab .option-section li {
+ margin-bottom: 5px;
+}
+.wpmdb .settings-tab .option-section li:last-child {
+ margin-bottom: 0px;
+}
+.wpmdb .settings-tab .option-section .ajax-spinner {
+ right: -23px;
+ left: inherit;
+ top: 0px;
+ position: absolute;
+}
+.wpmdb .settings-tab .option-section .ajax-success-msg {
+ right: -42px;
+ left: inherit;
+ top: 0px;
+ position: absolute;
+ font-weight: bold;
+}
+.wpmdb .settings-tab .option-section .bubble .ajax-spinner {
+ right: -45px;
+}
+.wpmdb .settings-tab .option-section .bubble .ajax-success-msg {
+ right: -65px;
+}
+.wpmdb .allow-remote-reqeusts {
+ font-size: 14px;
+ font-weight: bold;
+}
+.wpmdb .connection-info-label {
+ margin-top: 15px;
+ margin-bottom: 5px;
+ display: block;
+}
+.wpmdb .connection-info {
+ clear: both;
+ font-size: 15px;
+ line-height: 21px;
+ font-family: Consolas, Monaco, monospace;
+ padding: 10px 10px;
+ height: 67px;
+ text-shadow: 0px 1px 0px #fff;
+ display: block;
+ margin-bottom: 7px;
+ width: 418px;
+}
+.wpmdb .reset-button-wrap {
+ width: 418px;
+}
+.wpmdb .reset-api-key {
+ float: left;
+}
+.wpmdb .reset-api-key-ajax-spinner {
+ float: left;
+ margin: 4px 7px;
+}
+.wpmdb .masked-licence {
+ margin-top: 0px;
+}
+.wpmdb .bull {
+ font-size: 22px;
+ position: relative;
+ top: 4px;
+}
+.wpmdb .plugin-compatibility-wrap {
+ padding: 18px 18px 18px 24px;
+ background-color: #e6e6e6;
+ margin-left: 0;
+}
+.wpmdb .plugin-compatibility-wrap p:last-of-type {
+ margin-bottom: 0;
+}
+.wpmdb ul.plugin-compatibility-options {
+ display: block;
+ margin: 10px 0 10px 0px;
+}
+.wpmdb .plugin-compatibility-spinner {
+ position: relative;
+ top: 3px;
+ left: 10px;
+}
+.wpmdb .plugin-compatibility-success-msg {
+ position: relative;
+ left: 10px;
+ font-weight: bold;
+ display: none;
+}
+.wpmdb .help-tab {
+ display: none;
+}
+.wpmdb .help-tab h3 {
+ font-size: 18px;
+ font-weight: normal;
+}
+.wpmdb .help-tab .support {
+ border-bottom: 1px solid #ccc;
+ margin-bottom: 25px;
+ padding-bottom: 18px;
+}
+.wpmdb .help-tab .support p {
+ width: 640px;
+}
+.wpmdb .help-tab .support .email a {
+ font-size: 12px;
+}
+.wpmdb .help-tab .support .ajax-spinner {
+ top: 2px;
+}
+.wpmdb .help-tab .video-viewer {
+ margin-bottom: 30px;
+}
+.wpmdb .help-tab .videos {
+ width: 640px;
+}
+.wpmdb .help-tab .videos ul > li {
+ margin-bottom: 30px;
+ overflow: hidden;
+ position: relative;
+}
+.wpmdb .help-tab .videos ul > li a {
+ overflow: hidden;
+ display: block;
+ width: 320px;
+ height: 180px;
+ float: left;
+ margin-right: 15px;
+ position: relative;
+ z-index: 1;
+}
+.wpmdb .help-tab .videos ul > li a:before, .wpmdb .help-tab .videos ul > li a:after {
+ position: absolute;
+ content: " ";
+ margin: auto;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+}
+.wpmdb .help-tab .videos ul > li a:before {
+ width: 64px;
+ height: 64px;
+ -webkit-border-radius: 64px;
+ -moz-border-radius: 64px;
+ -ms-border-radius: 64px;
+ -o-border-radius: 64px;
+ border-radius: 64px;
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
+ opacity: 0.8;
+ border: 1px solid #ddd;
+ background-color: #fff;
+ z-index: 2;
+}
+.wpmdb .help-tab .videos ul > li a:after {
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
+ opacity: 0.8;
+ border: 21.33333px solid transparent;
+ border-top-width: 12.8px;
+ border-bottom-width: 12.8px;
+ border-left-color: #333;
+ background: transparent;
+ display: block;
+ left: 25px;
+ width: 0px;
+ height: 0px;
+ z-index: 3;
+}
+.wpmdb .help-tab .videos .video:last-child {
+ margin-bottom: 0px;
+}
+.wpmdb .help-tab .videos img {
+ width: 320px;
+ height: 240px;
+ position: relative;
+ top: 50%;
+ margin-top: -120px;
+}
+.wpmdb .help-tab .debug {
+ width: 640px;
+ border-bottom: 1px solid #CCCCCC;
+ margin-bottom: 25px;
+ padding-bottom: 28px;
+}
+.wpmdb .help-tab .debug textarea {
+ width: 100%;
+ min-height: 200px;
+ font-family: Consolas, Monaco, monospace;
+ margin-bottom: 5px;
+}
+.wpmdb .help-tab h4 {
+ margin: 0 0 0.2em 0;
+}
+.wpmdb .help-tab p {
+ margin: 0 0 0.5em 0;
+}
+.wpmdb .help-tab iframe {
+ display: none;
+}
+.wpmdb .addons-tab {
+ display: none;
+}
+.wpmdb .addons-tab .addon {
+ position: relative;
+ width: 100%;
+ min-height: 138px;
+ padding: 25px 30px 30px 165px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ color: #fff;
+ margin-bottom: 15px;
+}
+.wpmdb .addons-tab .addon .actions {
+ float: right;
+ font-size: 14px;
+}
+.wpmdb .addons-tab .addon .actions > * {
+ margin-right: 10px;
+}
+.wpmdb .addons-tab .addon .actions *:last-child {
+ margin-right: 0;
+}
+.wpmdb .addons-tab .addon .actions .action {
+ background-color: #fff;
+ font-weight: bold;
+ display: inline-block;
+ padding: 0.2em 0.4em;
+}
+.wpmdb .addons-tab .addon .actions .action:hover {
+ background-color: rgba(255, 255, 255, 0.92);
+}
+.wpmdb .addons-tab .addon .actions .status {
+ border-bottom: 2px solid #fff;
+ padding-bottom: 0.1em;
+}
+.wpmdb .addons-tab .addon h1 {
+ font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
+ font-weight: normal;
+ float: left;
+ margin: 0;
+ margin-top: 5px;
+}
+.wpmdb .addons-tab .addon p {
+ font-size: 16px;
+ line-height: 1.2em;
+ clear: both;
+ padding-top: 15px;
+ margin: 0;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-media-files {
+ background: #3fab3f url(../img/icon-media-files.svg) no-repeat 30px 30px;
+ background-size: 110px 85px;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-media-files .action {
+ color: #3fab3f;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli {
+ background: #272822 url(../img/icon-cli.svg) no-repeat 30px 30px;
+ background-size: 110px 97px;
+ min-height: 157px;
+ color: #e6db74;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli .action {
+ color: #272822;
+ background-color: #ddd;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli .action:hover {
+ color: #272822;
+ background-color: #eee;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli p a {
+ text-decoration: underline;
+ color: #e6db74;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli p a:hover {
+ color: #eee69f;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli code {
+ color: #66d9ef;
+ white-space: nowrap;
+ margin: 0;
+ padding: 0;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli code .var {
+ color: #f92772;
+}
+.wpmdb .addons-tab .addon.wp-migrate-db-pro-cli code .bracket {
+ color: #fff;
+}
+
+/* Progress Information */
+/* Contain floats: h5bp.com/q */
+.clearfix:before, .clearfix:after {
+ content: "";
+ display: table;
+}
+
+.clearfix:after {
+ clear: both;
+}
+
+.clearfix {
+ zoom: 1;
+}
+
+.general-spinner {
+ width: 16px;
+ height: 16px;
+}
+
+.migration-error {
+ color: #A21B1B;
+ display: block;
+ font-weight: bold;
+ max-height: 400px;
+ max-width: 100%;
+ overflow: scroll;
+ word-wrap: break-word;
+}
+
+.progress-content {
+ display: none;
+ position: relative;
+ margin: 0 auto;
+ background-color: #fff;
+ padding: 50px;
+ box-shadow: 0 0 10px #ccc;
+ cursor: default;
+ width: 80%;
+ z-index: 99999;
+ position: fixed;
+ left: 50%;
+ margin-left: -40%;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ max-height: 100%;
+ overflow-y: auto;
+}
+.progress-content .progress-bar {
+ height: 10px;
+ background-color: #8cc1e9;
+ margin-bottom: 5px;
+ background-image: -webkit-gradient(linear, 50% 100%, 50% 0%, color-stop(0%, #72a7cf), color-stop(100%, #8cc1e9));
+ background-image: -webkit-linear-gradient(bottom, #72a7cf, #8cc1e9);
+ background-image: -moz-linear-gradient(bottom, #72a7cf, #8cc1e9);
+ background-image: -o-linear-gradient(bottom, #72a7cf, #8cc1e9);
+ background-image: linear-gradient(bottom, #72a7cf, #8cc1e9);
+}
+.progress-content .progress-title {
+ font-size: 18px;
+ font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
+ font-weight: normal;
+ float: left;
+}
+.progress-content .progress-bar {
+ width: 0%;
+}
+.progress-content .progress-info-wrapper {
+ margin-bottom: 10px;
+}
+.progress-content .progress-text {
+ clear: left;
+ float: left;
+ width: 100%;
+}
+.progress-content .timer {
+ float: right;
+}
+.progress-content .progress-tables {
+ overflow: hidden;
+ margin-bottom: 2px;
+ padding: 0 0 20px 0;
+}
+.progress-content .progress-bar-wrapper {
+ position: relative;
+}
+.progress-content .progress-bar-wrapper:before {
+ content: '';
+ display: block;
+ height: 5px;
+ width: 1px;
+ background-color: #ccc;
+ position: absolute;
+ top: 15px;
+ left: 0px;
+}
+.progress-content .progress-tables-hover-boxes {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ display: block;
+ width: 100%;
+}
+.progress-content .progress-chunk-hover {
+ display: block;
+ float: left;
+ height: 35px;
+ position: relative;
+ top: -5px;
+ z-index: 1;
+}
+.progress-content .progress-chunk {
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ float: left;
+ display: block;
+ height: 6px;
+ border-right: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+ color: #999;
+ position: relative;
+ text-align: center;
+}
+.progress-content .progress-chunk > span {
+ padding: 0px 3px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ margin-top: 10px;
+ display: inline-block;
+}
+.progress-content .progress-label {
+ padding: 5px 10px;
+ border: 1px solid #ccc;
+ border-radius: 3px;
+ background-color: #fff;
+ font-family: Consolas, Monaco, monospace;
+ font-size: 12px;
+ display: inline-block;
+ top: -35px;
+ position: absolute;
+ opacity: 0;
+ -webkit-transition: opacity 200ms ease-in-out;
+ -moz-transition: opacity 200ms ease-in-out;
+ -ms-transition: opacity 200ms ease-in-out;
+ -o-transition: opacity 200ms ease-in-out;
+ transition: opacity 200ms ease-in-out;
+}
+.progress-content .label-visible {
+ opacity: 1;
+}
+.progress-content .progress-label:before {
+ content: "";
+ width: 0;
+ height: 0;
+ border-left: 4px solid transparent;
+ border-right: 4px solid transparent;
+ border-top: 4px solid #ccc;
+ display: block;
+ position: absolute;
+ bottom: -5px;
+ left: 50%;
+ margin-left: -2px;
+}
+.progress-content .progress-label:after {
+ content: "";
+ width: 0;
+ height: 0;
+ border-left: 4px solid transparent;
+ border-right: 4px solid transparent;
+ border-top: 4px solid #fff;
+ display: block;
+ position: absolute;
+ bottom: -4px;
+ left: 50%;
+ margin-left: -2px;
+}
+.progress-content .migration-progress-ajax-spinner {
+ left: 7px;
+ position: relative;
+ top: 15px;
+}
+.progress-content .close-progress-content {
+ color: #999999;
+ cursor: pointer;
+ font-family: "Times New Roman",serif;
+ font-size: 26px;
+ font-weight: 200;
+ position: absolute;
+ right: 20px;
+ top: 20px;
+ padding: 5px;
+ display: none;
+}
+.progress-content .close-progress-content:hover {
+ color: #666;
+ border-color: #aaa;
+}
+.progress-content .migration-controls {
+ display: block;
+ margin-top: 45px;
+ overflow: hidden;
+}
+.progress-content .migration-controls span {
+ float: left;
+ text-align: center;
+ display: block;
+}
+.progress-content .migration-controls span:first-child {
+ margin-right: 10px;
+ width: 71px;
+}
+.progress-content .pro-version {
+ margin-top: 45px;
+ padding-top: 40px;
+ position: relative;
+ border-top: 1px solid #ccc;
+}
+.progress-content .pro-version iframe {
+ position: absolute;
+ top: 40px;
+ right: 0;
+ display: block;
+}
+.progress-content .pro-version-content {
+ padding-right: 460px;
+ min-height: 255px;
+}
+.progress-content .pro-version-content h1 {
+ line-height: 1em;
+ margin-top: 0;
+ font-size: 20px;
+}
+.progress-content .pro-version-content ul {
+ margin-left: 24px;
+}
+.progress-content .pro-version-content li {
+ position: relative;
+ font-size: 14px;
+ line-height: 1.4em;
+ margin-bottom: 15px;
+ max-width: 580px;
+}
+.progress-content .pro-version-content li:before {
+ content: "\f147";
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 30px/1 'dashicons';
+ position: absolute;
+ top: -3px;
+ left: -32px;
+ vertical-align: top;
+ font-family: 'dashicons';
+}
+.progress-content .pro-version-content .pro-quote {
+ margin: 0 0 20px 0;
+ max-width: 570px;
+}
+.progress-content .pro-version-content .pro-quote .dashicons-star-filled {
+ font-size: 16px;
+ width: 16px;
+ height: 16px;
+ position: relative;
+ top: 2px;
+}
+.progress-content .pro-version-content .pro-quote-author {
+ font-style: italic;
+ white-space: nowrap;
+}
+@media screen and (max-width: 1096px) {
+ .progress-content .pro-version iframe {
+ position: relative;
+ top: auto;
+ right: auto;
+ }
+ .progress-content .pro-version-content {
+ min-height: 0;
+ padding: 0 0 20px 0;
+ }
+}
+
+.wpmdb-not-pro .wpmdb .wpmdb-main {
+ margin-top: 15px;
+}
+.wpmdb-not-pro .wpmdb .migrate-selection ul {
+ margin: 0px;
+}
+.wpmdb-not-pro .wpmdb .help-tab .support p {
+ width: auto;
+}
+
+#wpmdb-sidebar {
+ position: absolute;
+ top: -21px;
+ right: -312px;
+ width: 292px;
+}
+#wpmdb-sidebar .block {
+ padding: 20px;
+ border: 1px solid #ccc;
+}
+#wpmdb-sidebar .subscribe {
+ border-top: none;
+}
+#wpmdb-sidebar .subscribe h2 {
+ padding: 0;
+ margin: 0;
+ margin-bottom: 0.5em;
+ color: #666;
+ font-size: 20px;
+ line-height: 1.2em;
+ float: none;
+}
+#wpmdb-sidebar .subscribe h3 {
+ font-size: 16px;
+ margin: 0;
+}
+#wpmdb-sidebar .subscribe p {
+ margin: 0;
+}
+#wpmdb-sidebar .subscribe p.interesting {
+ margin-bottom: 1em;
+ line-height: 1.4;
+}
+#wpmdb-sidebar .subscribe .links {
+ margin-bottom: 2em;
+}
+#wpmdb-sidebar .subscribe .links a {
+ text-decoration: none;
+}
+#wpmdb-sidebar .subscribe .promise {
+ color: #999;
+ font-size: 12px;
+ line-height: 1.4em;
+}
+#wpmdb-sidebar .subscribe .field {
+ margin-bottom: 0.5em;
+}
+#wpmdb-sidebar .subscribe .field p {
+ margin-bottom: 0.3em;
+}
+#wpmdb-sidebar .subscribe .field.submit-button {
+ margin-bottom: 1em;
+}
+#wpmdb-sidebar .testimonial {
+ border-top: none;
+}
+#wpmdb-sidebar .testimonial p {
+ margin: 0;
+}
+#wpmdb-sidebar .testimonial .quote {
+ font-size: 20px;
+}
+#wpmdb-sidebar .testimonial .author {
+ white-space: nowrap;
+ text-align: right;
+}
+#wpmdb-sidebar .testimonial .stars {
+ white-space: nowrap;
+ margin-bottom: 5px;
+}
+#wpmdb-sidebar .testimonial .via {
+ text-align: right;
+ font-size: 12px;
+}
+#wpmdb-sidebar .testimonial .via a {
+ color: #666;
+}
+#wpmdb-sidebar .testimonial .via a:before {
+ content: "\f301";
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 18px/1 'dashicons';
+ vertical-align: top;
+ margin-right: 3px;
+}
+@media (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 2.6 / 2), (-webkit-min-device-pixel-ratio: 1.3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx) {
+ #wpmdb-sidebar .wpmdb-banner {
+ background-image: url(../img/wp-migrate-db-pro@2x.jpg);
+ background-size: 292px 292px;
+ width: 292px;
+ height: 292px;
+ display: block;
+ }
+ #wpmdb-sidebar .wpmdb-banner img {
+ display: none;
+ }
+}
+@media screen and (max-width: 1252px) {
+ #wpmdb-sidebar {
+ position: relative;
+ top: auto;
+ right: auto;
+ margin-top: 50px;
+ }
+}
+
+body.mp6 input[type=checkbox]:disabled {
+ opacity: 1;
+ border-color: #ccc;
+}
+body.mp6 #wpmdb-main {
+ margin-top: 20px;
+ font-size: 14px;
+}
+body.mp6 p {
+ font-size: 14px;
+}
+body.mp6 .wrap h2 {
+ float: left;
+}
+body.mp6 .wpmdb input[type=checkbox],
+body.mp6 .wpmdb input[type=radio] {
+ vertical-align: middle;
+ margin-top: -4px;
+}
+body.mp6 .wpmdb input[type=text],
+body.mp6 .wpmdb input[type=password] {
+ padding: 3px 5px;
+}
+body.mp6 .wpmdb input.code {
+ padding-top: 6px;
+}
+body.mp6 .wpmdb label {
+ font-size: 14px;
+}
+body.mp6 .wpmdb h2.nav-tab-wrapper {
+ float: none;
+ margin-bottom: 0;
+ width: 722px;
+}
+body.mp6 .wpmdb .help-tab h3 {
+ margin-top: 0;
+}
+body.mp6 .wpmdb .temp-disabled {
+ background-color: #f9f9f9;
+}
+body.mp6 .wpmdb .migration-profile-options li a {
+ border-color: #ccc;
+ color: #555;
+ background-color: #e4e4e4;
+}
+body.mp6 .wpmdb .migration-profile-options li a:hover {
+ background-color: #fff;
+ color: #464646;
+}
+body.mp6 .wpmdb .settings-tab .slider-label span {
+ vertical-align: middle;
+}
+body.mp6 .wpmdb .settings-tab .slider-label-wrapper {
+ font-size: 14px;
+}
+body.mp6 .wpmdb .settings-tab .ui-slider {
+ border-color: #ccc;
+ background-color: #fff;
+}
+body.mp6 .wpmdb .settings-tab .ui-slider-range {
+ background-color: #d8fcd1;
+}
+body.mp6 .wpmdb .settings-tab .option-section li label {
+ font-size: 14px;
+}
+body.mp6 .wpmdb .connection-info,
+body.mp6 .wpmdb .migrate-tab .pull-push-connection-info {
+ font-weight: bold;
+ font-size: 14px;
+}
+body.mp6 .wpmdb .general-helper {
+ border: 0;
+ width: auto;
+ height: auto;
+ top: auto;
+ margin: 0;
+}
+body.mp6 .wpmdb .general-helper:after {
+ content: "\f223";
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 22px/1 'dashicons';
+ vertical-align: top;
+ top: auto;
+ left: auto;
+ position: relative;
+}
+body.mp6 .wpmdb .helper-message {
+ font-size: 14px;
+ line-height: 1.4em;
+}
+body.mp6 .wpmdb .right-arrow {
+ display: none;
+}
+body.mp6 .wpmdb .arrow-col {
+ width: 75px;
+}
+body.mp6 .wpmdb .arrow-col:after {
+ content: "\f344";
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 22px/1 'dashicons';
+ vertical-align: top;
+ color: #999;
+}
+body.mp6 .wpmdb .find-heading {
+ width: 409px;
+}
+body.mp6 .wpmdb .replace-fields input {
+ width: 304px;
+}
+body.mp6 .wpmdb .replace-right-col span {
+ border-color: #999;
+}
+body.mp6 .wpmdb .replace-right-col span:hover {
+ border-color: #666;
+}
+body.mp6 .wpmdb .replace-add-row:after, body.mp6 .wpmdb .replace-add-row:before {
+ background-color: #999;
+}
+body.mp6 .wpmdb .replace-add-row:hover:after, body.mp6 .wpmdb .replace-add-row:hover:before {
+ background-color: #666;
+}
+body.mp6 .wpmdb .option-group.migrate-selection > li > label {
+ font-size: 16px;
+}
+body.mp6 .wpmdb .saved-migration-profile-label {
+ font-size: 16px;
+}
+body.mp6 .wpmdb .option-heading, body.mp6 .wpmdb .checkbox-label {
+ font-size: 16px;
+}
+body.mp6 .wpmdb .checkbox-label input[type=checkbox] {
+ top: auto;
+}
+body.mp6 .wpmdb .return-to-profile-selection {
+ font-size: 14px;
+}
+body.mp6 .wpmdb .option-description {
+ font-size: 13px;
+}
+body.mp6 .wpmdb .save-migration-profile-wrap li {
+ position: relative;
+}
+body.mp6 .wpmdb .replace-remove-row,
+body.mp6 .wpmdb .delete-profile {
+ border: 0;
+ border-radius: 0;
+ height: auto;
+ width: auto;
+ left: 0;
+ top: 50%;
+ margin-left: 0;
+}
+body.mp6 .wpmdb .replace-remove-row:after,
+body.mp6 .wpmdb .delete-profile:after {
+ content: "\f153";
+ display: inline-block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 18px/1 'dashicons';
+ vertical-align: middle;
+ color: #999;
+}
+body.mp6 .wpmdb .replace-remove-row:hover:after,
+body.mp6 .wpmdb .delete-profile:hover:after {
+ color: #666;
+}
+body.mp6 .wpmdb .addons-tab .addon h1 {
+ font-family: 'Open Sans', sans-serif;
+ font-weight: 200;
+ font-size: 24px;
+ margin-top: 2px;
+}
+body.mp6 .wpmdb .addons-tab .addon.wp-migrate-db-pro-cli h1 {
+ margin-top: 5px;
+}
+body.mp6 .wpmdb .addons-tab .addon p {
+ font-size: 14px;
+ line-height: 1.4em;
+}
+body.mp6 .wpmdb .help-tab .support p, body.mp6 .wpmdb .help-tab .support .email a {
+ font-size: 14px;
+}
+body.mp6 .wpmdb .help-tab div.warning p {
+ font-size: 13px;
+}
+body.mp6 .wpmdb .help-tab .videos h4, body.mp6 .wpmdb .help-tab .videos p {
+ font-size: 14px;
+}
+body.mp6 .wpmdb .inline-message, body.mp6 .wpmdb .notification-message {
+ border-radius: 0;
+ border: 0;
+ box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
+ padding: 10px 14px;
+ font-size: 13px;
+}
+body.mp6 .wpmdb .notification-message {
+ margin-bottom: 20px;
+ background-color: #fff;
+}
+body.mp6 .wpmdb .notification-message.ssl-notice, body.mp6 .wpmdb .notification-message.invalid-licence {
+ margin-bottom: 0;
+ margin-top: 15px;
+}
+body.mp6 .wpmdb .notification-message p {
+ font-size: 13px;
+ margin-top: 0;
+}
+body.mp6 .wpmdb .notification-message p:last-child {
+ margin: 0;
+}
+body.mp6 .wpmdb .notification-message h4 {
+ margin-top: 0;
+}
+body.mp6 .wpmdb .notification-message a {
+ color: #0074a2;
+ text-decoration: none;
+}
+body.mp6 .wpmdb .notification-message a:hover {
+ color: #2ea2cc;
+}
+body.mp6 .wpmdb div.notification-message.invalid-licence p:last-child {
+ margin: 0.5em 0;
+}
+body.mp6 .wpmdb div.notification-message.invalid-licence p:last-child a.button {
+ color: #555555;
+}
+body.mp6 .wpmdb .inline-message.error, body.mp6 .wpmdb .notification-message.error-notice {
+ border-left: 4px solid #dd3d36;
+ background-color: #fff;
+}
+body.mp6 .wpmdb .inline-message.warning, body.mp6 .wpmdb .notification-message.warning-notice {
+ background-color: #fff;
+ border-left: 4px solid #ffba00;
+}
+body.mp6 .wpmdb .inline-message.success, body.mp6 .wpmdb .notification-message.success-notice {
+ border-left: 4px solid #7ad03a;
+}
+body.mp6 .wpmdb .ssl-notice {
+ margin-bottom: 0;
+}
+body.mp6 .wpmdb .different-plugin-version-notice, body.mp6 .wpmdb .directory-permission-notice {
+ margin-bottom: 10px;
+}
+body.mp6 .wpmdb .licence-status {
+ color: #444;
+ margin-top: 15px;
+ float: left;
+ font-weight: normal;
+}
+body.mp6 .progress-content {
+ font-size: 14px;
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
+ background-color: #eee;
+}
+body.mp6 .progress-content .progress-title {
+ font-family: 'Open Sans', sans-serif;
+ font-weight: normal;
+ font-size: 22px;
+}
+body.mp6 .progress-content .dashicons-yes {
+ font-size: 42px;
+ line-height: 0.5em;
+}
+body.mp6 .progress-content .progress-bar {
+ background-image: none;
+ background-color: #0074a2;
+}
+body.mp6 #overlay {
+ background-color: rgba(0, 0, 0, 0.5);
+}
+body.mp6 .migration-progress-ajax-spinner {
+ top: 20px;
+}
--- /dev/null
+// global vars
+var hooks = [];
+var call_stack = [];
+var non_fatal_errors = '';
+var migration_error = false;
+var connection_data;
+var next_step_in_migration;
+
+function wpmdb_call_next_hook() {
+ if( ! call_stack.length ) {
+ call_stack = hooks;
+ }
+
+ var func = call_stack[0];
+ call_stack.shift();
+ window[func](); // Uses the string from the array to call the function of the same name
+}
+
+function wpmdb_add_commas( number_string ) {
+ number_string += '';
+ x = number_string.split('.');
+ x1 = x[0];
+ x2 = x.length > 1 ? '.' + x[1] : '';
+ var rgx = /(\d+)(\d{3})/;
+ while (rgx.test(x1)) {
+ x1 = x1.replace(rgx, '$1' + ',' + '$2');
+ }
+ return x1 + x2;
+}
+
+function wpmdb_parse_json( maybe_json ) {
+ try {
+ var json_object = jQuery.parseJSON( maybe_json );
+ }
+ catch(e){
+ // we simply return false here because the json data itself will never just contain a value of "false"
+ return false;
+ }
+ return json_object;
+}
+
+(function($) {
+ // jQuery code here
+})(jQuery);
\ No newline at end of file
--- /dev/null
+(function($) {
+
+ $.wpmdb = {
+ /**
+ * Implement a WordPress-link Hook System for Javascript
+ * TODO: Change 'tag' to 'args', allow number (priority), string (tag), object (priority+tag)
+ */
+ hooks: { action: {}, filter: {} },
+ add_action: function( action, callable, tag ) {
+ jQuery.wpmdb.add_hook( 'action', action, callable, tag );
+ },
+ add_filter: function( action, callable, tag ) {
+ jQuery.wpmdb.add_hook( 'filter', action, callable, tag );
+ },
+ do_action: function( action, args ) {
+ jQuery.wpmdb.do_hook( 'action', action, null, args );
+ },
+ apply_filters: function( action, value, args ) {
+ return jQuery.wpmdb.do_hook( 'filter', action, value, args );
+ },
+ remove_action: function( action, tag ) {
+ jQuery.wpmdb.remove_hook( 'action', action, tag );
+ },
+ remove_filter: function( action, tag ) {
+ jQuery.wpmdb.remove_hook( 'filter', action, tag );
+ },
+ add_hook: function( hook_type, action, callable, tag ) {
+ if ( undefined == jQuery.wpmdb.hooks[hook_type][action] ) {
+ jQuery.wpmdb.hooks[hook_type][action] = [];
+ }
+ var hooks = jQuery.wpmdb.hooks[hook_type][action];
+ if ( undefined == tag ) {
+ tag = action + '_' + hooks.length;
+ }
+ jQuery.wpmdb.hooks[hook_type][action].push( { tag:tag, callable:callable } );
+ },
+ do_hook: function( hook_type, action, value, args ) {
+ if ( undefined != jQuery.wpmdb.hooks[hook_type][action] ) {
+ var hooks = jQuery.wpmdb.hooks[hook_type][action];
+ for( var i=0; i<hooks.length; i++) {
+ if ( 'action'==hook_type ) {
+ hooks[i].callable(args);
+ } else {
+ value = hooks[i].callable(value, args);
+ }
+ }
+ }
+ if ( 'filter'==hook_type ) {
+ return value;
+ }
+ },
+ remove_hook: function( hook_type, action, tag ) {
+ if ( undefined != jQuery.wpmdb.hooks[hook_type][action] ) {
+ var hooks = jQuery.wpmdb.hooks[hook_type][action];
+ for( var i=hooks.length-1; i>=0; i--) {
+ if (undefined==tag||tag==hooks[i].tag)
+ hooks.splice(i,1);
+ }
+ }
+ }
+ }
+
+})(jQuery);
\ No newline at end of file
--- /dev/null
+// global functions
+var migration_complete;
+var migration_complete_events;
+var migrate_table_recursive;
+var execute_next_step;
+
+(function($) {
+
+ var connection_established = false;
+ var last_replace_switch = '';
+ var doing_ajax = false;
+ var doing_licence_registration_ajax = false;
+ var doing_reset_api_key_ajax = false;
+ var doing_save_profile = false;
+ var doing_plugin_compatibility_ajax = false;
+ var profile_name_edited = false;
+ var checked_licence = false;
+ var show_prefix_notice = false;
+ var show_ssl_notice = false;
+ var show_version_notice = false;
+ var migration_completed = false;
+ var currently_migrating = false;
+ var dump_filename = '';
+ var dump_url = '';
+ var migration_intent;
+ var remote_site;
+ var secret_key;
+ var form_data;
+ var stage;
+ var elapsed_interval;
+ var completed_msg;
+ var tables_to_migrate = '';
+ var migration_paused = false;
+ var previous_progress_title;
+ var previous_progress_text;
+ var timer_count;
+ var overall_percent;
+ var migration_cancelled = false;
+
+ var admin_url = ajaxurl.replace( '/admin-ajax.php', '' ), spinner_url = admin_url + '/images/wpspin_light';
+
+ if( window.devicePixelRatio >= 2 ){
+ spinner_url += '-2x';
+ }
+
+ spinner_url += '.gif';
+
+ window.onbeforeunload = function (e) {
+ if( currently_migrating ){
+ e = e || window.event;
+
+ // For IE and Firefox prior to version 4
+ if (e) {
+ e.returnValue = wpmdb_i10n.sure;
+ }
+
+ // For Safari
+ return wpmdb_i10n.sure;
+ }
+ };
+
+ function pad(n, width, z) {
+ z = z || '0';
+ n = n + '';
+ return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
+ }
+
+ function is_int(n) {
+ n = parseInt(n);
+ return typeof n === 'number' && n % 1 == 0;
+ }
+
+ function setup_counter() {
+ timer_count = 0,
+ counter_display = $('.timer'),
+ label = wpmdb_i10n.time_elapsed + ' ';
+
+ elapsed_interval = setInterval(count,1000);
+ }
+
+ function display_count() {
+ hours = Math.floor( timer_count / 3600 ) % 24;
+ minutes = Math.floor( timer_count / 60 ) % 60;
+ seconds = timer_count % 60;
+ var display = label + pad(hours,2,0) + ':' + pad(minutes,2,0) + ':' + pad(seconds,2,0);
+ counter_display.html(display);
+ }
+
+ function count() {
+ timer_count = timer_count + 1;
+ display_count();
+ }
+
+ function get_intersect(arr1, arr2) {
+ var r = [], o = {}, l = arr2.length, i, v;
+ for (i = 0; i < l; i++) {
+ o[arr2[i]] = true;
+ }
+ l = arr1.length;
+ for (i = 0; i < l; i++) {
+ v = arr1[i];
+ if (v in o) {
+ r.push(v);
+ }
+ }
+ return r;
+ }
+
+ function get_query_var( name ){
+ name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
+ var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
+ results = regex.exec(location.search);
+ return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+ }
+
+ function maybe_show_ssl_warning( url, key, remote_scheme ) {
+ var scheme = url.substr(0, url.indexOf(':'));
+ if( remote_scheme != scheme && url.indexOf('https') != -1 ) {
+ $('.ssl-notice').show();
+ show_ssl_notice = true;
+ url = url.replace('https','http');
+ $('.pull-push-connection-info').val( url + "\n" + key );
+ return;
+ }
+ show_ssl_notice = false;
+ return;
+ }
+
+ function maybe_show_version_warning( plugin_version, url ) {
+ if( typeof plugin_version != 'undefined' && plugin_version != wpmdb_plugin_version ) {
+ $('.different-plugin-version-notice').show();
+ $('.remote-version').html( plugin_version );
+ $('.remote-location').html( url );
+ $('.step-two').hide();
+ show_version_notice = true;
+ }
+ }
+
+ function maybe_show_prefix_notice( prefix ) {
+ if( prefix != wpmdb_this_prefix ) {
+ $('.remote-prefix').html( prefix );
+ show_prefix_notice = true;
+ if( $('#pull').is(':checked') ){
+ $('.prefix-notice.pull').show();
+ }
+ else {
+ $('.prefix-notice.push').show();
+ }
+ }
+ }
+
+ function get_domain_name( url ){
+ var temp_url = url;
+ var domain = temp_url.replace( /\/\/(.*)@/, '//' ).replace('http://','').replace('https://','').replace('www.','');
+ return domain;
+ }
+
+ function get_migration_status_label( url, intent, stage ){
+ var domain = get_domain_name(url);
+ var migrating_stage_label, completed_stage_label;
+ if ( intent == 'pull' ) {
+ migrating_stage_label = wpmdb_i10n.pull_migration_label_migrating;
+ completed_stage_label = wpmdb_i10n.pull_migration_label_completed;
+ } else {
+ migrating_stage_label = wpmdb_i10n.push_migration_label_migrating;
+ completed_stage_label = wpmdb_i10n.push_migration_label_completed;
+ }
+
+ migrating_stage_label = migrating_stage_label.replace( '%s', domain );
+ completed_stage_label = completed_stage_label.replace( '%s', domain );
+
+ if ( 'migrating' == stage ) {
+ return migrating_stage_label;
+ } else {
+ return completed_stage_label;
+ }
+ }
+
+ function remove_protocol( url ) {
+ return url.replace(/^https?:/i, "");
+ }
+
+ $(document).ready(function() {
+
+ $('#plugin-compatibility').change(function(e){
+ var install = '1';
+ if ( $(this).is(':checked') ) {
+ var answer = confirm( wpmdb_i10n.mu_plugin_confirmation );
+
+ if( ! answer ){
+ $(this).prop('checked',false);
+ return;
+ }
+ }
+ else {
+ install = '0';
+ }
+
+ $('.plugin-compatibility-wrap').toggle();
+
+ $(this).parent().append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+ $('#plugin-compatibility').attr('disabled','disabled');
+ $('.plugin-compatibility').addClass('disabled');
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_plugin_compatibility',
+ install : install,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.plugin_compatibility_settings_problem + '\r\n\r\n' + wpmdb_i10n.status + ' ' + jqXHR.status + ' ' + jqXHR.statusText + '\r\n\r\n' + wpmdb_i10n.response + '\r\n' + jqXHR.responseText );
+ $('.ajax-spinner').remove();
+ $('#plugin-compatibility').removeAttr('disabled');
+ $('.plugin-compatibility').removeClass('disabled');
+ },
+ success: function(data){
+ if( '' != $.trim( data ) ) {
+ alert( data );
+ }
+ else {
+ $('.plugin-compatibility').append('<span class="ajax-success-msg">' + wpmdb_i10n.saved + '</span>');
+ $('.ajax-success-msg').fadeOut(2000,function(){
+ $(this).remove();
+ });
+ }
+ $('.ajax-spinner').remove();
+ $('#plugin-compatibility').removeAttr('disabled');
+ $('.plugin-compatibility').removeClass('disabled');
+ }
+ });
+
+ });
+
+ if ( $('#plugin-compatibility').is(':checked') ){
+ $('.plugin-compatibility-wrap').show();
+ }
+
+ if ( navigator.userAgent.indexOf('MSIE') > 0 || navigator.userAgent.indexOf('Trident') > 0 ) {
+ $('.ie-warning').show();
+ }
+
+ if ( 0 == wpmdb_valid_licence ) {
+ $('#savefile').prop("checked", true);
+ }
+
+ $('.slider').slider({
+ range: 'min',
+ value: wpmdb_max_request / 1024,
+ min: 512,
+ max: wpmdb_bottleneck / 1024,
+ step: 512,
+ slide: function( event, ui ) {
+ $('.amount').html( wpmdb_add_commas( ui.value ) + ' kB' );
+ },
+ change: function( event, ui ) {
+ $('.amount').after( '<img src="' + spinner_url + '" alt="" class="slider-spinner general-spinner" />' );
+ $('.slider').slider('disable');
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'json',
+ cache: false,
+ data: {
+ action : 'wpmdb_update_max_request_size',
+ max_request_size : parseInt( ui.value ),
+ nonce : wpmdb_nonces.update_max_request_size,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ $('.slider').slider('enable');
+ $('.slider-spinner').remove();
+ alert( wpmdb_i10n.max_request_size_problem );
+ },
+ success: function(data){
+ $('.slider').slider('enable');
+ $('.slider-spinner').remove();
+ $('.slider-success-msg').show();
+ $('.slider-success-msg').fadeOut(2000,function(){
+ $(this).hide();
+ });
+ }
+ });
+ }
+ });
+ $('.amount').html( wpmdb_add_commas( $('.slider').slider('value') ) + ' kB' );
+
+ var progress_content_original = $('.progress-content').clone();
+ $('.progress-content').remove();
+
+ var push_select = $('#select-tables').clone();
+ var pull_select = $('#select-tables').clone();
+ var push_post_type_select = $('#select-post-types').clone();
+ var pull_post_type_select = $('#select-post-types').clone();
+ var push_select_backup = $('#select-backup').clone();
+ var pull_select_backup = $('#select-backup').clone();
+
+ $('.help-tab .video').each(function() {
+ var $container = $(this),
+ $viewer = $('.video-viewer');
+
+ $('a', this).click(function(e) {
+ e.preventDefault();
+
+ $viewer.attr('src', '//www.youtube.com/embed/' + $container.data('video-id') + '?autoplay=1');
+ $viewer.show();
+ var offset = $viewer.offset();
+ $(window).scrollTop(offset.top - 50);
+ });
+ });
+
+ $('.backup-options').show();
+ $('.keep-active-plugins').show();
+ if( $('#savefile').is(':checked') ){
+ $('.backup-options').hide();
+ $('.keep-active-plugins').hide();
+ }
+
+ function check_licence( licence ){
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'json',
+ cache: false,
+ data: {
+ action : 'wpmdb_check_licence',
+ licence : licence,
+ nonce : wpmdb_nonces.check_licence,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.license_check_problem );
+ },
+ success: function(data){
+ if ( typeof data.errors !== 'undefined' ) {
+ var msg = '';
+ for (var key in data.errors) {
+ msg += data.errors[key];
+ }
+ $('.support-content').empty().html( msg );
+ $('.addons-content').empty().html( msg );
+ }
+ else {
+ $('.support-content').empty().html(data.message);
+ $('.addons-content').empty().html(data.addon_content);
+ }
+ }
+ });
+ }
+
+ function disable_export_type_controls() {
+ $('.option-group').each(function(index){
+ $('input', this).attr('disabled','disabled');
+ $('label', this).css('cursor','default');
+ });
+ }
+
+ function enable_export_type_controls() {
+ $('.option-group').each(function(index){
+ $('input', this).removeAttr('disabled');
+ $('label', this).css('cursor','pointer');
+ });
+ }
+
+ // automatically validate connnection info if we're loading a saved profile
+ establish_remote_connection_from_saved_profile();
+
+ function establish_remote_connection_from_saved_profile(){
+ var action = $('input[name=action]:checked').val();
+ var connection_info = $.trim( $('.pull-push-connection-info').val() ).split("\n");
+ if( typeof wpmdb_default_profile == 'undefined' || wpmdb_default_profile == true || action == 'savefile' || doing_ajax || ! wpmdb_is_pro ){
+ return;
+ }
+
+ last_replace_switch = action;
+
+ doing_ajax = true;
+ disable_export_type_controls();
+
+ $('.connection-status').html( wpmdb_i10n.establishing_remote_connection );
+ $('.connection-status').removeClass( 'notification-message error-notice migration-error' );
+ $('.connection-status').append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+
+ var intent = $('input[name=action]:checked').val();
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'json',
+ cache: false,
+ data: {
+ action : 'wpmdb_verify_connection_to_remote_site',
+ url : connection_info[0],
+ key : connection_info[1],
+ intent : intent,
+ nonce : wpmdb_nonces.verify_connection_to_remote_site,
+ convert_post_type_selection : wpmdb_convert_post_type_selection,
+ profile : wpmdb_profile
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ $('.connection-status').html( wpmdb_i10n.connection_local_server_problem + ' (#102)' );
+ $('.connection-status').append( '<br /><br />' + wpmdb_i10n.status + ': ' + jqXHR.status + ' ' + jqXHR.statusText + '<br /><br />' + wpmdb_i10n.response + '<br />' + jqXHR.responseText );
+ $('.connection-status').addClass( 'notification-message error-notice migration-error' );
+ $('.ajax-spinner').remove();
+ doing_ajax = false;
+ enable_export_type_controls();
+ },
+ success: function(data){
+ $('.ajax-spinner').remove();
+ doing_ajax = false;
+ enable_export_type_controls();
+
+ if( typeof data.wpmdb_error != 'undefined' && data.wpmdb_error == 1 ){
+ $('.connection-status').html( data.body );
+ $('.connection-status').addClass( 'notification-message error-notice migration-error' );
+
+ if( data.body.indexOf( '401 Unauthorized' ) > -1 ) {
+ $('.basic-access-auth-wrapper').show();
+ }
+
+ return;
+ }
+
+ maybe_show_ssl_warning( connection_info[0], connection_info[1], data.scheme );
+ maybe_show_version_warning( data.plugin_version, connection_info[0] );
+ maybe_show_prefix_notice( data.prefix );
+
+ $('.pull-push-connection-info').addClass('temp-disabled');
+ $('.pull-push-connection-info').attr('readonly','readonly');
+ $('.connect-button').hide();
+
+ $('.connection-status').hide();
+ $('.step-two').show();
+ connection_established = true;
+ connection_data = data;
+ move_connection_info_box();
+
+ var loaded_tables = '';
+ if( wpmdb_default_profile == false && typeof wpmdb_loaded_tables != 'undefined' ){
+ loaded_tables = wpmdb_loaded_tables;
+ }
+
+ var table_select = document.createElement('select');
+ $(table_select).attr({
+ multiple : 'multiple',
+ name : 'select_tables[]',
+ id : 'select-tables',
+ class : 'multiselect'
+ });
+
+ $.each(connection_data.tables, function(index, value) {
+ var selected = $.inArray( value, loaded_tables );
+ if( selected != -1 ){
+ selected = ' selected="selected" ';
+ }
+ else{
+ selected = ' ';
+ }
+ $(table_select).append('<option' + selected + 'value="' + value + '">' + value + ' (' + connection_data.table_sizes_hr[value] + ')</option>');
+ });
+
+ pull_select = table_select;
+
+ var loaded_post_types = '';
+ if( wpmdb_default_profile == false && typeof wpmdb_loaded_post_types != 'undefined' ){
+ if ( typeof data.select_post_types != 'undefined' ) {
+ $('#exclude-post-types').attr('checked','checked');
+ $('.post-type-select-wrap').show();
+ loaded_post_types = data.select_post_types;
+ }
+ else {
+ loaded_post_types = wpmdb_loaded_post_types;
+ }
+ }
+
+ var post_type_select = document.createElement('select');
+ $(post_type_select).attr({
+ multiple : 'multiple',
+ name : 'select_post_types[]',
+ id : 'select-post-types',
+ class : 'multiselect'
+ });
+
+ $.each(connection_data.post_types, function(index, value) {
+ var selected = $.inArray( value, loaded_post_types );
+ if( selected != -1 || ( wpmdb_convert_exclude_revisions == true && value != 'revision' ) ){
+ selected = ' selected="selected" ';
+ }
+ else{
+ selected = ' ';
+ }
+ $(post_type_select).append('<option' + selected + 'value="' + value + '">' + value + '</option>');
+ });
+
+ pull_post_type_select = post_type_select;
+
+ var loaded_tables_backup = '';
+ if( wpmdb_default_profile == false && typeof wpmdb_loaded_tables_backup != 'undefined' ){
+ loaded_tables_backup = wpmdb_loaded_tables_backup;
+ }
+
+ var table_select_backup = document.createElement('select');
+ $(table_select_backup).attr({
+ multiple : 'multiple',
+ name : 'select_backup[]',
+ id : 'select-backup',
+ class : 'multiselect'
+ });
+
+ $.each(connection_data.tables, function(index, value) {
+ var selected = $.inArray( value, loaded_tables_backup );
+ if( selected != -1 ){
+ selected = ' selected="selected" ';
+ }
+ else{
+ selected = ' ';
+ }
+ $(table_select_backup).append('<option' + selected + 'value="' + value + '">' + value + ' (' + connection_data.table_sizes_hr[value] + ')</option>');
+ });
+
+ push_select_backup = table_select_backup;
+
+ if( $('#pull').is(':checked') ){
+ $('#select-tables').remove();
+ $('.select-tables-wrap').prepend(pull_select);
+ $('#select-post-types').remove();
+ $('.select-post-types-wrap').prepend(pull_post_type_select);
+ $('#select-backup').remove();
+ $('.backup-tables-wrap').prepend(pull_select_backup);
+ $('.table-prefix').html(data.prefix);
+ $('.uploads-dir').html(wpmdb_this_uploads_dir);
+ }
+ else {
+ $('#select-backup').remove();
+ $('.backup-tables-wrap').prepend(push_select_backup);
+ }
+
+ $.wpmdb.do_action( 'verify_connection_to_remote_site', connection_data );
+
+ }
+
+ });
+
+ }
+
+ // add to <a> tags which act as JS event buttons, will not jump page to top and will deselect the button
+ $('.js-action-link').click(function(e){
+ e.preventDefault();
+ $(this).blur();
+ });
+
+ // registers your licence
+ $('.licence-form').submit(function(e){
+ e.preventDefault();
+
+ if( doing_licence_registration_ajax ){
+ return;
+ }
+
+ $('.licence-status').removeClass( 'notification-message error-notice success-notice' );
+
+ var licence_key = $.trim( $('.licence-input').val() );
+
+ if( licence_key == '' ){
+ $('.licence-status').addClass( 'notification-message error-notice' );
+ $('.licence-status').html( wpmdb_i10n.enter_license_key );
+ return;
+ }
+
+ $('.licence-status').empty().removeClass('success');
+ doing_licence_registration_ajax = true;
+ $('.button.register-licence').after( '<img src="' + spinner_url + '" alt="" class="register-licence-ajax-spinner general-spinner" />' );
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'JSON',
+ cache: false,
+ data: {
+ action : 'wpmdb_activate_licence',
+ licence_key : licence_key,
+ nonce : wpmdb_nonces.activate_licence,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ doing_licence_registration_ajax = false;
+ $('.register-licence-ajax-spinner').remove();
+ $('.licence-status').html( wpmdb_i10n.register_license_problem );
+ },
+ success: function(data){
+ doing_licence_registration_ajax = false;
+ $('.register-licence-ajax-spinner').remove();
+
+ if ( typeof data.errors !== 'undefined' ) {
+ var msg = '';
+ for (var key in data.errors) {
+ msg += data.errors[key];
+ }
+ $('.licence-status').html( msg );
+ }
+ else if ( typeof data.wpmdb_error !== 'undefined' && typeof data.body !== 'undefined' ) {
+ $('.licence-status').html( data.body );
+ }
+ else {
+ $('.licence-input, .register-licence').remove();
+ $('.licence-not-entered').prepend( data.masked_licence );
+ $('.licence-status').html( wpmdb_i10n.license_registered ).delay(5000).fadeOut(1000);
+ $('.licence-status').addClass('success notification-message success-notice');
+ $('.support-content').empty().html('<p>' + wpmdb_i10n.fetching_license + '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" /></p>');
+ check_licence( licence_key );
+
+ $('.invalid-licence').hide();
+ $('.migrate-selection label').removeClass('disabled');
+ $('.migrate-selection input').removeAttr('disabled');
+ }
+ }
+ });
+
+ });
+
+ // clears the debug log
+ $('.clear-log').click(function(){
+ $('.debug-log-textarea').val('');
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_clear_log',
+ nonce : wpmdb_nonces.clear_log,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.clear_log_problem );
+ },
+ success: function(data){
+ }
+ });
+ });
+
+ // updates the debug log when the user switches to the help tab
+ function refresh_debug_log(){
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_get_log',
+ nonce : wpmdb_nonces.get_log,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.update_log_problem );
+ },
+ success: function(data){
+ $('.debug-log-textarea').val(data);
+ }
+ });
+ }
+
+ // select all tables
+ $('.multiselect-select-all').click(function(){
+ var multiselect = $(this).parents('.select-wrap').children('.multiselect');
+ $(multiselect).focus();
+ $('option', multiselect).attr('selected',1);
+ });
+
+ // deselect all tables
+ $('.multiselect-deselect-all').click(function(){
+ var multiselect = $(this).parents('.select-wrap').children('.multiselect');
+ $(multiselect).focus();
+ $('option', multiselect).removeAttr('selected');
+ });
+
+ // invert table selection
+ $('.multiselect-invert-selection').click(function(){
+ var multiselect = $(this).parents('.select-wrap').children('.multiselect');
+ $(multiselect).focus();
+ $('option', multiselect).each(function(){
+ $(this).attr('selected', ! $(this).attr('selected'));
+ });
+ });
+
+ // on option select hide all "advanced" option divs and show the correct div for the option selected
+ $('.option-group input[type=radio]').change(function() {
+ group = $(this).closest('.option-group');
+ $('ul', group).hide();
+ parent = $(this).closest('li');
+ $('ul', parent).show();
+ });
+
+ // on page load, expand hidden divs for selected options (browser form cache)
+ $('.option-group').each(function(){
+ $('.option-group input[type=radio]').each(function(){
+ if( $(this).is(':checked') ){
+ parent = $(this).closest('li');
+ $('ul', parent).show();
+ }
+ });
+ });
+
+ // expand and collapse content on click
+ $('.header-expand-collapse').click(function(){
+ if( $('.expand-collapse-arrow', this).hasClass('collapsed') ){
+ $('.expand-collapse-arrow', this).removeClass('collapsed');
+ $(this).next().show();
+ }
+ else{
+ $('.expand-collapse-arrow', this).addClass('collapsed');
+ $(this).next().hide();
+ }
+ });
+
+ $('.checkbox-label input[type=checkbox]').change(function() {
+ if( $(this).is(':checked') ){
+ $(this).parent().next().show();
+ }
+ else {
+ $(this).parent().next().hide();
+ }
+ });
+
+ // special expand and collapse content on click for save migration profile
+ $('#save-migration-profile').change(function() {
+ if( $(this).is(':checked') ){
+ $('.save-settings-button').show();
+ $('.migrate-db .button-primary').val(wpmdb_i10n.migrate_db_save);
+ }
+ else{
+ $('.save-settings-button').hide();
+ $('.migrate-db .button-primary').val(wpmdb_i10n.migrate_db);
+ }
+ });
+
+ if( $('#save-migration-profile').is(':checked') ){
+ $('.save-settings-button').show();
+ $('.migrate-db .button-primary').val(wpmdb_i10n.migrate_db_save);
+ };
+
+ $('.checkbox-label input[type=checkbox]').each(function(){
+ if( $(this).is(':checked') ){
+ $(this).parent().next().show();
+ }
+ });
+
+ $('#new-url').change(function(){
+ $('#new-url-missing-warning').hide();
+ });
+
+ $('#new-path').change(function(){
+ $('#new-path-missing-warning').hide();
+ });
+
+ // AJAX migrate button
+ $('.migrate-db-button').click(function(event){
+ $(this).blur();
+ event.preventDefault();
+
+ // check that they've selected some tables to migrate
+ if( $('#migrate-selected').is(':checked') && $('#select-tables').val() == null ){
+ alert( wpmdb_i10n.please_select_one_table );
+ return;
+ }
+
+ new_url_missing = false;
+ new_file_path_missing = false;
+ if ( $('#new-url').length && !$('#new-url').val() ) {
+ $('#new-url-missing-warning').show();
+ $('#new-url').focus();
+ $('html,body').scrollTop(0);
+ new_url_missing = true;
+ }
+
+ if ( $('#new-path').length && !$('#new-path').val() ) {
+ $('#new-path-missing-warning').show();
+ if ( false == new_url_missing ) {
+ $('#new-path').focus();
+ $('html,body').scrollTop(0);
+ }
+ new_file_path_missing = true;
+ }
+
+ if ( true == new_url_missing || true == new_file_path_missing ) return;
+
+ // also save profile
+ if( $('#save-migration-profile').is(':checked') ){
+
+ if( $.trim( $('.create-new-profile').val() ) == '' && $('#create_new').is(':checked') ){
+ alert( wpmdb_i10n.enter_name_for_profile );
+ $('.create-new-profile').focus();
+ return;
+ }
+
+ var create_new_profile = false;
+
+ if( $('#create_new').is(':checked') ){
+ create_new_profile = true;
+ }
+ var profile_name = $('.create-new-profile').val();
+
+ profile = $('#migrate-form').serialize();
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_save_profile',
+ profile : profile,
+ nonce : wpmdb_nonces.save_profile,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.save_profile_problem );
+ },
+ success: function(data){
+ if(create_new_profile){
+ var new_profile_key = parseInt(data, 10);
+ var new_profile_id = new_profile_key + 1;
+ var new_li = '<li><span style="display: none;" class="delete-profile" data-profile-id="' + new_profile_id + '"></span><label for="profile-' + new_profile_id + '"><input id="profile-' + new_profile_id + '" value="' + new_profile_key + '" name="save_migration_profile_option" type="radio"> ' + profile_name + '</label></li>';
+ $('#create_new').parents('li').before(new_li);
+ $('#profile-' + new_profile_id).attr('checked','checked');
+ $('.create-new-profile').val('');
+ }
+ }
+ });
+ }
+
+ form_data = $('#migrate-form').serialize();
+
+ var doc_height = $(document).height();
+
+ $('body').append('<div id="overlay"></div>');
+
+ $('#overlay')
+ .height(doc_height)
+ .css({
+ 'position': 'fixed',
+ 'top': 0,
+ 'left': 0,
+ 'width': '100%',
+ 'z-index': 99999,
+ 'display': 'none',
+ });
+
+ $progress_content = progress_content_original.clone();
+ migration_intent = $('input[name=action]:checked').val();
+
+ stage = 'backup';
+
+ if( migration_intent == 'savefile' ){
+ stage = 'migrate';
+ }
+
+ if( $('#create-backup').is(':checked') == false ){
+ stage = 'migrate';
+ }
+
+ var table_intent = $('input[name=table_migrate_option]:checked').val();
+ var connection_info = $.trim( $('.pull-push-connection-info').val() ).split("\n");
+ var table_rows = '';
+
+ remote_site = connection_info[0];
+ secret_key = connection_info[1];
+
+ var static_migration_label = '';
+
+ $('#overlay').after($progress_content);
+
+ completed_msg = wpmdb_i10n.exporting_complete;
+
+ if( migration_intent == 'savefile' ){
+ static_migration_label = wpmdb_i10n.exporting_please_wait;
+ }
+ else{
+ static_migration_label = get_migration_status_label(remote_site, migration_intent, 'migrating');
+ completed_msg = get_migration_status_label(remote_site, migration_intent, 'completed');
+ }
+
+ $('.progress-title').html(static_migration_label);
+
+ $('#overlay').show();
+ backup_option = $('input[name=backup_option]:checked').val();
+ table_option = $('input[name=table_migrate_option]:checked').val();
+
+ if( stage == 'backup' ) {
+ if( table_option == 'migrate_only_with_prefix' && backup_option == 'backup_selected' ) {
+ backup_option = 'backup_only_with_prefix';
+ }
+ if( migration_intent == 'push' ){
+ table_rows = connection_data.table_rows;
+ if( backup_option == 'backup_only_with_prefix' ) {
+ tables_to_migrate = connection_data.prefixed_tables;
+ }
+ else if( backup_option == 'backup_selected' ) {
+ selected_tables = $('#select-tables').val();
+ tables_to_migrate = get_intersect( selected_tables, connection_data.tables );
+ }
+ else if( backup_option == 'backup_manual_select' ) {
+ tables_to_migrate = $('#select-backup').val();
+ }
+ }
+ else{
+ table_rows = wpmdb_this_table_rows;
+ if( backup_option == 'backup_only_with_prefix' ) {
+ tables_to_migrate = wpmdb_this_prefixed_tables;
+ }
+ else if( backup_option == 'backup_selected' ) {
+ selected_tables = $('#select-tables').val();
+ tables_to_migrate = get_intersect( selected_tables, wpmdb_this_tables );
+ }
+ else if( backup_option == 'backup_manual_select' ) {
+ tables_to_migrate = $('#select-backup').val();
+ }
+ }
+ }
+ else {
+ if( table_intent == 'migrate_select' ){ // user has elected to migrate only certain tables
+ // grab tables as per what the user has selected from the multiselect box
+ tables_to_migrate = $('#select-tables').val();
+ // user is pushing or exporting
+ if( migration_intent == 'push' || migration_intent == 'savefile' ){
+ // default value, assuming we're not backing up
+ table_rows = wpmdb_this_table_rows;
+ }
+ else{
+ table_rows = connection_data.table_rows;
+ }
+ }
+ else{
+ if( migration_intent == 'push' || migration_intent == 'savefile' ){
+ tables_to_migrate = wpmdb_this_prefixed_tables;
+ table_rows = wpmdb_this_table_rows;
+ }
+ else{
+ tables_to_migrate = connection_data.prefixed_tables;
+ table_rows = connection_data.table_rows;
+ }
+ }
+ }
+
+ function decide_tables_to_display_rows( tables_to_migrate, table_rows ){
+
+ var total_size = 0;
+ $.each(tables_to_migrate, function(index, value) {
+ total_size += parseInt(table_rows[value]);
+ });
+
+ var last_element = '';
+ $.each(tables_to_migrate, function(index, value) {
+ var percent = table_rows[value] / total_size * 100;
+ var percent_rounded = Math.round(percent*1000)/1000;
+ $('.progress-tables').append('<div class="progress-chunk ' + value + '_chunk" style="width: ' + percent_rounded + '%;" title="' + value + '"><span>' + value + '</span></div>');
+ $('.progress-tables-hover-boxes').append('<div class="progress-chunk-hover" data-table="' + value + '" style="width: ' + percent_rounded + '%;"></div>');
+ var label = $('.progress-tables .progress-chunk:last span');
+ last_element = value;
+ });
+
+ $('.progress-chunk').each(function(index){
+ if( $(this).width() < 1 && tables_to_migrate[index] != last_element ){
+ $(this).hide();
+ $('.progress-chunk-hover[data-table=' + tables_to_migrate[index] + ']').hide();
+ table_rows[last_element] = Number(table_rows[last_element]);
+ table_rows[last_element] += Number(table_rows[tables_to_migrate[index]]);
+ table_rows[tables_to_migrate[index]] = 0;
+ }
+ var element = this;
+ setTimeout(function(){
+ hide_overflowing_elements(element);
+ }, 0);
+
+ function hide_overflowing_elements(element){
+ if( $('span', element).innerWidth() > $(element).width() ){
+ $('span', element).hide();
+ }
+ }
+
+ });
+
+ percent_rounded = 0;
+ if( table_rows[last_element] != 0 ){
+ var percent = table_rows[last_element] / total_size * 100;
+ var percent_rounded = Math.round(percent*1000)/1000;
+ }
+ $('.progress-tables .progress-chunk:last').css('width',percent_rounded + '%');
+ $('.progress-chunk-hover:last').css('width',percent_rounded + '%');
+
+ var return_vals = [table_rows,total_size];
+
+ return return_vals;
+
+ }
+
+ table_details = decide_tables_to_display_rows( tables_to_migrate, table_rows );
+ table_rows = table_details[0];
+ total_size = table_details[1];
+
+ $('.progress-title').after( '<img src="' + spinner_url + '" alt="" class="migration-progress-ajax-spinner general-spinner" />' );
+
+ var height = $('.progress-content').outerHeight();
+ $('.progress-content').css('top', '-' + height + 'px').show().animate({'top': '0px'});
+
+ setup_counter();
+ currently_migrating = true;
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'json',
+ cache: false,
+ data: {
+ action : 'wpmdb_initiate_migration',
+ intent : migration_intent,
+ url : remote_site,
+ key : secret_key,
+ form_data : form_data,
+ stage : stage,
+ nonce : wpmdb_nonces.initiate_migration,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ $('.progress-title').html(wpmdb_i10n.migration_failed);
+ $('.progress-text').html( wpmdb_i10n.connection_local_server_problem + ' (#112)' );
+ $('.progress-text').append( '<br /><br />' + wpmdb_i10n.status + ': ' + jqXHR.status + ' ' + jqXHR.statusText + '<br /><br />' + wpmdb_i10n.response + ':<br />' + jqXHR.responseText );
+ $('.progress-text').addClass( 'migration-error' );
+ console.log( jqXHR );
+ console.log( textStatus );
+ console.log( errorThrown );
+ migration_error = true;
+ migration_complete_events();
+ return;
+ },
+ success: function(data){
+ if( typeof data.wpmdb_error != 'undefined' && data.wpmdb_error == 1 ){
+ migration_error = true;
+ migration_complete_events();
+ $('.progress-title').html( wpmdb_i10n.migration_failed );
+ $('.progress-text').addClass( 'migration-error' );
+ $('.progress-text').html( data.body );
+ return;
+ }
+
+ dump_url = data.dump_url;
+ dump_filename = data.dump_filename;
+
+ var i = 0;
+ var progress_size = 0;
+ overall_percent = 0;
+ var table_progress = 0;
+ var temp_progress = 0;
+ var last_progress = 0;
+ var overall_table_progress = 0;
+
+ migrate_table_recursive = function( current_row, primary_keys ){
+
+ if( i >= tables_to_migrate.length ){
+ if( stage == 'backup' ) {
+ stage = 'migrate';
+ i = 0;
+ progress_size = 0;
+ $('.progress-bar').width('0px');
+
+ if( table_intent == 'migrate_select' ){
+ tables_to_migrate = $('#select-tables').val();
+ if( migration_intent == 'push' || migration_intent == 'savefile' ){
+ table_rows = wpmdb_this_table_rows;
+ }
+ else{
+ table_rows = connection_data.table_rows;
+ }
+ }
+ else{
+ if( migration_intent == 'push' || migration_intent == 'savefile' ){
+ tables_to_migrate = wpmdb_this_prefixed_tables;
+ table_rows = wpmdb_this_table_rows;
+ }
+ else{
+ tables_to_migrate = connection_data.prefixed_tables;
+ table_rows = connection_data.table_rows;
+ }
+ }
+
+ $('.progress-tables').empty();
+ $('.progress-tables-hover-boxes').empty();
+
+ table_details = decide_tables_to_display_rows( tables_to_migrate, table_rows );
+ table_rows = table_details[0];
+ total_size = table_details[1];
+
+ }
+ else {
+ hooks = $.wpmdb.apply_filters( 'wpmdb_before_migration_complete_hooks', hooks );
+ hooks.push( 'migration_complete' );
+ hooks = $.wpmdb.apply_filters( 'wpmdb_after_migration_complete_hooks', hooks );
+ hooks.push( 'migration_complete_events' );
+ next_step_in_migration = { fn: wpmdb_call_next_hook };
+ execute_next_step();
+ return;
+ }
+ }
+
+ if( stage == 'backup' ){
+ $('.progress-text').html( overall_percent + '% - ' + wpmdb_i10n.backing_up + ' "' + tables_to_migrate[i] + '"' );
+ }
+ else{
+ $('.progress-text').html( overall_percent + '% - ' + wpmdb_i10n.migrating + ' "' + tables_to_migrate[i] + '"');
+ }
+
+ last_table = 0;
+ if( i == ( tables_to_migrate.length - 1 ) ) {
+ last_table = 1;
+ }
+
+ gzip = 0;
+ if( migration_intent != 'savefile' && parseInt( connection_data.gzip ) == 1 ) {
+ gzip = 1;
+ }
+
+ var request_data = {
+ action : 'wpmdb_migrate_table',
+ intent : migration_intent,
+ url : remote_site,
+ key : secret_key,
+ table : tables_to_migrate[i],
+ form_data : form_data,
+ stage : stage,
+ current_row : current_row,
+ dump_filename : dump_filename,
+ last_table : last_table,
+ primary_keys : primary_keys,
+ gzip : gzip,
+ nonce : wpmdb_nonces.migrate_table,
+ };
+
+ if( migration_intent != 'savefile' ) {
+ request_data.bottleneck = connection_data.bottleneck;
+ request_data.prefix = connection_data.prefix;
+ }
+
+ if( connection_data && connection_data.path_current_site && connection_data.domain ) {
+ request_data.path_current_site = connection_data.path_current_site;
+ request_data.domain_current_site = connection_data.domain;
+ }
+
+ doing_ajax = true;
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ timeout: 0,
+ data: request_data,
+ error: function(jqXHR, textStatus, errorThrown){
+ $('.progress-title').html(wpmdb_i10n.migration_failed);
+ $('.progress-text').html( wpmdb_i10n.table_process_problem + ' ' + tables_to_migrate[i] );
+ $('.progress-text').append( '<br /><br />' + wpmdb_i10n.status + ': ' + jqXHR.status + ' ' + jqXHR.statusText + '<br /><br />' + wpmdb_i10n.response + ':<br />' + jqXHR.responseText );
+ $('.progress-text').addClass( 'migration-error' );
+ doing_ajax = false;
+ console.log( jqXHR );
+ console.log( textStatus );
+ console.log( errorThrown );
+ migration_error = true;
+ migration_complete_events();
+ return;
+ },
+ success: function(data){
+ doing_ajax = false;
+ data = $.trim( data );
+ row_information = wpmdb_parse_json( data );
+ if( false == row_information || null == row_information ){
+ $('.progress-title').html(wpmdb_i10n.migration_failed);
+ if( '' == data || null == data ) {
+ $('.progress-text').html( wpmdb_i10n.table_process_problem_empty_response + ' ' + tables_to_migrate[i] );
+ }
+ else {
+ $('.progress-text').html(data);
+ }
+ $('.progress-text').addClass('migration-error');
+ migration_error = true;
+ migration_complete_events();
+ return;
+ }
+
+ if( typeof row_information.wpmdb_error != 'undefined' && row_information.wpmdb_error == 1 ){
+ $('.progress-title').html(wpmdb_i10n.migration_failed);
+ $('.progress-text').addClass( 'migration-error' );
+ $('.progress-text').html( row_information.body );
+ migration_error = true;
+ migration_complete_events();
+ return;
+ }
+
+ if( row_information.current_row == '-1' ) {
+ progress_size -= overall_table_progress;
+ overall_table_progress = 0;
+ last_progress = 0;
+ progress_size += parseInt(table_rows[tables_to_migrate[i]]);
+ i++;
+ row_information.current_row = '';
+ row_information.primary_keys = '';
+ }
+ else {
+ temp_progress = parseInt( row_information.current_row );
+ table_progress = temp_progress - last_progress;
+ last_progress = temp_progress;
+ progress_size += table_progress;
+ overall_table_progress += table_progress;
+ }
+ var percent = 100 * progress_size / total_size;
+ $('.progress-bar').width(percent + '%');
+ overall_percent = Math.floor(percent);
+ next_step_in_migration = { fn: migrate_table_recursive, args: [ row_information.current_row, row_information.primary_keys ] };
+ execute_next_step();
+ }
+ });
+
+ }
+
+ next_step_in_migration = { fn: migrate_table_recursive, args: [ '-1', '' ] };
+ execute_next_step();
+
+ }
+
+ }); // end ajax
+
+ });
+
+ migration_complete_events = function() {
+ if( false == migration_error ) {
+ if( non_fatal_errors == '' ) {
+ if( 'savefile' != migration_intent && true == $('#save_computer').is(':checked') ) {
+ $('.progress-text').css('visibility','hidden');
+ }
+ $('.progress-title').html(completed_msg).append('<div class="dashicons dashicons-yes"></div>');
+ }
+ else {
+ $('.progress-text').html(non_fatal_errors);
+ $('.progress-text').addClass('migration-error');
+ $('.progress-title').html( wpmdb_i10n.completed_with_some_errors );
+ }
+
+ $('.progress-bar-wrapper').hide();
+ }
+
+ $('.migration-controls').hide();
+
+ // reset migration variables so consecutive migrations work correctly
+ hooks = [];
+ call_stack = [];
+ migration_error = false;
+ currently_migrating = false;
+ migration_completed = true;
+ migration_paused = false;
+ migration_cancelled = false;
+ doing_ajax = false;
+ non_fatal_errors = '';
+
+ $('.progress-label').remove();
+ $('.migration-progress-ajax-spinner').remove();
+ $('.close-progress-content').show();
+ $('#overlay').css('cursor','pointer');
+ clearInterval( elapsed_interval );
+ }
+
+ migration_complete = function() {
+ $('.migration-controls').fadeOut();
+ if( migration_intent == 'savefile' ){
+ currently_migrating = false;
+ var migrate_complete_text = wpmdb_i10n.migration_complete;
+ if( $('#save_computer').is(':checked') ){
+ var url = wpmdb_this_download_url + encodeURIComponent( dump_filename );
+ if( $('#gzip_file').is(':checked') ){
+ url += '&gzip=1';
+ }
+ window.location = url;
+ }
+ else{
+ migrate_complete_text = wpmdb_i10n.completed_dump_located_at + ' <a href="' + dump_url + '">' + dump_url + '</a>.';
+ }
+
+ if( migration_error == false ){
+ $('.progress-text').html(migrate_complete_text);
+ migration_complete_events();
+ $('.progress-title').html(completed_msg);
+ }
+
+ }
+ else{ // rename temp tables, delete old tables
+ $('.progress-text').html( wpmdb_i10n.finalizing_migration );
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_finalize_migration',
+ intent : migration_intent,
+ url : remote_site,
+ key : secret_key,
+ form_data : form_data,
+ prefix : connection_data.prefix,
+ temp_prefix : connection_data.temp_prefix,
+ tables : tables_to_migrate.join(','),
+ nonce : wpmdb_nonces.finalize_migration,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ $('.progress-title').html( wpmdb_i10n.migration_failed );
+ $('.progress-text').html( wpmdb_i10n.finalize_tables_problem );
+ $('.progress-text').addClass('migration-error');
+ alert( jqXHR + ' : ' + textStatus + ' : ' + errorThrown );
+ migration_error = true;
+ migration_complete_events();
+ return;
+ },
+ success: function(data){
+ if( $.trim( data ) != '' ){
+ $('.progress-title').html( wpmdb_i10n.migration_failed );
+ $('.progress-text').html(data);
+ $('.progress-text').addClass('migration-error');
+ migration_error = true;
+ migration_complete_events();
+ return;
+ }
+ next_step_in_migration = { fn: wpmdb_call_next_hook };
+ execute_next_step();
+ }
+ });
+ }
+
+ }
+
+ // close progress pop up once migration is completed
+ $('body').delegate('.close-progress-content-button', 'click', function(e){
+ hide_overlay();
+ });
+
+ $('body').delegate('#overlay', 'click', function(){
+ if( migration_completed == true ){
+ hide_overlay();
+ }
+ });
+
+ function hide_overlay(){
+ var height = $('.progress-content').outerHeight();
+ $('.progress-content').animate({'top' : '-' + height + 'px'}, 400, 'swing', function(){ $('#overlay').remove(); $('.progress-content').remove(); } );
+ migration_completed = false;
+ }
+
+ // AJAX save button profile
+ $('.save-settings-button').click(function(event){
+ var profile;
+ $(this).blur();
+ event.preventDefault();
+
+ if( doing_save_profile ){
+ return;
+ }
+
+ // check that they've selected some tables to migrate
+ if( $('#migrate-selected').is(':checked') && $('#select-tables').val() == null ){
+ alert( wpmdb_i10n.please_select_one_table );
+ return;
+ }
+
+ if( $.trim( $('.create-new-profile').val() ) == '' && $('#create_new').is(':checked') ){
+ alert( wpmdb_i10n.enter_name_for_profile );
+ $('.create-new-profile').focus();
+ return;
+ }
+
+ var create_new_profile = false;
+
+ if( $('#create_new').is(':checked') ){
+ create_new_profile = true;
+ }
+ var profile_name = $('.create-new-profile').val();
+
+ doing_save_profile = true;
+ profile = $('#migrate-form').serialize();
+
+ $('.save-settings-button').after( '<img src="' + spinner_url + '" alt="" class="save-profile-ajax-spinner general-spinner" />' );
+ $(this).attr('disabled','disabled');
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_save_profile',
+ profile : profile,
+ nonce : wpmdb_nonces.save_profile,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.save_profile_problem );
+ $('.save-settings-button').removeAttr('disabled');
+ $('.save-profile-ajax-spinner').remove();
+ $('.save-settings-button').after('<span class="ajax-success-msg">' + wpmdb_i10n.saved + '</span>');
+ $('.ajax-success-msg').fadeOut(2000,function(){
+ $(this).remove();
+ });
+ doing_save_profile = false;
+ },
+ success: function(data){
+ $('.save-settings-button').removeAttr('disabled');
+ $('.save-profile-ajax-spinner').remove();
+ $('.save-settings-button').after('<span class="ajax-success-msg">' + wpmdb_i10n.saved + '</span>');
+ $('.ajax-success-msg').fadeOut(2000,function(){
+ $(this).remove();
+ });
+ doing_save_profile = false;
+ $('.create-new-profile').val('');
+
+ if(create_new_profile){
+ var new_profile_key = parseInt(data, 10);
+ var new_profile_id = new_profile_key + 1;
+ var new_li = '<li><span style="display: none;" class="delete-profile" data-profile-id="' + new_profile_id + '"></span><label for="profile-' + new_profile_id + '"><input id="profile-' + new_profile_id + '" value="' + new_profile_key + '" name="save_migration_profile_option" type="radio"> ' + profile_name + '</label></li>';
+ $('#create_new').parents('li').before(new_li);
+ $('#profile-' + new_profile_id).attr('checked','checked');
+ }
+
+ }
+ });
+
+ });
+
+ // progress label updating
+ $('body').delegate('.progress-chunk-hover', 'mousemove', function(e) {
+ mX = e.pageX;
+ offset = $('.progress-bar-wrapper').offset();
+ label_offset = $('.progress-label').outerWidth() / 2;
+ mX = ( mX - offset.left ) - label_offset;
+ $('.progress-label').css('left', mX + 'px');
+ $('.progress-label').html($(this).attr('data-table'));
+ });
+
+ // show / hide progress lavel on hover
+ $('body').delegate('.progress-chunk-hover', 'hover', function(event) {
+ if( event.type === 'mouseenter' ){
+ $('.progress-label').addClass('label-visible');
+ }
+ else{
+ $('.progress-label').removeClass('label-visible');
+ }
+ });
+
+ // move around textarea depending on whether or not the push/pull options are selected
+ connection_info_box = $('.connection-info-wrapper');
+ move_connection_info_box();
+
+ $('.migrate-selection.option-group input[type=radio]').change(function() {
+ move_connection_info_box();
+ if( connection_established ){
+ change_replace_values();
+ }
+ });
+
+ // save file (export) / push / pull special conditions
+ function move_connection_info_box(){
+ $('.connection-status').hide();
+ $('.prefix-notice').hide();
+ $('.ssl-notice').hide();
+ $('.different-plugin-version-notice').hide();
+ $('.step-two').show();
+ $('.backup-options').show();
+ $('.keep-active-plugins').show();
+ $('.directory-permission-notice').hide();
+ $('#create-backup').removeAttr('disabled');
+ $('#create-backup-label').removeClass('disabled');
+ $('.backup-option-disabled').hide();
+ var connection_info = $.trim( $('.pull-push-connection-info').val() ).split("\n");
+ if( $('#pull').is(':checked') ){
+ $('.pull-list li').append( connection_info_box );
+ connection_info_box.show();
+ if( connection_established ){
+ $('.connection-status').hide();
+ $('.step-two').show();
+ $('.table-prefix').html(connection_data.prefix);
+ $('.uploads-dir').html(wpmdb_this_uploads_dir);
+ if( profile_name_edited == false ){
+ var profile_name = get_domain_name( connection_data.url );
+ $('.create-new-profile').val(profile_name);
+ }
+ if( show_prefix_notice == true ) {
+ $('.prefix-notice.pull').show();
+ }
+ if( show_ssl_notice == true ) {
+ $('.ssl-notice').show();
+ }
+ if( show_version_notice == true ) {
+ $('.different-plugin-version-notice').show();
+ $('.step-two').hide();
+ }
+ $('.directory-scope').html('local');
+ if( false == wpmdb_write_permission ) {
+ $('#create-backup').prop('checked',false);
+ $('#create-backup').attr('disabled','disabled');
+ $('#create-backup-label').addClass('disabled');
+ $('.backup-option-disabled').show();
+ $('.upload-directory-location').html(wpmdb_this_upload_dir_long);
+ }
+ }
+ else{
+ $('.connection-status').show();
+ $('.step-two').hide();
+ }
+ }
+ else if( $('#push').is(':checked') ){
+ $('.push-list li').append( connection_info_box );
+ connection_info_box.show();
+ if( connection_established ){
+ $('.connection-status').hide();
+ $('.step-two').show();
+ $('.table-prefix').html(wpmdb_this_prefix);
+ $('.uploads-dir').html(connection_data.uploads_dir);
+ if( profile_name_edited == false ){
+ var profile_name = get_domain_name( connection_data.url );
+ $('.create-new-profile').val(profile_name);
+ }
+ if( show_prefix_notice == true ) {
+ $('.prefix-notice.push').show();
+ }
+ if( show_ssl_notice == true ) {
+ $('.ssl-notice').show();
+ }
+ if( show_version_notice == true ) {
+ $('.different-plugin-version-notice').show();
+ $('.step-two').hide();
+ }
+ $('.directory-scope').html('remote');
+ if( '0' == connection_data.write_permissions ) {
+ $('#create-backup').prop('checked',false);
+ $('#create-backup').attr('disabled','disabled');
+ $('#create-backup-label').addClass('disabled');
+ $('.backup-option-disabled').show();
+ $('.upload-directory-location').html(connection_data.upload_dir_long);
+ }
+ }
+ else{
+ $('.connection-status').show();
+ $('.step-two').hide();
+ }
+ }
+ else if( $('#savefile').is(':checked') ){
+ $('.connection-status').hide();
+ $('.step-two').show();
+ $('.table-prefix').html(wpmdb_this_prefix);
+ if( profile_name_edited == false ){
+ $('.create-new-profile').val('');
+ }
+ $('.backup-options').hide();
+ $('.keep-active-plugins').hide();
+ if( false == wpmdb_write_permission ) {
+ $('.directory-permission-notice').show();
+ $('.step-two').hide();
+ }
+ }
+ $.wpmdb.do_action( 'move_connection_info_box' );
+ }
+
+ function change_replace_values(){
+ if( $('#push').is(':checked') || $('#savefile').is(':checked') ){
+ if( last_replace_switch == '' || last_replace_switch == 'pull' ){
+ $('.replace-row').each(function(){
+ var old_val = $('.old-replace-col input', this).val();
+ $('.old-replace-col input', this).val( $('.replace-right-col input', this).val() );
+ $('.replace-right-col input', this).val( old_val );
+ });
+ }
+ $('#select-tables').remove();
+ $('.select-tables-wrap').prepend(push_select);
+ $('#select-post-types').remove();
+ $('.select-post-types-wrap').prepend(push_post_type_select);
+ $('#select-backup').remove();
+ $('.backup-tables-wrap').prepend(push_select_backup);
+ last_replace_switch = 'push';
+ }
+ else if( $('#pull').is(':checked') ){
+ if( last_replace_switch == '' || last_replace_switch == 'push' ){
+ $('.replace-row').each(function(){
+ var old_val = $('.old-replace-col input', this).val();
+ $('.old-replace-col input', this).val( $('.replace-right-col input', this).val() );
+ $('.replace-right-col input', this).val( old_val );
+ });
+ }
+ $('#select-tables').remove();
+ $('.select-tables-wrap').prepend(pull_select);
+ $('#select-post-types').remove();
+ $('.select-post-types-wrap').prepend(pull_post_type_select);
+ $('#select-backup').remove();
+ $('.backup-tables-wrap').prepend(pull_select_backup);
+ last_replace_switch = 'pull';
+ }
+
+ }
+
+ // hide second section if pull or push is selected with no connection established
+ if( ( $('#pull').is(':checked') || $('#push').is(':checked') ) && ! connection_established ){
+ $('.step-two').hide();
+ $('.connection-status').show();
+ }
+
+ // show / hide GUID helper description
+ $('.general-helper').click(function(e){
+ var icon = $(this),
+ bubble = $(this).next();
+
+ // Close any that are already open
+ $('.helper-message').not(bubble).hide();
+
+ var position = icon.position();
+ if( bubble.hasClass('bottom') ) {
+ bubble.css({
+ 'left': (position.left - bubble.width()/2) + 'px',
+ 'top': (position.top + icon.height() + 9) + 'px'
+ });
+ } else {
+ bubble.css({
+ 'left': (position.left + icon.width() + 9) + 'px',
+ 'top': (position.top + icon.height()/2 - 18) + 'px'
+ });
+ }
+
+ bubble.toggle();
+ e.stopPropagation();
+ });
+
+ $('body').click(function(){
+ $('.helper-message').hide();
+ });
+
+ $('.helper-message').click(function(e){
+ e.stopPropagation();
+ });
+
+ // migrate / settings tabs
+ $('.nav-tab').click(function(){
+ $('.nav-tab').removeClass('nav-tab-active');
+ $(this).addClass('nav-tab-active');
+ $('.content-tab').hide();
+ $('.' + $(this).attr('data-div-name')).show();
+
+ var hash = $(this).attr('data-div-name');
+ hash = hash.replace('-tab','');
+ window.location.hash = hash;
+
+ if( $(this).hasClass('help') ) {
+ refresh_debug_log();
+ if( checked_licence == false && wpmdb_has_licence == '1' ) {
+ $('.support-content p').append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+ check_licence();
+ checked_licence = true;
+ }
+ }
+
+ if( $(this).hasClass('addons') ) {
+ if( checked_licence == false && wpmdb_has_licence == '1' ) {
+ $('.addons-content p').append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+ check_licence();
+ checked_licence = true;
+ }
+ }
+
+ });
+
+ // repeatable fields
+ $('body').delegate('.add-row', 'click', function() {
+ $(this).parents('tr').before( $('.original-repeatable-field').clone().removeClass('original-repeatable-field') );
+ });
+
+ // repeatable fields
+ $('body').delegate('.replace-remove-row', 'click', function() {
+ $(this).parents('tr').remove();
+ if( $('.replace-row').length < 2 ){
+ $('.no-replaces-message').show();
+ }
+ });
+
+ $('.add-replace').click(function(){
+ $('.replace-fields').prepend( $('.original-repeatable-field').clone().removeClass('original-repeatable-field') );
+ $('.no-replaces-message').hide();
+ });
+
+ $
+
+ $('body').delegate('#find-and-replace-sort tbody tr.replace-row', 'hover', function(event) {
+ if( event.type === 'mouseenter' ){
+ $('.replace-remove-row', this).show();
+ }
+ else{
+ $('.replace-remove-row', this).hide();
+ }
+ });
+
+ $('#find-and-replace-sort tbody').sortable({
+ items: '> tr:not(.pin)',
+ handle: 'td:first',
+ start: function () {
+ $('.sort-handle').css('cursor', '-webkit-grabbing');
+ $('.sort-handle').css('cursor', '-moz-grabbing');
+ },
+ stop: function () {
+ $('.sort-handle').css('cursor', '-webkit-grab');
+ $('.sort-handle').css('cursor', '-moz-grab');
+ }
+ });
+
+ // delete saved profiles
+ $('body').delegate('.save-migration-profile-wrap li', 'hover', function(event) {
+ if( event.type === 'mouseenter' ){
+ $('.delete-profile', this).show();
+ }
+ else{
+ $('.delete-profile', this).hide();
+ }
+ });
+
+ function validate_url( url ){
+ return /^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url);
+ }
+
+ // check for hash in url (settings || migrate) switch tabs accordingly
+ if(window.location.hash) {
+ var hash = window.location.hash.substring(1);
+ switch_to_plugin_tab(hash, false);
+ }
+
+ if( get_query_var( 'install-plugin' ) != '' ) {
+ hash = 'addons';
+ checked_licence = true;
+ switch_to_plugin_tab(hash, true);
+ }
+
+ function switch_to_plugin_tab( hash, skip_addons_check ) {
+ $('.nav-tab').removeClass('nav-tab-active');
+ $('.nav-tab.' + hash).addClass('nav-tab-active');
+ $('.content-tab').hide();
+ $('.' + hash + '-tab').show();
+
+ if ( hash == 'help' ) {
+ refresh_debug_log();
+ if( wpmdb_has_licence == '1' ) {
+ $('.support-content p').append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+ check_licence();
+ checked_licence = true;
+ }
+ }
+
+ if ( hash == 'addons' && true != skip_addons_check ) {
+ if( wpmdb_has_licence == '1' ) {
+ $('.addons-content p').append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+ check_licence();
+ checked_licence = true;
+ }
+ }
+ }
+
+ // regenerates the saved secret key
+ $('.reset-api-key').click(function(){
+ var answer = confirm( wpmdb_i10n.reset_api_key );
+
+ if( ! answer || doing_reset_api_key_ajax ){
+ return;
+ }
+
+ doing_reset_api_key_ajax = true;
+ $('.reset-api-key').after( '<img src="' + spinner_url + '" alt="" class="reset-api-key-ajax-spinner general-spinner" />' );
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_reset_api_key',
+ nonce : wpmdb_nonces.reset_api_key,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.reset_api_key_problem );
+ $('.reset-api-key-ajax-spinner').remove();
+ doing_reset_api_key_ajax = false;
+ },
+ success: function(data){
+ $('.reset-api-key-ajax-spinner').remove();
+ doing_reset_api_key_ajax = false;
+ $('.connection-info').html(data);
+ }
+ });
+
+ });
+
+ // show / hide table select box when specific settings change
+ $('input.multiselect-toggle').change(function(){
+ $(this).parents('.expandable-content').children('.select-wrap').toggle();
+ });
+
+ $('.show-multiselect').each(function(){
+ if( $(this).is(':checked') ){
+ $(this).parents('.option-section').children('.header-expand-collapse').children('.expand-collapse-arrow').removeClass('collapsed');
+ $(this).parents('.expandable-content').show();
+ $(this).parents('.expandable-content').children('.select-wrap').toggle();
+ }
+ });
+
+ $('input[name=backup_option]').change(function(){
+ $('.backup-tables-wrap').hide();
+ if( $(this).val() == 'backup_manual_select' ) {
+ $('.backup-tables-wrap').show();
+ }
+ });
+
+ if( $('#backup-manual-select').is(':checked') ) {
+ $('.backup-tables-wrap').show();
+ }
+
+ $('.plugin-compatibility-save').click(function(){
+ if( doing_plugin_compatibility_ajax ) {
+ return;
+ }
+ $(this).addClass('disabled');
+ select_element = $('#selected-plugins');
+ $(select_element).attr('disabled','disabled');
+
+ doing_plugin_compatibility_ajax = true;
+ $(this).after( '<img src="' + spinner_url + '" alt="" class="plugin-compatibility-spinner general-spinner" />' );
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_blacklist_plugins',
+ blacklist_plugins : $(select_element).val(),
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.blacklist_problem + '\r\n\r\n' + wpmdb_i10n.status + ' ' + jqXHR.status + ' ' + jqXHR.statusText + '\r\n\r\n' + wpmdb_i10n.response + '\r\n' + jqXHR.responseText );
+ $(select_element).removeAttr('disabled');
+ $('.plugin-compatibility-save').removeClass('disabled');
+ doing_plugin_compatibility_ajax = false;
+ $('.plugin-compatibility-spinner').remove();
+ $('.plugin-compatibility-success-msg').show().fadeOut(2000);
+ },
+ success: function(data){
+ if( '' != $.trim( data ) ) {
+ alert( data );
+ }
+ $(select_element).removeAttr('disabled');
+ $('.plugin-compatibility-save').removeClass('disabled');
+ doing_plugin_compatibility_ajax = false;
+ $('.plugin-compatibility-spinner').remove();
+ $('.plugin-compatibility-success-msg').show().fadeOut(2000);
+ }
+ });
+ });
+
+ // delete a profile from the migrate form area
+ $('body').delegate('.delete-profile', 'click', function(){
+ var name = $(this).next().clone();
+ $('input',name).remove();
+ var name = $.trim($(name).html());
+ var answer = confirm( wpmdb_i10n.remove_profile + ' "' + name + '"' );
+
+ if(!answer){
+ return;
+ }
+
+ $(this).parent().fadeOut(500);
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_delete_migration_profile',
+ profile_id : $(this).attr('data-profile-id'),
+ nonce : wpmdb_nonces.delete_migration_profile,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.remove_profile_problem );
+ },
+ success: function(data){
+ if( data == '-1' ){
+ alert( wpmdb_i10n.remove_profile_not_found );
+ }
+ }
+ });
+
+ });
+
+ // deletes a profile from the main profile selection screen
+ $('.main-list-delete-profile-link').click(function(){
+ var name = $(this).prev().html();
+ var answer = confirm( wpmdb_i10n.remove_profile + ' "' + name + '"' );
+
+ if(!answer){
+ return;
+ }
+
+ $(this).parent().fadeOut(500);
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_delete_migration_profile',
+ profile_id : $(this).attr('data-profile-id'),
+ nonce : wpmdb_nonces.delete_migration_profile,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.remove_profile_problem );
+ }
+ });
+
+ });
+
+ // warn the user when editing the connection info after a connection has been established
+ $('body').delegate('.temp-disabled', 'click', function() {
+ var answer = confirm( wpmdb_i10n.change_connection_info );
+
+ if( ! answer ){
+ return;
+ }
+ else{
+ $('.ssl-notice').hide();
+ $('.different-plugin-version-notice').hide();
+ $('.migrate-db-button').show();
+ $('.temp-disabled').removeAttr('readonly');
+ $('.temp-disabled').removeClass('temp-disabled');
+ $('.connect-button').show();
+ $('.step-two').hide();
+ $('.connection-status').show().html( wpmdb_i10n.enter_connection_info );
+ connection_established = false;
+ }
+ });
+
+ // ajax request for settings page when checking/unchecking setting radio buttons
+ $('.settings-tab input[type=checkbox]').change(function(){
+ if ( 'plugin-compatibility' == $(this).attr('id') ) return;
+ var checked = $(this).is(':checked');
+ var setting = $(this).attr('id');
+
+ $(this).parent().append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+ var $label = $(this).parent();
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: {
+ action : 'wpmdb_save_setting',
+ checked : checked,
+ setting : setting,
+ nonce : wpmdb_nonces.save_setting,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ alert( wpmdb_i10n.save_settings_problem );
+ $('.ajax-spinner').remove();
+ },
+ success: function(data){
+ $('.ajax-spinner').remove();
+ $($label).append('<span class="ajax-success-msg">' + wpmdb_i10n.saved + '</span>');
+ $('.ajax-success-msg').fadeOut(2000,function(){
+ $(this).remove();
+ });
+ }
+ });
+
+ });
+
+ // disable form submissions
+ $('.migrate-form').submit(function(e){
+ e.preventDefault();
+ });
+
+ // fire connection_box_changed when the connect button is pressed
+ $('.connect-button').click(function(event){
+ event.preventDefault();
+ $(this).blur();
+ connection_box_changed();
+ });
+
+ // send paste even to connection_box_changed() function
+ $('.pull-push-connection-info').bind('paste', function(e) {
+ var $this = this;
+ setTimeout(function () {
+ connection_box_changed();
+ }, 0);
+
+ });
+
+ $('body').delegate('.try-again','click',function(){
+ connection_box_changed();
+ });
+
+ $('body').delegate('.try-http','click',function(){
+ var connection_info = $.trim( $('.pull-push-connection-info').val() ).split("\n");
+ var new_url = connection_info[0].replace( 'https', 'http' );
+ var new_contents = new_url + "\n" + connection_info[1];
+ $('.pull-push-connection-info').val( new_contents );
+ connection_box_changed();
+ });
+
+ $('.create-new-profile').change(function(){
+ profile_name_edited = true;
+ });
+
+ $('body').delegate('.temporarily-disable-ssl','click',function(){
+ if(window.location.hash) {
+ var hash = window.location.hash.substring(1);
+ }
+ $(this).attr('href', $(this).attr('href') + '&hash=' + hash );
+ });
+
+ // fired when the connection info box changes (e.g. gets pasted into)
+ function connection_box_changed(data){
+ var $this = $('.pull-push-connection-info');
+
+ if( doing_ajax || $($this).hasClass('temp-disabled') ){
+ return;
+ }
+
+ var data = $('.pull-push-connection-info').val();
+
+ var connection_info = $.trim(data).split("\n");
+ var error = false;
+ var error_message = '';
+
+ if( connection_info == '' ){
+ error = true;
+ error_message = wpmdb_i10n.connection_info_missing;
+ }
+
+ if( connection_info.length != 2 && ! error ){
+ error = true;
+ error_message = wpmdb_i10n.connection_info_incorrect;
+ }
+
+ if( ! error && ! validate_url( connection_info[0] ) ){
+ error = true;
+ error_message = wpmdb_i10n.connection_info_url_invalid;
+ }
+
+ if( ! error && connection_info[1].length != 32 ){
+ error = true;
+ error_message = wpmdb_i10n.connection_info_key_invalid;
+ }
+
+ if( ! error && connection_info[0] == wpmdb_connection_info[0] ){
+ error = true;
+ error_message = wpmdb_i10n.connection_info_local_url;
+ }
+
+ if( ! error && connection_info[1] == wpmdb_connection_info[1] ){
+ error = true;
+ error_message = wpmdb_i10n.connection_info_local_key;
+ }
+
+ if( error ){
+ $('.connection-status').html( error_message );
+ $('.connection-status').addClass( 'notification-message error-notice migration-error' );
+ return;
+ }
+
+ if( wpmdb_openssl_available == false ) {
+ connection_info[0] = connection_info[0].replace('https://','http://');
+ var new_connection_info_contents = connection_info[0] + "\n" + connection_info[1];
+ $('.pull-push-connection-info').val(new_connection_info_contents);
+ }
+
+ show_prefix_notice = false;
+ doing_ajax = true;
+ disable_export_type_controls();
+
+ if( $('.basic-access-auth-wrapper').is(':visible') ) {
+ connection_info[0] = connection_info[0].replace( /\/\/(.*)@/, '//' );
+ connection_info[0] = connection_info[0].replace( '//', '//' + encodeURIComponent( $.trim( $('.auth-username').val() ) ) + ':' + encodeURIComponent( $.trim( $('.auth-password').val() ) ) + '@' );
+ var new_connection_info_contents = connection_info[0] + "\n" + connection_info[1];
+ $('.pull-push-connection-info').val(new_connection_info_contents);
+ $('.basic-access-auth-wrapper').hide();
+ }
+
+ $('.step-two').hide();
+ $('.ssl-notice').hide();
+ $('.prefix-notice').hide();
+ $('.connection-status').show();
+
+ $('.connection-status').html( wpmdb_i10n.establishing_remote_connection );
+ $('.connection-status').removeClass( 'notification-message error-notice migration-error' );
+ $('.connection-status').append( '<img src="' + spinner_url + '" alt="" class="ajax-spinner general-spinner" />' );
+
+ var intent = $('input[name=action]:checked').val();
+
+ profile_name_edited = false;
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'json',
+ cache: false,
+ data: {
+ action : 'wpmdb_verify_connection_to_remote_site',
+ url : connection_info[0],
+ key : connection_info[1],
+ intent : intent,
+ nonce : wpmdb_nonces.verify_connection_to_remote_site,
+ },
+ error: function(jqXHR, textStatus, errorThrown){
+ $('.connection-status').html( wpmdb_i10n.connection_local_server_problem + ' (#100)' );
+ $('.connection-status').append( '<br /><br />' + wpmdb_i10n.status + ': ' + jqXHR.status + ' ' + jqXHR.statusText + '<br /><br />' + wpmdb_i10n.response + ':<br />' + jqXHR.responseText );
+ $('.connection-status').addClass( 'notification-message error-notice migration-error' );
+ $('.ajax-spinner').remove();
+ doing_ajax = false;
+ enable_export_type_controls();
+ },
+ success: function(data){
+ $('.ajax-spinner').remove();
+ doing_ajax = false;
+ enable_export_type_controls();
+
+ if( typeof data.wpmdb_error != 'undefined' && data.wpmdb_error == 1 ){
+ $('.connection-status').html( data.body );
+ $('.connection-status').addClass( 'notification-message error-notice migration-error' );
+
+ if( data.body.indexOf( '401 Unauthorized' ) > -1 ) {
+ $('.basic-access-auth-wrapper').show();
+ }
+
+ return;
+ }
+
+ var profile_name = get_domain_name( data.url );
+ $('.create-new-profile').val(profile_name);
+
+ $('.pull-push-connection-info').addClass('temp-disabled');
+ $('.pull-push-connection-info').attr('readonly','readonly');
+ $('.connect-button').hide();
+
+ $('.connection-status').hide();
+ $('.step-two').show();
+
+ maybe_show_ssl_warning( connection_info[0], connection_info[1], data.scheme );
+ maybe_show_version_warning( data.plugin_version, connection_info[0] );
+ maybe_show_prefix_notice( data.prefix );
+
+ connection_established = true;
+ connection_data = data;
+ move_connection_info_box();
+
+ var table_select = document.createElement('select');
+ $(table_select).attr({
+ multiple : 'multiple',
+ name : 'select_tables[]',
+ id : 'select-tables',
+ class : 'multiselect'
+ });
+
+ $.each(connection_data.tables, function(index, value) {
+ $(table_select).append('<option value="' + value + '">' + value + ' (' + connection_data.table_sizes_hr[value] + ')</option>');
+ });
+
+ pull_select = table_select;
+ push_select_backup = $(table_select).clone();
+ $(push_select_backup).attr({
+ name : 'select_backup[]',
+ id : 'select-backup'
+ });
+
+ var post_type_select = document.createElement('select');
+ $(post_type_select).attr({
+ multiple : 'multiple',
+ name : 'select_post_types[]',
+ id : 'select-post-types',
+ class : 'multiselect'
+ });
+
+ $.each(connection_data.post_types, function(index, value) {
+ $(post_type_select).append('<option value="' + value + '">' + value + '</option>');
+ });
+
+ pull_post_type_select = post_type_select;
+
+ if( $('#pull').is(':checked') ){
+ $('#new-url').val( remove_protocol( wpmdb_this_url ) );
+ $('#new-path').val( wpmdb_this_path );
+ if( wpmdb_is_multisite == true ) {
+ $('#new-domain').val( wpmdb_this_domain );
+ }
+ $('#old-url').val( remove_protocol( data.url ) );
+ $('#old-path').val( data.path );
+ $('#select-tables').remove();
+ $('.select-tables-wrap').prepend(pull_select);
+ $('#select-post-types').remove();
+ $('.select-post-types-wrap').prepend(pull_post_type_select);
+ $('.table-prefix').html(data.prefix);
+ $('.uploads-dir').html(wpmdb_this_uploads_dir);
+ }
+ else{
+ $('#select-backup').remove();
+ $('.backup-tables-wrap').prepend(push_select_backup);
+ $('#new-url').val( remove_protocol( data.url ) );
+ $('#new-path').val( data.path );
+ }
+
+ next_step_in_migration = { fn: $.wpmdb.do_action, args: [ 'verify_connection_to_remote_site', connection_data ] };
+ execute_next_step();
+ }
+
+ });
+
+ }
+
+ $('body').delegate('.pause-resume','click',function(){
+ if( true == migration_paused ) {
+ migration_paused = false;
+ doing_ajax = true;
+ $('.progress-title').html(previous_progress_title);
+ $('.progress-text').html(previous_progress_text);
+ $('.migration-progress-ajax-spinner').show();
+ $('.pause-resume').html(wpmdb_i10n.pause);
+ // resume the timer
+ elapsed_interval = setInterval(count,1000);
+ execute_next_step();
+ }
+ else {
+ migration_paused = true;
+ doing_ajax = false;
+ previous_progress_title = $('.progress-title').html();
+ previous_progress_text = $('.progress-text').html();
+ $('.progress-title').html(wpmdb_i10n.migration_paused);
+ $('.pause-resume').html(wpmdb_i10n.resume);
+ $('.progress-text').html(wpmdb_i10n.completing_current_request);
+ }
+ });
+
+ $('body').delegate('.cancel','click',function(){
+ migration_cancelled = true;
+ migration_paused = false;
+ $('.progress-text').html(wpmdb_i10n.completing_current_request);
+ $('.progress-title').html(wpmdb_i10n.cancelling_migration);
+ $('.migration-controls').fadeOut();
+ $('.migration-progress-ajax-spinner').show();
+
+ if( false == doing_ajax ) {
+ execute_next_step();
+ }
+ });
+
+ $('.enter-licence').click(function() {
+ $('.settings').click();
+ $('.licence-input').focus();
+ });
+
+ execute_next_step = function() {
+ if( true == migration_paused ) {
+ $('.migration-progress-ajax-spinner').hide();
+ // pause the timer
+ clearInterval( elapsed_interval );
+ $('.progress-text').html(wpmdb_i10n.paused);
+ return;
+ }
+ else if( true == migration_cancelled) {
+ migration_intent = $('input[name=action]:checked').val();
+
+ if( 'savefile' == migration_intent ) {
+ progress_msg = wpmdb_i10n.removing_local_sql;
+ }
+ else if( 'pull' == migration_intent ) {
+ if( 'backup' == stage ) {
+ progress_msg = wpmdb_i10n.removing_local_backup;
+ }
+ else {
+ progress_msg = wpmdb_i10n.removing_local_temp_tables;
+ }
+ }
+ else if( 'push' == migration_intent ) {
+ if( 'backup' == stage ) {
+ progress_msg = wpmdb_i10n.removing_remote_sql;
+ }
+ else {
+ progress_msg = wpmdb_i10n.removing_remote_temp_tables;
+ }
+ }
+ $('.progress-text').html(progress_msg);
+
+ var request_data = {
+ action : 'wpmdb_cancel_migration',
+ intent : migration_intent,
+ url : remote_site,
+ key : secret_key,
+ stage : stage,
+ dump_filename : dump_filename,
+ form_data : form_data,
+ };
+
+ if( typeof connection_data != 'undefined' ) {
+ request_data.temp_prefix = connection_data.temp_prefix;
+ }
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ dataType: 'text',
+ cache: false,
+ data: request_data,
+ error: function(jqXHR, textStatus, errorThrown){
+ $('.progress-title').html(wpmdb_i10n.migration_cancellation_failed);
+ $('.progress-text').html(wpmdb_i10n.manually_remove_temp_files);
+ $('.progress-text').append( '<br /><br />' + wpmdb_i10n.status + ': ' + jqXHR.status + ' ' + jqXHR.statusText + '<br /><br />' + wpmdb_i10n.response + ':<br />' + jqXHR.responseText );
+ $('.progress-text').addClass( 'migration-error' );
+ console.log( jqXHR );
+ console.log( textStatus );
+ console.log( errorThrown );
+ migration_error = true;
+ migration_complete_events();
+ return;
+ },
+ success: function(data){
+ doing_ajax = false;
+ data = $.trim( data );
+ if( data != '' ){
+ $('.progress-title').html(wpmdb_i10n.migration_cancellation_failed);
+ $('.progress-text').html(data);
+ $('.progress-text').addClass('migration-error');
+ migration_error = true;
+ migration_complete_events();
+ return;
+ }
+ completed_msg = wpmdb_i10n.migration_cancelled;
+ $('.progress-text').hide();
+ migration_complete_events();
+ }
+ });
+ }
+ else {
+ next_step_in_migration.fn.apply( null, next_step_in_migration.args );
+ }
+ }
+
+ });
+
+})(jQuery);
\ No newline at end of file
--- /dev/null
+var migration_complete,migration_complete_events,migrate_table_recursive,execute_next_step;!function(a){function b(a,b,c){return c=c||"0",a+="",a.length>=b?a:new Array(b-a.length+1).join(c)+a}function c(){w=0,counter_display=a(".timer"),label=wpmdb_i10n.time_elapsed+" ",s=setInterval(e,1e3)}function d(){hours=Math.floor(w/3600)%24,minutes=Math.floor(w/60)%60,seconds=w%60;var a=label+b(hours,2,0)+":"+b(minutes,2,0)+":"+b(seconds,2,0);counter_display.html(a)}function e(){w+=1,d()}function f(a,b){var c,d,e=[],f={},g=b.length;for(c=0;g>c;c++)f[b[c]]=!0;for(g=a.length,c=0;g>c;c++)d=a[c],d in f&&e.push(d);return e}function g(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null==c?"":decodeURIComponent(c[1].replace(/\+/g," "))}function h(b,c,d){var e=b.substr(0,b.indexOf(":"));return d!=e&&-1!=b.indexOf("https")?(a(".ssl-notice").show(),I=!0,b=b.replace("https","http"),void a(".pull-push-connection-info").val(b+"\n"+c)):void(I=!1)}function i(b,c){"undefined"!=typeof b&&b!=wpmdb_plugin_version&&(a(".different-plugin-version-notice").show(),a(".remote-version").html(b),a(".remote-location").html(c),a(".step-two").hide(),J=!0)}function j(b){b!=wpmdb_this_prefix&&(a(".remote-prefix").html(b),H=!0,a("#pull").is(":checked")?a(".prefix-notice.pull").show():a(".prefix-notice.push").show())}function k(a){var b=a,c=b.replace(/\/\/(.*)@/,"//").replace("http://","").replace("https://","").replace("www.","");return c}function l(a,b,c){var d,e,f=k(a);return"pull"==b?(d=wpmdb_i10n.pull_migration_label_migrating,e=wpmdb_i10n.pull_migration_label_completed):(d=wpmdb_i10n.push_migration_label_migrating,e=wpmdb_i10n.push_migration_label_completed),d=d.replace("%s",f),e=e.replace("%s",f),"migrating"==c?d:e}function m(a){return a.replace(/^https?:/i,"")}var n,o,p,q,r,s,t,u,v,w,x,y=!1,z="",A=!1,B=!1,C=!1,D=!1,E=!1,F=!1,G=!1,H=!1,I=!1,J=!1,K=!1,L=!1,M="",N="",O="",P=!1,Q=!1,R=ajaxurl.replace("/admin-ajax.php",""),S=R+"/images/wpspin_light";window.devicePixelRatio>=2&&(S+="-2x"),S+=".gif",window.onbeforeunload=function(a){return L?(a=a||window.event,a&&(a.returnValue=wpmdb_i10n.sure),wpmdb_i10n.sure):void 0},a(document).ready(function(){function b(b){a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_check_licence",licence:b,nonce:wpmdb_nonces.check_licence},error:function(){alert(wpmdb_i10n.license_check_problem)},success:function(b){if("undefined"!=typeof b.errors){var c="";for(var d in b.errors)c+=b.errors[d];a(".support-content").empty().html(c),a(".addons-content").empty().html(c)}else a(".support-content").empty().html(b.message),a(".addons-content").empty().html(b.addon_content)}})}function d(){a(".option-group").each(function(){a("input",this).attr("disabled","disabled"),a("label",this).css("cursor","default")})}function w(){a(".option-group").each(function(){a("input",this).removeAttr("disabled"),a("label",this).css("cursor","pointer")})}function R(){var b=a("input[name=action]:checked").val(),c=a.trim(a(".pull-push-connection-info").val()).split("\n");if("undefined"!=typeof wpmdb_default_profile&&1!=wpmdb_default_profile&&"savefile"!=b&&!A&&wpmdb_is_pro){z=b,A=!0,d(),a(".connection-status").html(wpmdb_i10n.establishing_remote_connection),a(".connection-status").removeClass("notification-message error-notice migration-error"),a(".connection-status").append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />');var e=a("input[name=action]:checked").val();a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_verify_connection_to_remote_site",url:c[0],key:c[1],intent:e,nonce:wpmdb_nonces.verify_connection_to_remote_site,convert_post_type_selection:wpmdb_convert_post_type_selection,profile:wpmdb_profile},error:function(b){a(".connection-status").html(wpmdb_i10n.connection_local_server_problem+" (#102)"),a(".connection-status").append("<br /><br />"+wpmdb_i10n.status+": "+b.status+" "+b.statusText+"<br /><br />"+wpmdb_i10n.response+"<br />"+b.responseText),a(".connection-status").addClass("notification-message error-notice migration-error"),a(".ajax-spinner").remove(),A=!1,w()},success:function(b){if(a(".ajax-spinner").remove(),A=!1,w(),"undefined"!=typeof b.wpmdb_error&&1==b.wpmdb_error)return a(".connection-status").html(b.body),a(".connection-status").addClass("notification-message error-notice migration-error"),void(b.body.indexOf("401 Unauthorized")>-1&&a(".basic-access-auth-wrapper").show());h(c[0],c[1],b.scheme),i(b.plugin_version,c[0]),j(b.prefix),a(".pull-push-connection-info").addClass("temp-disabled"),a(".pull-push-connection-info").attr("readonly","readonly"),a(".connect-button").hide(),a(".connection-status").hide(),a(".step-two").show(),y=!0,connection_data=b,V();var d="";0==wpmdb_default_profile&&"undefined"!=typeof wpmdb_loaded_tables&&(d=wpmdb_loaded_tables);var e=document.createElement("select");a(e).attr({multiple:"multiple",name:"select_tables[]",id:"select-tables","class":"multiselect"}),a.each(connection_data.tables,function(b,c){var f=a.inArray(c,d);f=-1!=f?' selected="selected" ':" ",a(e).append("<option"+f+'value="'+c+'">'+c+" ("+connection_data.table_sizes_hr[c]+")</option>")}),ab=e;var f="";0==wpmdb_default_profile&&"undefined"!=typeof wpmdb_loaded_post_types&&("undefined"!=typeof b.select_post_types?(a("#exclude-post-types").attr("checked","checked"),a(".post-type-select-wrap").show(),f=b.select_post_types):f=wpmdb_loaded_post_types);var g=document.createElement("select");a(g).attr({multiple:"multiple",name:"select_post_types[]",id:"select-post-types","class":"multiselect"}),a.each(connection_data.post_types,function(b,c){var d=a.inArray(c,f);d=-1!=d||1==wpmdb_convert_exclude_revisions&&"revision"!=c?' selected="selected" ':" ",a(g).append("<option"+d+'value="'+c+'">'+c+"</option>")}),cb=g;var k="";0==wpmdb_default_profile&&"undefined"!=typeof wpmdb_loaded_tables_backup&&(k=wpmdb_loaded_tables_backup);var l=document.createElement("select");a(l).attr({multiple:"multiple",name:"select_backup[]",id:"select-backup","class":"multiselect"}),a.each(connection_data.tables,function(b,c){var d=a.inArray(c,k);d=-1!=d?' selected="selected" ':" ",a(l).append("<option"+d+'value="'+c+'">'+c+" ("+connection_data.table_sizes_hr[c]+")</option>")}),db=l,a("#pull").is(":checked")?(a("#select-tables").remove(),a(".select-tables-wrap").prepend(ab),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(cb),a("#select-backup").remove(),a(".backup-tables-wrap").prepend(eb),a(".table-prefix").html(b.prefix),a(".uploads-dir").html(wpmdb_this_uploads_dir)):(a("#select-backup").remove(),a(".backup-tables-wrap").prepend(db)),a.wpmdb.do_action("verify_connection_to_remote_site",connection_data)}})}}function T(){a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_get_log",nonce:wpmdb_nonces.get_log},error:function(){alert(wpmdb_i10n.update_log_problem)},success:function(b){a(".debug-log-textarea").val(b)}})}function U(){var b=a(".progress-content").outerHeight();a(".progress-content").animate({top:"-"+b+"px"},400,"swing",function(){a("#overlay").remove(),a(".progress-content").remove()}),K=!1}function V(){a(".connection-status").hide(),a(".prefix-notice").hide(),a(".ssl-notice").hide(),a(".different-plugin-version-notice").hide(),a(".step-two").show(),a(".backup-options").show(),a(".keep-active-plugins").show(),a(".directory-permission-notice").hide(),a("#create-backup").removeAttr("disabled"),a("#create-backup-label").removeClass("disabled"),a(".backup-option-disabled").hide();a.trim(a(".pull-push-connection-info").val()).split("\n");if(a("#pull").is(":checked"))if(a(".pull-list li").append(connection_info_box),connection_info_box.show(),y){if(a(".connection-status").hide(),a(".step-two").show(),a(".table-prefix").html(connection_data.prefix),a(".uploads-dir").html(wpmdb_this_uploads_dir),0==F){var b=k(connection_data.url);a(".create-new-profile").val(b)}1==H&&a(".prefix-notice.pull").show(),1==I&&a(".ssl-notice").show(),1==J&&(a(".different-plugin-version-notice").show(),a(".step-two").hide()),a(".directory-scope").html("local"),0==wpmdb_write_permission&&(a("#create-backup").prop("checked",!1),a("#create-backup").attr("disabled","disabled"),a("#create-backup-label").addClass("disabled"),a(".backup-option-disabled").show(),a(".upload-directory-location").html(wpmdb_this_upload_dir_long))}else a(".connection-status").show(),a(".step-two").hide();else if(a("#push").is(":checked"))if(a(".push-list li").append(connection_info_box),connection_info_box.show(),y){if(a(".connection-status").hide(),a(".step-two").show(),a(".table-prefix").html(wpmdb_this_prefix),a(".uploads-dir").html(connection_data.uploads_dir),0==F){var b=k(connection_data.url);a(".create-new-profile").val(b)}1==H&&a(".prefix-notice.push").show(),1==I&&a(".ssl-notice").show(),1==J&&(a(".different-plugin-version-notice").show(),a(".step-two").hide()),a(".directory-scope").html("remote"),"0"==connection_data.write_permissions&&(a("#create-backup").prop("checked",!1),a("#create-backup").attr("disabled","disabled"),a("#create-backup-label").addClass("disabled"),a(".backup-option-disabled").show(),a(".upload-directory-location").html(connection_data.upload_dir_long))}else a(".connection-status").show(),a(".step-two").hide();else a("#savefile").is(":checked")&&(a(".connection-status").hide(),a(".step-two").show(),a(".table-prefix").html(wpmdb_this_prefix),0==F&&a(".create-new-profile").val(""),a(".backup-options").hide(),a(".keep-active-plugins").hide(),0==wpmdb_write_permission&&(a(".directory-permission-notice").show(),a(".step-two").hide()));a.wpmdb.do_action("move_connection_info_box")}function W(){a("#push").is(":checked")||a("#savefile").is(":checked")?((""==z||"pull"==z)&&a(".replace-row").each(function(){var b=a(".old-replace-col input",this).val();a(".old-replace-col input",this).val(a(".replace-right-col input",this).val()),a(".replace-right-col input",this).val(b)}),a("#select-tables").remove(),a(".select-tables-wrap").prepend(_),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(bb),a("#select-backup").remove(),a(".backup-tables-wrap").prepend(db),z="push"):a("#pull").is(":checked")&&((""==z||"push"==z)&&a(".replace-row").each(function(){var b=a(".old-replace-col input",this).val();a(".old-replace-col input",this).val(a(".replace-right-col input",this).val()),a(".replace-right-col input",this).val(b)}),a("#select-tables").remove(),a(".select-tables-wrap").prepend(ab),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(cb),a("#select-backup").remove(),a(".backup-tables-wrap").prepend(eb),z="pull")}function X(a){return/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)}function Y(c,d){a(".nav-tab").removeClass("nav-tab-active"),a(".nav-tab."+c).addClass("nav-tab-active"),a(".content-tab").hide(),a("."+c+"-tab").show(),"help"==c&&(T(),"1"==wpmdb_has_licence&&(a(".support-content p").append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />'),b(),G=!0)),"addons"==c&&1!=d&&"1"==wpmdb_has_licence&&(a(".addons-content p").append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />'),b(),G=!0)}function Z(b){var c=a(".pull-push-connection-info");if(!A&&!a(c).hasClass("temp-disabled")){var b=a(".pull-push-connection-info").val(),e=a.trim(b).split("\n"),f=!1,g="";if(""==e&&(f=!0,g=wpmdb_i10n.connection_info_missing),2==e.length||f||(f=!0,g=wpmdb_i10n.connection_info_incorrect),f||X(e[0])||(f=!0,g=wpmdb_i10n.connection_info_url_invalid),f||32==e[1].length||(f=!0,g=wpmdb_i10n.connection_info_key_invalid),f||e[0]!=wpmdb_connection_info[0]||(f=!0,g=wpmdb_i10n.connection_info_local_url),f||e[1]!=wpmdb_connection_info[1]||(f=!0,g=wpmdb_i10n.connection_info_local_key),f)return a(".connection-status").html(g),void a(".connection-status").addClass("notification-message error-notice migration-error");if(0==wpmdb_openssl_available){e[0]=e[0].replace("https://","http://");var l=e[0]+"\n"+e[1];a(".pull-push-connection-info").val(l)}if(H=!1,A=!0,d(),a(".basic-access-auth-wrapper").is(":visible")){e[0]=e[0].replace(/\/\/(.*)@/,"//"),e[0]=e[0].replace("//","//"+encodeURIComponent(a.trim(a(".auth-username").val()))+":"+encodeURIComponent(a.trim(a(".auth-password").val()))+"@");var l=e[0]+"\n"+e[1];a(".pull-push-connection-info").val(l),a(".basic-access-auth-wrapper").hide()}a(".step-two").hide(),a(".ssl-notice").hide(),a(".prefix-notice").hide(),a(".connection-status").show(),a(".connection-status").html(wpmdb_i10n.establishing_remote_connection),a(".connection-status").removeClass("notification-message error-notice migration-error"),a(".connection-status").append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />');var n=a("input[name=action]:checked").val();F=!1,a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_verify_connection_to_remote_site",url:e[0],key:e[1],intent:n,nonce:wpmdb_nonces.verify_connection_to_remote_site},error:function(b){a(".connection-status").html(wpmdb_i10n.connection_local_server_problem+" (#100)"),a(".connection-status").append("<br /><br />"+wpmdb_i10n.status+": "+b.status+" "+b.statusText+"<br /><br />"+wpmdb_i10n.response+":<br />"+b.responseText),a(".connection-status").addClass("notification-message error-notice migration-error"),a(".ajax-spinner").remove(),A=!1,w()},success:function(b){if(a(".ajax-spinner").remove(),A=!1,w(),"undefined"!=typeof b.wpmdb_error&&1==b.wpmdb_error)return a(".connection-status").html(b.body),a(".connection-status").addClass("notification-message error-notice migration-error"),void(b.body.indexOf("401 Unauthorized")>-1&&a(".basic-access-auth-wrapper").show());var c=k(b.url);a(".create-new-profile").val(c),a(".pull-push-connection-info").addClass("temp-disabled"),a(".pull-push-connection-info").attr("readonly","readonly"),a(".connect-button").hide(),a(".connection-status").hide(),a(".step-two").show(),h(e[0],e[1],b.scheme),i(b.plugin_version,e[0]),j(b.prefix),y=!0,connection_data=b,V();var d=document.createElement("select");a(d).attr({multiple:"multiple",name:"select_tables[]",id:"select-tables","class":"multiselect"}),a.each(connection_data.tables,function(b,c){a(d).append('<option value="'+c+'">'+c+" ("+connection_data.table_sizes_hr[c]+")</option>")}),ab=d,db=a(d).clone(),a(db).attr({name:"select_backup[]",id:"select-backup"});var f=document.createElement("select");a(f).attr({multiple:"multiple",name:"select_post_types[]",id:"select-post-types","class":"multiselect"}),a.each(connection_data.post_types,function(b,c){a(f).append('<option value="'+c+'">'+c+"</option>")}),cb=f,a("#pull").is(":checked")?(a("#new-url").val(m(wpmdb_this_url)),a("#new-path").val(wpmdb_this_path),1==wpmdb_is_multisite&&a("#new-domain").val(wpmdb_this_domain),a("#old-url").val(m(b.url)),a("#old-path").val(b.path),a("#select-tables").remove(),a(".select-tables-wrap").prepend(ab),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(cb),a(".table-prefix").html(b.prefix),a(".uploads-dir").html(wpmdb_this_uploads_dir)):(a("#select-backup").remove(),a(".backup-tables-wrap").prepend(db),a("#new-url").val(m(b.url)),a("#new-path").val(b.path)),next_step_in_migration={fn:a.wpmdb.do_action,args:["verify_connection_to_remote_site",connection_data]},execute_next_step()}})}}a("#plugin-compatibility").change(function(){var b="1";if(a(this).is(":checked")){var c=confirm(wpmdb_i10n.mu_plugin_confirmation);if(!c)return void a(this).prop("checked",!1)}else b="0";a(".plugin-compatibility-wrap").toggle(),a(this).parent().append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />'),a("#plugin-compatibility").attr("disabled","disabled"),a(".plugin-compatibility").addClass("disabled"),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_plugin_compatibility",install:b},error:function(b){alert(wpmdb_i10n.plugin_compatibility_settings_problem+"\r\n\r\n"+wpmdb_i10n.status+" "+b.status+" "+b.statusText+"\r\n\r\n"+wpmdb_i10n.response+"\r\n"+b.responseText),a(".ajax-spinner").remove(),a("#plugin-compatibility").removeAttr("disabled"),a(".plugin-compatibility").removeClass("disabled")},success:function(b){""!=a.trim(b)?alert(b):(a(".plugin-compatibility").append('<span class="ajax-success-msg">'+wpmdb_i10n.saved+"</span>"),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()})),a(".ajax-spinner").remove(),a("#plugin-compatibility").removeAttr("disabled"),a(".plugin-compatibility").removeClass("disabled")}})}),a("#plugin-compatibility").is(":checked")&&a(".plugin-compatibility-wrap").show(),(navigator.userAgent.indexOf("MSIE")>0||navigator.userAgent.indexOf("Trident")>0)&&a(".ie-warning").show(),0==wpmdb_valid_licence&&a("#savefile").prop("checked",!0),a(".slider").slider({range:"min",value:wpmdb_max_request/1024,min:512,max:wpmdb_bottleneck/1024,step:512,slide:function(b,c){a(".amount").html(wpmdb_add_commas(c.value)+" kB")},change:function(b,c){a(".amount").after('<img src="'+S+'" alt="" class="slider-spinner general-spinner" />'),a(".slider").slider("disable"),a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_update_max_request_size",max_request_size:parseInt(c.value),nonce:wpmdb_nonces.update_max_request_size},error:function(){a(".slider").slider("enable"),a(".slider-spinner").remove(),alert(wpmdb_i10n.max_request_size_problem)},success:function(){a(".slider").slider("enable"),a(".slider-spinner").remove(),a(".slider-success-msg").show(),a(".slider-success-msg").fadeOut(2e3,function(){a(this).hide()})}})}}),a(".amount").html(wpmdb_add_commas(a(".slider").slider("value"))+" kB");var $=a(".progress-content").clone();a(".progress-content").remove();var _=a("#select-tables").clone(),ab=a("#select-tables").clone(),bb=a("#select-post-types").clone(),cb=a("#select-post-types").clone(),db=a("#select-backup").clone(),eb=a("#select-backup").clone();if(a(".help-tab .video").each(function(){var b=a(this),c=a(".video-viewer");a("a",this).click(function(d){d.preventDefault(),c.attr("src","//www.youtube.com/embed/"+b.data("video-id")+"?autoplay=1"),c.show();var e=c.offset();a(window).scrollTop(e.top-50)})}),a(".backup-options").show(),a(".keep-active-plugins").show(),a("#savefile").is(":checked")&&(a(".backup-options").hide(),a(".keep-active-plugins").hide()),R(),a(".js-action-link").click(function(b){b.preventDefault(),a(this).blur()}),a(".licence-form").submit(function(c){if(c.preventDefault(),!B){a(".licence-status").removeClass("notification-message error-notice success-notice");var d=a.trim(a(".licence-input").val());if(""==d)return a(".licence-status").addClass("notification-message error-notice"),void a(".licence-status").html(wpmdb_i10n.enter_license_key);a(".licence-status").empty().removeClass("success"),B=!0,a(".button.register-licence").after('<img src="'+S+'" alt="" class="register-licence-ajax-spinner general-spinner" />'),a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",cache:!1,data:{action:"wpmdb_activate_licence",licence_key:d,nonce:wpmdb_nonces.activate_licence},error:function(){B=!1,a(".register-licence-ajax-spinner").remove(),a(".licence-status").html(wpmdb_i10n.register_license_problem)},success:function(c){if(B=!1,a(".register-licence-ajax-spinner").remove(),"undefined"!=typeof c.errors){var e="";for(var f in c.errors)e+=c.errors[f];a(".licence-status").html(e)}else"undefined"!=typeof c.wpmdb_error&&"undefined"!=typeof c.body?a(".licence-status").html(c.body):(a(".licence-input, .register-licence").remove(),a(".licence-not-entered").prepend(c.masked_licence),a(".licence-status").html(wpmdb_i10n.license_registered).delay(5e3).fadeOut(1e3),a(".licence-status").addClass("success notification-message success-notice"),a(".support-content").empty().html("<p>"+wpmdb_i10n.fetching_license+'<img src="'+S+'" alt="" class="ajax-spinner general-spinner" /></p>'),b(d),a(".invalid-licence").hide(),a(".migrate-selection label").removeClass("disabled"),a(".migrate-selection input").removeAttr("disabled"))}})}}),a(".clear-log").click(function(){a(".debug-log-textarea").val(""),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_clear_log",nonce:wpmdb_nonces.clear_log},error:function(){alert(wpmdb_i10n.clear_log_problem)},success:function(){}})}),a(".multiselect-select-all").click(function(){var b=a(this).parents(".select-wrap").children(".multiselect");a(b).focus(),a("option",b).attr("selected",1)}),a(".multiselect-deselect-all").click(function(){var b=a(this).parents(".select-wrap").children(".multiselect");a(b).focus(),a("option",b).removeAttr("selected")}),a(".multiselect-invert-selection").click(function(){var b=a(this).parents(".select-wrap").children(".multiselect");a(b).focus(),a("option",b).each(function(){a(this).attr("selected",!a(this).attr("selected"))})}),a(".option-group input[type=radio]").change(function(){group=a(this).closest(".option-group"),a("ul",group).hide(),parent=a(this).closest("li"),a("ul",parent).show()}),a(".option-group").each(function(){a(".option-group input[type=radio]").each(function(){a(this).is(":checked")&&(parent=a(this).closest("li"),a("ul",parent).show())})}),a(".header-expand-collapse").click(function(){a(".expand-collapse-arrow",this).hasClass("collapsed")?(a(".expand-collapse-arrow",this).removeClass("collapsed"),a(this).next().show()):(a(".expand-collapse-arrow",this).addClass("collapsed"),a(this).next().hide())}),a(".checkbox-label input[type=checkbox]").change(function(){a(this).is(":checked")?a(this).parent().next().show():a(this).parent().next().hide()}),a("#save-migration-profile").change(function(){a(this).is(":checked")?(a(".save-settings-button").show(),a(".migrate-db .button-primary").val(wpmdb_i10n.migrate_db_save)):(a(".save-settings-button").hide(),a(".migrate-db .button-primary").val(wpmdb_i10n.migrate_db))}),a("#save-migration-profile").is(":checked")&&(a(".save-settings-button").show(),a(".migrate-db .button-primary").val(wpmdb_i10n.migrate_db_save)),a(".checkbox-label input[type=checkbox]").each(function(){a(this).is(":checked")&&a(this).parent().next().show()}),a("#new-url").change(function(){a("#new-url-missing-warning").hide()}),a("#new-path").change(function(){a("#new-path-missing-warning").hide()}),a(".migrate-db-button").click(function(b){function d(b,c){var d=0;a.each(b,function(a,b){d+=parseInt(c[b])});var e="";if(a.each(b,function(b,f){var g=c[f]/d*100,h=Math.round(1e3*g)/1e3;a(".progress-tables").append('<div class="progress-chunk '+f+'_chunk" style="width: '+h+'%;" title="'+f+'"><span>'+f+"</span></div>"),a(".progress-tables-hover-boxes").append('<div class="progress-chunk-hover" data-table="'+f+'" style="width: '+h+'%;"></div>');a(".progress-tables .progress-chunk:last span");e=f}),a(".progress-chunk").each(function(d){function f(b){a("span",b).innerWidth()>a(b).width()&&a("span",b).hide()}a(this).width()<1&&b[d]!=e&&(a(this).hide(),a(".progress-chunk-hover[data-table="+b[d]+"]").hide(),c[e]=Number(c[e]),c[e]+=Number(c[b[d]]),c[b[d]]=0);var g=this;setTimeout(function(){f(g)},0)}),g=0,0!=c[e])var f=c[e]/d*100,g=Math.round(1e3*f)/1e3;a(".progress-tables .progress-chunk:last").css("width",g+"%"),a(".progress-chunk-hover:last").css("width",g+"%");var h=[c,d];return h}if(a(this).blur(),b.preventDefault(),a("#migrate-selected").is(":checked")&&null==a("#select-tables").val())return void alert(wpmdb_i10n.please_select_one_table);if(new_url_missing=!1,new_file_path_missing=!1,a("#new-url").length&&!a("#new-url").val()&&(a("#new-url-missing-warning").show(),a("#new-url").focus(),a("html,body").scrollTop(0),new_url_missing=!0),a("#new-path").length&&!a("#new-path").val()&&(a("#new-path-missing-warning").show(),0==new_url_missing&&(a("#new-path").focus(),a("html,body").scrollTop(0)),new_file_path_missing=!0),1!=new_url_missing&&1!=new_file_path_missing){if(a("#save-migration-profile").is(":checked")){if(""==a.trim(a(".create-new-profile").val())&&a("#create_new").is(":checked"))return alert(wpmdb_i10n.enter_name_for_profile),void a(".create-new-profile").focus();var e=!1;a("#create_new").is(":checked")&&(e=!0);var g=a(".create-new-profile").val();profile=a("#migrate-form").serialize(),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_save_profile",profile:profile,nonce:wpmdb_nonces.save_profile},error:function(){alert(wpmdb_i10n.save_profile_problem)},success:function(b){if(e){var c=parseInt(b,10),d=c+1,f='<li><span style="display: none;" class="delete-profile" data-profile-id="'+d+'"></span><label for="profile-'+d+'"><input id="profile-'+d+'" value="'+c+'" name="save_migration_profile_option" type="radio"> '+g+"</label></li>";a("#create_new").parents("li").before(f),a("#profile-"+d).attr("checked","checked"),a(".create-new-profile").val("")}}})}q=a("#migrate-form").serialize();var h=a(document).height();a("body").append('<div id="overlay"></div>'),a("#overlay").height(h).css({position:"fixed",top:0,left:0,width:"100%","z-index":99999,display:"none"}),$progress_content=$.clone(),n=a("input[name=action]:checked").val(),r="backup","savefile"==n&&(r="migrate"),0==a("#create-backup").is(":checked")&&(r="migrate");var i=a("input[name=table_migrate_option]:checked").val(),j=a.trim(a(".pull-push-connection-info").val()).split("\n"),k="";o=j[0],p=j[1];var m="";a("#overlay").after($progress_content),t=wpmdb_i10n.exporting_complete,"savefile"==n?m=wpmdb_i10n.exporting_please_wait:(m=l(o,n,"migrating"),t=l(o,n,"completed")),a(".progress-title").html(m),a("#overlay").show(),backup_option=a("input[name=backup_option]:checked").val(),table_option=a("input[name=table_migrate_option]:checked").val(),"backup"==r?("migrate_only_with_prefix"==table_option&&"backup_selected"==backup_option&&(backup_option="backup_only_with_prefix"),"push"==n?(k=connection_data.table_rows,"backup_only_with_prefix"==backup_option?O=connection_data.prefixed_tables:"backup_selected"==backup_option?(selected_tables=a("#select-tables").val(),O=f(selected_tables,connection_data.tables)):"backup_manual_select"==backup_option&&(O=a("#select-backup").val())):(k=wpmdb_this_table_rows,"backup_only_with_prefix"==backup_option?O=wpmdb_this_prefixed_tables:"backup_selected"==backup_option?(selected_tables=a("#select-tables").val(),O=f(selected_tables,wpmdb_this_tables)):"backup_manual_select"==backup_option&&(O=a("#select-backup").val()))):"migrate_select"==i?(O=a("#select-tables").val(),k="push"==n||"savefile"==n?wpmdb_this_table_rows:connection_data.table_rows):"push"==n||"savefile"==n?(O=wpmdb_this_prefixed_tables,k=wpmdb_this_table_rows):(O=connection_data.prefixed_tables,k=connection_data.table_rows),table_details=d(O,k),k=table_details[0],total_size=table_details[1],a(".progress-title").after('<img src="'+S+'" alt="" class="migration-progress-ajax-spinner general-spinner" />');var s=a(".progress-content").outerHeight();a(".progress-content").css("top","-"+s+"px").show().animate({top:"0px"}),c(),L=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_initiate_migration",intent:n,url:o,key:p,form_data:q,stage:r,nonce:wpmdb_nonces.initiate_migration},error:function(b,c,d){a(".progress-title").html(wpmdb_i10n.migration_failed),a(".progress-text").html(wpmdb_i10n.connection_local_server_problem+" (#112)"),a(".progress-text").append("<br /><br />"+wpmdb_i10n.status+": "+b.status+" "+b.statusText+"<br /><br />"+wpmdb_i10n.response+":<br />"+b.responseText),a(".progress-text").addClass("migration-error"),console.log(b),console.log(c),console.log(d),migration_error=!0,migration_complete_events()},success:function(b){if("undefined"!=typeof b.wpmdb_error&&1==b.wpmdb_error)return migration_error=!0,migration_complete_events(),a(".progress-title").html(wpmdb_i10n.migration_failed),a(".progress-text").addClass("migration-error"),void a(".progress-text").html(b.body);N=b.dump_url,M=b.dump_filename;var c=0,e=0;x=0;var f=0,g=0,h=0,j=0;migrate_table_recursive=function(b,l){if(c>=O.length){if("backup"!=r)return hooks=a.wpmdb.apply_filters("wpmdb_before_migration_complete_hooks",hooks),hooks.push("migration_complete"),hooks=a.wpmdb.apply_filters("wpmdb_after_migration_complete_hooks",hooks),hooks.push("migration_complete_events"),next_step_in_migration={fn:wpmdb_call_next_hook},void execute_next_step();r="migrate",c=0,e=0,a(".progress-bar").width("0px"),"migrate_select"==i?(O=a("#select-tables").val(),k="push"==n||"savefile"==n?wpmdb_this_table_rows:connection_data.table_rows):"push"==n||"savefile"==n?(O=wpmdb_this_prefixed_tables,k=wpmdb_this_table_rows):(O=connection_data.prefixed_tables,k=connection_data.table_rows),a(".progress-tables").empty(),a(".progress-tables-hover-boxes").empty(),table_details=d(O,k),k=table_details[0],total_size=table_details[1]}a(".progress-text").html("backup"==r?x+"% - "+wpmdb_i10n.backing_up+' "'+O[c]+'"':x+"% - "+wpmdb_i10n.migrating+' "'+O[c]+'"'),last_table=0,c==O.length-1&&(last_table=1),gzip=0,"savefile"!=n&&1==parseInt(connection_data.gzip)&&(gzip=1);var m={action:"wpmdb_migrate_table",intent:n,url:o,key:p,table:O[c],form_data:q,stage:r,current_row:b,dump_filename:M,last_table:last_table,primary_keys:l,gzip:gzip,nonce:wpmdb_nonces.migrate_table};"savefile"!=n&&(m.bottleneck=connection_data.bottleneck,m.prefix=connection_data.prefix),connection_data&&connection_data.path_current_site&&connection_data.domain&&(m.path_current_site=connection_data.path_current_site,m.domain_current_site=connection_data.domain),A=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,timeout:0,data:m,error:function(b,d,e){a(".progress-title").html(wpmdb_i10n.migration_failed),a(".progress-text").html(wpmdb_i10n.table_process_problem+" "+O[c]),a(".progress-text").append("<br /><br />"+wpmdb_i10n.status+": "+b.status+" "+b.statusText+"<br /><br />"+wpmdb_i10n.response+":<br />"+b.responseText),a(".progress-text").addClass("migration-error"),A=!1,console.log(b),console.log(d),console.log(e),migration_error=!0,migration_complete_events()},success:function(b){if(A=!1,b=a.trim(b),row_information=wpmdb_parse_json(b),0==row_information||null==row_information)return a(".progress-title").html(wpmdb_i10n.migration_failed),a(".progress-text").html(""==b||null==b?wpmdb_i10n.table_process_problem_empty_response+" "+O[c]:b),a(".progress-text").addClass("migration-error"),migration_error=!0,void migration_complete_events();if("undefined"!=typeof row_information.wpmdb_error&&1==row_information.wpmdb_error)return a(".progress-title").html(wpmdb_i10n.migration_failed),a(".progress-text").addClass("migration-error"),a(".progress-text").html(row_information.body),migration_error=!0,void migration_complete_events();"-1"==row_information.current_row?(e-=j,j=0,h=0,e+=parseInt(k[O[c]]),c++,row_information.current_row="",row_information.primary_keys=""):(g=parseInt(row_information.current_row),f=g-h,h=g,e+=f,j+=f);
+var d=100*e/total_size;a(".progress-bar").width(d+"%"),x=Math.floor(d),next_step_in_migration={fn:migrate_table_recursive,args:[row_information.current_row,row_information.primary_keys]},execute_next_step()}})},next_step_in_migration={fn:migrate_table_recursive,args:["-1",""]},execute_next_step()}})}}),migration_complete_events=function(){0==migration_error&&(""==non_fatal_errors?("savefile"!=n&&1==a("#save_computer").is(":checked")&&a(".progress-text").css("visibility","hidden"),a(".progress-title").html(t).append('<div class="dashicons dashicons-yes"></div>')):(a(".progress-text").html(non_fatal_errors),a(".progress-text").addClass("migration-error"),a(".progress-title").html(wpmdb_i10n.completed_with_some_errors)),a(".progress-bar-wrapper").hide()),a(".migration-controls").hide(),hooks=[],call_stack=[],migration_error=!1,L=!1,K=!0,P=!1,Q=!1,A=!1,non_fatal_errors="",a(".progress-label").remove(),a(".migration-progress-ajax-spinner").remove(),a(".close-progress-content").show(),a("#overlay").css("cursor","pointer"),clearInterval(s)},migration_complete=function(){if(a(".migration-controls").fadeOut(),"savefile"==n){L=!1;var b=wpmdb_i10n.migration_complete;if(a("#save_computer").is(":checked")){var c=wpmdb_this_download_url+encodeURIComponent(M);a("#gzip_file").is(":checked")&&(c+="&gzip=1"),window.location=c}else b=wpmdb_i10n.completed_dump_located_at+' <a href="'+N+'">'+N+"</a>.";0==migration_error&&(a(".progress-text").html(b),migration_complete_events(),a(".progress-title").html(t))}else a(".progress-text").html(wpmdb_i10n.finalizing_migration),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_finalize_migration",intent:n,url:o,key:p,form_data:q,prefix:connection_data.prefix,temp_prefix:connection_data.temp_prefix,tables:O.join(","),nonce:wpmdb_nonces.finalize_migration},error:function(b,c,d){a(".progress-title").html(wpmdb_i10n.migration_failed),a(".progress-text").html(wpmdb_i10n.finalize_tables_problem),a(".progress-text").addClass("migration-error"),alert(b+" : "+c+" : "+d),migration_error=!0,migration_complete_events()},success:function(b){return""!=a.trim(b)?(a(".progress-title").html(wpmdb_i10n.migration_failed),a(".progress-text").html(b),a(".progress-text").addClass("migration-error"),migration_error=!0,void migration_complete_events()):(next_step_in_migration={fn:wpmdb_call_next_hook},void execute_next_step())}})},a("body").delegate(".close-progress-content-button","click",function(){U()}),a("body").delegate("#overlay","click",function(){1==K&&U()}),a(".save-settings-button").click(function(b){var c;if(a(this).blur(),b.preventDefault(),!D){if(a("#migrate-selected").is(":checked")&&null==a("#select-tables").val())return void alert(wpmdb_i10n.please_select_one_table);if(""==a.trim(a(".create-new-profile").val())&&a("#create_new").is(":checked"))return alert(wpmdb_i10n.enter_name_for_profile),void a(".create-new-profile").focus();var d=!1;a("#create_new").is(":checked")&&(d=!0);var e=a(".create-new-profile").val();D=!0,c=a("#migrate-form").serialize(),a(".save-settings-button").after('<img src="'+S+'" alt="" class="save-profile-ajax-spinner general-spinner" />'),a(this).attr("disabled","disabled"),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_save_profile",profile:c,nonce:wpmdb_nonces.save_profile},error:function(){alert(wpmdb_i10n.save_profile_problem),a(".save-settings-button").removeAttr("disabled"),a(".save-profile-ajax-spinner").remove(),a(".save-settings-button").after('<span class="ajax-success-msg">'+wpmdb_i10n.saved+"</span>"),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()}),D=!1},success:function(b){if(a(".save-settings-button").removeAttr("disabled"),a(".save-profile-ajax-spinner").remove(),a(".save-settings-button").after('<span class="ajax-success-msg">'+wpmdb_i10n.saved+"</span>"),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()}),D=!1,a(".create-new-profile").val(""),d){var c=parseInt(b,10),f=c+1,g='<li><span style="display: none;" class="delete-profile" data-profile-id="'+f+'"></span><label for="profile-'+f+'"><input id="profile-'+f+'" value="'+c+'" name="save_migration_profile_option" type="radio"> '+e+"</label></li>";a("#create_new").parents("li").before(g),a("#profile-"+f).attr("checked","checked")}}})}}),a("body").delegate(".progress-chunk-hover","mousemove",function(b){mX=b.pageX,offset=a(".progress-bar-wrapper").offset(),label_offset=a(".progress-label").outerWidth()/2,mX=mX-offset.left-label_offset,a(".progress-label").css("left",mX+"px"),a(".progress-label").html(a(this).attr("data-table"))}),a("body").delegate(".progress-chunk-hover","hover",function(b){"mouseenter"===b.type?a(".progress-label").addClass("label-visible"):a(".progress-label").removeClass("label-visible")}),connection_info_box=a(".connection-info-wrapper"),V(),a(".migrate-selection.option-group input[type=radio]").change(function(){V(),y&&W()}),!a("#pull").is(":checked")&&!a("#push").is(":checked")||y||(a(".step-two").hide(),a(".connection-status").show()),a(".general-helper").click(function(b){var c=a(this),d=a(this).next();a(".helper-message").not(d).hide();var e=c.position();d.css(d.hasClass("bottom")?{left:e.left-d.width()/2+"px",top:e.top+c.height()+9+"px"}:{left:e.left+c.width()+9+"px",top:e.top+c.height()/2-18+"px"}),d.toggle(),b.stopPropagation()}),a("body").click(function(){a(".helper-message").hide()}),a(".helper-message").click(function(a){a.stopPropagation()}),a(".nav-tab").click(function(){a(".nav-tab").removeClass("nav-tab-active"),a(this).addClass("nav-tab-active"),a(".content-tab").hide(),a("."+a(this).attr("data-div-name")).show();var c=a(this).attr("data-div-name");c=c.replace("-tab",""),window.location.hash=c,a(this).hasClass("help")&&(T(),0==G&&"1"==wpmdb_has_licence&&(a(".support-content p").append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />'),b(),G=!0)),a(this).hasClass("addons")&&0==G&&"1"==wpmdb_has_licence&&(a(".addons-content p").append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />'),b(),G=!0)}),a("body").delegate(".add-row","click",function(){a(this).parents("tr").before(a(".original-repeatable-field").clone().removeClass("original-repeatable-field"))}),a("body").delegate(".replace-remove-row","click",function(){a(this).parents("tr").remove(),a(".replace-row").length<2&&a(".no-replaces-message").show()}),a(".add-replace").click(function(){a(".replace-fields").prepend(a(".original-repeatable-field").clone().removeClass("original-repeatable-field")),a(".no-replaces-message").hide()}),a("body").delegate("#find-and-replace-sort tbody tr.replace-row","hover",function(b){"mouseenter"===b.type?a(".replace-remove-row",this).show():a(".replace-remove-row",this).hide()}),a("#find-and-replace-sort tbody").sortable({items:"> tr:not(.pin)",handle:"td:first",start:function(){a(".sort-handle").css("cursor","-webkit-grabbing"),a(".sort-handle").css("cursor","-moz-grabbing")},stop:function(){a(".sort-handle").css("cursor","-webkit-grab"),a(".sort-handle").css("cursor","-moz-grab")}}),a("body").delegate(".save-migration-profile-wrap li","hover",function(b){"mouseenter"===b.type?a(".delete-profile",this).show():a(".delete-profile",this).hide()}),window.location.hash){var fb=window.location.hash.substring(1);Y(fb,!1)}""!=g("install-plugin")&&(fb="addons",G=!0,Y(fb,!0)),a(".reset-api-key").click(function(){var b=confirm(wpmdb_i10n.reset_api_key);b&&!C&&(C=!0,a(".reset-api-key").after('<img src="'+S+'" alt="" class="reset-api-key-ajax-spinner general-spinner" />'),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_reset_api_key",nonce:wpmdb_nonces.reset_api_key},error:function(){alert(wpmdb_i10n.reset_api_key_problem),a(".reset-api-key-ajax-spinner").remove(),C=!1},success:function(b){a(".reset-api-key-ajax-spinner").remove(),C=!1,a(".connection-info").html(b)}}))}),a("input.multiselect-toggle").change(function(){a(this).parents(".expandable-content").children(".select-wrap").toggle()}),a(".show-multiselect").each(function(){a(this).is(":checked")&&(a(this).parents(".option-section").children(".header-expand-collapse").children(".expand-collapse-arrow").removeClass("collapsed"),a(this).parents(".expandable-content").show(),a(this).parents(".expandable-content").children(".select-wrap").toggle())}),a("input[name=backup_option]").change(function(){a(".backup-tables-wrap").hide(),"backup_manual_select"==a(this).val()&&a(".backup-tables-wrap").show()}),a("#backup-manual-select").is(":checked")&&a(".backup-tables-wrap").show(),a(".plugin-compatibility-save").click(function(){E||(a(this).addClass("disabled"),select_element=a("#selected-plugins"),a(select_element).attr("disabled","disabled"),E=!0,a(this).after('<img src="'+S+'" alt="" class="plugin-compatibility-spinner general-spinner" />'),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_blacklist_plugins",blacklist_plugins:a(select_element).val()},error:function(b){alert(wpmdb_i10n.blacklist_problem+"\r\n\r\n"+wpmdb_i10n.status+" "+b.status+" "+b.statusText+"\r\n\r\n"+wpmdb_i10n.response+"\r\n"+b.responseText),a(select_element).removeAttr("disabled"),a(".plugin-compatibility-save").removeClass("disabled"),E=!1,a(".plugin-compatibility-spinner").remove(),a(".plugin-compatibility-success-msg").show().fadeOut(2e3)},success:function(b){""!=a.trim(b)&&alert(b),a(select_element).removeAttr("disabled"),a(".plugin-compatibility-save").removeClass("disabled"),E=!1,a(".plugin-compatibility-spinner").remove(),a(".plugin-compatibility-success-msg").show().fadeOut(2e3)}}))}),a("body").delegate(".delete-profile","click",function(){var b=a(this).next().clone();a("input",b).remove();var b=a.trim(a(b).html()),c=confirm(wpmdb_i10n.remove_profile+' "'+b+'"');c&&(a(this).parent().fadeOut(500),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_delete_migration_profile",profile_id:a(this).attr("data-profile-id"),nonce:wpmdb_nonces.delete_migration_profile},error:function(){alert(wpmdb_i10n.remove_profile_problem)},success:function(a){"-1"==a&&alert(wpmdb_i10n.remove_profile_not_found)}}))}),a(".main-list-delete-profile-link").click(function(){var b=a(this).prev().html(),c=confirm(wpmdb_i10n.remove_profile+' "'+b+'"');c&&(a(this).parent().fadeOut(500),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_delete_migration_profile",profile_id:a(this).attr("data-profile-id"),nonce:wpmdb_nonces.delete_migration_profile},error:function(){alert(wpmdb_i10n.remove_profile_problem)}}))}),a("body").delegate(".temp-disabled","click",function(){var b=confirm(wpmdb_i10n.change_connection_info);b&&(a(".ssl-notice").hide(),a(".different-plugin-version-notice").hide(),a(".migrate-db-button").show(),a(".temp-disabled").removeAttr("readonly"),a(".temp-disabled").removeClass("temp-disabled"),a(".connect-button").show(),a(".step-two").hide(),a(".connection-status").show().html(wpmdb_i10n.enter_connection_info),y=!1)}),a(".settings-tab input[type=checkbox]").change(function(){if("plugin-compatibility"!=a(this).attr("id")){var b=a(this).is(":checked"),c=a(this).attr("id");a(this).parent().append('<img src="'+S+'" alt="" class="ajax-spinner general-spinner" />');var d=a(this).parent();a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_save_setting",checked:b,setting:c,nonce:wpmdb_nonces.save_setting},error:function(){alert(wpmdb_i10n.save_settings_problem),a(".ajax-spinner").remove()},success:function(){a(".ajax-spinner").remove(),a(d).append('<span class="ajax-success-msg">'+wpmdb_i10n.saved+"</span>"),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()})}})}}),a(".migrate-form").submit(function(a){a.preventDefault()}),a(".connect-button").click(function(b){b.preventDefault(),a(this).blur(),Z()}),a(".pull-push-connection-info").bind("paste",function(){setTimeout(function(){Z()},0)}),a("body").delegate(".try-again","click",function(){Z()}),a("body").delegate(".try-http","click",function(){var b=a.trim(a(".pull-push-connection-info").val()).split("\n"),c=b[0].replace("https","http"),d=c+"\n"+b[1];a(".pull-push-connection-info").val(d),Z()}),a(".create-new-profile").change(function(){F=!0}),a("body").delegate(".temporarily-disable-ssl","click",function(){if(window.location.hash)var b=window.location.hash.substring(1);a(this).attr("href",a(this).attr("href")+"&hash="+b)}),a("body").delegate(".pause-resume","click",function(){1==P?(P=!1,A=!0,a(".progress-title").html(u),a(".progress-text").html(v),a(".migration-progress-ajax-spinner").show(),a(".pause-resume").html(wpmdb_i10n.pause),s=setInterval(e,1e3),execute_next_step()):(P=!0,A=!1,u=a(".progress-title").html(),v=a(".progress-text").html(),a(".progress-title").html(wpmdb_i10n.migration_paused),a(".pause-resume").html(wpmdb_i10n.resume),a(".progress-text").html(wpmdb_i10n.completing_current_request))}),a("body").delegate(".cancel","click",function(){Q=!0,P=!1,a(".progress-text").html(wpmdb_i10n.completing_current_request),a(".progress-title").html(wpmdb_i10n.cancelling_migration),a(".migration-controls").fadeOut(),a(".migration-progress-ajax-spinner").show(),0==A&&execute_next_step()}),a(".enter-licence").click(function(){a(".settings").click(),a(".licence-input").focus()}),execute_next_step=function(){if(1==P)return a(".migration-progress-ajax-spinner").hide(),clearInterval(s),void a(".progress-text").html(wpmdb_i10n.paused);if(1==Q){n=a("input[name=action]:checked").val(),"savefile"==n?progress_msg=wpmdb_i10n.removing_local_sql:"pull"==n?progress_msg="backup"==r?wpmdb_i10n.removing_local_backup:wpmdb_i10n.removing_local_temp_tables:"push"==n&&(progress_msg="backup"==r?wpmdb_i10n.removing_remote_sql:wpmdb_i10n.removing_remote_temp_tables),a(".progress-text").html(progress_msg);var b={action:"wpmdb_cancel_migration",intent:n,url:o,key:p,stage:r,dump_filename:M,form_data:q};"undefined"!=typeof connection_data&&(b.temp_prefix=connection_data.temp_prefix),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:b,error:function(b,c,d){a(".progress-title").html(wpmdb_i10n.migration_cancellation_failed),a(".progress-text").html(wpmdb_i10n.manually_remove_temp_files),a(".progress-text").append("<br /><br />"+wpmdb_i10n.status+": "+b.status+" "+b.statusText+"<br /><br />"+wpmdb_i10n.response+":<br />"+b.responseText),a(".progress-text").addClass("migration-error"),console.log(b),console.log(c),console.log(d),migration_error=!0,migration_complete_events()},success:function(b){return A=!1,b=a.trim(b),""!=b?(a(".progress-title").html(wpmdb_i10n.migration_cancellation_failed),a(".progress-text").html(b),a(".progress-text").addClass("migration-error"),migration_error=!0,void migration_complete_events()):(t=wpmdb_i10n.migration_cancelled,a(".progress-text").hide(),void migration_complete_events())}})}else next_step_in_migration.fn.apply(null,next_step_in_migration.args)}})}(jQuery);
\ No newline at end of file
--- /dev/null
+<?php
+class WPMDB_Base {
+ protected $settings;
+ protected $plugin_file_path;
+ protected $plugin_dir_path;
+ protected $plugin_slug;
+ protected $plugin_folder_name;
+ protected $plugin_basename;
+ protected $plugin_base;
+ protected $plugin_version;
+ protected $template_dir;
+ protected $plugin_title;
+ protected $dbrains_api_url;
+ protected $transient_timeout;
+ protected $transient_retry_timeout;
+ protected $dbrains_api_base = 'https://deliciousbrains.com';
+ protected $multipart_boundary = 'bWH4JVmYCnf6GfXacrcc';
+ protected $attempting_to_connect_to;
+ protected $error;
+ protected $temp_prefix = '_mig_';
+ protected $invalid_content_verification_error;
+ protected $addons;
+ protected $doing_cli_migration = false;
+ protected $is_pro = false;
+ protected $is_addon = false;
+ protected $core_slug;
+
+ function __construct( $plugin_file_path ) {
+ $this->settings = get_option( 'wpmdb_settings' );
+
+ $this->plugin_file_path = $plugin_file_path;
+ $this->plugin_dir_path = plugin_dir_path( $plugin_file_path );
+ $this->plugin_folder_name = basename( $this->plugin_dir_path );
+ $this->plugin_basename = plugin_basename( $plugin_file_path );
+ $this->template_dir = $this->plugin_dir_path . 'template' . DS;
+ $this->plugin_title = ucwords( str_ireplace( '-', ' ', basename( $plugin_file_path ) ) );
+ $this->plugin_title = str_ireplace( array( 'db', 'wp', '.php' ), array( 'DB', 'WP', '' ), $this->plugin_title );
+
+ // We need to set $this->plugin_slug here because it was set here
+ // in Media Files prior to version 1.1.2. If we remove it the customer
+ // cannot upgrade, view release notes, etc
+ // used almost exclusively as a identifier for plugin version checking (both core and addons)
+ $this->plugin_slug = basename( $plugin_file_path, '.php' );
+
+ // used to add admin menus and to identify the core version in the $GLOBALS['wpmdb_meta'] variable for delicious brains api calls, version checking etc
+ $this->core_slug = ( $this->is_pro || $this->is_addon ) ? 'wp-migrate-db-pro' : 'wp-migrate-db';
+
+ if ( is_multisite() ) {
+ $this->plugin_base = 'settings.php?page=' . $this->core_slug;
+ } else {
+ $this->plugin_base = 'tools.php?page=' . $this->core_slug;
+ }
+
+ if ( $this->is_addon || $this->is_pro ) {
+ $this->pro_addon_construct();
+ }
+ }
+
+ function pro_addon_construct() {
+ $this->addons = array(
+ 'wp-migrate-db-pro-media-files/wp-migrate-db-pro-media-files.php' => array(
+ 'name' => 'Media Files',
+ 'required_version' => '1.1.4',
+ ),
+ 'wp-migrate-db-pro-cli/wp-migrate-db-pro-cli.php' => array(
+ 'name' => 'CLI',
+ 'required_version' => '1.0',
+ )
+ );
+
+ $this->invalid_content_verification_error = __( 'Invalid content verification signature, please verify the connection information on the remote site and try again.', 'wp-migrate-db' );
+
+ $this->transient_timeout = 60 * 60 * 12;
+ $this->transient_retry_timeout = 60 * 60 * 2;
+
+ if ( defined( 'DBRAINS_API_BASE' ) ) {
+ $this->dbrains_api_base = DBRAINS_API_BASE;
+ }
+
+ if ( $this->open_ssl_enabled() == false ) {
+ $this->dbrains_api_base = str_replace( 'https://', 'http://', $this->dbrains_api_base );
+ }
+
+ $this->dbrains_api_url = $this->dbrains_api_base . '/?wc-api=delicious-brains';
+
+ // allow devs to change the temporary prefix applied to the tables
+ $this->temp_prefix = apply_filters( 'wpmdb_temporary_prefix', $this->temp_prefix );
+
+ // Seen when the user clicks "view details" on the plugin listing page
+ add_action( 'install_plugins_pre_plugin-information', array( $this, 'plugin_update_popup' ) );
+
+ // Add an extra row to the plugin screen
+ add_action( 'after_plugin_row_' . $this->plugin_basename, array( $this, 'plugin_row' ), 11 );
+
+ // Adds a custom error message to the plugin install page if required (licence expired / invalid)
+ add_filter( 'http_response', array( $this, 'verify_download' ), 10, 3 );
+
+ add_action( 'wpmdb_notices', array( $this, 'version_update_notice' ) );
+ }
+
+ function template( $template, $dir = '', $args = array() ) {
+ global $wpdb;
+ extract( $args, EXTR_OVERWRITE );
+ $dir = ( ! empty( $dir ) ) ? trailingslashit( $dir ) : $dir;
+ include $this->template_dir . $dir . $template . '.php';
+ }
+
+ function open_ssl_enabled() {
+ if ( defined( 'OPENSSL_VERSION_TEXT' ) ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function set_time_limit() {
+ if ( ! function_exists( 'ini_get' ) || ! ini_get( 'safe_mode' ) ) {
+ @set_time_limit( 0 );
+ }
+ }
+
+ function remote_post( $url, $data, $scope, $args = array(), $expecting_serial = false ) {
+ $this->set_time_limit();
+
+ if ( function_exists( 'fsockopen' ) && strpos( $url, 'https://' ) === 0 && $scope == 'ajax_verify_connection_to_remote_site' ) {
+ $url_parts = parse_url( $url );
+ $host = $url_parts['host'];
+ if ( $pf = @fsockopen( $host, 443, $err, $err_string, 1 ) ) {
+ // worked
+ fclose( $pf );
+ } else {
+ // failed
+ $url = substr_replace( $url, 'http', 0, 5 );
+ }
+ }
+
+ $sslverify = ( $this->settings['verify_ssl'] == 1 ? true : false );
+
+ $default_remote_post_timeout = apply_filters( 'wpmdb_default_remote_post_timeout', 60 * 20 );
+
+ $args = wp_parse_args( $args, array(
+ 'timeout' => $default_remote_post_timeout,
+ 'blocking' => true,
+ 'sslverify' => $sslverify,
+ ) );
+
+ $args['method'] = 'POST';
+
+ if ( ! isset( $args['body'] ) ) {
+ $args['body'] = $this->array_to_multipart( $data );
+ }
+
+ $args['headers']['Content-Type'] = 'multipart/form-data; boundary=' . $this->multipart_boundary;
+ $args['headers']['Referer'] = network_admin_url( 'admin-ajax.php' );
+
+ $this->attempting_to_connect_to = $url;
+
+ $response = wp_remote_post( $url, $args );
+
+ if ( ! is_wp_error( $response ) ) {
+ $response['body'] = trim( $response['body'], "\xef\xbb\xbf" );
+ }
+
+ if ( is_wp_error( $response ) ) {
+ if ( strpos( $url, 'https://' ) === 0 && $scope == 'ajax_verify_connection_to_remote_site' ) {
+ return $this->retry_remote_post( $url, $data, $scope, $args, $expecting_serial );
+ } elseif ( isset( $response->errors['http_request_failed'][0] ) && strstr( $response->errors['http_request_failed'][0], 'timed out' ) ) {
+ $this->error = sprintf( __( 'The connection to the remote server has timed out, no changes have been committed. (#134 - scope: %s)', 'wp-migrate-db' ), $scope );
+ } elseif ( isset( $response->errors['http_request_failed'][0] ) && ( strstr( $response->errors['http_request_failed'][0], 'Could not resolve host' ) || strstr( $response->errors['http_request_failed'][0], 'couldn\'t connect to host' ) ) ) {
+ $this->error = sprintf( __( 'We could not find: %s. Are you sure this is the correct URL?', 'wp-migrate-db' ), $_POST['url'] );
+ $url_bits = parse_url( $_POST['url'] );
+ if ( strstr( $_POST['url'], 'dev.' ) || strstr( $_POST['url'], '.dev' ) || ! strstr( $url_bits['host'], '.' ) ) {
+ $this->error .= '<br />';
+ if ( $_POST['intent'] == 'pull' ) {
+ $this->error .= __( 'It appears that you might be trying to pull from a local environment. This will not work if <u>this</u> website happens to be located on a remote server, it would be impossible for this server to contact your local environment.', 'wp-migrate-db' );
+ } else {
+ $this->error .= __( 'It appears that you might be trying to push to a local environment. This will not work if <u>this</u> website happens to be located on a remote server, it would be impossible for this server to contact your local environment.', 'wp-migrate-db' );
+ }
+ }
+ } else {
+ $this->error = sprintf( __( 'The connection failed, an unexpected error occurred, please contact support. (#121 - scope: %s)', 'wp-migrate-db' ), $scope );
+ }
+ $this->log_error( $this->error, $response );
+ return false;
+ } elseif ( (int) $response['response']['code'] < 200 || (int) $response['response']['code'] > 399 ) {
+ if ( strpos( $url, 'https://' ) === 0 && $scope == 'ajax_verify_connection_to_remote_site' ) {
+ return $this->retry_remote_post( $url, $data, $scope, $args, $expecting_serial );
+ } elseif ( $response['response']['code'] == '401' ) {
+ $this->error = __( 'The remote site is protected with Basic Authentication. Please enter the username and password above to continue. (401 Unauthorized)', 'wp-migrate-db' );
+ $this->log_error( $this->error, $response );
+ return false;
+ } else {
+ $this->error = sprintf( __( 'Unable to connect to the remote server, please check the connection details - %1$s %2$s (#129 - scope: %3$s)', 'wp-migrate-db' ), $response['response']['code'], $response['response']['message'], $scope );
+ $this->log_error( $this->error, $response );
+ return false;
+ }
+ } elseif ( $expecting_serial && is_serialized( $response['body'] ) == false ) {
+ if ( strpos( $url, 'https://' ) === 0 && $scope == 'ajax_verify_connection_to_remote_site' ) {
+ return $this->retry_remote_post( $url, $data, $scope, $args, $expecting_serial );
+ }
+ $this->error = __( 'There was a problem with the AJAX request, we were expecting a serialized response, instead we received:<br />', 'wp-migrate-db' ) . htmlentities( $response['body'] );
+ $this->log_error( $this->error, $response );
+ return false;
+ } elseif ( $response['body'] === '0' ) {
+ if ( strpos( $url, 'https://' ) === 0 && $scope == 'ajax_verify_connection_to_remote_site' ) {
+ return $this->retry_remote_post( $url, $data, $scope, $args, $expecting_serial );
+ }
+ $this->error = sprintf( __( 'WP Migrate DB Pro does not seem to be installed or active on the remote site. (#131 - scope: %s)', 'wp-migrate-db' ), $scope );
+ $this->log_error( $this->error, $response );
+ return false;
+ } elseif ( $expecting_serial && is_serialized( $response['body'] ) == true && $scope == 'ajax_verify_connection_to_remote_site' ) {
+ $unserialized_response = unserialize( $response['body'] );
+ if ( isset( $unserialized_response['error'] ) && '1' == $unserialized_response['error'] && strpos( $url, 'https://' ) === 0 ) {
+ return $this->retry_remote_post( $url, $data, $scope, $args, $expecting_serial );
+ }
+ }
+
+ return $response['body'];
+ }
+
+ function retry_remote_post( $url, $data, $scope, $args = array(), $expecting_serial = false ) {
+ $url = substr_replace( $url, 'http', 0, 5 );
+ if ( $response = $this->remote_post( $url, $data, $scope, $args, $expecting_serial ) ) {
+ return $response;
+ }
+ return false;
+ }
+
+ function array_to_multipart( $data ) {
+ if ( !$data || !is_array( $data ) ) {
+ return $data;
+ }
+
+ $result = '';
+
+ foreach ( $data as $key => $value ) {
+ $result .= '--' . $this->multipart_boundary . "\r\n" .
+ sprintf( 'Content-Disposition: form-data; name="%s"', $key );
+
+ if ( 'chunk' == $key ) {
+ if ( $data['chunk_gzipped'] ) {
+ $result .= "; filename=\"chunk.txt.gz\"\r\nContent-Type: application/x-gzip";
+ } else {
+ $result .= "; filename=\"chunk.txt\"\r\nContent-Type: text/plain;";
+ }
+ } else {
+ $result .= "\r\nContent-Type: text/plain; charset=" . get_option( 'blog_charset' );
+ }
+
+ $result .= "\r\n\r\n" . $value . "\r\n";
+ }
+
+ $result .= "--" . $this->multipart_boundary . "--\r\n";
+
+ return $result;
+ }
+
+ function file_to_multipart( $file ) {
+ $result = '';
+
+ if ( false == file_exists( $file ) ) {
+ return false;
+ }
+
+ $filetype = wp_check_filetype( $file );
+ $contents = file_get_contents( $file );
+
+ $result .= '--' . $this->multipart_boundary . "\r\n" . sprintf( 'Content-Disposition: form-data; name="media[]"; filename="%s"', basename( $file ) );
+ $result .= sprintf( "\r\nContent-Type: %s", $filetype['type'] );
+ $result .= "\r\n\r\n" . $contents . "\r\n";
+ $result .= "--" . $this->multipart_boundary . "--\r\n";
+
+ return $result;
+ }
+
+ function log_error( $wpmdb_error, $additional_error_var = false ) {
+ $error_header = "********************************************\n****** Log date: " . date( 'Y/m/d H:i:s' ) . " ******\n********************************************\n\n";
+ $error = $error_header . "WPMDB Error: " . $wpmdb_error . "\n\n";
+
+ if ( ! empty( $this->attempting_to_connect_to ) ) {
+ $error .= "Attempted to connect to: " . $this->attempting_to_connect_to . "\n\n";
+ }
+
+ if ( $additional_error_var !== false ) {
+ $error .= print_r( $additional_error_var, true ) . "\n\n";
+ }
+
+ $log = get_option( 'wpmdb_error_log' );
+
+ if ( $log ) {
+ $log = $log . $error;
+ } else {
+ $log = $error;
+ }
+
+ update_option( 'wpmdb_error_log', $log );
+ }
+
+ function display_errors() {
+ if ( ! empty( $this->error ) ) {
+ echo $this->error;
+ $this->error = '';
+ return true;
+ }
+
+ return false;
+ }
+
+ function filter_post_elements( $post_array, $accepted_elements ) {
+ if ( isset( $post_array['form_data'] ) ) {
+ $post_array['form_data'] = stripslashes( $post_array['form_data'] );
+ }
+
+ $accepted_elements[] = 'sig';
+ return array_intersect_key( $post_array, array_flip( $accepted_elements ) );
+ }
+
+ function create_signature( $data, $key ) {
+ if ( isset( $data['sig'] ) ) {
+ unset( $data['sig'] );
+ }
+ $flat_data = implode( '', $data );
+ return base64_encode( hash_hmac( 'sha1', $flat_data, $key, true ) );
+ }
+
+ function verify_signature( $data, $key ) {
+ if ( empty( $data['sig'] ) ) {
+ return false;
+ }
+
+ if ( isset( $data['nonce'] ) ) {
+ unset( $data['nonce'] );
+ }
+
+ $temp = $data;
+ $computed_signature = $this->create_signature( $temp, $key );
+ return $computed_signature === $data['sig'];
+ }
+
+ function get_dbrains_api_url( $request, $args = array() ) {
+ $url = $this->dbrains_api_url;
+ $args['request'] = $request;
+ $args['version'] = $GLOBALS['wpmdb_meta'][$this->core_slug]['version'];
+ $url = add_query_arg( $args, $url );
+ if ( false !== get_site_transient( 'wpmdb_temporarily_disable_ssl' ) && 0 === strpos( $this->dbrains_api_url, 'https://' ) ) {
+ $url = substr_replace( $url, 'http', 0, 5 );
+ }
+
+ $url .= '&locale=' . urlencode( get_locale() );
+
+ return $url;
+ }
+
+ function dbrains_api_request( $request, $args = array() ) {
+ $sslverify = ( $this->settings['verify_ssl'] == 1 ? true : false );
+
+ $url = $this->get_dbrains_api_url( $request, $args );
+ $response = wp_remote_get( $url, array(
+ 'timeout' => 30,
+ 'blocking' => true,
+ 'sslverify' => $sslverify
+ ) );
+
+ if ( is_wp_error( $response ) || (int) $response['response']['code'] < 200 || (int) $response['response']['code'] > 399 ) {
+ $this->log_error( print_r( $response, true ) );
+ $disable_ssl_url = network_admin_url( $this->plugin_base . '&nonce=' . wp_create_nonce( 'wpmdb-disable-ssl' ) . '&wpmdb-disable-ssl=1' );
+ $connection_failed_message = '<div class="updated warning inline-message">';
+ $connection_failed_message .= sprintf( __( '<strong>Could not connect to deliciousbrains.com</strong> — You will not receive update notifications or be able to activate your license until this is fixed. This issue is often caused by an improperly configured SSL server (https). We recommend <a href="%1$s" target="_blank">fixing the SSL configuration on your server</a>, but if you need a quick fix you can:<p><a href="%2$s" class="temporarily-disable-ssl button">Temporarily disable SSL for connections to deliciousbrains.com</a></p>', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/documentation/#could-no-connect', $disable_ssl_url );
+ $connection_failed_message .= '</div>';
+ return json_encode( array( 'errors' => array( 'connection_failed' => $connection_failed_message ) ) );
+ }
+
+ return $response['body'];
+ }
+
+ function plugin_update_popup() {
+ if ( $this->plugin_slug != $_GET['plugin'] ) {
+ return;
+ }
+
+ $filename = $this->plugin_slug;
+ $latest_version = $this->get_latest_version( $this->plugin_slug );
+
+ if ( $this->is_beta_version( $latest_version ) ) {
+ $filename .= '-beta';
+ }
+
+ $url = $this->dbrains_api_base . '/content/themes/delicious-brains/update-popup/' . $filename . '.html';
+ $data = wp_remote_get( $url, array( 'timeout' => 30 ) );
+
+ if ( is_wp_error( $data ) || 200 != $data['response']['code'] ) {
+ echo '<p>' . __( 'Could not retrieve version details. Please try again.', 'wp-migrate-db' ) . '</p>';
+ } else {
+ echo $data['body'];
+ }
+
+ exit;
+ }
+
+ /*
+ * Shows a message below the plugin on the plugins page when:
+ * 1. the license hasn't been activated
+ * 2. when there's an update available but the license is expired
+ *
+ * TODO: Implement "Check my license again" link
+ */
+ function plugin_row() {
+ $licence = $this->get_licence_key();
+ $licence_response = $this->is_licence_expired();
+ $licence_problem = isset( $licence_response['errors'] );
+
+ if ( ! isset( $GLOBALS['wpmdb_meta'][$this->plugin_slug]['version'] ) ) {
+ $installed_version = '0';
+ } else {
+ $installed_version = $GLOBALS['wpmdb_meta'][$this->plugin_slug]['version'];
+ }
+
+ $latest_version = $this->get_latest_version( $this->plugin_slug );
+
+ $new_version = '';
+ if ( version_compare( $installed_version, $latest_version, '<' ) ) {
+ $new_version = __( 'There is a new version of ' . $this->plugin_title . ' available.', 'wp-migrate-db' );
+ $new_version .= ' <a class="thickbox" title="' . $this->plugin_title . '" href="plugin-install.php?tab=plugin-information&plugin=' . rawurlencode( $this->plugin_slug ) . '&TB_iframe=true&width=640&height=808">';
+ $new_version .= sprintf( __( 'View version %s details', 'wp-migrate-db' ), $latest_version ) . '</a>.';
+ }
+
+ if ( ! $new_version && ! empty( $licence ) ) {
+ return;
+ }
+
+ if ( empty( $licence ) ) {
+ $settings_link = sprintf( '<a href="%s">%s</a>', network_admin_url( $this->plugin_base ) . '#settings', __( 'Settings', 'wp-migrate-db' ) );
+ if ( $new_version ) {
+ $message = sprintf( __( 'To update, go to %1$s and enter your license key. If you don\'t have a license key, you may <a href="%2$s">purchase one</a>.', 'wp-migrate-db' ), $settings_link, 'http://deliciousbrains.com/wp-migrate-db-pro/pricing/' );
+ } else {
+ $message = sprintf( __( 'To finish activating %1$s, please go to %2$s and enter your license key. If you don\'t have a license key, you may <a href="%3$s">purchase one</a>.', 'wp-migrate-db' ), $this->plugin_title, $settings_link, 'http://deliciousbrains.com/wp-migrate-db-pro/pricing/' );
+ }
+ } elseif ( $licence_problem ) {
+ $message = array_shift( $licence_response['errors'] ) . sprintf( ' <a href="#" class="check-my-licence-again">%s</a>', __( 'Check my license again', 'wp-migrate-db' ) );
+ } else {
+ return;
+ } ?>
+
+ <tr class="plugin-update-tr wpmdbpro-custom">
+ <td colspan="3" class="plugin-update">
+ <div class="update-message"><span class="wpmdb-new-version-notice"><?php echo $new_version; ?></span> <span class="wpmdb-licence-error-notice"><?php echo $message; ?></span></div>
+ </td>
+ </tr>
+
+ <?php if ( $new_version ) : // removes the built-in plugin update message ?>
+ <script type="text/javascript">
+ (function($) {
+ var wpmdb_row = jQuery('#<?php echo $this->plugin_slug; ?>'),
+ next_row = wpmdb_row.next();
+
+ // If there's a plugin update row - need to keep the original update row available so we can switch it out
+ // if the user has a successful response from the 'check my license again' link
+ if (next_row.hasClass('plugin-update-tr') && !next_row.hasClass('wpmdbpro-custom')) {
+ var original = next_row.clone();
+ original.add
+ next_row.html(next_row.next().html()).addClass('wpmdbpro-custom-visible');
+ next_row.next().remove();
+ next_row.after(original);
+ original.addClass('wpmdb-original-update-row');
+ }
+ })(jQuery);
+ </script>
+ <?php endif;
+ }
+
+ function verify_download( $response, $args, $url ) {
+ $download_url = $this->get_plugin_update_download_url( $this->plugin_slug );
+
+ if ( 0 === strpos( $url, $download_url ) || 402 != $response['response']['code'] ) {
+ return $response;
+ }
+
+ // The $response['body'] is blank but output is actually saved to a file in this case
+ $data = @file_get_contents( $response['filename'] );
+
+ if ( ! $data ) {
+ return new WP_Error( 'wpmdbpro_download_error_empty', sprintf( __( 'Error retrieving download from deliciousbrain.com. Please try again or download manually from <a href="%1$s">%2$s</a>.', 'wp-migrate-db' ), 'https://deliciousbrains.com/my-account/', __( 'My Account', 'wp-migrate-db' ) ) );
+ }
+
+ $decoded_data = json_decode( $data, true );
+
+ // Can't decode the JSON errors, so just barf it all out
+ if ( ! isset( $decoded_data['errors'] ) || ! $decoded_data['errors'] ) {
+ return new WP_Error( 'wpmdbpro_download_error_raw', $data );
+ }
+
+ foreach ( $decoded_data['errors'] as $key => $msg ) {
+ return new WP_Error( 'wpmdbpro_' . $key, $msg );
+ }
+ }
+
+ function is_licence_constant() {
+ return defined( 'WPMDB_LICENCE' );
+ }
+
+ function get_licence_key() {
+ return $this->is_licence_constant() ? WPMDB_LICENCE : $this->settings['licence'];
+ }
+
+ function is_valid_licence( $skip_transient_check = false ) {
+ $response = $this->is_licence_expired( $skip_transient_check );
+ return ( isset( $response['errors'] ) ) ? false : true;
+ }
+
+ function is_licence_expired( $skip_transient_check = false ) {
+ $licence = $this->get_licence_key();
+
+ if ( empty( $licence ) ) {
+ $settings_link = sprintf( '<a href="%s">%s</a>', network_admin_url( $this->plugin_base ) . '#settings', __( 'Settings', 'wp-migrate-db' ) );
+ $message = sprintf( __( 'To finish activating WP Migrate DB Pro, please go to %1$s and enter your license key. If you don\'t have a license key, you may <a href="%2$s">purchase one</a>.', 'wp-migrate-db' ), $settings_link, 'http://deliciousbrains.com/wp-migrate-db-pro/pricing/' );
+ return array( 'errors' => array( 'no_licence' => $message ) );
+ }
+
+ if ( ! $skip_transient_check ) {
+ $trans = get_site_transient( 'wpmdb_licence_response' );
+ if ( false !== $trans ) {
+ return json_decode( $trans, true );
+ }
+ }
+
+ return json_decode( $this->check_licence( $licence ), true );
+ }
+
+ function check_licence( $licence_key ) {
+ // testing only 1st line = valid licence 2nd line = not valid licence
+ // return json_encode( array( 'ok' => 'ok' ) );
+ // return json_encode( array( 'errors' => array( 'standard' => 'oh no! licence is not working.') ) );
+ if ( empty( $licence_key ) ) {
+ return false;
+ }
+
+ $args = array(
+ 'licence_key' => $licence_key,
+ 'site_url' => home_url( '', 'http' ),
+ );
+
+ $response = $this->dbrains_api_request( 'check_support_access', $args );
+ set_site_transient( 'wpmdb_licence_response', $response, $this->transient_timeout );
+ return $response;
+ }
+
+ function is_beta_version( $ver ) {
+ if ( preg_match( '@b[0-9]+$@', $ver ) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ function get_required_version( $slug ) {
+ $plugin_file = sprintf( '%1$s/%1$s.php', $slug );
+
+ if ( isset( $this->addons[$plugin_file]['required_version'] ) ) {
+ return $this->addons[$plugin_file]['required_version'];
+ } else {
+ return 0;
+ }
+ }
+
+ function get_latest_version( $slug ) {
+ $data = $this->get_upgrade_data();
+
+ if ( ! isset( $data[$slug] ) ) {
+ return false;
+ }
+
+ // If pre-1.1.2 version of Media Files addon
+ if ( ! isset( $GLOBALS['wpmdb_meta'][$slug]['version'] ) ) {
+ $installed_version = false;
+ } else {
+ $installed_version = $GLOBALS['wpmdb_meta'][$slug]['version'];
+ }
+
+ $required_version = $this->get_required_version( $slug );
+
+ // Return the latest beta version if the installed version is beta
+ // and the API returned a beta version and it's newer than the latest stable version
+ if ( $installed_version
+ && ( $this->is_beta_version( $installed_version ) || $this->is_beta_version( $required_version ) )
+ && isset( $data[$slug]['beta_version'] )
+ && version_compare( $data[$slug]['version'], $data[$slug]['beta_version'], '<' )
+ ) {
+ return $data[$slug]['beta_version'];
+ }
+
+ return $data[$slug]['version'];
+ }
+
+ function get_upgrade_data() {
+ $info = get_site_transient( 'wpmdb_upgrade_data' );
+
+ if ( isset( $info['version'] ) ) {
+ delete_site_transient( 'wpmdb_licence_response' );
+ delete_site_transient( 'wpmdb_upgrade_data' );
+ $info = false;
+ }
+
+ if ( $info ) {
+ return $info;
+ }
+
+ $data = $this->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->core_slug]['version'] ) );
+
+ if ( !$data ) {
+ set_site_transient( 'wpmdb_upgrade_data', $default_upgrade_data, $this->transient_retry_timeout );
+ $this->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->transient_retry_timeout );
+ $this->log_error( 'Error trying to get upgrade data.', $data['errors'] );
+ return false;
+ }
+
+ set_site_transient( 'wpmdb_upgrade_data', $data, $this->transient_timeout );
+
+ return $data;
+ }
+
+ function get_plugin_update_download_url( $plugin_slug, $is_beta = false ) {
+ $licence = $this->get_licence_key();
+ $query_args = array(
+ 'request' => 'download',
+ 'licence_key' => $licence,
+ 'slug' => $plugin_slug,
+ 'site_url' => home_url( '', 'http' ),
+ );
+
+ if ( $is_beta ) {
+ $query_args['beta'] = '1';
+ }
+
+ return add_query_arg( $query_args, $this->dbrains_api_url );
+ }
+
+ function diverse_array( $vector ) {
+ $result = array();
+
+ foreach ( $vector as $key1 => $value1 ) {
+ foreach ( $value1 as $key2 => $value2 ) {
+ $result[$key2][$key1] = $value2;
+ }
+ }
+ return $result;
+ }
+
+ function set_time_limit_available() {
+ if ( ! function_exists( 'set_time_limit' ) || ! function_exists( 'ini_get' ) ) {
+ return false;
+ }
+
+ $current_max_execution_time = ini_get( 'max_execution_time' );
+ $proposed_max_execution_time = ( $current_max_execution_time == 30 ) ? 31 : 30;
+ @set_time_limit( $proposed_max_execution_time );
+ $current_max_execution_time = ini_get( 'max_execution_time' );
+ return $proposed_max_execution_time == $current_max_execution_time;
+ }
+
+ function get_plugin_name( $plugin = false ) {
+ if ( ! is_admin() ) {
+ return false;
+ }
+
+ $plugin_basename = ( false !== $plugin ? $plugin : $this->plugin_basename );
+
+ $plugins = get_plugins();
+
+ if ( ! isset( $plugins[$plugin_basename]['Name'] ) ) {
+ return false;
+ }
+
+ return $plugins[$plugin_basename]['Name'];
+ }
+
+ function get_class_props() {
+ return get_object_vars( $this );
+ }
+
+ // Get only the table beginning with our DB prefix or temporary prefix, also skip views
+ function get_tables( $scope = 'regular' ) {
+ global $wpdb;
+ $prefix = ( $scope == 'temp' ? $this->temp_prefix : $wpdb->prefix );
+ $tables = $wpdb->get_results( 'SHOW FULL TABLES', ARRAY_N );
+ $clean_tables = array();
+
+ foreach ( $tables as $table ) {
+ if ( ( ( $scope == 'temp' || $scope == 'prefix' ) && 0 !== strpos( $table[0], $prefix ) ) || $table[1] == 'VIEW' ) {
+ continue;
+ }
+ $clean_tables[] = $table[0];
+ }
+
+ return apply_filters( 'wpmdb_tables', $clean_tables, $scope );
+ }
+
+ function version_update_notice() {
+ // We don't want to show both the "Update Required" and "Update Available" messages at the same time
+ if ( isset( $this->addons[$this->plugin_basename] ) && true == $this->is_addon_outdated( $this->plugin_basename ) ) {
+ return;
+ }
+
+ // To reduce UI clutter we hide addon update notices if the core plugin has updates available
+ if ( isset( $this->addons[$this->plugin_basename] ) ) {
+ $core_installed_version = $GLOBALS['wpmdb_meta'][$this->core_slug]['version'];
+ $core_latest_version = $this->get_latest_version( $this->core_slug );
+ // Core update is available, don't show update notices for addons until core is updated
+ if ( version_compare( $core_installed_version, $core_latest_version, '<' ) ) {
+ return;
+ }
+ }
+
+ $update_url = wp_nonce_url( network_admin_url( 'update.php?action=upgrade-plugin&plugin=' . urlencode( $this->plugin_basename ) ), 'upgrade-plugin_' . $this->plugin_basename );
+
+ // If pre-1.1.2 version of Media Files addon, don't bother getting the versions
+ if ( !isset( $GLOBALS['wpmdb_meta'][$this->plugin_slug]['version'] ) ) { ?>
+ <div style="display: block;" class="updated warning inline-message">
+ <strong>Update Available</strong> —
+ A new version of <?php echo $this->plugin_title; ?> is now available. <a href="<?php echo $update_url; ?>">Update Now</a>
+ </div>
+ <?php
+ } else {
+ $installed_version = $GLOBALS['wpmdb_meta'][$this->plugin_slug]['version'];
+ $latest_version = $this->get_latest_version( $this->plugin_slug );
+
+ if ( version_compare( $installed_version, $latest_version, '<' ) ) { ?>
+ <div style="display: block;" class="updated warning inline-message">
+ <strong><?php _e( 'Update Available', 'wp-migrate-db' ); ?></strong> —
+ <?php printf( __( '%1$s %2$s is now available. You currently have %3$s installed. <a href="%4$s">%5$s</a>', 'wp-migrate-db' ), $this->plugin_title, $latest_version, $installed_version, $update_url, __( 'Update Now', 'wp-migrate-db' ) ); ?>
+ </div>
+ <?php
+ }
+ }
+ }
+
+ function plugins_dir() {
+ $path = untrailingslashit( $this->plugin_dir_path );
+ return substr( $path, 0, strrpos( $path, DS ) ) . DS;
+ }
+
+ 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, '<' );
+ }
+
+ function get_plugin_file_path() {
+ return $this->plugin_file_path;
+ }
+
+ function get_licence_status_message() {
+ $licence = $this->get_licence_key();
+
+ if ( empty( $licence ) ) {
+ $message = sprintf( __( '<strong>Activate Your License</strong> — Please <a href="#" class="%s">enter your license key</a> to enable push and pull.', 'wp-migrate-db' ), 'js-action-link enter-licence' );
+ return $message;
+ }
+
+ $trans = get_site_transient( 'wpmdb_licence_response' );
+
+ if ( false === $trans ) {
+ $trans = $this->check_licence( $licence );
+ }
+
+ $trans = json_decode( $trans, true );
+ $errors = $trans['errors'];
+
+ $check_licence_again_url = network_admin_url( $this->plugin_base . '&nonce=' . wp_create_nonce( 'wpmdb-check-licence' ) . '&wpmdb-check-licence=1' );
+
+ if ( isset( $errors['connection_failed'] ) ) {
+ $disable_ssl_url = network_admin_url( $this->plugin_base . '&nonce=' . wp_create_nonce( 'wpmdb-disable-ssl' ) . '&wpmdb-disable-ssl=1' );
+ $message = sprintf( __( '<strong>Could not connect to deliciousbrains.com</strong> — You will not receive update notifications or be able to activate your license until this is fixed. This issue is often caused by an improperly configured SSL server (https). We recommend <a href="%s" target="_blank">fixing the SSL configuration on your server</a>, but if you need a quick fix you can:', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/documentation/#could-no-connect' );
+ $message .= sprintf( '<p><a href="%1$s" class="temporarily-disable-ssl button">%2$s</a></p>', $disable_ssl_url, __( 'Temporarily disable SSL for connections to deliciousbrains.com', 'wp-migrate-db' ) );
+ } elseif ( isset( $errors['subscription_cancelled'] ) ) {
+ $message = sprintf( __( '<strong>Your License Was Cancelled</strong> — Please visit <a href="%s" target="_blank">My Account</a> to renew or upgrade your license and enable push and pull.', 'wp-migrate-db' ), 'https://deliciousbrains.com/my-account/' );
+ $message .= sprintf( '<br /><a href="%s">%s</a>', $check_licence_again_url, __( 'Check my license again', 'wp-migrate-db' ) );
+ } elseif ( isset( $errors['subscription_expired'] ) ) {
+ $message = sprintf( __( '<strong>Your License Has Expired</strong> — Please visit <a href="%s" target="_blank">My Account</a> to purchase a new license and enable push and pull.', 'wp-migrate-db' ), 'https://deliciousbrains.com/my-account/' );
+ $message .= sprintf( '<br /><a href="%s">%s</a>', $check_licence_again_url, __( 'Check my license again', 'wp-migrate-db' ) );
+ } elseif ( isset( $errors['no_activations_left'] ) ) {
+ $message = sprintf( __( '<strong>No Activations Left</strong> — Please visit <a href="%s" target="_blank">My Account</a> to upgrade your license or deactivate a previous activation and enable push and pull.', 'wp-migrate-db' ), 'https://deliciousbrains.com/my-account/' );
+ $message .= sprintf( ' <a href="%s">%s</a>', $check_licence_again_url, __( 'Check my license again', 'wp-migrate-db' ) );
+ } elseif ( isset( $errors['licence_not_found'] ) ) {
+ $message = sprintf( __( '<strong>Your License Was Not Found</strong> — Perhaps you made a typo when defining your WPMDB_LICENCE constant in your wp-config.php? Please visit <a href="%s" target="_blank">My Account</a> to double check your license key.', 'wp-migrate-db' ), 'https://deliciousbrains.com/my-account/' );
+ $message .= sprintf( ' <a href="%s">%s</a>', $check_licence_again_url, __( 'Check my license again', 'wp-migrate-db' ) );
+ } else {
+ $error = reset( $errors );
+ $message = sprintf( __( '<strong>An Unexpected Error Occurred</strong> — Please contact us at <a href="%1$s">%2$s</a> and quote the following:', 'wp-migrate-db' ), 'mailto:nom@deliciousbrains.com', 'nom@deliciousbrains.com' );
+ $message .= sprintf( '<p>%s</p>', $error );
+ }
+
+ return $message;
+ }
+
+ function set_cli_migration() {
+ $this->doing_cli_migration = true;
+ }
+
+ function end_ajax( $return = false ) {
+ if ( defined( 'DOING_WPMDB_TESTS' ) || $this->doing_cli_migration ) {
+ return ( false === $return ) ? NULL : $return;
+ }
+
+ echo ( false === $return ) ? '' : $return;
+ exit;
+ }
+
+ function check_ajax_referer( $action ) {
+ if ( defined( 'DOING_WPMDB_TESTS' ) || $this->doing_cli_migration ) {
+ return;
+ }
+
+ $result = check_ajax_referer( $action, 'nonce', false );
+
+ if ( false === $result ) {
+ $return = array( 'wpmdb_error' => 1, 'body' => sprintf( __( 'Invalid nonce for: %s', 'wp-migrate-db' ), $action ) );
+ $this->end_ajax( json_encode( $return ) );
+ }
+
+ $cap = ( is_multisite() ) ? 'manage_network_options' : 'export';
+ $cap = apply_filters( 'wpmdb_ajax_cap', $cap );
+
+ if ( ! current_user_can( $cap ) ) {
+ $return = array( 'wpmdb_error' => 1, 'body' => sprintf( __( 'Access denied for: %s', 'wp-migrate-db' ), $action ) );
+ $this->end_ajax( json_encode( $return ) );
+ }
+ }
+
+}
--- /dev/null
+<?php
+class WPMDB_Utils {
+
+ /**
+ * Test to see if executing an AJAX call specific to the WP Migrate DB family of plugins.
+ *
+ * @return bool
+ */
+ public static function is_ajax() {
+ // must be doing AJAX the WordPress way
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
+ return false;
+ }
+
+ // must be one of our actions -- e.g. core plugin (wpmdb_*), media files (wpmdbmf_*)
+ if ( ! isset( $_POST['action'] ) || 0 !== strpos( $_POST['action'], 'wpmdb' ) ) {
+ return false;
+ }
+
+ // must be on blog #1 (first site) if multisite
+ if ( is_multisite() && 1 != get_current_site()->id ) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+class WPMDB extends WPMDB_Base {
+ protected $fp;
+ protected $absolute_root_file_path;
+ protected $form_defaults;
+ protected $accepted_fields;
+ protected $default_profile;
+ protected $maximum_chunk_size;
+ protected $current_chunk = '';
+ protected $connection_details;
+ protected $remote_url;
+ protected $remote_key;
+ protected $form_data;
+ protected $max_insert_string_len;
+ protected $row_tracker;
+ protected $rows_per_segment = 100;
+ protected $create_alter_table_query;
+ protected $alter_table_name;
+ protected $session_salt;
+ protected $primary_keys;
+ protected $unhook_templates = array();
+ protected $plugin_tabs;
+ protected $lock_url_find_replace_row = false;
+ protected $subdomain_replaces_on;
+ protected $domain_replace;
+ protected $tables;
+ protected $checkbox_options;
+
+ function __construct( $plugin_file_path ) {
+ parent::__construct( $plugin_file_path );
+
+ $this->plugin_version = $GLOBALS['wpmdb_meta'][$this->core_slug]['version'];
+
+ $this->max_insert_string_len = 50000; // 50000 is the default as defined by phphmyadmin
+
+ $default_settings = array(
+ 'key' => $this->generate_key(),
+ 'allow_pull' => false,
+ 'allow_push' => false,
+ 'profiles' => array(),
+ 'licence' => '',
+ 'verify_ssl' => false,
+ 'blacklist_plugins' => array(),
+ );
+
+ if ( empty( $this->settings['max_request'] ) ) {
+ $this->settings['max_request'] = min( 1024 * 1024, $this->get_bottleneck( 'max' ) );
+ update_option( 'wpmdb_settings', $this->settings );
+ }
+
+ // if no settings exist then this is a fresh install, set up some default settings
+ if ( empty( $this->settings ) ) {
+ $this->settings = $default_settings;
+ update_option( 'wpmdb_settings', $this->settings );
+ } else {
+ // When we add a new setting, an existing customer's db won't have this
+ // new setting, so we need to add it. Otherwise, they'll see
+ // array index errors in debug mode
+ $update_settings = false;
+
+ foreach ( $default_settings as $key => $value ) {
+ if ( ! isset( $this->settings[$key] ) ) {
+ $this->settings[$key] = $value;
+ $update_settings = true;
+ }
+ }
+
+ if ( $update_settings ) {
+ update_option( 'wpmdb_settings', $this->settings );
+ }
+ }
+
+ add_filter( 'plugin_action_links_' . $this->plugin_basename, array( $this, 'plugin_action_links' ) );
+ add_filter( 'network_admin_plugin_action_links_' . $this->plugin_basename, array( $this, 'plugin_action_links' ) );
+
+ // internal AJAX handlers
+ add_action( 'wp_ajax_wpmdb_delete_migration_profile', array( $this, 'ajax_delete_migration_profile' ) );
+ add_action( 'wp_ajax_wpmdb_save_profile', array( $this, 'ajax_save_profile' ) );
+ add_action( 'wp_ajax_wpmdb_initiate_migration', array( $this, 'ajax_initiate_migration' ) );
+ add_action( 'wp_ajax_wpmdb_migrate_table', array( $this, 'ajax_migrate_table' ) );
+ add_action( 'wp_ajax_wpmdb_finalize_migration', array( $this, 'ajax_finalize_migration' ) );
+ add_action( 'wp_ajax_wpmdb_clear_log', array( $this, 'ajax_clear_log' ) );
+ add_action( 'wp_ajax_wpmdb_get_log', array( $this, 'ajax_get_log' ) );
+ add_action( 'wp_ajax_wpmdb_fire_migration_complete', array( $this, 'fire_migration_complete' ) );
+ add_action( 'wp_ajax_wpmdb_plugin_compatibility', array( $this, 'ajax_plugin_compatibility' ) );
+ add_action( 'wp_ajax_wpmdb_blacklist_plugins', array( $this, 'ajax_blacklist_plugins' ) );
+ add_action( 'wp_ajax_wpmdb_update_max_request_size', array( $this, 'ajax_update_max_request_size' ) );
+ add_action( 'wp_ajax_wpmdb_cancel_migration', array( $this, 'ajax_cancel_migration' ) );
+
+ $absolute_path = rtrim( ABSPATH, '\\/' );
+ $site_url = rtrim( site_url( '', 'http' ), '\\/' );
+ $home_url = rtrim( home_url( '', 'http' ), '\\/' );
+ if ( $site_url != $home_url ) {
+ $difference = str_replace( $home_url, '', $site_url );
+ if ( strpos( $absolute_path, $difference ) !== false ) {
+ $absolute_path = rtrim( substr( $absolute_path, 0, -strlen( $difference ) ), '\\/' );
+ }
+ }
+ $this->absolute_root_file_path = $absolute_path;
+
+ $this->accepted_fields = array(
+ 'action',
+ 'save_computer',
+ 'gzip_file',
+ 'connection_info',
+ 'replace_old',
+ 'replace_new',
+ 'table_migrate_option',
+ 'select_tables',
+ 'replace_guids',
+ 'exclude_spam',
+ 'save_migration_profile',
+ 'save_migration_profile_option',
+ 'create_new_profile',
+ 'create_backup',
+ 'remove_backup',
+ 'keep_active_plugins',
+ 'select_post_types',
+ 'backup_option',
+ 'select_backup',
+ 'exclude_transients',
+ 'exclude_post_types',
+ 'exclude_post_revisions',
+ );
+
+ $this->default_profile = array(
+ 'action' => 'savefile',
+ 'save_computer' => '1',
+ 'gzip_file' => '1',
+ 'table_migrate_option' => 'migrate_only_with_prefix',
+ 'replace_guids' => '1',
+ 'default_profile' => true,
+ 'name' => '',
+ 'select_tables' => array(),
+ 'select_post_types' => array(),
+ 'backup_option' => 'backup_only_with_prefix',
+ 'exclude_transients' => '1',
+ );
+
+ $this->checkbox_options = array(
+ 'save_computer' => '0',
+ 'gzip_file' => '0',
+ 'replace_guids' => '0',
+ 'exclude_spam' => '0',
+ 'keep_active_plugins' => '0',
+ 'create_backup' => '0',
+ 'exclude_post_types' => '0',
+ );
+
+ $this->plugin_tabs = array(
+ '<a href="#" class="nav-tab nav-tab-active js-action-link migrate" data-div-name="migrate-tab">' . __( 'Migrate', 'wp-migrate-db' ) . '</a>',
+ '<a href="#" class="nav-tab js-action-link settings" data-div-name="settings-tab">' . __( 'Settings', 'wp-migrate-db' ) . '</a>',
+ '<a href="#" class="nav-tab js-action-link help" data-div-name="help-tab">' . __( 'Help', 'wp-migrate-db' ) . '</a>',
+ );
+
+ // automatically deactivate WPMDB Pro / Free if the other is already active
+ add_action( 'activated_plugin', array( $this, 'deactivate_other_instances' ) );
+
+ // display a notice when either WP Migrate DB or WP Migrate DB Pro is automatically deactivated
+ add_action( 'pre_current_active_plugins', array( $this, 'plugin_deactivated_notice' ) );
+
+ // this is how many DB rows are processed at a time, allow devs to change this value
+ $this->rows_per_segment = apply_filters( 'wpmdb_rows_per_segment', $this->rows_per_segment );
+
+ if ( is_multisite() ) {
+ add_action( 'network_admin_menu', array( $this, 'network_admin_menu' ) );
+ /*
+ * The URL find & replace is locked down (delete & reorder disabled) on multisite installations as we require the URL
+ * of the remote site for export migrations. This URL is parsed into it's various components and
+ * used to change values in the 'domain' & 'path' columns in the wp_blogs and wp_site tables.
+ */
+ $this->lock_url_find_replace_row = true;
+ } else {
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
+ }
+ }
+
+ function get_alter_table_name() {
+ if ( ! is_null( $this->alter_table_name ) ) {
+ return $this->alter_table_name;
+ }
+
+ global $wpdb;
+ $this->alter_table_name = apply_filters( 'wpmdb_alter_table_name', $wpdb->prefix . 'wpmdb_alter_statements' );
+ return $this->alter_table_name;
+ }
+
+ function get_create_alter_table_query() {
+ if ( ! is_null( $this->create_alter_table_query ) ) {
+ return $this->create_alter_table_query;
+ }
+
+ $alter_table_name = $this->get_alter_table_name();
+ $this->create_alter_table_query = sprintf( "DROP TABLE IF EXISTS `%s`;\n", $alter_table_name );
+ $this->create_alter_table_query .= sprintf( "CREATE TABLE `%s` ( `query` longtext NOT NULL );\n", $alter_table_name );
+ $this->create_alter_table_query = apply_filters( 'wpmdb_create_alter_table_query', $this->create_alter_table_query );
+ return $this->create_alter_table_query;
+ }
+
+ function get_short_uploads_dir() {
+ $short_path = str_replace( $this->absolute_root_file_path, '', $this->get_upload_info( 'path' ) );
+ return trailingslashit( substr( str_replace( '\\', '/', $short_path ), 1 ) );
+ }
+
+ function get_upload_info( $type = 'path' ) {
+ // Let developers define their own path to for export files
+ // Note: We require a very specific data set here, it should be similiar to the following
+ // array(
+ // 'path' => '/path/to/custom/uploads/directory', <- note missing end trailing slash
+ // 'url' => 'http://yourwebsite.com/custom/uploads/directory' <- note missing end trailing slash
+ // );
+ $upload_info = apply_filters( 'wpmdb_upload_info', array() );
+
+ if ( ! empty( $upload_info ) ) {
+ return $upload_info[$type];
+ }
+
+ $upload_dir = wp_upload_dir();
+
+ $upload_info['path'] = $upload_dir['basedir'];
+ $upload_info['url'] = $upload_dir['baseurl'];
+
+ $upload_dir_name = apply_filters( 'wpmdb_upload_dir_name', 'wp-migrate-db' );
+
+ if ( ! file_exists( $upload_dir['basedir'] . DS . $upload_dir_name ) ) {
+ $url = wp_nonce_url( $this->plugin_base, 'wp-migrate-db-pro-nonce' );
+
+ if ( false === @mkdir( $upload_dir['basedir'] . DS . $upload_dir_name, 0755 ) ) {
+ return $upload_info[$type];
+ }
+
+ $filename = $upload_dir['basedir'] . DS . $upload_dir_name . DS . 'index.php';
+ if ( false === @file_put_contents( $filename, "<?php\r\n// Silence is golden\r\n?>" ) ) {
+ return $upload_info[$type];
+ }
+ }
+
+ $upload_info['path'] .= DS . $upload_dir_name;
+ $upload_info['url'] .= '/' . $upload_dir_name;
+
+ return $upload_info[$type];
+ }
+
+ function ajax_plugin_compatibility() {
+ $mu_dir = ( defined( 'WPMU_PLUGIN_DIR' ) && defined( 'WPMU_PLUGIN_URL' ) ) ? WPMU_PLUGIN_DIR : trailingslashit( WP_CONTENT_DIR ) . 'mu-plugins';
+ $source = trailingslashit( $this->plugin_dir_path ) . 'compatibility/wp-migrate-db-pro-compatibility.php';
+ $dest = trailingslashit( $mu_dir ) . 'wp-migrate-db-pro-compatibility.php';
+ if ( '1' === trim( $_POST['install'] ) ) { // install MU plugin
+ if ( ! wp_mkdir_p( $mu_dir ) ) {
+ _e( sprintf( 'The following directory could not be created: %s', $mu_dir ), 'wp-migrate-db' );
+ exit;
+ }
+
+ if ( ! copy( $source, $dest ) ) {
+ _e( sprintf( 'Could not copy the compatibility plugin from %1$s to %2$s', $source, $dest ), 'wp-migrate-db' );
+ exit;
+ }
+ } else { // uninstall MU plugin
+ if ( file_exists( $dest ) && ! unlink( $dest ) ) {
+ _e( sprintf( 'Could not remove the compatibility plugin from %s', $dest ), 'wp-migrate-db' );
+ exit;
+ }
+ }
+ exit;
+ }
+
+ function ajax_blacklist_plugins() {
+ $this->settings['blacklist_plugins'] = $_POST['blacklist_plugins'];
+ update_option( 'wpmdb_settings', $this->settings );
+ exit;
+ }
+
+ function ajax_update_max_request_size() {
+ $this->check_ajax_referer( 'update-max-request-size' );
+ $this->settings['max_request'] = (int) $_POST['max_request_size'] * 1024;
+ update_option( 'wpmdb_settings', $this->settings );
+ $result = $this->end_ajax();
+ return $result;
+ }
+
+ function is_json( $string, $strict = false ) {
+ $json = @json_decode( $string, true );
+ if ( $strict == true && ! is_array( $json ) ) {
+ return false;
+ }
+ return ! ( $json == NULL || $json == false );
+ }
+
+ function get_sql_dump_info( $migration_type, $info_type ) {
+ if ( empty( $this->session_salt ) ) {
+ $this->session_salt = strtolower( wp_generate_password( 5, false, false ) );
+ }
+ $datetime = date( 'YmdHis' );
+ $ds = ( $info_type == 'path' ? DS : '/' );
+ return sprintf( '%s%s%s-%s-%s-%s.sql', $this->get_upload_info( $info_type ), $ds, sanitize_title_with_dashes( DB_NAME ), $migration_type, $datetime, $this->session_salt );
+ }
+
+ function parse_migration_form_data( $data ) {
+ parse_str( $data, $form_data );
+ $this->accepted_fields = apply_filters( 'wpmdb_accepted_profile_fields', $this->accepted_fields );
+ $form_data = array_intersect_key( $form_data, array_flip( $this->accepted_fields ) );
+ unset( $form_data['replace_old'][0] );
+ unset( $form_data['replace_new'][0] );
+
+ if ( isset( $form_data['exclude_post_revisions'] ) ) {
+ $form_data['exclude_post_types'] = '1';
+ $form_data['select_post_types'][] = 'revision';
+ $form_data['select_post_types'] = array_unique( $form_data['select_post_types'] );
+ unset( $form_data['exclude_post_revisions'] );
+ }
+
+ return $form_data;
+ }
+
+ function plugin_action_links( $links ) {
+ $link = sprintf( '<a href="%s">%s</a>', network_admin_url( $this->plugin_base ), __( 'Settings', 'wp-migrate-db' ) );
+ array_unshift( $links, $link );
+ return $links;
+ }
+
+ function ajax_clear_log() {
+ $this->check_ajax_referer( 'clear-log' );
+ delete_option( 'wpmdb_error_log' );
+ $result = $this->end_ajax();
+ return $result;
+ }
+
+ function ajax_get_log() {
+ $this->check_ajax_referer( 'get-log' );
+ ob_start();
+ $this->output_diagnostic_info();
+ $this->output_log_file();
+ $return = ob_get_clean();
+ $result = $this->end_ajax( $return );
+ return $result;
+ }
+
+ function output_log_file() {
+ $log = get_option( 'wpmdb_error_log' );
+ if ( $log ) {
+ echo $log;
+ }
+ }
+
+ function output_diagnostic_info() {
+ global $table_prefix;
+ global $wpdb;
+
+ echo 'site_url(): ';
+ echo site_url();
+ echo "\r\n";
+
+ echo 'home_url(): ';
+ echo home_url();
+ echo "\r\n";
+
+ echo 'Table Prefix: ';
+ echo $table_prefix;
+ echo "\r\n";
+
+ echo 'WordPress: ';
+ echo ( is_multisite() ) ? 'WPMU' : 'MU';
+ echo bloginfo( 'version' );
+ echo "\r\n";
+
+ echo 'Web Server: ';
+ echo $_SERVER['SERVER_SOFTWARE'];
+ echo "\r\n";
+
+ echo 'PHP: ';
+ if ( function_exists( 'phpversion' ) ) {
+ echo esc_html( phpversion() );
+ }
+ echo "\r\n";
+
+ echo 'MySQL: ';
+ echo esc_html( empty( $wpdb->use_mysqli ) ? mysql_get_server_info() : mysqli_get_server_info( $wpdb->dbh ) );
+ echo "\r\n";
+
+ _e( 'ext/mysqli', 'wp-app-store' ); echo ': ';
+ echo empty( $wpdb->use_mysqli ) ? 'no' : 'yes';
+ echo "\r\n";
+
+ _e( 'WP Memory Limit', 'wp-app-store' ); echo ': ';
+ echo WP_MEMORY_LIMIT;
+ echo "\r\n";
+
+ echo 'WPMDB Bottleneck: ';
+ echo size_format( $this->get_bottleneck() );
+ echo "\r\n";
+
+ if ( function_exists( 'ini_get' ) && $suhosin_limit = ini_get( 'suhosin.post.max_value_length' ) ) {
+ echo 'Suhosin Post Max Value Length: ';
+ echo is_numeric( $suhosin_limit ) ? size_format( $suhosin_limit ) : $suhosin_limit;
+ echo "\r\n";
+ }
+
+ if ( function_exists( 'ini_get' ) && $suhosin_limit = ini_get( 'suhosin.request.max_value_length' ) ) {
+ echo 'Suhosin Request Max Value Length: ';
+ echo is_numeric( $suhosin_limit ) ? size_format( $suhosin_limit ) : $suhosin_limit;
+ echo "\r\n";
+ }
+
+ echo 'Debug Mode: ';
+ echo ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No';
+ echo "\r\n";
+
+ echo 'WP Max Upload Size: ';
+ echo size_format( wp_max_upload_size() );
+ echo "\r\n";
+
+ echo 'PHP Post Max Size: ';
+ echo size_format( $this->get_post_max_size() );
+ echo "\r\n";
+
+ echo 'PHP Time Limit: ';
+ if ( function_exists( 'ini_get' ) ) {
+ echo ini_get( 'max_execution_time' );
+ }
+ echo "\r\n";
+
+ echo 'PHP Error Log: ';
+ if ( function_exists( 'ini_get' ) ) {
+ echo ini_get( 'error_log' );
+ }
+ echo "\r\n";
+
+ echo 'fsockopen: ';
+ if ( function_exists( 'fsockopen' ) ) {
+ echo 'Enabled';
+ } else {
+ echo 'Disabled';
+ }
+ echo "\r\n";
+
+ echo 'OpenSSL: ';
+ if ( $this->open_ssl_enabled() ) {
+ echo OPENSSL_VERSION_TEXT;
+ } else {
+ echo 'Disabled';
+ }
+ echo "\r\n";
+
+ echo 'cURL: ';
+ if ( function_exists( 'curl_init' ) ) {
+ echo 'Enabled';
+ } else {
+ echo 'Disabled';
+ }
+ echo "\r\n";
+ echo "\r\n";
+
+ echo "Active Plugins:\r\n";
+
+ $active_plugins = (array) get_option( 'active_plugins', array() );
+
+ if ( is_multisite() ) {
+ $network_active_plugins = wp_get_active_network_plugins();
+ $active_plugins = array_map( array( $this, 'remove_wp_plugin_dir' ), $network_active_plugins );
+ }
+
+ foreach ( $active_plugins as $plugin ) {
+ $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
+ if ( empty( $plugin_data['Name'] ) ) {
+ continue;
+ }
+ printf( "%s (v%s) by %s\r\n", $plugin_data['Name'], $plugin_data['Version'], $plugin_data['AuthorName'] );
+ }
+
+ echo "\r\n";
+ }
+
+ function remove_wp_plugin_dir( $name ) {
+ $plugin = str_replace( WP_PLUGIN_DIR, '', $name );
+ return substr( $plugin, 1 );
+ }
+
+ function get_alter_queries() {
+ global $wpdb;
+ $alter_table_name = $this->get_alter_table_name();
+ $sql = '';
+ $alter_queries = $wpdb->get_results( "SELECT * FROM `{$alter_table_name}`", ARRAY_A );
+ if ( ! empty( $alter_queries ) ) {
+ foreach ( $alter_queries as $alter_query ) {
+ $sql .= $alter_query['query'];
+ }
+ }
+ return $sql;
+ }
+
+ function process_chunk( $chunk ) {
+ // prepare db
+ global $wpdb;
+ $this->set_time_limit();
+
+ $queries = array_filter( explode( ";\n", $chunk ) );
+ array_unshift( $queries, "SET sql_mode='NO_AUTO_VALUE_ON_ZERO';" );
+
+ ob_start();
+ $wpdb->show_errors();
+
+ if ( empty( $wpdb->charset ) ) {
+ $charset = ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'utf8' );
+ $wpdb->charset = $charset;
+ $wpdb->set_charset( $wpdb->dbh, $wpdb->charset );
+ }
+
+ foreach ( $queries as $query ) {
+ if ( false === $wpdb->query( $query ) ) {
+ $return = ob_get_clean();
+ $result = $this->end_ajax( $return );
+ return $result;
+ }
+ }
+
+ return true;
+ }
+
+ function ajax_migrate_table() {
+ $this->check_ajax_referer( 'migrate-table' );
+ global $wpdb;
+
+ $this->form_data = $this->parse_migration_form_data( $_POST['form_data'] );
+
+ $result = '';
+
+ // checks if we're performing a backup, if so, continue with the backup and exit immediately after
+ if ( $_POST['stage'] == 'backup' && $_POST['intent'] != 'savefile' ) {
+ // if performing a push we need to backup the REMOTE machine's DB
+ if ( $_POST['intent'] == 'push' ) {
+ $data = $_POST;
+ if ( isset( $data['nonce'] ) ) {
+ unset( $data['nonce'] );
+ }
+ $data['action'] = 'wpmdb_backup_remote_table';
+ $data['intent'] = 'pull';
+ $ajax_url = trailingslashit( $_POST['url'] ) . 'wp-admin/admin-ajax.php';
+ $data['primary_keys'] = stripslashes( $data['primary_keys'] );
+ $data['sig'] = $this->create_signature( $data, $data['key'] );
+ $response = $this->remote_post( $ajax_url, $data, __FUNCTION__ );
+ ob_start();
+ $this->display_errors();
+ $return = ob_get_clean();
+ $return .= $response;
+ } else {
+ $return = $this->handle_table_backup();
+ }
+
+ $result = $this->end_ajax( $return );
+ return $result;
+ }
+
+ // Pull and push need to be handled differently for obvious reasons, trigger different code depending on the migration intent (push or pull)
+ if ( $_POST['intent'] == 'push' || $_POST['intent'] == 'savefile' ) {
+ $this->maximum_chunk_size = $this->get_bottleneck();
+
+ if ( isset( $_POST['bottleneck'] ) ) {
+ $this->maximum_chunk_size = (int) $_POST['bottleneck'];
+ }
+
+ if ( $_POST['intent'] == 'push' ) {
+ $this->remote_key = $_POST['key'];
+ $this->remote_url = $_POST['url'];
+ }
+
+ $sql_dump_file_name = $this->get_upload_info( 'path' ) . DS;
+ $sql_dump_file_name .= $this->format_dump_name( $_POST['dump_filename'] );
+
+ if ( $_POST['intent'] == 'savefile' ) {
+ $this->fp = $this->open( $sql_dump_file_name );
+ }
+
+ $result = $this->export_table( $_POST['table'] );
+
+ if ( $_POST['intent'] == 'savefile' ) {
+ $this->close( $this->fp );
+ }
+
+ ob_start();
+ $this->display_errors();
+ $maybe_errors = trim( ob_get_clean() );
+ if ( false === empty( $maybe_errors ) ) {
+ $result = $this->end_ajax( $maybe_errors );
+ return $result;
+ }
+
+ return $result;
+ } else {
+ $data = $_POST;
+
+ if ( isset( $data['nonce'] ) ) {
+ unset( $data['nonce'] );
+ }
+
+ $data['action'] = 'wpmdb_process_pull_request';
+ $data['pull_limit'] = $this->get_sensible_pull_limit();
+
+ if ( is_multisite() ) {
+ $data['path_current_site'] = $this->get_path_current_site();
+ $data['domain_current_site'] = $this->get_domain_current_site();
+ }
+
+ $data['prefix'] = $wpdb->prefix;
+
+ if ( isset( $data['sig'] ) ) {
+ unset( $data['sig'] );
+ }
+
+ $ajax_url = trailingslashit( $data['url'] ) . 'wp-admin/admin-ajax.php';
+ $data['primary_keys'] = stripslashes( $data['primary_keys'] );
+ $data['sig'] = $this->create_signature( $data, $data['key'] );
+
+ $response = $this->remote_post( $ajax_url, $data, __FUNCTION__ );
+ ob_start();
+ $this->display_errors();
+ $maybe_errors = trim( ob_get_clean() );
+
+ if ( false === empty( $maybe_errors ) ) {
+ $result = $this->end_ajax( $maybe_errors );
+ return $result;
+ }
+
+ if ( strpos( $response, ';' ) === false ) {
+ $result = $this->end_ajax( $response );
+ return $result;
+ }
+
+ // returned data is just a big string like this query;query;query;33
+ // need to split this up into a chunk and row_tracker
+ $row_information = trim( substr( strrchr( $response, "\n" ), 1 ) );
+ $row_information = explode( ',', $row_information );
+ $chunk = substr( $response, 0, strrpos( $response, ";\n" ) + 1 );
+
+ if ( ! empty( $chunk ) ) {
+ $process_chunk_result = $this->process_chunk( $chunk );
+ if ( true !== $process_chunk_result ) {
+ $result = $this->end_ajax( $process_chunk_result );
+ return $result;
+ }
+ }
+
+ $result = $this->end_ajax( json_encode(
+ array(
+ 'current_row' => $row_information[0],
+ 'primary_keys' => $row_information[1]
+ )
+ ) );
+ }
+
+ return $result;
+ }
+
+ // Occurs right before the first table is migrated / backed up during the migration process
+ // Does a quick check to make sure the verification string is valid and also opens / creates files for writing to (if required)
+ function ajax_initiate_migration() {
+ $this->check_ajax_referer( 'initiate-migration' );
+ $this->form_data = $this->parse_migration_form_data( $_POST['form_data'] );
+
+ if ( $_POST['intent'] == 'savefile' ) {
+ $return = array(
+ 'code' => 200,
+ 'message' => 'OK',
+ 'body' => json_encode( array( 'error' => 0 ) ),
+ );
+
+ $return['dump_filename'] = basename( $this->get_sql_dump_info( 'migrate', 'path' ) );
+ $return['dump_url'] = $this->get_sql_dump_info( 'migrate', 'url' );
+ $dump_filename_no_extension = substr( $return['dump_filename'], 0, -4 );
+
+ $create_alter_table_query = $this->get_create_alter_table_query();
+ // sets up our table to store 'ALTER' queries
+ $process_chunk_result = $this->process_chunk( $create_alter_table_query );
+
+ if ( true !== $process_chunk_result ) {
+ $result = $this->end_ajax( $process_chunk_result );
+ return $result;
+ }
+
+ if ( $this->gzip() && isset( $this->form_data['gzip_file'] ) ) {
+ $return['dump_filename'] .= '.gz';
+ $return['dump_url'] .= '.gz';
+ }
+
+ $this->fp = $this->open( $this->get_upload_info( 'path' ) . DS . $return['dump_filename'] );
+ $this->db_backup_header();
+ $this->close( $this->fp );
+
+ $return['dump_filename'] = $dump_filename_no_extension;
+ } else { // does one last check that our verification string is valid
+ $data = array(
+ 'action' => 'wpmdb_remote_initiate_migration',
+ 'intent' => $_POST['intent'],
+ 'form_data' => $_POST['form_data'],
+ );
+
+ $data['sig'] = $this->create_signature( $data, $_POST['key'] );
+ $ajax_url = trailingslashit( $_POST['url'] ) . 'wp-admin/admin-ajax.php';
+ $response = $this->remote_post( $ajax_url, $data, __FUNCTION__ );
+
+ if ( false === $response ) {
+ $return = array( 'wpmdb_error' => 1, 'body' => $this->error );
+ $result = $this->end_ajax( json_encode( $return ) );
+ return $result;
+ }
+
+ $return = @unserialize( trim( $response ) );
+
+ if ( false === $return ) {
+ $error_msg = __( 'Failed attempting to unserialize the response from the remote server. Please contact support.', 'wp-migrate-db' );
+ $return = array( 'wpmdb_error' => 1, 'body' => $error_msg );
+ $this->log_error( $error_msg, $response );
+ $result = $this->end_ajax( json_encode( $return ) );
+ return $result;
+ }
+
+ if ( isset( $return['error'] ) && $return['error'] == 1 ) {
+ $return = array( 'wpmdb_error' => 1, 'body' => $return['message'] );
+ $result = $this->end_ajax( json_encode( $return ) );
+ return $result;
+ }
+
+ if ( $_POST['intent'] == 'pull' ) {
+ // sets up our table to store 'ALTER' queries
+ $create_alter_table_query = $this->get_create_alter_table_query();
+ $process_chunk_result = $this->process_chunk( $create_alter_table_query );
+ if ( true !== $process_chunk_result ) {
+ $result = $this->end_ajax( $process_chunk_result );
+ return $result;
+ }
+ }
+
+ if ( ! empty( $this->form_data['create_backup'] ) && $_POST['intent'] == 'pull' ) {
+ $return['dump_filename'] = basename( $this->get_sql_dump_info( 'backup', 'path' ) );
+ $return['dump_filename'] = substr( $return['dump_filename'], 0, -4 );
+ $return['dump_url'] = $this->get_sql_dump_info( 'backup', 'url' );
+ }
+ }
+
+ $return['dump_filename'] = ( empty( $return['dump_filename'] ) ) ? '' : $return['dump_filename'];
+ $return['dump_url'] = ( empty( $return['dump_url'] ) ) ? '' : $return['dump_url'];
+
+ $result = $this->end_ajax( json_encode( $return ) );
+ return $result;
+ }
+
+ function ajax_save_profile() {
+ $this->check_ajax_referer( 'save-profile' );
+ $profile = $this->parse_migration_form_data( $_POST['profile'] );
+ $profile = wp_parse_args( $profile, $this->checkbox_options );
+
+ if ( isset( $profile['save_migration_profile_option'] ) && $profile['save_migration_profile_option'] == 'new' ) {
+ $profile['name'] = $profile['create_new_profile'];
+ $this->settings['profiles'][] = $profile;
+ } else {
+ $key = $profile['save_migration_profile_option'];
+ $name = $this->settings['profiles'][$key]['name'];
+ $this->settings['profiles'][$key] = $profile;
+ $this->settings['profiles'][$key]['name'] = $name;
+ }
+
+ update_option( 'wpmdb_settings', $this->settings );
+ end( $this->settings['profiles'] );
+ $key = key( $this->settings['profiles'] );
+ $result = $this->end_ajax( $key );
+ return $result;
+ }
+
+ function ajax_delete_migration_profile() {
+ $this->check_ajax_referer( 'delete-migration-profile' );
+ $key = absint( $_POST['profile_id'] );
+ --$key;
+ $return = '';
+
+ if ( isset( $this->settings['profiles'][$key] ) ) {
+ unset( $this->settings['profiles'][$key] );
+ update_option( 'wpmdb_settings', $this->settings );
+ } else {
+ $return = '-1';
+ }
+
+ $result = $this->end_ajax( $return );
+ return $result;
+ }
+
+ function format_table_sizes( $size ) {
+ $size *= 1024;
+ return size_format( $size );
+ }
+
+ // Generates our secret key
+ function generate_key() {
+ $keyset = 'abcdefghijklmnopqrstuvqxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/';
+ $key = '';
+
+ for ( $i = 0; $i < 32; $i++ ) {
+ $key .= substr( $keyset, rand( 0, strlen( $keyset ) -1 ), 1 );
+ }
+
+ return $key;
+ }
+
+ function get_post_types() {
+ global $wpdb;
+
+ if ( is_multisite() ) {
+ $tables = $this->get_tables();
+ $sql = "SELECT `post_type` FROM `{$wpdb->prefix}posts` ";
+ foreach ( $tables as $table ) {
+ if ( 0 == preg_match( '/' . $wpdb->prefix . '[0-9]+_posts/', $table ) ) continue;
+ $blog_id = str_replace( array( $wpdb->prefix, '_posts' ), array( '', '' ), $table );
+ $sql .= "UNION SELECT `post_type` FROM `{$wpdb->prefix}" . $blog_id . "_posts` ";
+ }
+ $sql .= ";";
+ $post_types = $wpdb->get_results( $sql, ARRAY_A );
+ } else {
+ $post_types = $wpdb->get_results(
+ "SELECT DISTINCT `post_type`
+ FROM `{$wpdb->prefix}posts`
+ WHERE 1;", ARRAY_A
+ );
+ }
+
+ $return = array( 'revision' );
+
+ foreach ( $post_types as $post_type ) {
+ $return[] = $post_type['post_type'];
+ }
+
+ return apply_filters( 'wpmdb_post_types', array_unique( $return ) );
+ }
+
+ // Retrieves the specified profile, if -1, returns the default profile
+ function get_profile( $profile_id ) {
+ --$profile_id;
+
+ if ( $profile_id == '-1' || ! isset( $this->settings['profiles'][$profile_id] ) ) {
+ return $this->default_profile;
+ }
+
+ return $this->settings['profiles'][$profile_id];
+ }
+
+ function get_table_row_count() {
+ global $wpdb;
+
+ $sql = $wpdb->prepare( "SELECT table_name, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = %s", DB_NAME );
+ $results = $wpdb->get_results( $sql, ARRAY_A );
+
+ $return = array();
+
+ foreach ( $results as $results ) {
+ $return[$results['table_name']] = ( $results['TABLE_ROWS'] == 0 ? 1 : $results['TABLE_ROWS'] );
+ }
+
+ return $return;
+ }
+
+ function get_table_sizes( $scope = 'regular' ) {
+ global $wpdb;
+
+ $prefix = ( $scope == 'temp' ? $this->temp_prefix : $wpdb->prefix );
+
+ $sql = $wpdb->prepare(
+ "SELECT TABLE_NAME AS 'table',
+ ROUND ( ( data_length + index_length ) / 1024, 0 ) AS 'size'
+ FROM information_schema.TABLES
+ WHERE information_schema.TABLES.table_schema='%s'
+ AND information_schema.TABLES.table_type='%s'", DB_NAME, 'BASE TABLE'
+ );
+
+ $results = $wpdb->get_results( $sql, ARRAY_A );
+
+ $return = array();
+
+ foreach ( $results as $result ) {
+ $return[$result['table']] = $result['size'];
+ }
+
+ return apply_filters( 'wpmdb_table_sizes', $return, $scope );
+ }
+
+ function get_post_max_size() {
+ $val = trim( ini_get( 'post_max_size' ) );
+ $last = strtolower( $val[ strlen( $val ) - 1 ] );
+
+ switch ( $last ) {
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ }
+
+ return $val;
+ }
+
+ function get_bottleneck( $type = 'regular' ) {
+ $suhosin_limit = false;
+ $suhosin_request_limit = false;
+ $suhosin_post_limit = false;
+
+ if ( function_exists( 'ini_get' ) ) {
+ $suhosin_request_limit = $this->return_bytes( ini_get( 'suhosin.request.max_value_length' ) );
+ $suhosin_post_limit = $this->return_bytes( ini_get( 'suhosin.post.max_value_length' ) );
+ }
+
+ if ( $suhosin_request_limit && $suhosin_post_limit ) {
+ $suhosin_limit = min( $suhosin_request_limit, $suhosin_post_limit );
+ }
+
+ // we have to account for HTTP headers and other bloating, here we minus 1kb for bloat
+ $post_max_upper_size = apply_filters( 'wpmdb_post_max_upper_size', 26214400 );
+ $calculated_bottleneck = min( ( $this->get_post_max_size() - 1024 ), $post_max_upper_size );
+
+ if ( $suhosin_limit ) {
+ $calculated_bottleneck = min( $calculated_bottleneck, $suhosin_limit - 1024 );
+ }
+
+ if ( $type != 'max' ) {
+ $calculated_bottleneck = min( $calculated_bottleneck, $this->settings['max_request'] );
+ }
+
+ return apply_filters( 'wpmdb_bottleneck', $calculated_bottleneck );
+ }
+
+ function format_dump_name( $dump_name ) {
+ $extension = '.sql';
+ $dump_name = sanitize_file_name( $dump_name );
+
+ if ( $this->gzip() && isset( $this->form_data['gzip_file'] ) ) {
+ $extension .= '.gz';
+ }
+
+ return $dump_name . $extension;
+ }
+
+ function options_page() {
+ $this->template( 'options' );
+ }
+
+ function apply_replaces( $subject, $is_serialized = false ) {
+ $search = $this->form_data['replace_old'];
+ $replace = $this->form_data['replace_new'];
+ $new = str_ireplace( $search, $replace, $subject, $count );
+ if ( $this->is_subdomain_replaces_on() ) {
+ $new = $this->subdomain_replaces( $new );
+ }
+ return $new;
+ }
+
+ /**
+ * Determine whether to apply a subdomain replace over each value in the database.
+ *
+ * @return bool
+ */
+ function is_subdomain_replaces_on() {
+ if ( ! isset( $this->subdomain_replaces_on ) ) {
+ $this->subdomain_replaces_on = ( is_multisite() && defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL && apply_filters( 'wpmdb_subdomain_replace', true ) );
+ }
+ return $this->subdomain_replaces_on;
+ }
+
+ /**
+ * Get the remote site's base domain for subdomain multisite search/replace.
+ *
+ * @return string|bool The remote site's domain or false on error.
+ */
+ function get_domain_replace() {
+ if ( ! isset( $this->domain_replace ) ) {
+ if ( ! empty( $_POST['domain_current_site'] ) ) {
+ $this->domain_replace = $_POST['domain_current_site'];
+ } elseif ( ! empty ( $this->form_data['replace_new'][1] ) ) { // occurs when performing an export migration
+ $url = $this->form_data['replace_new'][1];
+ $url = ( 0 === strpos( $url, '//' ) ) ? 'http:' . $url : $url;
+ $url = parse_url( $url );
+ $this->domain_replace = $url['host'];
+ } else {
+ $this->domain_replace = false;
+ }
+ }
+ return $this->domain_replace;
+ }
+
+ /*
+ * Automatically replace URLs for subdomain based multisite installations
+ * e.g. //site1.example.com -> //site1.example.local for site with domain example.com
+ * NB: only handles the current network site, does not work for additional networks / mapped domains
+ */
+ function subdomain_replaces( $new ) {
+ $domain_replace = $this->get_domain_replace();
+
+ if ( empty( $domain_replace ) ) {
+ return $new;
+ }
+
+ $pattern = '|//(.*?)\\.' . preg_quote( $this->get_domain_current_site(), '|' ) . '|';
+ $replacement = '//$1.' . trim( $domain_replace );
+ $new = preg_replace( $pattern, $replacement, $new );
+
+ return $new;
+ }
+
+ function process_sql_constraint( $create_query, $table, &$alter_table_query ) {
+ if ( preg_match( '@CONSTRAINT|FOREIGN[\s]+KEY@', $create_query ) ) {
+ $sql_constraints_query = '';
+
+ $nl_nix = "\n";
+ $nl_win = "\r\n";
+ $nl_mac = "\r";
+
+ if ( strpos( $create_query, $nl_win ) !== false ) {
+ $crlf = $nl_win;
+ } elseif ( strpos( $create_query, $nl_mac ) !== false ) {
+ $crlf = $nl_mac;
+ } else {
+ $crlf = $nl_nix;
+ }
+
+ // Split the query into lines, so we can easily handle it.
+ // We know lines are separated by $crlf (done few lines above).
+ $sql_lines = explode( $crlf, $create_query );
+ $sql_count = count( $sql_lines );
+
+ // lets find first line with constraints
+ for ( $i = 0; $i < $sql_count; $i++ ) {
+ if ( preg_match(
+ '@^[\s]*(CONSTRAINT|FOREIGN[\s]+KEY)@',
+ $sql_lines[$i]
+ ) ) {
+ break;
+ }
+ }
+
+ // If we really found a constraint
+ if ( $i != $sql_count ) {
+ // remove, from the end of create statement
+ $sql_lines[$i - 1] = preg_replace(
+ '@,$@',
+ '',
+ $sql_lines[$i - 1]
+ );
+
+ // let's do the work
+ $sql_constraints_query .= 'ALTER TABLE '
+ . $this->backquote( $table )
+ . $crlf;
+
+ $first = true;
+ for ( $j = $i; $j < $sql_count; $j++ ) {
+ if ( preg_match(
+ '@CONSTRAINT|FOREIGN[\s]+KEY@',
+ $sql_lines[$j]
+ ) ) {
+ if ( strpos( $sql_lines[$j], 'CONSTRAINT' ) === false ) {
+ $tmp_str = preg_replace(
+ '/(FOREIGN[\s]+KEY)/',
+ 'ADD \1',
+ $sql_lines[$j]
+ );
+ $sql_constraints_query .= $tmp_str;
+ } else {
+ $tmp_str = preg_replace(
+ '/(CONSTRAINT)/',
+ 'ADD \1',
+ $sql_lines[$j]
+ );
+ $sql_constraints_query .= $tmp_str;
+ preg_match(
+ '/(CONSTRAINT)([\s])([\S]*)([\s])/',
+ $sql_lines[$j],
+ $matches
+ );
+ }
+ $first = false;
+ } else {
+ break;
+ }
+ }
+
+ $sql_constraints_query .= ";\n";
+
+ $create_query = implode(
+ $crlf,
+ array_slice( $sql_lines, 0, $i )
+ )
+ . $crlf
+ . implode(
+ $crlf,
+ array_slice( $sql_lines, $j, $sql_count - 1 )
+ );
+ unset( $sql_lines );
+
+ $alter_table_query = $sql_constraints_query;
+ return $create_query;
+ }
+ }
+ return $create_query;
+ }
+
+ /**
+ * Taken partially from phpMyAdmin and partially from
+ * Alain Wolf, Zurich - Switzerland
+ * Website: http://restkultur.ch/personal/wolf/scripts/db_backup/
+ * Modified by Scott Merrill (http://www.skippy.net/)
+ * to use the WordPress $wpdb object
+ *
+ * @param string $table
+ * @return void
+ */
+ function export_table( $table ) {
+ global $wpdb;
+ $this->set_time_limit();
+
+ if ( empty( $this->form_data ) ) {
+ $this->form_data = $this->parse_migration_form_data( $_POST['form_data'] );
+ }
+
+ $temp_prefix = $this->temp_prefix;
+ $remote_prefix = ( isset( $_POST['prefix'] ) ? $_POST['prefix'] : $wpdb->prefix );
+
+ $table_structure = $wpdb->get_results( "DESCRIBE " . $this->backquote( $table ) );
+
+ if ( ! $table_structure ) {
+ $this->error = __( 'Failed to retrieve table structure, please ensure your database is online. (#125)', 'wp-migrate-db' );
+ return false;
+ }
+
+ $current_row = -1;
+
+ if ( ! empty( $_POST['current_row'] ) ) {
+ $temp_current_row = trim( $_POST['current_row'] );
+ if ( ! empty( $temp_current_row ) ) {
+ $current_row = (int) $temp_current_row;
+ }
+ }
+
+ if ( $current_row == -1 ) {
+ // Add SQL statement to drop existing table
+ if ( $this->form_data['action'] == 'savefile' || $_POST['stage'] == 'backup' ) {
+ $this->stow( "\n\n" );
+ $this->stow( "#\n" );
+ $this->stow( "# " . sprintf( __( 'Delete any existing table %s', 'wp-migrate-db' ), $this->backquote( $table ) ) . "\n" );
+ $this->stow( "#\n" );
+ $this->stow( "\n" );
+ $this->stow( "DROP TABLE IF EXISTS " . $this->backquote( $table ) . ";\n" );
+ } else {
+ $this->stow( "DROP TABLE IF EXISTS " . $this->backquote( $temp_prefix . $table ) . ";\n" );
+ }
+
+ // Table structure
+ // Comment in SQL-file
+ if ( $this->form_data['action'] == 'savefile' || $_POST['stage'] == 'backup' ) {
+ $this->stow( "\n\n" );
+ $this->stow( "#\n" );
+ $this->stow( "# " . sprintf( __( 'Table structure of table %s', 'wp-migrate-db' ), $this->backquote( $table ) ) . "\n" );
+ $this->stow( "#\n" );
+ $this->stow( "\n" );
+ }
+
+ $create_table = $wpdb->get_results( "SHOW CREATE TABLE " . $this->backquote( $table ), ARRAY_N );
+
+ if ( false === $create_table ) {
+ $this->error = __( 'Failed to generate the create table query, please ensure your database is online. (#126)', 'wp-migrate-db' );
+ return false;
+ }
+
+ if ( $this->form_data['action'] != 'savefile' && $_POST['stage'] != 'backup' ) {
+ $create_table[0][1] = str_replace( 'CREATE TABLE `', 'CREATE TABLE `' . $temp_prefix, $create_table[0][1] );
+ }
+
+ $create_table[0][1] = str_replace( 'TYPE=', 'ENGINE=', $create_table[0][1] );
+
+ $alter_table_query = '';
+ $create_table[0][1] = $this->process_sql_constraint( $create_table[0][1], $table, $alter_table_query );
+
+ $create_table[0][1] = apply_filters( 'wpmdb_create_table_query', $create_table[0][1], $table );
+
+ $this->stow( $create_table[0][1] . ";\n" );
+
+ if ( ! empty( $alter_table_query ) ) {
+ $alter_table_name = $this->get_alter_table_name();
+ $insert = sprintf( "INSERT INTO %s ( `query` ) VALUES ( '%s' );\n", $this->backquote( $alter_table_name ), esc_sql( $alter_table_query ) );
+ if ( $this->form_data['action'] == 'savefile' || $_POST['stage'] == 'backup' ) {
+ $process_chunk_result = $this->process_chunk( $insert );
+ if ( true !== $process_chunk_result ) {
+ $result = $this->end_ajax( $process_chunk_result );
+ return $result;
+ }
+ } else {
+ $this->stow( $insert );
+ }
+ }
+
+ // Comment in SQL-file
+ if ( $this->form_data['action'] == 'savefile' || $_POST['stage'] == 'backup' ) {
+ $this->stow( "\n\n" );
+ $this->stow( "#\n" );
+ $this->stow( '# ' . sprintf( __( 'Data contents of table %s', 'wp-migrate-db' ), $this->backquote( $table ) ) . "\n" );
+ $this->stow( "#\n" );
+ }
+ }
+
+ // $defs = mysql defaults, looks up the default for that paricular column, used later on to prevent empty inserts values for that column
+ // $ints = holds a list of the possible integar types so as to not wrap them in quotation marks later in the insert statements
+ $defs = array();
+ $ints = array();
+ foreach ( $table_structure as $struct ) {
+ if ( ( 0 === strpos( $struct->Type, 'tinyint' ) ) ||
+ ( 0 === strpos( strtolower( $struct->Type ), 'smallint' ) ) ||
+ ( 0 === strpos( strtolower( $struct->Type ), 'mediumint' ) ) ||
+ ( 0 === strpos( strtolower( $struct->Type ), 'int' ) ) ||
+ ( 0 === strpos( strtolower( $struct->Type ), 'bigint' ) ) ) {
+ $defs[strtolower( $struct->Field )] = ( null === $struct->Default ) ? 'NULL' : $struct->Default;
+ $ints[strtolower( $struct->Field )] = "1";
+ }
+ }
+
+ // Batch by $row_inc
+
+ $row_inc = $this->rows_per_segment;
+ $row_start = 0;
+ if ( $current_row != -1 ) {
+ $row_start = $current_row;
+ }
+
+ $this->row_tracker = $row_start;
+
+ // \x08\\x09, not required
+ $search = array( "\x00", "\x0a", "\x0d", "\x1a" );
+ $replace = array( '\0', '\n', '\r', '\Z' );
+
+ $query_size = 0;
+
+ $table_name = $table;
+
+ if ( $this->form_data['action'] != 'savefile' && $_POST['stage'] != 'backup' ) {
+ $table_name = $temp_prefix . $table;
+ }
+
+ $this->primary_keys = array();
+ $field_set = array();
+ $use_primary_keys = true;
+
+ foreach ( $table_structure as $col ) {
+ $field_set[] = $this->backquote( $col->Field );
+ if ( $col->Key == 'PRI' && true == $use_primary_keys ) {
+ if ( false === strpos( $col->Type, 'int' ) ) {
+ $use_primary_keys = false;
+ $this->primary_keys = array();
+ continue;
+ }
+ $this->primary_keys[$col->Field] = 0;
+ }
+ }
+
+ $first_select = true;
+ if ( ! empty( $_POST['primary_keys'] ) ) {
+ $_POST['primary_keys'] = trim( $_POST['primary_keys'] );
+ if ( ! empty( $_POST['primary_keys'] ) && is_serialized( $_POST['primary_keys'] ) ) {
+ $this->primary_keys = unserialize( stripslashes( $_POST['primary_keys'] ) );
+ $first_select = false;
+ }
+ }
+
+ $fields = implode( ', ', $field_set );
+
+ $insert_buffer = $insert_query_template = "INSERT INTO " . $this->backquote( $table_name ) . " ( " . $fields . ") VALUES\n";
+
+ do {
+ $join = array();
+ $where = 'WHERE 1=1';
+ $order_by = '';
+ // We need ORDER BY here because with LIMIT, sometimes it will return
+ // the same results from the previous query and we'll have duplicate insert statements
+ if ( 'backup' != $_POST['stage'] && isset( $this->form_data['exclude_spam'] ) ) {
+ if ( $this->table_is( 'comments', $table ) ) {
+ $where .= ' AND comment_approved != "spam"';
+ } elseif ( $this->table_is( 'commentmeta', $table ) ) {
+ $tables = $this->get_ms_compat_table_names( array( 'commentmeta', 'comments' ), $table ) ;
+ $join[] = sprintf( 'INNER JOIN %1$s ON %1$s.comment_ID = %2$s.comment_id', $this->backquote( $tables['comments_table'] ), $this->backquote( $tables['commentmeta_table'] ) );
+ $where .= sprintf( ' AND %1$s.comment_approved != \'spam\'', $this->backquote( $tables['comments_table'] ) );
+ }
+ }
+
+ if ( 'backup' != $_POST['stage'] && isset( $this->form_data['exclude_post_types'] ) && ! empty( $this->form_data['select_post_types'] ) ) {
+ $post_types = '\'' . implode( '\', \'', $this->form_data['select_post_types'] ) . '\'';
+ if ( $this->table_is( 'posts', $table ) ) {
+ $where .= ' AND `post_type` NOT IN ( ' . $post_types . ' )';
+ } elseif ( $this->table_is( 'postmeta', $table ) ) {
+ $tables = $this->get_ms_compat_table_names( array( 'postmeta', 'posts' ), $table );
+ $join[] = sprintf( 'INNER JOIN %1$s ON %1$s.ID = %2$s.post_id', $this->backquote( $tables['posts_table'] ), $this->backquote( $tables['postmeta_table'] ) );
+ $where .= sprintf( ' AND %1$s.post_type NOT IN ( ' . $post_types . ' )', $this->backquote( $tables['posts_table'] ) );
+ } elseif ( $this->table_is( 'comments', $table ) ) {
+ $tables = $this->get_ms_compat_table_names( array( 'comments', 'posts' ), $table );
+ $join[] = sprintf( 'INNER JOIN %1$s ON %1$s.ID = %2$s.comment_post_ID', $this->backquote( $tables['posts_table'] ), $this->backquote( $tables['comments_table'] ) );
+ $where .= sprintf( ' AND %1$s.post_type NOT IN ( ' . $post_types . ' )', $this->backquote( $tables['posts_table'] ) );
+ } elseif ( $this->table_is( 'commentmeta', $table ) ) {
+ $tables = $this->get_ms_compat_table_names( array( 'commentmeta', 'posts', 'comments' ), $table );
+ $join[] = sprintf( 'INNER JOIN %1$s ON %1$s.comment_ID = %2$s.comment_id', $this->backquote( $tables['comments_table'] ), $this->backquote( $tables['commentmeta_table'] ) );
+ $join[] = sprintf( 'INNER JOIN %2$s ON %2$s.ID = %1$s.comment_post_ID', $this->backquote( $tables['comments_table'] ), $this->backquote( $tables['posts_table'] ) );
+ $where .= sprintf( ' AND %1$s.post_type NOT IN ( ' . $post_types . ' )', $this->backquote( $tables['posts_table'] ) );
+ }
+ }
+
+ if ( 'backup' != $_POST['stage'] && true === apply_filters( 'wpmdb_exclude_transients', true ) && isset( $this->form_data['exclude_transients'] ) && '1' === $this->form_data['exclude_transients'] && ( $this->table_is( 'options', $table ) || ( isset( $wpdb->sitemeta ) && $wpdb->sitemeta == $table ) ) ) {
+ $col_name = 'option_name';
+
+ if ( isset( $wpdb->sitemeta ) && $wpdb->sitemeta == $table ) {
+ $col_name = 'meta_key';
+ }
+
+ $where .= " AND `{$col_name}` NOT LIKE '\_transient\_%' AND `{$col_name}` NOT LIKE '\_site\_transient\_%'";
+ }
+
+ // don't export/migrate the wpmdb_settings or wpmdb_error_log option rows unless we're performing a backup
+ if ( 'backup' != $_POST['stage'] && $wpdb->options === $table ) {
+ $where .= " AND `option_name` NOT LIKE 'wpmdb_settings'";
+ $where .= " AND `option_name` NOT LIKE 'wpmdb_error_log'";
+ }
+
+ $limit = "LIMIT {$row_start}, {$row_inc}";
+
+ if ( ! empty( $this->primary_keys ) ) {
+ $primary_keys_keys = array_keys( $this->primary_keys );
+ $primary_keys_keys = array_map( array( $this, 'backquote' ), $primary_keys_keys );
+
+ $order_by = 'ORDER BY ' . implode( ',', $primary_keys_keys );
+ $limit = "LIMIT $row_inc";
+
+ if ( false == $first_select ) {
+ $where .= ' AND ';
+
+ $temp_primary_keys = $this->primary_keys;
+ $primary_key_count = count( $temp_primary_keys );
+
+ // build a list of clauses, iteratively reducing the number of fields compared in the compound key
+ // e.g. (a = 1 AND b = 2 AND c > 3) OR (a = 1 AND b > 2) OR (a > 1)
+ $clauses = array();
+ for ( $j = 0; $j < $primary_key_count; $j++ ) {
+ // build a subclause for each field in the compound index
+ $subclauses = array();
+ $i = 0;
+ foreach ( $temp_primary_keys as $primary_key => $value ) {
+ // only the last field in the key should be different in this subclause
+ $operator = ( count( $temp_primary_keys ) - 1 == $i ? '>' : '=' );
+ $subclauses[] = sprintf( '%s %s %s', $this->backquote( $primary_key ), $operator, $wpdb->prepare( '%s', $value ) );
+ ++$i;
+ }
+
+ // remove last field from array to reduce fields in next clause
+ array_pop( $temp_primary_keys );
+
+ // join subclauses into a single clause
+ // NB: AND needs to be wrapped in () as it has higher precedence than OR
+ $clauses[] = '( ' . implode( ' AND ', $subclauses ) . ' )';
+ }
+ // join clauses into a single clause
+ // NB: OR needs to be wrapped in () as it has lower precedence than AND
+ $where .= '( ' . implode( ' OR ', $clauses ) . ' )';
+ }
+
+ $first_select = false;
+ }
+
+ $join = implode( ' ', array_unique( $join ) );
+ $join = apply_filters( 'wpmdb_rows_join', $join, $table );
+ $where = apply_filters( 'wpmdb_rows_where', $where, $table );
+ $order_by = apply_filters( 'wpmdb_rows_order_by', $order_by, $table );
+ $limit = apply_filters( 'wpmdb_rows_limit', $limit, $table );
+
+ $sql = "SELECT " . $this->backquote( $table ) . ".* FROM " . $this->backquote( $table ) . " $join $where $order_by $limit";
+ $sql = apply_filters( 'wpmdb_rows_sql', $sql, $table );
+
+ $table_data = $wpdb->get_results( $sql );
+
+ if ( $table_data ) {
+ foreach ( $table_data as $row ) {
+ $values = array();
+ foreach ( $row as $key => $value ) {
+ if ( isset( $ints[strtolower( $key )] ) && $ints[strtolower( $key )] ) {
+ // make sure there are no blank spots in the insert syntax,
+ // yet try to avoid quotation marks around integers
+ $value = ( null === $value || '' === $value ) ? $defs[strtolower( $key )] : $value;
+ $values[] = ( '' === $value ) ? "''" : $value;
+ } else {
+ if ( null === $value ) {
+ $values[] = 'NULL';
+ } else {
+ if ( is_multisite() && 'path' == $key && $_POST['stage'] != 'backup' && ( $wpdb->site == $table || $wpdb->blogs == $table ) ) {
+ $old_path_current_site = $this->get_path_current_site();
+ $new_path_current_site = '';
+
+ if ( ! empty( $_POST['path_current_site'] ) ) {
+ $new_path_current_site = stripslashes( $_POST['path_current_site'] );
+ } elseif ( ! empty ( $this->form_data['replace_new'][1] ) ) {
+ $new_path_current_site = $this->get_path_from_url( $this->form_data['replace_new'][1] );
+ }
+
+ $new_path_current_site = apply_filters( 'wpmdb_new_path_current_site', $new_path_current_site );
+
+ if ( ! empty( $new_path_current_site ) && $old_path_current_site != $new_path_current_site ) {
+ $pos = strpos( $value, $old_path_current_site );
+ $value = substr_replace( $value, $new_path_current_site, $pos, strlen( $old_path_current_site ) );
+ }
+ }
+
+ if ( is_multisite() && 'domain' == $key && $_POST['stage'] != 'backup' && ( $wpdb->site == $table || $wpdb->blogs == $table ) ) {
+ if ( ! empty( $_POST['domain_current_site'] ) ) {
+ $main_domain_replace = $_POST['domain_current_site'];
+ } elseif ( ! empty ( $this->form_data['replace_new'][1] ) ) {
+ $url = parse_url( $this->form_data['replace_new'][1] );
+ $main_domain_replace = $url['host'];
+ }
+
+ $domain_replaces = array();
+ $main_domain_find = sprintf( "/%s/", preg_quote( $this->get_domain_current_site(), '/' ) );
+ if ( isset( $main_domain_replace ) ) {
+ $domain_replaces[$main_domain_find] = $main_domain_replace;
+ }
+
+ $domain_replaces = apply_filters( 'wpmdb_domain_replaces', $domain_replaces );
+
+ $value = preg_replace( array_keys( $domain_replaces ), array_values( $domain_replaces ), $value );
+ }
+
+ if ( 'guid' != $key || ( isset( $this->form_data['replace_guids'] ) && $this->table_is( 'posts', $table ) ) ) {
+ if ( $_POST['stage'] != 'backup' ) {
+ $value = $this->recursive_unserialize_replace( $value );
+ }
+ }
+
+ $values[] = "'" . str_replace( $search, $replace, $this->sql_addslashes( $value ) ) . "'";
+ }
+ }
+ }
+
+ $insert_line = '(' . implode( ', ', $values ) . '),';
+ $insert_line .= "\n";
+
+ if ( ( strlen( $this->current_chunk ) + strlen( $insert_line ) + strlen( $insert_buffer ) + 10 ) > $this->maximum_chunk_size ) {
+ if ( $insert_buffer == $insert_query_template ) {
+ $insert_buffer .= $insert_line;
+
+ ++$this->row_tracker;
+
+ if ( ! empty( $this->primary_keys ) ) {
+ foreach ( $this->primary_keys as $primary_key => $value ) {
+ $this->primary_keys[$primary_key] = $row->$primary_key;
+ }
+ }
+ }
+
+ $insert_buffer = rtrim( $insert_buffer, "\n," );
+ $insert_buffer .= " ;\n";
+ $this->stow( $insert_buffer );
+ $insert_buffer = $insert_query_template;
+ $query_size = 0;
+ return $this->transfer_chunk();
+ }
+
+ if ( ( $query_size + strlen( $insert_line ) ) > $this->max_insert_string_len && $insert_buffer != $insert_query_template ) {
+ $insert_buffer = rtrim( $insert_buffer, "\n," );
+ $insert_buffer .= " ;\n";
+ $this->stow( $insert_buffer );
+ $insert_buffer = $insert_query_template;
+ $query_size = 0;
+ }
+
+ $insert_buffer .= $insert_line;
+ $query_size += strlen( $insert_line );
+
+ ++$this->row_tracker;
+
+ if ( ! empty( $this->primary_keys ) ) {
+ foreach ( $this->primary_keys as $primary_key => $value ) {
+ $this->primary_keys[$primary_key] = $row->$primary_key;
+ }
+ }
+ }
+
+ $row_start += $row_inc;
+
+ if ( $insert_buffer != $insert_query_template ) {
+ $insert_buffer = rtrim( $insert_buffer, "\n," );
+ $insert_buffer .= " ;\n";
+ $this->stow( $insert_buffer );
+ $insert_buffer = $insert_query_template;
+ $query_size = 0;
+ }
+
+ }
+ } while ( count( $table_data ) > 0 );
+
+ // Create footer/closing comment in SQL-file
+ if ( $this->form_data['action'] == 'savefile' || $_POST['stage'] == 'backup' ) {
+ $this->stow( "\n" );
+ $this->stow( "#\n" );
+ $this->stow( "# " . sprintf( __( 'End of data contents of table %s', 'wp-migrate-db' ), $this->backquote( $table ) ) . "\n" );
+ $this->stow( "# --------------------------------------------------------\n" );
+ $this->stow( "\n" );
+
+ if ( $_POST['last_table'] == '1' ) {
+ $this->stow( "#\n" );
+ $this->stow( "# Add constraints back in\n" );
+ $this->stow( "#\n\n" );
+ $this->stow( $this->get_alter_queries() );
+ $alter_table_name = $this->get_alter_table_name();
+
+ if ( $this->form_data['action'] == 'savefile' ) {
+ $wpdb->query( "DROP TABLE IF EXISTS " . $this->backquote( $alter_table_name ) . ";" );
+ }
+ }
+ }
+
+ $this->row_tracker = -1;
+ return $this->transfer_chunk();
+
+ } // end backup_table()
+
+ function table_is( $desired_table, $given_table ) {
+ global $wpdb;
+ return $wpdb->{$desired_table} == $given_table || preg_match( '/' . $wpdb->prefix . '[0-9]+_' . $desired_table . '/', $given_table );
+ }
+
+ /**
+ * return multisite-compatible names for requested tables, based on queried table name
+ *
+ * @param array $tables list of table names required
+ * @param string $queried_table name of table from which to derive the blog ID
+ *
+ * @return array list of table names altered for multisite compatibility
+ */
+ function get_ms_compat_table_names( $tables, $queried_table ) {
+ global $wpdb;
+
+ // default table prefix
+ $prefix = $wpdb->prefix;
+
+ // if multisite, extract blog ID from queried table name and add to prefix
+ // won't match for primary blog because it uses standard table names, i.e. blog_id will never be 1
+ if ( is_multisite() && preg_match( '/^' . preg_quote( $wpdb->prefix, '/' ) . '([0-9]+)_/', $queried_table, $matches ) ) {
+ $blog_id = $matches[1];
+ $prefix .= $blog_id . '_';
+ }
+
+ // build table names
+ $ms_compat_table_names = array();
+
+ foreach ( $tables as $table ) {
+ $ms_compat_table_names[$table . '_table'] = $prefix . $table;
+ }
+
+ return $ms_compat_table_names;
+ }
+
+ /**
+ * Take a serialized array and unserialize it replacing elements as needed and
+ * unserialising any subordinate arrays and performing the replace on those too.
+ *
+ * Mostly from https://github.com/interconnectit/Search-Replace-DB
+ *
+ * @param array $data Used to pass any subordinate arrays back to in.
+ * @param bool $serialized Does the array passed via $data need serialising.
+ * @param bool $parent_serialized Passes whether the original data passed in was serialized
+ *
+ * @return array The original array with all elements replaced as needed.
+ */
+ function recursive_unserialize_replace( $data, $serialized = false, $parent_serialized = false ) {
+ $is_json = false;
+ // some unseriliased data cannot be re-serialized eg. SimpleXMLElements
+ try {
+ if ( is_string( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
+ // PHP currently has a bug that doesn't allow you to clone the DateInterval / DatePeriod classes.
+ // We skip them here as they probably won't need data to be replaced anyway
+ if ( is_object( $unserialized ) ) {
+ if ( $unserialized instanceof DateInterval || $unserialized instanceof DatePeriod ) return $data;
+ }
+ $data = $this->recursive_unserialize_replace( $unserialized, true, true );
+ } elseif ( is_array( $data ) ) {
+ $_tmp = array( );
+ foreach ( $data as $key => $value ) {
+ $_tmp[ $key ] = $this->recursive_unserialize_replace( $value, false, $parent_serialized );
+ }
+
+ $data = $_tmp;
+ unset( $_tmp );
+ } elseif ( is_object( $data ) ) { // Submitted by Tina Matter
+ $_tmp = clone $data;
+ foreach ( $data as $key => $value ) {
+ $_tmp->$key = $this->recursive_unserialize_replace( $value, false, $parent_serialized );
+ }
+
+ $data = $_tmp;
+ unset( $_tmp );
+ } elseif ( $this->is_json( $data, true ) ) {
+ $_tmp = array( );
+ $data = json_decode( $data, true );
+
+ foreach ( $data as $key => $value ) {
+ $_tmp[ $key ] = $this->recursive_unserialize_replace( $value, false, $parent_serialized );
+ }
+
+ $data = $_tmp;
+ unset( $_tmp );
+ $is_json = true;
+ } elseif ( is_string( $data ) ) {
+ $data = $this->apply_replaces( $data, $parent_serialized );
+ }
+
+ if ( $serialized ) {
+ return serialize( $data );
+ }
+
+ if ( $is_json ) {
+ return json_encode( $data );
+ }
+ } catch( Exception $error ) {
+
+ }
+
+ return $data;
+ }
+
+ function db_backup_header() {
+ $charset = ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'utf8' );
+ $this->stow( "# " . __( 'WordPress MySQL database migration', 'wp-migrate-db' ) . "\n", false );
+ $this->stow( "#\n", false );
+ $this->stow( "# " . sprintf( __( 'Generated: %s', 'wp-migrate-db' ), date( "l j. F Y H:i T" ) ) . "\n", false );
+ $this->stow( "# " . sprintf( __( 'Hostname: %s', 'wp-migrate-db' ), DB_HOST ) . "\n", false );
+ $this->stow( "# " . sprintf( __( 'Database: %s', 'wp-migrate-db' ), $this->backquote( DB_NAME ) ) . "\n", false );
+ $this->stow( "# --------------------------------------------------------\n\n", false );
+ $this->stow( "/*!40101 SET NAMES $charset */;\n\n", false );
+ $this->stow( "SET sql_mode='NO_AUTO_VALUE_ON_ZERO';\n\n", false );
+ }
+
+ function gzip() {
+ return function_exists( 'gzopen' );
+ }
+
+ function open( $filename = '', $mode = 'a' ) {
+ if ( '' == $filename ) {
+ return false;
+ }
+
+ if ( $this->gzip() && isset( $this->form_data['gzip_file'] ) ) {
+ $fp = gzopen( $filename, $mode );
+ } else {
+ $fp = fopen( $filename, $mode );
+ }
+
+ return $fp;
+ }
+
+ function close( $fp ) {
+ if ( $this->gzip() && isset( $this->form_data['gzip_file'] ) ) {
+ gzclose( $fp );
+ } else {
+ fclose( $fp );
+ }
+
+ unset( $this->fp );
+ }
+
+ function stow( $query_line, $replace = true ) {
+ $this->current_chunk .= $query_line;
+
+ if ( $this->form_data['action'] == 'savefile' || $_POST['stage'] == 'backup' ) {
+ if ( $this->gzip() && isset( $this->form_data['gzip_file'] ) ) {
+ if ( ! @gzwrite( $this->fp, $query_line ) ) {
+ $this->error = __( 'Failed to write the gzipped SQL data to the file. (#127)', 'wp-migrate-db' );
+ return false;
+ }
+ } else {
+ if ( false === @fwrite( $this->fp, $query_line ) ) {
+ $this->error = __( 'Failed to write the SQL data to the file. (#128)', 'wp-migrate-db' );
+ return false;
+ }
+ }
+ } elseif ( $_POST['intent'] == 'pull' ) {
+ echo $query_line;
+ }
+ }
+
+ // Called in the $this->stow function once our chunk buffer is full, will transfer the SQL to the remote server for importing
+ function transfer_chunk() {
+ if ( $_POST['intent'] == 'savefile' || $_POST['stage'] == 'backup' ) {
+ $this->close( $this->fp );
+
+ $result = $this->end_ajax( json_encode(
+ array(
+ 'current_row' => $this->row_tracker,
+ 'primary_keys' => serialize( $this->primary_keys )
+ )
+ ) );
+ return $result;
+ }
+
+ if ( $_POST['intent'] == 'pull' ) {
+ $result = $this->end_ajax( $this->row_tracker . ',' . serialize( $this->primary_keys ) );
+ return $result;
+ }
+
+ $chunk_gzipped = '0';
+ if ( isset( $_POST['gzip'] ) && $_POST['gzip'] == '1' && $this->gzip() ) {
+ $this->current_chunk = gzcompress( $this->current_chunk );
+ $chunk_gzipped = '1';
+ }
+
+ $data = array(
+ 'action' => 'wpmdb_process_chunk',
+ 'table' => $_POST['table'],
+ 'chunk_gzipped' => $chunk_gzipped,
+ 'chunk' => $this->current_chunk // NEEDS TO BE the last element in this array because of adding it back into the array in ajax_process_chunk()
+ );
+
+ $data['sig'] = $this->create_signature( $data, $_POST['key'] );
+
+ $ajax_url = trailingslashit( $this->remote_url ) . 'wp-admin/admin-ajax.php';
+ $response = $this->remote_post( $ajax_url, $data, __FUNCTION__ );
+ ob_start();
+ $this->display_errors();
+ $response = ob_get_clean();
+ $response .= trim( $response );
+
+ if ( ! empty( $response ) ) {
+ $result = $this->end_ajax( $response );
+ return $result;
+ }
+
+ $result = $this->end_ajax( json_encode(
+ array(
+ 'current_row' => $this->row_tracker,
+ 'primary_keys' => serialize( $this->primary_keys )
+ )
+ ) );
+ return $result;
+ }
+
+ /**
+ * Add backquotes to tables and db-names in
+ * SQL queries. Taken from phpMyAdmin.
+ */
+ function backquote( $a_name ) {
+ if ( !empty( $a_name ) && $a_name != '*' ) {
+ if ( is_array( $a_name ) ) {
+ $result = array();
+ reset( $a_name );
+ while ( list( $key, $val ) = each( $a_name ) )
+ $result[$key] = '`' . $val . '`';
+ return $result;
+ } else {
+ return '`' . $a_name . '`';
+ }
+ } else {
+ return $a_name;
+ }
+ }
+
+ /**
+ * Better addslashes for SQL queries.
+ * Taken from phpMyAdmin.
+ */
+ function sql_addslashes( $a_string = '', $is_like = false ) {
+ if ( $is_like ) {
+ $a_string = str_replace( '\\', '\\\\\\\\', $a_string );
+ } else {
+ $a_string = str_replace( '\\', '\\\\', $a_string );
+ }
+
+ return str_replace( '\'', '\\\'', $a_string );
+ }
+
+ function network_admin_menu() {
+ $title = ( $this->is_pro ) ? __( 'Migrate DB Pro', 'wp-migrate-db' ) : __( 'Migrate DB', 'wp-migrate-db' );
+ $hook_suffix = add_submenu_page( 'settings.php', $title, $title, 'manage_network_options', $this->core_slug, array( $this, 'options_page' ) );
+ $this->after_admin_menu( $hook_suffix );
+ }
+
+ function admin_menu() {
+ $title = ( $this->is_pro ) ? __( 'Migrate DB Pro', 'wp-migrate-db' ) : __( 'Migrate DB', 'wp-migrate-db' );
+ $hook_suffix = add_management_page( $title, $title, 'export', $this->core_slug, array( $this, 'options_page' ) );
+ $this->after_admin_menu( $hook_suffix );
+ }
+
+ function after_admin_menu( $hook_suffix ) {
+ add_action( 'admin_head-' . $hook_suffix, array( $this, 'admin_head_connection_info' ) );
+ add_action( 'load-' . $hook_suffix , array( $this, 'load_assets' ) );
+
+ // Remove licence from the database if constant is set
+ if ( $this->is_licence_constant() && !empty( $this->settings['licence'] ) ) {
+ $this->settings['licence'] = '';
+ update_option( 'wpmdb_settings', $this->settings );
+ }
+ }
+
+ function admin_body_class( $classes ) {
+ if ( !$classes ) {
+ $classes = array();
+ } else {
+ $classes = explode( ' ', $classes );
+ }
+
+ $version_class = 'wpmdb-not-pro';
+ if ( true == $this->is_pro ) {
+ $version_class = 'wpmdb-pro';
+ }
+
+ $classes[] = $version_class;
+
+ // Recommended way to target WP 3.8+
+ // http://make.wordpress.org/ui/2013/11/19/targeting-the-new-dashboard-design-in-a-post-mp6-world/
+ if ( version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>' ) ) {
+ if ( !in_array( 'mp6', $classes ) ) {
+ $classes[] = 'mp6';
+ }
+ }
+
+ return implode( ' ', $classes );
+ }
+
+ function load_assets() {
+ if ( ! empty( $_GET['download'] ) ) {
+ $this->download_file();
+ }
+
+ if ( isset( $_GET['wpmdb-remove-licence'] ) && wp_verify_nonce( $_GET['nonce'], 'wpmdb-remove-licence' ) ) {
+ $this->settings['licence'] = '';
+ update_option( 'wpmdb_settings', $this->settings );
+ // delete these transients as they contain information only valid for authenticated licence holders
+ delete_site_transient( 'update_plugins' );
+ delete_site_transient( 'wpmdb_upgrade_data' );
+ delete_site_transient( 'wpmdb_licence_response' );
+ // redirecting here because we don't want to keep the query string in the web browsers address bar
+ wp_redirect( network_admin_url( $this->plugin_base . '#settings' ) );
+ exit;
+ }
+
+ if ( isset( $_GET['wpmdb-disable-ssl'] ) && wp_verify_nonce( $_GET['nonce'], 'wpmdb-disable-ssl' ) ) {
+ set_site_transient( 'wpmdb_temporarily_disable_ssl', '1', 60 * 60 * 24 * 30 ); // 30 days
+ $hash = ( isset( $_GET['hash'] ) ) ? '#' . sanitize_title( $_GET['hash'] ) : '';
+ // delete the licence transient as we want to attempt to fetch the licence details again
+ delete_site_transient( 'wpmdb_licence_response' );
+ // redirecting here because we don't want to keep the query string in the web browsers address bar
+ wp_redirect( network_admin_url( $this->plugin_base . $hash ) );
+ exit;
+ }
+
+ if ( isset( $_GET['wpmdb-check-licence'] ) && wp_verify_nonce( $_GET['nonce'], 'wpmdb-check-licence' ) ) {
+ $hash = ( isset( $_GET['hash'] ) ) ? '#' . sanitize_title( $_GET['hash'] ) : '';
+ // delete the licence transient as we want to attempt to fetch the licence details again
+ delete_site_transient( 'wpmdb_licence_response' );
+ // redirecting here because we don't want to keep the query string in the web browsers address bar
+ wp_redirect( network_admin_url( $this->plugin_base . $hash ) );
+ exit;
+ }
+
+ // add our custom CSS classes to <body>
+ add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
+
+ $plugins_url = trailingslashit( plugins_url() ) . trailingslashit( $this->plugin_folder_name );
+
+ $version = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? time() : $this->plugin_version;
+ $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
+
+ $src = $plugins_url . 'asset/css/styles.css';
+ wp_enqueue_style( 'wp-migrate-db-pro-styles', $src, array(), $version );
+
+ $src = $plugins_url . 'asset/js/common.js';
+ wp_enqueue_script( 'wp-migrate-db-pro-common', $src, NULL, $version, true );
+
+ $src = $plugins_url . 'asset/js/hook.js';
+ wp_enqueue_script( 'wp-migrate-db-pro-hook', $src, NULL, $version, true );
+
+ do_action( 'wpmdb_load_assets' );
+
+
+
+ $src = $plugins_url . "asset/js/script$min.js";
+ wp_enqueue_script( 'wp-migrate-db-pro-script', $src, array( 'jquery' ), $version, true );
+
+ wp_localize_script( 'wp-migrate-db-pro-script', 'wpmdb_i10n', array(
+ 'max_request_size_problem' => __( "A problem occurred when trying to change the maximum request size, please try again.", 'wp-migrate-db' ),
+ 'license_check_problem' => __( "A problem occurred when trying to check the license, please try again.", 'wp-migrate-db' ),
+ 'establishing_remote_connection' => __( "Establishing connection to remote server, please wait", 'wp-migrate-db' ),
+ 'connection_local_server_problem' => __( "A problem occurred when attempting to connect to the local server, please check the details and try again.", 'wp-migrate-db' ),
+ 'enter_license_key' => __( "Please enter your license key.", 'wp-migrate-db' ),
+ 'register_license_problem' => __( "A problem occurred when trying to register the license, please try again.", 'wp-migrate-db' ),
+ 'license_registered' => __( "Your license has been activated. You will now receive automatic updates and access to email support.", 'wp-migrate-db' ),
+ 'fetching_license' => __( "Fetching license details, please wait...", 'wp-migrate-db' ),
+ 'clear_log_problem' => __( "An error occurred when trying to clear the debug log. Please contact support. (#132)", 'wp-migrate-db' ),
+ 'update_log_problem' => __( "An error occurred when trying to update the debug log. Please contact support. (#133)", 'wp-migrate-db' ),
+ 'migrate_db_save' => __( "Migrate DB & Save", 'wp-migrate-db' ),
+ 'migrate_db' => __( "Migrate DB", 'wp-migrate-db' ),
+ 'please_select_one_table' => __( "Please select at least one table to migrate.", 'wp-migrate-db' ),
+ 'enter_name_for_profile' => __( "Please enter a name for your migration profile.", 'wp-migrate-db' ),
+ 'save_profile_problem' => __( "An error occurred when attempting to save the migration profile. Please see the Help tab for details on how to request support. (#118)", 'wp-migrate-db' ),
+ 'exporting_complete' => __( "Exporting complete", 'wp-migrate-db' ),
+ 'exporting_please_wait' => __( "Exporting, please wait...", 'wp-migrate-db' ),
+ 'please_wait' => __( "please wait...", 'wp-migrate-db' ),
+ 'complete' => __( "complete", 'wp-migrate-db' ),
+ 'migration_failed' => __( "Migration failed", 'wp-migrate-db' ),
+ 'backing_up' => __( "Backing up", 'wp-migrate-db' ),
+ 'migrating' => __( "Migrating", 'wp-migrate-db' ),
+ 'status' => __( "Status", 'wp-migrate-db' ),
+ 'response' => __( "Response", 'wp-migrate-db' ),
+ 'table_process_problem' => __( "A problem occurred when attempting to process the following table (#113)", 'wp-migrate-db' ),
+ 'table_process_problem_empty_response' => __( "A problem occurred when processing the following table. We were expecting a response in JSON format but instead received an empty response.", 'wp-migrate-db' ),
+ 'completed_with_some_errors' => __( "Migration completed with some errors", 'wp-migrate-db' ),
+ 'completed_dump_located_at' => __( "Migration complete, your backup is located at:", 'wp-migrate-db' ),
+ 'finalize_tables_problem' => __( "A problem occurred when finalizing the backup. (#132)", 'wp-migrate-db' ),
+ 'saved' => __( "Saved", 'wp-migrate-db' ),
+ 'reset_api_key' => __( "Any sites setup to use the current API key will no longer be able to connect. You will need to update those sites with the newly generated API key. Do you wish to continue?", 'wp-migrate-db' ),
+ 'reset_api_key_problem' => __( "An error occurred when trying to generate the API key. Please see the Help tab for details on how to request support. (#105)", 'wp-migrate-db' ),
+ 'remove_profile' => __( "You are removing the following migration profile. This cannot be undone. Do you wish to continue?", 'wp-migrate-db' ),
+ 'remove_profile_problem' => __( "An error occurred when trying to delete the profile. Please see the Help tab for details on how to request support. (#106)", 'wp-migrate-db' ),
+ 'remove_profile_not_found' => __( "The selected migration profile could not be deleted because it was not found.\nPlease refresh this page to see an accurate list of the currently available migration profiles.", 'wp-migrate-db' ),
+ 'change_connection_info' => __( "If you change the connection details, you will lose any replaces and table selections you have made below. Do you wish to continue?", 'wp-migrate-db' ),
+ 'enter_connection_info' => __( "Please enter the connection information above to continue.", 'wp-migrate-db' ),
+ 'save_settings_problem' => __( "An error occurred when trying to save the settings. Please try again. If the problem persists, please see the Help tab for details on how to request support. (#108)", 'wp-migrate-db' ),
+ 'connection_info_missing' => __( "The connection information appears to be missing, please enter it to continue.", 'wp-migrate-db' ),
+ 'connection_info_incorrect' => __( "The connection information appears to be incorrect, it should consist of two lines. The first being the remote server's URL and the second being the secret key.", 'wp-migrate-db' ),
+ 'connection_info_url_invalid' => __( "The URL on the first line appears to be invalid, please check it and try again.", 'wp-migrate-db' ),
+ 'connection_info_key_invalid' => __( "The secret key on the second line appears to be invalid. It should be a 32 character string that consists of letters, numbers and special characters only.", 'wp-migrate-db' ),
+ 'connection_info_local_url' => __( "It appears you've entered the URL for this website, you need to provide the URL of the remote website instead.", 'wp-migrate-db' ),
+ 'connection_info_local_key' => __( "It appears you've entered the secret key for this website, you need to provide the secret key for the remote website instead.", 'wp-migrate-db' ),
+ 'time_elapsed' => __( "Time Elapsed:", 'wp-migrate-db' ),
+ 'pause' => __( "Pause", 'wp-migrate-db' ),
+ 'migration_paused' => __( "Migration Paused", 'wp-migrate-db' ),
+ 'resume' => __( "Resume", 'wp-migrate-db' ),
+ 'completing_current_request' => __( "Completing current request", 'wp-migrate-db' ),
+ 'cancelling_migration' => __( "Cancelling migration", 'wp-migrate-db' ),
+ 'paused' => __( "Paused", 'wp-migrate-db' ),
+ 'removing_local_sql' => __( "Removing the local MySQL export file", 'wp-migrate-db' ),
+ 'removing_local_backup' => __( "Removing the local backup MySQL export file", 'wp-migrate-db' ),
+ 'removing_local_temp_tables' => __( "Removing the local temporary tables", 'wp-migrate-db' ),
+ 'removing_remote_sql' => __( "Removing the remote backup MySQL export file", 'wp-migrate-db' ),
+ 'removing_remote_temp_tables' => __( "Removing the remote temporary tables", 'wp-migrate-db' ),
+ 'migration_cancellation_failed' => __( "Migration cancellation failed", 'wp-migrate-db' ),
+ 'manually_remove_temp_files' => __( "A problem occurred while cancelling the migration, you may have to manually delete some temporary files / tables.", 'wp-migrate-db' ),
+ 'migration_cancelled' => __( "Migration cancelled", 'wp-migrate-db' ),
+ 'migration_complete' => __( "Migration complete", 'wp-migrate-db' ),
+ 'finalizing_migration' => __( "Finalizing migration", 'wp-migrate-db' ),
+ 'blacklist_problem' => __( "A problem occurred when trying to add plugins to backlist.", 'wp-migrate-db' ),
+ 'mu_plugin_confirmation' => __( "If confirmed we will install an additional WordPress 'Must Use' plugin. This plugin will allow us to control which plugins are loaded during WP Migrate DB Pro specific operations. Do you wish to continue?", 'wp-migrate-db' ),
+ 'plugin_compatibility_settings_problem' => __( "A problem occurred when trying to change the plugin compatibility setting.", 'wp-migrate-db' ),
+ 'sure' => __( "Sure?", 'wp-migrate-db' ),
+ 'pull_migration_label_migrating' => __( 'Pulling from %s, please wait...', 'wp-migrate-db' ),
+ 'pull_migration_label_completed' => __( 'Pulling from %s complete', 'wp-migrate-db' ),
+ 'push_migration_label_migrating' => __( 'Pushing to %s, please wait...', 'wp-migrate-db' ),
+ 'push_migration_label_completed' => __( 'Pushing to %s complete', 'wp-migrate-db' ),
+ ) );
+
+ wp_enqueue_script( 'jquery' );
+ wp_enqueue_script( 'jquery-ui-core' );
+ wp_enqueue_script( 'jquery-ui-slider' );
+ wp_enqueue_script( 'jquery-ui-sortable' );
+ }
+
+ function download_file() {
+ // dont need to check for user permissions as our 'add_management_page' already takes care of this
+ $this->set_time_limit();
+
+ $dump_name = $this->format_dump_name( $_GET['download'] );
+
+ if ( isset( $_GET['gzip'] ) ) {
+ $dump_name .= '.gz';
+ }
+
+ $diskfile = $this->get_upload_info( 'path' ) . DS . $dump_name;
+ $filename = basename( $diskfile );
+ $last_dash = strrpos( $filename, '-' );
+ $salt = substr( $filename, $last_dash, 6 );
+ $filename_no_salt = str_replace( $salt, '', $filename );
+
+ if ( file_exists( $diskfile ) ) {
+ header( 'Content-Description: File Transfer' );
+ header( 'Content-Type: application/octet-stream' );
+ header( 'Content-Length: ' . filesize( $diskfile ) );
+ header( 'Content-Disposition: attachment; filename=' . $filename_no_salt );
+ $success = readfile( $diskfile );
+ unlink( $diskfile );
+ exit;
+ } else {
+ wp_die( __( 'Could not find the file to download:', 'wp-migrate-db' ) . '<br />' . $diskfile );
+ }
+ }
+
+ function admin_head_connection_info() {
+ global $table_prefix;
+
+ $nonces = array(
+ 'update_max_request_size' => wp_create_nonce( 'update-max-request-size' ),
+ 'check_licence' => wp_create_nonce( 'check-licence' ),
+ 'verify_connection_to_remote_site' => wp_create_nonce( 'verify-connection-to-remote-site' ),
+ 'activate_licence' => wp_create_nonce( 'activate-licence' ),
+ 'clear_log' => wp_create_nonce( 'clear-log' ),
+ 'get_log' => wp_create_nonce( 'get-log' ),
+ 'save_profile' => wp_create_nonce( 'save-profile' ),
+ 'initiate_migration' => wp_create_nonce( 'initiate-migration' ),
+ 'migrate_table' => wp_create_nonce( 'migrate-table' ),
+ 'finalize_migration' => wp_create_nonce( 'finalize-migration' ),
+ 'reset_api_key' => wp_create_nonce( 'reset-api-key' ),
+ 'delete_migration_profile' => wp_create_nonce( 'delete-migration-profile' ),
+ 'save_setting' => wp_create_nonce( 'save-setting' ),
+ );
+
+ $nonces = apply_filters( 'wpmdb_nonces', $nonces ); ?>
+
+ <script type='text/javascript'>
+ var wpmdb_connection_info = <?php echo json_encode( array( site_url( '', 'https' ), $this->settings['key'] ) ); ?>;
+ var wpmdb_this_url = '<?php echo addslashes( home_url() ) ?>';
+ var wpmdb_this_path = '<?php echo addslashes( $this->absolute_root_file_path ); ?>';
+ var wpmdb_this_domain = '<?php echo $this->get_domain_current_site(); ?>';
+ var wpmdb_this_tables = <?php echo json_encode( $this->get_tables() ); ?>;
+ var wpmdb_this_prefixed_tables = <?php echo json_encode( $this->get_tables( 'prefix' ) ); ?>;
+ var wpmdb_this_table_sizes = <?php echo json_encode( $this->get_table_sizes() ); ?>;
+ var wpmdb_this_table_rows = <?php echo json_encode( $this->get_table_row_count() ); ?>;
+ var wpmdb_this_upload_url = '<?php echo addslashes( trailingslashit( $this->get_upload_info( 'url' ) ) ); ?>';
+ var wpmdb_this_upload_dir_long = '<?php echo addslashes( trailingslashit( $this->get_upload_info( 'path' ) ) ); ?>';
+ var wpmdb_this_website_name = '<?php echo sanitize_title_with_dashes( DB_NAME ); ?>';
+ var wpmdb_this_download_url = '<?php echo network_admin_url( $this->plugin_base . '&download=' ); ?>';
+ var wpmdb_this_prefix = '<?php echo $table_prefix; ?>';
+ var wpmdb_is_multisite = <?php echo is_multisite() ? 'true' : 'false'; ?>;
+ var wpmdb_openssl_available = <?php echo $this->open_ssl_enabled() ? 'true' : 'false'; ?>;
+ var wpmdb_plugin_version = '<?php echo $this->plugin_version; ?>';
+ var wpmdb_max_request = '<?php echo $this->settings['max_request'] ?>';
+ var wpmdb_bottleneck = '<?php echo $this->get_bottleneck( 'max' ); ?>';
+ var wpmdb_this_uploads_dir = '<?php echo addslashes( $this->get_short_uploads_dir() ); ?>';
+ var wpmdb_has_licence = '<?php echo $this->get_licence_key() == '' ? '0' : '1'; ?>';
+ var wpmdb_write_permission = <?php echo is_writeable( $this->get_upload_info( 'path' ) ) ? 'true' : 'false'; ?>;
+ var wpmdb_nonces = <?php echo json_encode( $nonces ); ?>;
+ var wpmdb_valid_licence = '<?php echo ( $this->is_valid_licence() ) ? '1' : '0'; ?>';
+ var wpmdb_profile = '<?php echo isset( $_GET['wpmdb-profile'] ) ? $_GET['wpmdb-profile'] : '-1'; ?>';
+ var wpmdb_is_pro = <?php echo ( $this->is_pro ) ? 'true' : 'false' ?>;
+ <?php do_action( 'wpmdb_js_variables' ); ?>
+ </script>
+ <?php
+ }
+
+ function maybe_update_profile( $profile, $profile_id ) {
+ $profile_changed = false;
+
+ if ( isset( $profile['exclude_revisions'] ) ) {
+ unset( $profile['exclude_revisions'] );
+ $profile['select_post_types'] = array( 'revision' );
+ $profile_changed = true;
+ }
+
+ if ( isset( $profile['post_type_migrate_option'] ) && 'migrate_select_post_types' == $profile['post_type_migrate_option'] && 'pull' != $profile['action'] ) {
+ unset( $profile['post_type_migrate_option'] );
+ $profile['exclude_post_types'] = '1';
+ $all_post_types = $this->get_post_types();
+ $profile['select_post_types'] = array_diff( $all_post_types, $profile['select_post_types'] );
+ $profile_changed = true;
+ }
+
+ if ( $profile_changed ) {
+ $this->settings['profiles'][$profile_id] = $profile;
+ update_option( 'wpmdb_settings', $this->settings );
+ }
+
+ return $profile;
+ }
+
+ function get_path_from_url( $url ) {
+ $parts = parse_url( $url );
+ return ( ! empty( $parts['path'] ) ) ? trailingslashit( $parts['path'] ) : '/';
+ }
+
+ function get_path_current_site() {
+ if ( ! is_multisite() ) {
+ return '';
+ }
+
+ $current_site = get_current_site();
+ return $current_site->path;
+ }
+
+ function get_domain_current_site() {
+ if ( ! is_multisite() ) {
+ return '';
+ }
+
+ $current_site = get_current_site();
+ return $current_site->domain;
+ }
+
+ function return_bytes( $val ) {
+ if ( is_numeric( $val ) ) {
+ return $val;
+ }
+
+ if ( empty( $val ) ) {
+ return false;
+ }
+
+ $val = trim( $val );
+ $last = strtolower( $val[strlen( $val )-1] );
+
+ switch ( $last ) {
+ // The 'G' modifier is available since PHP 5.1.0
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ break;
+ default :
+ $val = false;
+ break;
+ }
+
+ return $val;
+ }
+
+ function maybe_checked( $option ) {
+ echo ( isset( $option ) && $option == '1' ) ? ' checked="checked"' : '';
+ }
+
+ function ajax_cancel_migration() {
+ $this->form_data = $this->parse_migration_form_data( $_POST['form_data'] );
+
+ switch ( $_POST['intent'] ) {
+ case 'savefile' :
+ $this->delete_export_file( $_POST['dump_filename'], false );
+ break;
+ case 'push' :
+ $data = $_POST;
+ $data['action'] = 'wpmdb_process_push_migration_cancellation';
+ $data['temp_prefix'] = $this->temp_prefix;
+ $ajax_url = trailingslashit( $data['url'] ) . 'wp-admin/admin-ajax.php';
+ $data['sig'] = $this->create_signature( $data, $data['key'] );
+
+ $response = $this->remote_post( $ajax_url, $data, __FUNCTION__ );
+ $this->display_errors();
+
+ echo trim( $response );
+ break;
+ case 'pull' :
+ if ( $_POST['stage'] == 'backup' ) {
+ $this->delete_export_file( $_POST['dump_filename'], true );
+ } else {
+ $this->delete_temporary_tables( $_POST['temp_prefix'] );
+ }
+ break;
+ default:
+ break;
+ }
+
+ exit;
+ }
+
+ function delete_export_file( $filename, $is_backup ) {
+ $dump_file = $this->format_dump_name( $filename );
+
+ if ( true == $is_backup ) {
+ $dump_file = preg_replace( '/.gz$/', '', $dump_file );
+ }
+
+ $dump_file = $this->get_upload_info( 'path' ) . DS . $dump_file;
+
+ if ( empty( $dump_file ) || false == file_exists( $dump_file ) ) {
+ _e( 'MySQL export file not found.', 'wp-migrate-db' );
+ exit;
+ }
+
+ if ( false === @unlink( $dump_file ) ) {
+ e( 'Could not delete the MySQL export file.', 'wp-migrate-db' );
+ exit;
+ }
+ }
+
+ function empty_current_chunk() {
+ $this->current_chunk = '';
+ }
+
+ function template_compatibility() {
+ $args = array(
+ 'plugin_compatibility_checked' => ( isset( $GLOBALS['wpmdb_compatibility'] ) ? ' checked="checked"' : '' ),
+ );
+ $this->template( 'compatibility', 'common', $args );
+ }
+
+ function template_max_request_size() {
+ $this->template( 'max-request-size', 'common' );
+ }
+
+ function template_debug_info() {
+ $this->template( 'debug-info', 'common' );
+ }
+
+ function template_exclude_post_revisions( $loaded_profile ) {
+ $args = array(
+ 'loaded_profile' => $loaded_profile,
+ );
+ $this->template( 'exclude-post-revisions', 'wpmdb', $args );
+ }
+
+ function template_wordpress_org_support() {
+ $this->template( 'wordpress-org-support', 'wpmdb' );
+ }
+
+ function template_progress_upgrade() {
+ $this->template( 'progress-upgrade', 'wpmdb' );
+ }
+
+ function template_sidebar() {
+ $this->template( 'sidebar', 'wpmdb' );
+ }
+
+ function template_part( $methods, $args = false ) {
+ $methods = array_diff( $methods, $this->unhook_templates );
+
+ foreach ( $methods as $method ) {
+ $method_name = 'template_' . $method;
+
+ if ( method_exists( $this, $method_name ) ) {
+ call_user_func( array( $this, $method_name ), $args );
+ }
+ }
+
+ }
+
+ function plugin_tabs() {
+ echo implode( '', $this->plugin_tabs );
+ }
+
+ function get_plugin_title() {
+ return __( 'Migrate DB', 'wp-migrate-db' );
+ }
+
+ function deactivate_other_instances( $plugin ) {
+ if ( ! in_array( basename( $plugin ), array( 'wp-migrate-db-pro.php', 'wp-migrate-db.php' ) ) ) {
+ return;
+ }
+
+ $plugin_to_deactivate = 'wp-migrate-db.php';
+ $deactivated_notice_id = '1';
+ if ( $plugin_to_deactivate == basename( $plugin ) ) {
+ $plugin_to_deactivate = 'wp-migrate-db-pro.php';
+ $deactivated_notice_id = '2';
+ }
+
+ if ( is_multisite() ) {
+ $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
+ $active_plugins = array_keys( $active_plugins );
+ } else {
+ $active_plugins = (array) get_option( 'active_plugins', array() );
+ }
+
+ foreach ( $active_plugins as $basename ) {
+ if ( false !== strpos( $basename, $plugin_to_deactivate ) ) {
+ set_transient( 'wp_migrate_db_deactivated_notice_id', $deactivated_notice_id, 1 * HOUR_IN_SECONDS );
+ deactivate_plugins( $basename );
+ return;
+ }
+ }
+ }
+
+ function plugin_deactivated_notice() {
+ if ( false !== ( $deactivated_notice_id = get_transient( 'wp_migrate_db_deactivated_notice_id' ) ) ) {
+ if ( '1' === $deactivated_notice_id ) {
+ $message = __( "WP Migrate DB and WP Migrate DB Pro cannot both be active. We've automatically deactivated WP Migrate DB.", 'wp-migrate-db' );
+ } else {
+ $message = __( "WP Migrate DB and WP Migrate DB Pro cannot both be active. We've automatically deactivated WP Migrate DB Pro.", 'wp-migrate-db' );
+ } ?>
+
+ <div class="updated" style="border-left: 4px solid #ffba00;">
+ <p><?php echo $message; ?></p>
+ </div> <?php
+
+ delete_transient( 'wp_migrate_db_deactivated_notice_id' );
+ }
+ }
+
+}
--- /dev/null
+<?php
+/*
+Plugin Name: WP Migrate DB Pro Compatibility
+Plugin URI: http://deliciousbrains.com/wp-migrate-db-pro/
+Description: Prevents 3rd party plugins from being loaded during WP Migrate DB Pro specific operations
+Author: Delicious Brains
+Version: 1.0
+Author URI: http://deliciousbrains.com
+*/
+
+$GLOBALS['wpmdb_compatibility'] = true;
+
+
+/**
+* remove blog-active plugins
+* @param array $plugins numerically keyed array of plugin names
+* @return array
+*/
+function wpmdbc_exclude_plugins( $plugins ) {
+ if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX || !isset( $_POST['action'] ) || false === strpos( $_POST['action'], 'wpmdb' ) ) return $plugins;
+ $wpmdb_settings = get_option( 'wpmdb_settings' );
+ if ( !empty( $wpmdb_settings['blacklist_plugins'] ) ) {
+ $blacklist_plugins = array_flip( $wpmdb_settings['blacklist_plugins'] );
+ }
+ foreach( $plugins as $key => $plugin ) {
+ if ( false !== strpos( $plugin, 'wp-migrate-db-pro' ) || !isset( $blacklist_plugins[$plugin] ) ) continue;
+ unset( $plugins[$key] );
+ }
+ return $plugins;
+}
+add_filter( 'option_active_plugins', 'wpmdbc_exclude_plugins' );
+
+
+/**
+* remove network-active plugins
+* @param array $plugins array of plugins keyed by name (name=>timestamp pairs)
+* @return array
+*/
+function wpmdbc_exclude_site_plugins( $plugins ) {
+ if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX || !isset( $_POST['action'] ) || false === strpos( $_POST['action'], 'wpmdb' ) ) return $plugins;
+ $wpmdb_settings = get_option( 'wpmdb_settings' );
+ if ( !empty( $wpmdb_settings['blacklist_plugins'] ) ) {
+ $blacklist_plugins = array_flip( $wpmdb_settings['blacklist_plugins'] );
+ }
+ foreach( array_keys( $plugins ) as $plugin ) {
+ if ( false !== strpos( $plugin, 'wp-migrate-db-pro' ) || !isset( $blacklist_plugins[$plugin] ) ) continue;
+ unset( $plugins[$plugin] );
+ }
+ return $plugins;
+}
+add_filter( 'site_option_active_sitewide_plugins', 'wpmdbc_exclude_site_plugins' );
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: WP Migrate DB Pro\n"
+"POT-Creation-Date: 2014-08-13 12:59+1000\n"
+"PO-Revision-Date: 2014-08-13 13:00+1000\n"
+"Last-Translator: Delicious Brains <nom@deliciousbrains.com>\n"
+"Language-Team: Delicious Brains <nom@deliciousbrains.com>\n"
+"Language: en\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.6.7\n"
+"X-Poedit-Basepath: ..\n"
+"X-Poedit-SourceCharset: UTF-8\n"
+"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
+"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
+"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Poedit-SearchPath-0: .\n"
+
+#: class/wpmdb-base.php:71
+msgid ""
+"Invalid content verification signature, please verify the connection "
+"information on the remote site and try again."
+msgstr ""
+
+#: class/wpmdb-base.php:168
+#, php-format
+msgid ""
+"The connection to the remote server has timed out, no changes have been "
+"committed. (#134 - scope: %s)"
+msgstr ""
+
+#: class/wpmdb-base.php:170
+#, php-format
+msgid "We could not find: %s. Are you sure this is the correct URL?"
+msgstr ""
+
+#: class/wpmdb-base.php:175
+msgid ""
+"It appears that you might be trying to pull from a local environment. This "
+"will not work if <u>this</u> website happens to be located on a remote "
+"server, it would be impossible for this server to contact your local "
+"environment."
+msgstr ""
+
+#: class/wpmdb-base.php:177
+msgid ""
+"It appears that you might be trying to push to a local environment. This "
+"will not work if <u>this</u> website happens to be located on a remote "
+"server, it would be impossible for this server to contact your local "
+"environment."
+msgstr ""
+
+#: class/wpmdb-base.php:181
+#, php-format
+msgid ""
+"The connection failed, an unexpected error occurred, please contact support. "
+"(#121 - scope: %s)"
+msgstr ""
+
+#: class/wpmdb-base.php:189
+msgid ""
+"The remote site is protected with Basic Authentication. Please enter the "
+"username and password above to continue. (401 Unauthorized)"
+msgstr ""
+
+#: class/wpmdb-base.php:193
+#, php-format
+msgid ""
+"Unable to connect to the remote server, please check the connection details "
+"- %1$s %2$s (#129 - scope: %3$s)"
+msgstr ""
+
+#: class/wpmdb-base.php:201
+msgid ""
+"There was a problem with the AJAX request, we were expecting a serialized "
+"response, instead we received:<br />"
+msgstr ""
+
+#: class/wpmdb-base.php:208
+#, php-format
+msgid ""
+"WP Migrate DB Pro does not seem to be installed or active on the remote "
+"site. (#131 - scope: %s)"
+msgstr ""
+
+#: class/wpmdb-base.php:368
+#, php-format
+msgid ""
+"<strong>Could not connect to deliciousbrains.com</strong> — You will "
+"not receive update notifications or be able to activate your license until "
+"this is fixed. This issue is often caused by an improperly configured SSL "
+"server (https). We recommend <a href=\"%1$s\" target=\"_blank\">fixing the "
+"SSL configuration on your server</a>, but if you need a quick fix you can:"
+"<p><a href=\"%2$s\" class=\"temporarily-disable-ssl button\">Temporarily "
+"disable SSL for connections to deliciousbrains.com</a></p>"
+msgstr ""
+
+#: class/wpmdb-base.php:392
+msgid "Could not retrieve version details. Please try again."
+msgstr ""
+
+#: class/wpmdb-base.php:422
+msgid "There is a new version of "
+msgstr ""
+
+#: class/wpmdb-base.php:424
+#, php-format
+msgid "View version %s details"
+msgstr ""
+
+#: class/wpmdb-base.php:432 class/wpmdb-base.php:514 class/wpmdb.php:152
+#: class/wpmdb.php:316
+msgid "Settings"
+msgstr ""
+
+#: class/wpmdb-base.php:434
+#, php-format
+msgid ""
+"To update, go to %1$s and enter your license key. If you don't have a "
+"license key, you may <a href=\"%2$s\">purchase one</a>."
+msgstr ""
+
+#: class/wpmdb-base.php:436
+#, php-format
+msgid ""
+"To finish activating %1$s, please go to %2$s and enter your license key. If "
+"you don't have a license key, you may <a href=\"%3$s\">purchase one</a>."
+msgstr ""
+
+#: class/wpmdb-base.php:439 class/wpmdb-base.php:797 class/wpmdb-base.php:800
+#: class/wpmdb-base.php:803 class/wpmdb-base.php:806 class/wpmdbpro.php:532
+msgid "Check my license again"
+msgstr ""
+
+#: class/wpmdb-base.php:482
+#, php-format
+msgid ""
+"Error retrieving download from deliciousbrain.com. Please try again or "
+"download manually from <a href=\"%1$s\">%2$s</a>."
+msgstr ""
+
+#: class/wpmdb-base.php:482
+msgid "My Account"
+msgstr ""
+
+#: class/wpmdb-base.php:515
+#, php-format
+msgid ""
+"To finish activating WP Migrate DB Pro, please go to %1$s and enter your "
+"license key. If you don't have a license key, you may <a href=\"%2$s"
+"\">purchase one</a>."
+msgstr ""
+
+#: class/wpmdb-base.php:742
+msgid "Update Available"
+msgstr ""
+
+#: class/wpmdb-base.php:743
+#, php-format
+msgid ""
+"%1$s %2$s is now available. You currently have %3$s installed. <a href=\"%4$s"
+"\">%5$s</a>"
+msgstr ""
+
+#: class/wpmdb-base.php:743
+msgid "Update Now"
+msgstr ""
+
+#: class/wpmdb-base.php:776
+#, php-format
+msgid ""
+"<strong>Activate Your License</strong> — Please <a href=\"#\" class="
+"\"%s\">enter your license key</a> to enable push and pull."
+msgstr ""
+
+#: class/wpmdb-base.php:793
+#, php-format
+msgid ""
+"<strong>Could not connect to deliciousbrains.com</strong> — You will "
+"not receive update notifications or be able to activate your license until "
+"this is fixed. This issue is often caused by an improperly configured SSL "
+"server (https). We recommend <a href=\"%s\" target=\"_blank\">fixing the SSL "
+"configuration on your server</a>, but if you need a quick fix you can:"
+msgstr ""
+
+#: class/wpmdb-base.php:794
+msgid "Temporarily disable SSL for connections to deliciousbrains.com"
+msgstr ""
+
+#: class/wpmdb-base.php:796
+#, php-format
+msgid ""
+"<strong>Your License Was Cancelled</strong> — Please visit <a href=\"%s"
+"\" target=\"_blank\">My Account</a> to renew or upgrade your license and "
+"enable push and pull."
+msgstr ""
+
+#: class/wpmdb-base.php:799
+#, php-format
+msgid ""
+"<strong>Your License Has Expired</strong> — Please visit <a href=\"%s"
+"\" target=\"_blank\">My Account</a> to purchase a new license and enable "
+"push and pull."
+msgstr ""
+
+#: class/wpmdb-base.php:802
+#, php-format
+msgid ""
+"<strong>No Activations Left</strong> — Please visit <a href=\"%s\" "
+"target=\"_blank\">My Account</a> to upgrade your license or deactivate a "
+"previous activation and enable push and pull."
+msgstr ""
+
+#: class/wpmdb-base.php:805
+#, php-format
+msgid ""
+"<strong>Your License Was Not Found</strong> — Perhaps you made a typo "
+"when defining your WPMDB_LICENCE constant in your wp-config.php? Please "
+"visit <a href=\"%s\" target=\"_blank\">My Account</a> to double check your "
+"license key."
+msgstr ""
+
+#: class/wpmdb-base.php:809
+#, php-format
+msgid ""
+"<strong>An Unexpected Error Occurred</strong> — Please contact us at "
+"<a href=\"%1$s\">%2$s</a> and quote the following:"
+msgstr ""
+
+#: class/wpmdb-base.php:837
+#, php-format
+msgid "Invalid nonce for: %s"
+msgstr ""
+
+#: class/wpmdb-base.php:845
+#, php-format
+msgid "Access denied for: %s"
+msgstr ""
+
+#: class/wpmdb.php:151
+msgid "Migrate"
+msgstr ""
+
+#: class/wpmdb.php:153
+msgid "Help"
+msgstr ""
+
+#: class/wpmdb.php:380
+msgid "ext/mysqli"
+msgstr ""
+
+#: class/wpmdb.php:384
+msgid "WP Memory Limit"
+msgstr ""
+
+#: class/wpmdb.php:709 class/wpmdbpro.php:189
+msgid ""
+"Failed attempting to unserialize the response from the remote server. Please "
+"contact support."
+msgstr ""
+
+#: class/wpmdb.php:1125
+msgid ""
+"Failed to retrieve table structure, please ensure your database is online. "
+"(#125)"
+msgstr ""
+
+#: class/wpmdb.php:1143
+#, php-format
+msgid "Delete any existing table %s"
+msgstr ""
+
+#: class/wpmdb.php:1156
+#, php-format
+msgid "Table structure of table %s"
+msgstr ""
+
+#: class/wpmdb.php:1164
+msgid ""
+"Failed to generate the create table query, please ensure your database is "
+"online. (#126)"
+msgstr ""
+
+#: class/wpmdb.php:1199
+#, php-format
+msgid "Data contents of table %s"
+msgstr ""
+
+#: class/wpmdb.php:1499
+#, php-format
+msgid "End of data contents of table %s"
+msgstr ""
+
+#: class/wpmdb.php:1627
+msgid "WordPress MySQL database migration"
+msgstr ""
+
+#: class/wpmdb.php:1629
+#, php-format
+msgid "Generated: %s"
+msgstr ""
+
+#: class/wpmdb.php:1630
+#, php-format
+msgid "Hostname: %s"
+msgstr ""
+
+#: class/wpmdb.php:1631
+#, php-format
+msgid "Database: %s"
+msgstr ""
+
+#: class/wpmdb.php:1671
+msgid "Failed to write the gzipped SQL data to the file. (#127)"
+msgstr ""
+
+#: class/wpmdb.php:1676
+msgid "Failed to write the SQL data to the file. (#128)"
+msgstr ""
+
+#: class/wpmdb.php:1775 class/wpmdb.php:1781 class/wpmdbpro.php:867
+msgid "Migrate DB Pro"
+msgstr ""
+
+#: class/wpmdb.php:1775 class/wpmdb.php:1781 class/wpmdb.php:1894
+#: class/wpmdb.php:2231
+msgid "Migrate DB"
+msgstr ""
+
+#: class/wpmdb.php:1883
+msgid ""
+"A problem occurred when trying to change the maximum request size, please "
+"try again."
+msgstr ""
+
+#: class/wpmdb.php:1884 class/wpmdbpro.php:533
+msgid "A problem occurred when trying to check the license, please try again."
+msgstr ""
+
+#: class/wpmdb.php:1885
+msgid "Establishing connection to remote server, please wait"
+msgstr ""
+
+#: class/wpmdb.php:1886
+msgid ""
+"A problem occurred when attempting to connect to the local server, please "
+"check the details and try again."
+msgstr ""
+
+#: class/wpmdb.php:1887
+msgid "Please enter your license key."
+msgstr ""
+
+#: class/wpmdb.php:1888
+msgid ""
+"A problem occurred when trying to register the license, please try again."
+msgstr ""
+
+#: class/wpmdb.php:1889
+msgid ""
+"Your license has been activated. You will now receive automatic updates and "
+"access to email support."
+msgstr ""
+
+#: class/wpmdb.php:1890 template/pro/licence-info.php:5
+msgid "Fetching license details, please wait..."
+msgstr ""
+
+#: class/wpmdb.php:1891
+msgid ""
+"An error occurred when trying to clear the debug log. Please contact "
+"support. (#132)"
+msgstr ""
+
+#: class/wpmdb.php:1892
+msgid ""
+"An error occurred when trying to update the debug log. Please contact "
+"support. (#133)"
+msgstr ""
+
+#: class/wpmdb.php:1893
+msgid "Migrate DB & Save"
+msgstr ""
+
+#: class/wpmdb.php:1895
+msgid "Please select at least one table to migrate."
+msgstr ""
+
+#: class/wpmdb.php:1896
+msgid "Please enter a name for your migration profile."
+msgstr ""
+
+#: class/wpmdb.php:1897
+msgid ""
+"An error occurred when attempting to save the migration profile. Please see "
+"the Help tab for details on how to request support. (#118)"
+msgstr ""
+
+#: class/wpmdb.php:1898
+msgid "Exporting complete"
+msgstr ""
+
+#: class/wpmdb.php:1899
+msgid "Exporting, please wait..."
+msgstr ""
+
+#: class/wpmdb.php:1900
+msgid "please wait..."
+msgstr ""
+
+#: class/wpmdb.php:1901
+msgid "complete"
+msgstr ""
+
+#: class/wpmdb.php:1902
+msgid "Migration failed"
+msgstr ""
+
+#: class/wpmdb.php:1903
+msgid "Backing up"
+msgstr ""
+
+#: class/wpmdb.php:1904
+msgid "Migrating"
+msgstr ""
+
+#: class/wpmdb.php:1905
+msgid "Status"
+msgstr ""
+
+#: class/wpmdb.php:1906
+msgid "Response"
+msgstr ""
+
+#: class/wpmdb.php:1907
+msgid ""
+"A problem occurred when attempting to process the following table (#113)"
+msgstr ""
+
+#: class/wpmdb.php:1908
+msgid ""
+"A problem occurred when processing the following table. We were expecting a "
+"response in JSON format but instead received an empty response."
+msgstr ""
+
+#: class/wpmdb.php:1909
+msgid "Migration completed with some errors"
+msgstr ""
+
+#: class/wpmdb.php:1910
+msgid "Migration complete, your backup is located at:"
+msgstr ""
+
+#: class/wpmdb.php:1911
+msgid "A problem occurred when finalizing the backup. (#132)"
+msgstr ""
+
+#: class/wpmdb.php:1912 template/common/compatibility.php:33
+#: template/common/max-request-size.php:10
+msgid "Saved"
+msgstr ""
+
+#: class/wpmdb.php:1913
+msgid ""
+"Any sites setup to use the current API key will no longer be able to "
+"connect. You will need to update those sites with the newly generated API "
+"key. Do you wish to continue?"
+msgstr ""
+
+#: class/wpmdb.php:1914
+msgid ""
+"An error occurred when trying to generate the API key. Please see the Help "
+"tab for details on how to request support. (#105)"
+msgstr ""
+
+#: class/wpmdb.php:1915
+msgid ""
+"You are removing the following migration profile. This cannot be undone. Do "
+"you wish to continue?"
+msgstr ""
+
+#: class/wpmdb.php:1916
+msgid ""
+"An error occurred when trying to delete the profile. Please see the Help tab "
+"for details on how to request support. (#106)"
+msgstr ""
+
+#: class/wpmdb.php:1917
+msgid ""
+"The selected migration profile could not be deleted because it was not "
+"found.\n"
+"Please refresh this page to see an accurate list of the currently available "
+"migration profiles."
+msgstr ""
+
+#: class/wpmdb.php:1918
+msgid ""
+"If you change the connection details, you will lose any replaces and table "
+"selections you have made below. Do you wish to continue?"
+msgstr ""
+
+#: class/wpmdb.php:1919 template/migrate.php:113
+msgid "Please enter the connection information above to continue."
+msgstr ""
+
+#: class/wpmdb.php:1920
+msgid ""
+"An error occurred when trying to save the settings. Please try again. If the "
+"problem persists, please see the Help tab for details on how to request "
+"support. (#108)"
+msgstr ""
+
+#: class/wpmdb.php:1921
+msgid ""
+"The connection information appears to be missing, please enter it to "
+"continue."
+msgstr ""
+
+#: class/wpmdb.php:1922
+msgid ""
+"The connection information appears to be incorrect, it should consist of two "
+"lines. The first being the remote server's URL and the second being the "
+"secret key."
+msgstr ""
+
+#: class/wpmdb.php:1923
+msgid ""
+"The URL on the first line appears to be invalid, please check it and try "
+"again."
+msgstr ""
+
+#: class/wpmdb.php:1924
+msgid ""
+"The secret key on the second line appears to be invalid. It should be a 32 "
+"character string that consists of letters, numbers and special characters "
+"only."
+msgstr ""
+
+#: class/wpmdb.php:1925
+msgid ""
+"It appears you've entered the URL for this website, you need to provide the "
+"URL of the remote website instead."
+msgstr ""
+
+#: class/wpmdb.php:1926
+msgid ""
+"It appears you've entered the secret key for this website, you need to "
+"provide the secret key for the remote website instead."
+msgstr ""
+
+#: class/wpmdb.php:1927 template/migrate-progress.php:8
+msgid "Time Elapsed:"
+msgstr ""
+
+#: class/wpmdb.php:1928 template/migrate-progress.php:19
+msgid "Pause"
+msgstr ""
+
+#: class/wpmdb.php:1929
+msgid "Migration Paused"
+msgstr ""
+
+#: class/wpmdb.php:1930
+msgid "Resume"
+msgstr ""
+
+#: class/wpmdb.php:1931
+msgid "Completing current request"
+msgstr ""
+
+#: class/wpmdb.php:1932
+msgid "Cancelling migration"
+msgstr ""
+
+#: class/wpmdb.php:1933
+msgid "Paused"
+msgstr ""
+
+#: class/wpmdb.php:1934
+msgid "Removing the local MySQL export file"
+msgstr ""
+
+#: class/wpmdb.php:1935
+msgid "Removing the local backup MySQL export file"
+msgstr ""
+
+#: class/wpmdb.php:1936
+msgid "Removing the local temporary tables"
+msgstr ""
+
+#: class/wpmdb.php:1937
+msgid "Removing the remote backup MySQL export file"
+msgstr ""
+
+#: class/wpmdb.php:1938
+msgid "Removing the remote temporary tables"
+msgstr ""
+
+#: class/wpmdb.php:1939
+msgid "Migration cancellation failed"
+msgstr ""
+
+#: class/wpmdb.php:1940
+msgid ""
+"A problem occurred while cancelling the migration, you may have to manually "
+"delete some temporary files / tables."
+msgstr ""
+
+#: class/wpmdb.php:1941
+msgid "Migration cancelled"
+msgstr ""
+
+#: class/wpmdb.php:1942
+msgid "Migration complete"
+msgstr ""
+
+#: class/wpmdb.php:1943
+msgid "Finalizing migration"
+msgstr ""
+
+#: class/wpmdb.php:1944
+msgid "A problem occurred when trying to add plugins to backlist."
+msgstr ""
+
+#: class/wpmdb.php:1945
+msgid ""
+"If confirmed we will install an additional WordPress 'Must Use' plugin. This "
+"plugin will allow us to control which plugins are loaded during WP Migrate "
+"DB Pro specific operations. Do you wish to continue?"
+msgstr ""
+
+#: class/wpmdb.php:1946
+msgid ""
+"A problem occurred when trying to change the plugin compatibility setting."
+msgstr ""
+
+#: class/wpmdb.php:1947
+msgid "Sure?"
+msgstr ""
+
+#: class/wpmdb.php:1948
+#, php-format
+msgid "Pulling from %s, please wait..."
+msgstr ""
+
+#: class/wpmdb.php:1949
+#, php-format
+msgid "Pulling from %s complete"
+msgstr ""
+
+#: class/wpmdb.php:1950
+#, php-format
+msgid "Pushing to %s, please wait..."
+msgstr ""
+
+#: class/wpmdb.php:1951
+#, php-format
+msgid "Pushing to %s complete"
+msgstr ""
+
+#: class/wpmdb.php:1985
+msgid "Could not find the file to download:"
+msgstr ""
+
+#: class/wpmdb.php:2165
+msgid "MySQL export file not found."
+msgstr ""
+
+#: class/wpmdb.php:2265
+msgid ""
+"WP Migrate DB and WP Migrate DB Pro cannot both be active. We've "
+"automatically deactivated WP Migrate DB."
+msgstr ""
+
+#: class/wpmdb.php:2267
+msgid ""
+"WP Migrate DB and WP Migrate DB Pro cannot both be active. We've "
+"automatically deactivated WP Migrate DB Pro."
+msgstr ""
+
+#: class/wpmdbpro-addon.php:60
+#, php-format
+msgid ""
+"The version of %1$s you have installed, requires version %2$s of WP Migrate "
+"DB Pro. You currently have %3$s installed. <strong><a href=\"%4$s\">Update "
+"Now</a></strong>"
+msgstr ""
+
+#: class/wpmdbpro.php:54
+msgid "Addons"
+msgstr ""
+
+#: class/wpmdbpro.php:117
+msgid "Feature Walkthrough"
+msgstr ""
+
+#: class/wpmdbpro.php:118
+msgid ""
+"A brief walkthrough of the WP Migrate DB plugin showing all of the different "
+"options and explaining them."
+msgstr ""
+
+#: class/wpmdbpro.php:121
+msgid "Pulling Live Data Into Your Local Development Environment"
+msgstr ""
+
+#: class/wpmdbpro.php:122
+msgid ""
+"This screencast demonstrates how you can pull data from a remote, live "
+"WordPress install and update the data in your local development environment."
+msgstr ""
+
+#: class/wpmdbpro.php:125
+msgid "Pushing Local Development Data to a Staging Environment"
+msgstr ""
+
+#: class/wpmdbpro.php:126
+msgid ""
+"This screencast demonstrates how you can push a local WordPress database "
+"you've been using for development to a staging environment."
+msgstr ""
+
+#: class/wpmdbpro.php:129
+msgid "Media Files Addon Demo"
+msgstr ""
+
+#: class/wpmdbpro.php:130
+msgid ""
+"A short demo of how the Media Files addon allows you to sync up your "
+"WordPress Media Libraries."
+msgstr ""
+
+#: class/wpmdbpro.php:163
+msgid ""
+"Please activate your license before attempting a pull or push migration."
+msgstr ""
+
+#: class/wpmdbpro.php:269
+msgid ""
+"The connection succeeded but the remote site is configured to reject pull "
+"connections. You can change this in the \"settings\" tab on the remote site. "
+"(#132)"
+msgstr ""
+
+#: class/wpmdbpro.php:291 class/wpmdbpro.php:344
+msgid "pull"
+msgstr ""
+
+#: class/wpmdbpro.php:293 class/wpmdbpro.php:346
+msgid "push"
+msgstr ""
+
+#: class/wpmdbpro.php:295
+#, php-format
+msgid ""
+"The connection succeeded but the remote site is configured to reject %s "
+"connections. You can change this in the \"settings\" tab on the remote site. "
+"(#110)"
+msgstr ""
+
+#: class/wpmdbpro.php:334
+msgid "Try again?"
+msgstr ""
+
+#: class/wpmdbpro.php:349
+#, php-format
+msgid ""
+"The connection succeeded but the remote site is configured to reject %s "
+"connections. You can change this in the \"settings\" tab on the remote site. "
+"(#122) <a href=\"#\" class=\"try-again js-action-link\">Try again?</a>"
+msgstr ""
+
+#: class/wpmdbpro.php:437
+msgctxt ""
+"\"Remove\" in this context is used to delete a license, example formatting: "
+"xxxx-xxxx-xxxx Remove"
+msgid "Remove"
+msgstr ""
+
+#: class/wpmdbpro.php:596
+msgid "Addons Unavailable"
+msgstr ""
+
+#: class/wpmdbpro.php:596
+#, php-format
+msgid ""
+"Addons are not included with the Personal license. Visit <a href=\"%s\" "
+"target=\"_blank\">My Account</a> to upgrade in just a few clicks."
+msgstr ""
+
+#: class/wpmdbpro.php:609
+msgid "Installed"
+msgstr ""
+
+#: class/wpmdbpro.php:611
+msgid "Activated"
+msgstr ""
+
+#: class/wpmdbpro.php:614
+msgid "Activate"
+msgstr ""
+
+#: class/wpmdbpro.php:618
+msgid "Install"
+msgstr ""
+
+#: class/wpmdbpro.php:624
+msgid "Download"
+msgstr ""
+
+#: class/wpmdbpro.php:800
+msgid "Could not upload the SQL to the server. (#135)"
+msgstr ""
+
+#: class/wpmdbpro.php:805
+msgid "Could not read the SQL file we uploaded to the server. (#136)"
+msgstr ""
+
+#: class/wpmdbpro.php:821
+msgid ""
+"The connection succeeded but the remote site is configured to reject push "
+"connections. You can change this in the \"settings\" tab on the remote site. "
+"(#133)"
+msgstr ""
+
+#: template/addons.php:7
+msgid "Fetching addon details, please wait..."
+msgstr ""
+
+#: template/addons.php:9 template/pro/licence-info.php:7
+msgid ""
+"We couldn't find your license information. Please switch to the settings tab "
+"and enter your license."
+msgstr ""
+
+#: template/addons.php:10
+msgid "Once completed, you may visit this tab to view the available addons."
+msgstr ""
+
+#: template/common/compatibility.php:4
+msgid ""
+"Improve performance and reliability by not loading the following plugins for "
+"migration requests"
+msgstr ""
+
+#: template/common/compatibility.php:8
+msgid ""
+"Some plugins add a lot of overhead to each request, requiring extra memory "
+"and CPU. And some plugins even interfere with migrations and cause them to "
+"fail. We recommend only loading plugins that affect migration requests, for "
+"example a plugin that hooks into WP Migrate DB."
+msgstr ""
+
+#: template/common/compatibility.php:25 template/pro/backup.php:43
+#: template/pro/exclude-post-types.php:20 template/pro/select-tables.php:37
+msgid "Select All"
+msgstr ""
+
+#: template/common/compatibility.php:27 template/pro/backup.php:45
+#: template/pro/exclude-post-types.php:22 template/pro/select-tables.php:39
+msgid "Deselect All"
+msgstr ""
+
+#: template/common/compatibility.php:29 template/pro/backup.php:47
+#: template/pro/exclude-post-types.php:24 template/pro/select-tables.php:41
+msgid "Invert Selection"
+msgstr ""
+
+#: template/common/compatibility.php:32
+msgid "Save Changes"
+msgstr ""
+
+#: template/common/debug-info.php:2
+msgid "Diagnostic Info & Error Log"
+msgstr ""
+
+#: template/common/debug-info.php:4
+msgid "Clear Error Log"
+msgstr ""
+
+#: template/common/max-request-size.php:3
+msgid "Maximum Request Size"
+msgstr ""
+
+#: template/common/max-request-size.php:6
+#, php-format
+msgid ""
+"We've detected that your server supports requests up to %s, but it's "
+"possible that your server has limitations that we could not detect. To be on "
+"the safe side, we set the default to 1 MB, but you can try throttling it up "
+"to get better performance. If you're getting a 413 error or having trouble "
+"with time outs, try throttling this setting down."
+msgstr ""
+
+#: template/migrate-progress.php:4
+msgid "Please wait while migration is running..."
+msgstr ""
+
+#: template/migrate-progress.php:7
+msgid "Establishing Connection"
+msgstr ""
+
+#: template/migrate-progress.php:20
+msgid "Cancel"
+msgstr ""
+
+#: template/migrate.php:62 template/migrate.php:333
+msgid "Back to select a saved profile"
+msgstr ""
+
+#: template/migrate.php:73
+msgid "Export File"
+msgstr ""
+
+#: template/migrate.php:79
+msgid "Save as file to your computer"
+msgstr ""
+
+#: template/migrate.php:86
+msgid "Compress file with gzip"
+msgstr ""
+
+#: template/migrate.php:96
+msgid "Connection Info - Site URL & Secret Key"
+msgstr ""
+
+#: template/migrate.php:106
+msgid "SSL Disabled"
+msgstr ""
+
+#: template/migrate.php:106
+msgid ""
+"We couldn't connect over SSL but regular http (no SSL) appears to be working "
+"so we've switched to that. If you run a push or pull, your data will be "
+"transmitted unencrypted. Most people are fine with this, but just a heads up."
+msgstr ""
+
+#: template/migrate.php:116
+msgid "Version Mismatch"
+msgstr ""
+
+#: template/migrate.php:116
+#, php-format
+msgid ""
+"We've detected you have version <span class=\"remote-version\"></span> of WP "
+"Migrate DB Pro at <span class=\"remote-location\"></span> but are using %1$s "
+"here. Please go to the <a href=\"%2$s\">Plugins page</a> on both installs "
+"and check for updates."
+msgstr ""
+
+#: template/migrate.php:120
+msgid "Cannot Access Uploads Directory"
+msgstr ""
+
+#: template/migrate.php:122
+msgid ""
+"We require write permissions to the standard WordPress uploads directory. "
+"Without this permission exports are unavailable. Please grant 755 "
+"permissions on the following directory:"
+msgstr ""
+
+#: template/migrate.php:131
+msgid "Find"
+msgstr ""
+
+#: template/migrate.php:132
+msgid "Replace"
+msgstr ""
+
+#: template/migrate.php:135
+msgid ""
+"Doesn't look we have any replaces yet, <a href=\"#\" class=\"js-action-link "
+"add-replace\">add one?</a>"
+msgstr ""
+
+#: template/migrate.php:217
+#, php-format
+msgid ""
+"<strong>New URL Missing</strong> — Please enter the protocol-relative "
+"URL of the remote website in the \"New URL\" field. If you are unsure of "
+"what this URL should be, please consult <a href=\"%s\" target=\"_blank\">our "
+"documentation</a> on find and replace fields."
+msgstr ""
+
+#: template/migrate.php:218
+#, php-format
+msgid ""
+"<strong>New File Path Missing</strong> — Please enter the root file "
+"path of the remote website in the \"New file path\" field. If you are unsure "
+"of what the file path should be, please consult <a href=\"%s\" target="
+"\"_blank\">our documentation</a> on find and replace fields."
+msgstr ""
+
+#: template/migrate.php:227
+msgid "Advanced Options"
+msgstr ""
+
+#: template/migrate.php:236
+msgid "Replace GUIDs"
+msgstr ""
+
+#: template/migrate.php:242
+#, php-format
+msgid ""
+"Although the <a href=\"%s\" target=\"_blank\">WordPress Codex emphasizes</a> "
+"that GUIDs should not be changed, this is limited to sites that are already "
+"live. If the site has never been live, I recommend replacing the GUIDs. For "
+"example, you may be developing a new site locally at dev.somedomain.com and "
+"want to migrate the site live to somedomain.com."
+msgstr ""
+
+#: template/migrate.php:248
+msgid "Exclude spam comments"
+msgstr ""
+
+#: template/migrate.php:254
+msgid ""
+"Do not migrate the 'active_plugins' setting (i.e. which plugins are "
+"activated/deactivated)"
+msgstr ""
+
+#: template/migrate.php:276
+msgid "Save Migration Profile"
+msgstr ""
+
+#: template/migrate.php:276
+msgid "Save the above settings for the next time you do a similiar migration"
+msgstr ""
+
+#: template/migrate.php:295
+msgid "Create new profile"
+msgstr ""
+
+#: template/migrate.php:304 template/migrate.php:314
+msgid "Warning: Different Table Prefixes"
+msgstr ""
+
+#: template/migrate.php:306
+msgid ""
+"Whoa! We've detected that the database table prefix differs between "
+"installations. Clicking the Migrate DB button below will create new database "
+"tables in your local database with prefix \"<span class=\"remote-prefix\"></"
+"span>\"."
+msgstr ""
+
+#: template/migrate.php:308
+#, php-format
+msgid ""
+"However, your local install is configured to use table prefix \"%1$s\" and "
+"will ignore the migrated tables. So, <b>AFTER</b> migration is complete, you "
+"will need to edit your local install's wp-config.php and change the \"%1$s\" "
+"variable to \"<span class=\"remote-prefix\"></span>\"."
+msgstr ""
+
+#: template/migrate.php:310
+msgid ""
+"This will allow your local install the use the migrated tables. Once you do "
+"this, you shouldn't have to do it again."
+msgstr ""
+
+#: template/migrate.php:316
+#, php-format
+msgid ""
+"Whoa! We've detected that the database table prefix differs between "
+"installations. Clicking the Migrate DB button below will create new database "
+"tables in the remote database with prefix \"%s\"."
+msgstr ""
+
+#: template/migrate.php:318
+#, php-format
+msgid ""
+"However, your remote install is configured to use table prefix \"<span class="
+"\"remote-prefix\"></span>\" and will ignore the migrated tables. So, "
+"<b>AFTER</b> migration is complete, you will need to edit your remote "
+"install's wp-config.php and change the \"<span class=\"remote-prefix\"></"
+"span>\" variable to \"%s\"."
+msgstr ""
+
+#: template/migrate.php:320
+msgid ""
+"This will allow your remote install the use the migrated tables. Once you do "
+"this, you shouldn't have to do it again."
+msgstr ""
+
+#: template/options.php:16
+msgid ""
+"<strong>PHP Safe Mode Enabled</strong> — We do not officially support "
+"running this plugin in safe mode because <code>set_time_limit()</code> has "
+"no effect. Therefore we can't extend the run time of the script and ensure "
+"it doesn't time out before the migration completes. We haven't disabled the "
+"plugin however, so you're free to cross your fingers and hope for the best. "
+"However, if you have trouble, we can't help you until you turn off safe mode."
+msgstr ""
+
+#: template/options.php:18 template/options.php:37
+#, php-format
+msgid "Your current PHP run time limit is set to %s seconds."
+msgstr ""
+
+#: template/options.php:26
+#, php-format
+msgid ""
+"<strong>Internet Explorer Not Supported</strong> — Less than 2% of our "
+"customers use IE, so we've decided not to spend time supporting it. We ask "
+"that you use Firefox or a Webkit-based browser like Chrome or Safari "
+"instead. If this is a problem for you, please let us know."
+msgstr ""
+
+#: template/options.php:35
+msgid ""
+"<strong>PHP Function Disabled</strong> — The <code>set_time_limit()</"
+"code> function is currently disabled on your server. We use this function to "
+"ensure that the migration doesn't time out. We haven't disabled the plugin "
+"however, so you're free to cross your fingers and hope for the best. You may "
+"want to contact your web host to enable this function."
+msgstr ""
+
+#: template/pro/backup.php:4
+msgid ""
+"Backup the <span class=\"directory-scope\">local</span> database before "
+"replacing it"
+msgstr ""
+
+#: template/pro/backup.php:5
+msgid "An SQL file will be saved to"
+msgstr ""
+
+#: template/pro/backup.php:13
+msgid "Backup all tables with prefix"
+msgstr ""
+
+#: template/pro/backup.php:19
+msgid "Backup only tables selected for migration"
+msgstr ""
+
+#: template/pro/backup.php:25
+msgid "Backup only selected tables below"
+msgstr ""
+
+#: template/pro/backup.php:50
+#, php-format
+msgid ""
+"The backup option has been disabled as your <span class=\"directory-scope"
+"\">local</span> uploads directory is currently not writeable. The following "
+"directory should have 755 permissions: <span class=\"upload-directory-"
+"location\">%s</span></p>"
+msgstr ""
+
+#: template/pro/connection-info.php:2
+msgid "Connection Info"
+msgstr ""
+
+#: template/pro/connection-info.php:4
+msgid "Reset API Key"
+msgstr ""
+
+#: template/pro/exclude-post-types.php:4
+msgid "Exclude Post Types"
+msgstr ""
+
+#: template/pro/licence-info.php:2
+msgid "Email Support"
+msgstr ""
+
+#: template/pro/licence-info.php:8
+msgid "Once completed, you may visit this tab to view your support details."
+msgstr ""
+
+#: template/pro/licence.php:2
+msgid "Your License"
+msgstr ""
+
+#: template/pro/licence.php:5
+msgid "The license key is currently defined in wp-config.php."
+msgstr ""
+
+#: template/pro/licence.php:13
+msgid "Activate License"
+msgstr ""
+
+#: template/pro/outdated-addons-warning.php:12
+#, php-format
+msgid ""
+"The version of the %1$s addon you have installed%2$s is out-of-date and will "
+"not work with this version WP Migrate DB Pro. <a href=\"%3$s\">Update Now</a>"
+msgstr ""
+
+#: template/pro/pull-push-radio-buttons.php:4
+msgid "Pull"
+msgstr ""
+
+#: template/pro/pull-push-radio-buttons.php:4
+msgid "Replace this site's db with remote db"
+msgstr ""
+
+#: template/pro/pull-push-radio-buttons.php:13
+msgid "Push"
+msgstr ""
+
+#: template/pro/pull-push-radio-buttons.php:13
+msgid "Replace remote db with this site's db"
+msgstr ""
+
+#: template/pro/select-tables.php:4
+msgid "Tables"
+msgstr ""
+
+#: template/pro/select-tables.php:13
+msgid "Migrate all tables with prefix"
+msgstr ""
+
+#: template/pro/select-tables.php:19
+msgid "Migrate only selected tables below"
+msgstr ""
+
+#: template/pro/toggle-remote-requests.php:6
+msgid ""
+"Accept <b>pull</b> requests allow this database to be exported and downloaded"
+msgstr ""
+
+#: template/pro/toggle-remote-requests.php:12
+msgid "Accept <b>push</b> requests allow this database to be overwritten"
+msgstr ""
+
+#: template/pro/toggle-remote-requests.php:18
+msgid "Enable SSL verification"
+msgstr ""
+
+#: template/pro/toggle-remote-requests.php:22
+msgid ""
+"We disable SSL verification by default because a lot of people's "
+"environments are not setup for it to work. For example, with XAMPP, you have "
+"to manually enable OpenSSL by editing the php.ini. Without SSL verification, "
+"an HTTPS connection is vulnerable to a man-in-the-middle attack, so we do "
+"recommend you configure your environment and enable this."
+msgstr ""
+
+#: template/pro/videos.php:2
+msgid "Videos"
+msgstr ""
+
+#: template/profile.php:2
+msgid "Would you like to use a saved migration profile?"
+msgstr ""
+
+#: template/profile.php:7
+msgid "Nope, let's start fresh..."
+msgstr ""
+
+#: template/wpmdb/exclude-post-revisions.php:4
+msgid "Exclude post revisions"
+msgstr ""
+
+#: template/wpmdb/progress-upgrade.php:3
+msgid "Seen the PRO version?"
+msgstr ""
+
+#: template/wpmdb/progress-upgrade.php:5
+msgid ""
+"One-click in your WordPress dashboard to push your database up to staging/"
+"production or pull it down to dev"
+msgstr ""
+
+#: template/wpmdb/progress-upgrade.php:6
+msgid "Sync the Media Libraries of two sites"
+msgstr ""
+
+#: template/wpmdb/progress-upgrade.php:7
+msgid "Run migrations from the command line"
+msgstr ""
+
+#: template/wpmdb/progress-upgrade.php:11
+msgid "Within a few hours WP Migrate DB Pro has paid for itself!"
+msgstr ""
+
+#: template/wpmdb/progress-upgrade.php:15
+msgid "More About The Pro Version"
+msgstr ""
+
+#: template/wpmdb/sidebar.php:3
+msgid ""
+"WP Migrate DB Pro — Push and pull your database from one WordPress "
+"install to another in 1-click."
+msgstr ""
+
+#: template/wpmdb/sidebar.php:6
+msgid "Get 20% Off!"
+msgstr ""
+
+#: template/wpmdb/sidebar.php:11
+#, php-format
+msgid ""
+"Submit your name and email and we’ll send you a coupon for 20% off "
+"your upgrade to the pro version."
+msgstr ""
+
+#: template/wpmdb/sidebar.php:15
+msgid "Your Name"
+msgstr ""
+
+#: template/wpmdb/sidebar.php:19
+msgid "Your Email"
+msgstr ""
+
+#: template/wpmdb/sidebar.php:23
+msgid "Send me the coupon"
+msgstr ""
+
+#: template/wpmdb/sidebar.php:27
+msgid ""
+"We promise we will not use your email for anything else and you can "
+"unsubscribe with <span style=\"white-space: nowrap;\">1-click anytime</span>."
+msgstr ""
+
+#: template/wpmdb/sidebar.php:33
+msgid ""
+"WOW. WP Migrate DB Pro has made our local/live development a breeze. What a "
+"brilliant plugin. Worth every penny."
+msgstr ""
+
+#: template/wpmdb/wordpress-org-support.php:2
+msgid "Support"
+msgstr ""
+
+#: template/wpmdb/wordpress-org-support.php:4
+msgid "As this is a free plugin, we do not provide support."
+msgstr ""
+
+#: template/wpmdb/wordpress-org-support.php:6
+#, php-format
+msgid ""
+"You may ask the WordPress community for help by posting to the <a href=\"%s"
+"\">WordPress.org support forum</a>. Response time can range from a few days "
+"to a few weeks and will likely be from a non-developer."
+msgstr ""
+
+#: template/wpmdb/wordpress-org-support.php:8
+#, php-format
+msgid ""
+"If you want a <strong>timely response via email from a developer</strong> "
+"who works on this plugin, <a href=\"%s\">upgrade to WP "
+"Migrate DB Pro</a> and send us an email."
+msgstr ""
+
+#: template/wpmdb/wordpress-org-support.php:10
+#, php-format
+msgid ""
+"If you've found a bug, please <a href=\"%s\">submit an issue at Github</a>."
+msgstr ""
--- /dev/null
+=== WP Migrate DB ===
+Contributors: bradt
+Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5VPMGLLK94XJC
+Tags: database, migrate, backup, mysql
+Requires at least: 3.0
+Tested up to: 4.0
+Stable tag: 0.6
+License: GPLv2
+
+Exports your database, does a find and replace on URLs and file paths, then allows you to save it to your computer.
+
+== Description ==
+
+WP Migrate DB exports your database as a MySQL data dump (much like phpMyAdmin), does a find and replace on URLs and file paths, then allows you to save it to your computer. It is perfect for developers who need to update their local install with fresh data from the production site, or copy their locally developed site to a staging or production server.
+
+It even takes into account serialized data (both arrays and objects) and updates the string length values.
+
+Example: <code>s:5:"hello"</code> becomes <code>s:11:"hello world"</code>
+
+**\*NEW\* Pro Version with Email Support and More Features**
+
+* Select the tables you want to migrate
+* Pull production db down and replace local db
+* Push local db up and replace production/staging db
+* Multisite support
+* Video walkthroughs and howtos
+* Media files migration
+* Fire migrations from the command line or via a function call
+* More frequent bug fixes and improvements
+* And more features on the way!
+
+See the video below or [visit the web site](http://deliciousbrains.com/wp-migrate-db-pro/?utm_source=wordpressorg&utm_medium=web&utm_content=faq&utm_campaign=freeplugin) to learn more about the pro version.
+
+http://www.youtube.com/watch?v=IFdHIpf6jjc
+
+== Installation ==
+
+1. Use WordPress' built-in installer
+2. Access the "Migrate DB" menu option under Tools (or under Settings on multsite intallations)
+
+== Frequently Asked Questions ==
+
+= Does this plugin support multisite? =
+
+Yes, in a limited capacity. The Developer license of the [pro version](http://deliciousbrains.com/wp-migrate-db-pro/?utm_source=wordpressorg&utm_medium=web&utm_content=faq&utm_campaign=freeplugin) fully supports multisite.
+
+= Does the plugin migrate files as well? =
+
+No, it only operates on the database.
+
+= Why do I end up with a wp-login.php download instead of the exported SQL file? =
+
+It is likely you have a download manager plugin or extension installed in your web browser. You will need to disable it for the SQL download to work properly.
+
+== Screenshots ==
+
+1. Main screen
+2. Settings tab
+3. Saving the exported database
+
+== Changelog ==
+
+= 0.6 =
+* New: Updated the migration UI to include a detailed progress bar, time elapsed, pause and cancel buttons and more!
+* New: Option to exclude transients (temporary cached data)
+* New: Migration profiles
+* New: Setting to configure the maximum request size (how much data is exported in a given HTTP request)
+* Improvement: Unlimited find & replace fields with drag & drop reordering
+
+= 0.5 - 2013-07-26 =
+* Language support! Thanks to an awesome [pull request](https://github.com/bradt/wp-migrate-db/pull/19) from [Rafael Funchal](https://github.com/rafaelfunchal).
+* New Language: Brazilian Portugese
+* [Added filter for the filename of the exported file](https://github.com/bradt/wp-migrate-db/issues/16)
+* Bug fix: [Spam commentmeta included when "Do not export spam comments" checked](https://github.com/bradt/wp-migrate-db/issues/18)
+* Bug fix: [Fatal error method `error` does not exist](https://github.com/bradt/wp-migrate-db/issues/20)
+* Bug fix: [Table names with dashes not exporting](https://github.com/bradt/wp-migrate-db/issues/15)
+* Bug fix: [Find & replace is case-sensitive but shouldn't](https://github.com/bradt/wp-migrate-db/issues/13)
+
+= 0.4.4 - 2013-05-19 =
+* [Pro version has arrived!](http://deliciousbrains.com/wp-migrate-db-pro/?utm_source=wordpressorg&utm_medium=web&utm_content=changelog&utm_campaign=freeplugin) Added some info to the sidebar.
+* Updated required version to WordPress 3.0+
+* Bug fix: [Does not handle serialized objects](https://github.com/bradt/wp-migrate-db/issues/11)
+* Bug fix: [Admin menu disappears when DISALLOW_FILE_MODS is true](https://github.com/bradt/wp-migrate-db/issues/8)
+* Bug fix: [Duplicate records on export](https://github.com/bradt/wp-migrate-db/issues/5)
+* Bug fix: Updated spinner image for HiDPI displays
+
+= 0.4.3 - 2012-12-18 =
+* Fixed deprecated error notices when debug mode is on
+* Bug fix: [Exports views as tables](https://github.com/bradt/wp-migrate-db/issues/3)
+* Compatibility tested with WordPress 3.5
+
+= 0.4.2 - 2012-09-13 =
+* Moved screenshots to /assets folder and updated them to support retina
+* Added sidebar including author profile and survey to gauge interest for a pro version
+
+= 0.4.1 - 2012-08-15 =
+* Removed WP App Store installer - not allowed in WP.org repo
+
+= 0.4 - 2012-08-07 =
+* New: More than 4x faster than version 0.3 due to find & replace improvements
+* New: Option to turn off replacing GUIDs
+* New: Option to exclude spam comments and post revisions from the export
+* New: Option to save file with gzip compression
+* New: Added date and time to file names
+* New: Display path to SQL file on the server
+* New: WP App Store installer integration
+* Bug fix: Notices and warnings displayed when WP_DEBUG is on
+
+= 0.3 - 2011-12-16 =
+* Bug fix: [Null formatting error](http://plugins.trac.wordpress.org/ticket/1430)
+* Bug fix: [Deprecated capability](http://plugins.trac.wordpress.org/ticket/1431)
+* Bug fix: Serialized string lengths incorrect when string contains double quotes
+
+= 0.2.2 - 2011-09-23 =
+* Bug fix: [Breaks Export](http://wordpress.org/support/topic/plugin-wp-migrate-db-breaks-export?replies=1)
+
+= 0.2.1 - 2009-12-13 =
+* Moved to WordPress.org hosting
+
+= 0.2 - 2009-04-03 =
+* Moved menu link from "Settings" to "Tools"
+* The random string of characters no longer appears in the filename on save.
+
+= 0.1 - 2009-03-20 =
+* First release
+
+== Upgrade Notice ==
+
+= 0.4 =
+Runs export over 4x faster and adds some nice new features often requested. Upgrade recommended.
+
+= 0.2.2 =
+This version fixes a bug that breaks the WordPress core export feature. It is highly recommended that everyone upgrade.
--- /dev/null
+<?php
+ $licence = $this->get_licence_key();
+?>
+<div class="addons-tab content-tab">
+ <div class="addons-content">
+ <?php if( ! empty( $licence ) ) : ?>
+ <p><?php _e( 'Fetching addon details, please wait...', 'wp-migrate-db' ); ?></p>
+ <?php else : ?>
+ <p><?php _e( 'We couldn\'t find your license information. Please switch to the settings tab and enter your license.', 'wp-migrate-db' ); ?></p>
+ <p><?php _e( 'Once completed, you may visit this tab to view the available addons.', 'wp-migrate-db' ); ?></p>
+ <?php endif; ?>
+ </div>
+</div>
\ No newline at end of file
--- /dev/null
+<div class="option-section plugin-compatibility-section">
+ <label for="plugin-compatibility" class="plugin-compatibility bubble">
+ <input id="plugin-compatibility" type="checkbox" name="plugin_compatibility"<?php echo $plugin_compatibility_checked; ?> autocomplete="off"<?php echo $plugin_compatibility_checked; ?> />
+ <?php _e( 'Improve performance and reliability by not loading the following plugins for migration requests', 'wp-migrate-db' ); ?>
+ </label>
+ <a href="#" class="general-helper plugin-compatibility-helper js-action-link"></a>
+ <div class="plugin-compatibility-message helper-message bottom">
+ <?php _e( 'Some plugins add a lot of overhead to each request, requiring extra memory and CPU. And some plugins even interfere with migrations and cause them to fail. We recommend only loading plugins that affect migration requests, for example a plugin that hooks into WP Migrate DB.', 'wp-migrate-db' ); ?></br>
+ </div>
+
+ <div class="indent-wrap expandable-content plugin-compatibility-wrap select-wrap">
+ <select autocomplete="off" class="multiselect" id="selected-plugins" name="selected_plugins[]" multiple="multiple">
+ <?php
+ $blacklist = array_flip( $this->settings['blacklist_plugins'] );
+ foreach ( get_plugins() as $key => $plugin ) {
+ if ( 0 === strpos( $plugin['Name'], 'WP Migrate DB' ) ) {
+ continue;
+ }
+ $selected = ( isset( $blacklist[$key] ) ) ? ' selected' : '';
+ printf( '<option value="%s"%s>%s</option>', $key, $selected, $plugin['Name'] );
+ }
+ ?>
+ </select>
+ <br>
+ <a class="multiselect-select-all js-action-link" href="#"><?php _e( 'Select All', 'wp-migrate-db' ); ?></a>
+ <span class="select-deselect-divider">/</span>
+ <a class="multiselect-deselect-all js-action-link" href="#"><?php _e( 'Deselect All', 'wp-migrate-db' ); ?></a>
+ <span class="select-deselect-divider">/</span>
+ <a class="multiselect-invert-selection js-action-link" href="#"><?php _e( 'Invert Selection', 'wp-migrate-db' ); ?></a>
+
+ <p>
+ <span class="button plugin-compatibility-save"><?php _e( 'Save Changes', 'wp-migrate-db' ); ?></span>
+ <span class="plugin-compatibility-success-msg"><?php _e( 'Saved', 'wp-migrate-db' ); ?></span>
+ </p>
+ </div>
+</div>
\ No newline at end of file
--- /dev/null
+<div class="debug">
+ <h3><?php _e( 'Diagnostic Info & Error Log', 'wp-migrate-db' ); ?></h3>
+ <textarea class="debug-log-textarea" autocomplete="off" readonly></textarea>
+ <a class="button clear-log js-action-link"><?php _e( 'Clear Error Log', 'wp-migrate-db' ); ?></a>
+</div>
\ No newline at end of file
--- /dev/null
+<div class="option-section slider-outer-wrapper">
+ <div class="clearfix slider-label-wrapper">
+ <div class="slider-label"><span><?php _e( 'Maximum Request Size', 'wp-migrate-db' ); ?></span>
+ <a class="general-helper slider-helper js-action-link" href="#"></a>
+ <div class="slider-message helper-message">
+ <?php printf( __( 'We\'ve detected that your server supports requests up to %s, but it\'s possible that your server has limitations that we could not detect. To be on the safe side, we set the default to 1 MB, but you can try throttling it up to get better performance. If you\'re getting a 413 error or having trouble with time outs, try throttling this setting down.', 'wp-migrate-db' ), size_format( $this->get_bottleneck( 'max' ) ) ); ?>
+ </div>
+ </div>
+ <div class="amount"></div>
+ <span class="slider-success-msg"><?php _e( 'Saved', 'wp-migrate-db' ); ?></span>
+ </div>
+ <div class="slider"></div>
+</div>
\ No newline at end of file
--- /dev/null
+<div class="help-tab content-tab">
+ <?php $this->template_part( array( 'wordpress_org_support', 'licence_info', 'debug_info', 'videos' ) ); ?>
+</div> <!-- end .help-tab -->
--- /dev/null
+<div class="progress-content">
+ <span class="close-progress-content close-progress-content-button">×</span>
+ <div>
+ <h2 class="progress-title"><?php _e( 'Please wait while migration is running...', 'wp-migrate-db' ); ?></h2>
+ </div>
+ <div class="progress-info-wrapper clearfix">
+ <div class="progress-text"><?php _e( 'Establishing Connection', 'wp-migrate-db' ); ?></div>
+ <span class="timer"><?php echo __( 'Time Elapsed:', 'wp-migrate-db' ) . ' 00:00:00'; ?></span>
+ </div>
+ <div class="clearfix"></div>
+ <div class="progress-bar-wrapper">
+ <div class="progress-tables-hover-boxes"></div>
+ <div class="progress-label">wp_options</div>
+ <div class="progress-bar"></div>
+ <div class="progress-tables"></div>
+ </div>
+
+ <div class="migration-controls">
+ <span class="pause-resume button"><?php _e( 'Pause', 'wp-migrate-db' ); ?></span>
+ <span class="cancel button"><?php _e( 'Cancel', 'wp-migrate-db' ); ?></span>
+ </div>
+
+ <?php $this->template_part( array( 'progress_upgrade' ) ); ?>
+
+</div> <!-- end .progress-content -->
\ No newline at end of file
--- /dev/null
+<?php
+global $wpdb;
+global $loaded_profile;
+
+if( isset( $_GET['wpmdb-profile'] ) ){
+ $loaded_profile = $this->get_profile( $_GET['wpmdb-profile'] );
+}
+else{
+ $loaded_profile = $this->default_profile;
+}
+
+$is_default_profile = isset( $loaded_profile['default_profile'] );
+
+$convert_exclude_revisions = false;
+$convert_post_type_selection = false;
+if( ! $is_default_profile ) {
+ if( isset( $loaded_profile['exclude_revisions'] ) ) {
+ $convert_exclude_revisions = true;
+ }
+ /* We used to provide users the option of selecting which post types they'd like to migrate.
+ * We found that our wording for this funtionality was a little confusing so we switched it to instead read "Exclude Post Types"
+ * Once we made the switch we needed a way of inverting their saved post type selection to instead exclude the select post types.
+ * This was required to make their select compatible with the new "exclude" wording.
+ * This is easy enough for "push" and "export" saved profile as we know which post types exist on the local system and
+ * can easily invert the selection. Pull saved profiles is a little tricker.
+ * $this->maybe_update_profile() is used to update deprecated profile options to their new values.
+ * At the time of page request $this->maybe_update_profile() cannot be used to update a pull profile as we don't know which
+ * post types exist on the remote machine. As such we invert this selection later using the $convert_post_type_selection flag below.
+ */
+ if ( isset( $loaded_profile['post_type_migrate_option'] ) && 'migrate_select_post_types' == $loaded_profile['post_type_migrate_option'] && 'pull' == $loaded_profile['action'] ) {
+ $convert_post_type_selection = true;
+ }
+ $loaded_profile = $this->maybe_update_profile( $loaded_profile, $_GET['wpmdb-profile'] );
+}
+
+if( false == $is_default_profile ) {
+ $loaded_profile = wp_parse_args( $loaded_profile, $this->default_profile );
+}
+$loaded_profile = wp_parse_args( $loaded_profile, $this->checkbox_options );
+?>
+<script type='text/javascript'>
+ var wpmdb_default_profile = <?php echo ( $is_default_profile ? 'true' : 'false' ); ?>;
+ <?php if( isset( $loaded_profile['select_tables'] ) && ! empty( $loaded_profile['select_tables'] ) ) : ?>
+ var wpmdb_loaded_tables = <?php echo json_encode( $loaded_profile['select_tables'] ); ?>;
+ <?php endif; ?>
+ <?php if( isset( $loaded_profile['select_post_types'] ) ) : ?>
+ var wpmdb_loaded_post_types = <?php echo json_encode( $loaded_profile['select_post_types'] ); ?>;
+ <?php endif; ?>
+ <?php if( isset( $loaded_profile['select_backup'] ) && ! empty( $loaded_profile['select_backup'] ) ) : ?>
+ var wpmdb_loaded_tables_backup = <?php echo json_encode( $loaded_profile['select_backup'] ); ?>;
+ <?php endif; ?>
+ var wpmdb_convert_exclude_revisions = <?php echo ( $convert_exclude_revisions ? 'true' : 'false' ); ?>;
+ var wpmdb_convert_post_type_selection = <?php echo ( $convert_post_type_selection ? '1' : '0' ); ?>;
+</script>
+
+<div class="migrate-tab content-tab">
+
+ <form method="post" id="migrate-form" action="#migrate" enctype="multipart/form-data">
+
+ <?php if ( count( $this->settings['profiles'] ) > 0 ) : ?>
+ <a href="<?php echo $this->plugin_base; ?>" class="return-to-profile-selection clearfix">
+ ← <?php _e( 'Back to select a saved profile', 'wp-migrate-db' ); ?>
+ </a>
+ <?php endif; ?>
+
+ <div class="option-section">
+
+ <ul class="option-group migrate-selection">
+ <li>
+ <?php $savefile_style = ( true == $this->is_pro ) ? '' : ' style="display: none;"'; ?>
+ <label for="savefile"<?php echo $savefile_style; ?>>
+ <input id="savefile" type="radio" value="savefile" name="action"<?php echo ( $loaded_profile['action'] == 'savefile' || ! $this->is_pro ) ? ' checked="checked"' : ''; ?> />
+ <?php _e( 'Export File', 'wp-migrate-db' ); ?>
+ </label>
+ <ul>
+ <li>
+ <label for="save_computer">
+ <input id="save_computer" type="checkbox" value="1" name="save_computer"<?php $this->maybe_checked( $loaded_profile['save_computer'] ); ?> />
+ <?php _e( 'Save as file to your computer', 'wp-migrate-db' ); ?>
+ </label>
+ </li>
+ <?php if ( $this->gzip() ) : ?>
+ <li>
+ <label for="gzip_file">
+ <input id="gzip_file" type="checkbox" value="1" name="gzip_file"<?php $this->maybe_checked( $loaded_profile['gzip_file'] ); ?> />
+ <?php _e( 'Compress file with gzip', 'wp-migrate-db' ); ?>
+ </label>
+ </li>
+ <?php endif; ?>
+ </ul>
+ </li>
+ <?php $this->template_part( array( 'pull_push_radio_buttons' ), $loaded_profile ); ?>
+ </ul>
+
+ <div class="connection-info-wrapper clearfix">
+ <textarea class="pull-push-connection-info" name="connection_info" placeholder="<?php _e( 'Connection Info - Site URL & Secret Key', 'wp-migrate-db' ); ?>"><?php echo ( isset( $loaded_profile['connection_info'] ) ? $loaded_profile['connection_info'] : '' ); ?></textarea>
+ <br />
+ <div class="basic-access-auth-wrapper clearfix">
+ <input type="text" name="auth_username" class="auth-username auth-credentials" placeholder="Username" autocomplete="off" />
+ <input type="password" name="auth_password" class="auth-password auth-credentials" placeholder="Password" autocomplete="off" />
+ </div>
+ <input class="button connect-button" type="submit" value="Connect" name="Connect" autocomplete="off" />
+ </div>
+
+ <div class="notification-message warning-notice ssl-notice inline-message">
+ <strong><?php _e( 'SSL Disabled', 'wp-migrate-db' ); ?></strong> — <?php _e( 'We couldn\'t connect over SSL but regular http (no SSL) appears to be working so we\'ve switched to that. If you run a push or pull, your data will be transmitted unencrypted. Most people are fine with this, but just a heads up.', 'wp-migrate-db' ); ?>
+ </div>
+
+ <?php $this->template_part( array( 'invalid_licence_warning' ) ); ?>
+
+ </div>
+
+ <p class="connection-status"><?php _e( 'Please enter the connection information above to continue.', 'wp-migrate-db' ); ?></p>
+
+ <div class="notification-message error-notice different-plugin-version-notice inline-message" style="display: none;">
+ <b><?php _e( 'Version Mismatch', 'wp-migrate-db' ); ?></b> — <?php printf( __( 'We\'ve detected you have version <span class="remote-version"></span> of WP Migrate DB Pro at <span class="remote-location"></span> but are using %1$s here. Please go to the <a href="%2$s">Plugins page</a> on both installs and check for updates.', 'wp-migrate-db' ), $GLOBALS['wpmdb_meta'][$this->plugin_slug]['version'], network_admin_url( 'plugins.php' ) ); ?>
+ </div>
+
+ <div class="notification-message error-notice directory-permission-notice inline-message" style="display: none;">
+ <strong><?php _e( 'Cannot Access Uploads Directory', 'wp-migrate-db' ); ?></strong> —
+ <?php
+ _e( 'We require write permissions to the standard WordPress uploads directory. Without this permission exports are unavailable. Please grant 755 permissions on the following directory:', 'wp-migrate-db' );
+ echo $this->get_upload_info( 'path' );
+ ?>
+ </div>
+
+ <div class="step-two">
+
+ <div class="option-section">
+ <div class="header-wrapper clearfix">
+ <div class="option-heading find-heading"><?php _e( 'Find', 'wp-migrate-db' ); ?></div>
+ <div class="option-heading replace-heading"><?php _e( 'Replace', 'wp-migrate-db' ); ?></div>
+ </div>
+
+ <p class="no-replaces-message"><?php _e( 'Doesn\'t look we have any replaces yet, <a href="#" class="js-action-link add-replace">add one?</a>', 'wp-migrate-db' ); ?></p>
+
+ <table id="find-and-replace-sort" class="clearfix replace-fields">
+ <tbody>
+ <tr class="replace-row original-repeatable-field">
+ <td class="sort-handle-col">
+ <span class="sort-handle"></span>
+ </td>
+ <td class="old-replace-col">
+ <input type="text" size="40" name="replace_old[]" class="code" placeholder="Old value" autocomplete="off" />
+ </td>
+ <td class="arrow-col">
+ <span class="right-arrow">→</span>
+ </td>
+ <td class="replace-right-col">
+ <input type="text" size="40" name="replace_new[]" class="code" placeholder="New value" autocomplete="off" />
+ <span style="display: none;" class="replace-remove-row" data-profile-id="0"></span>
+ </td>
+ </tr>
+ <?php if( $is_default_profile ) : ?>
+ <tr class="replace-row ui-state-default<?php echo ( $this->lock_url_find_replace_row ) ? ' pin' : ''; ?>">
+ <td class="sort-handle-col">
+ <span class="sort-handle"></span>
+ </td>
+ <td class="old-replace-col">
+ <input type="text" size="40" name="replace_old[]" class="code" id="old-url" placeholder="Old URL" value="<?php echo preg_replace( '#^https?:#', '', htmlentities( home_url() ) ); ?>" autocomplete="off"<?php echo ( $this->lock_url_find_replace_row ) ? ' readonly' : ''; ?> />
+ </td>
+ <td class="arrow-col">
+ <span class="right-arrow">→</span>
+ </td>
+ <td class="replace-right-col">
+ <input type="text" size="40" name="replace_new[]" class="code" id="new-url" placeholder="New URL" autocomplete="off" />
+ <?php if ( ! $this->lock_url_find_replace_row ) : ?>
+ <span style="display: none;" class="replace-remove-row" data-profile-id="0"></span>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <tr class="replace-row ui-state-default">
+ <td class="sort-handle-col">
+ <span class="sort-handle"></span>
+ </td>
+ <td class="old-replace-col">
+ <input type="text" size="40" name="replace_old[]" class="code" id="old-path" placeholder="Old file path" value="<?php echo htmlentities( $this->absolute_root_file_path ); ?>" autocomplete="off" />
+ </td>
+ <td class="arrow-col">
+ <span class="right-arrow">→</span>
+ </td>
+ <td class="replace-right-col">
+ <input type="text" size="40" name="replace_new[]" class="code" id="new-path" placeholder="New file path" autocomplete="off" />
+ <span style="display: none;" class="replace-remove-row" data-profile-id="0"></span>
+ </td>
+ </tr>
+ <?php else :
+ $i = 1;
+ foreach( $loaded_profile['replace_old'] as $replace_old ) : ?>
+ <tr class="replace-row ui-state-default<?php echo ( 1 == $i && $this->lock_url_find_replace_row ) ? ' pin' : ''; ?>">
+ <td class="sort-handle-col">
+ <span class="sort-handle"></span>
+ </td>
+ <td class="old-replace-col">
+ <input type="text" size="40" name="replace_old[]" class="code" placeholder="Old value" value="<?php echo $replace_old; ?>" autocomplete="off"<?php echo ( 1 == $i && $this->lock_url_find_replace_row ) ? ' readonly' : ''; ?> />
+ </td>
+ <td class="arrow-col">
+ <span class="right-arrow">→</span>
+ </td>
+ <td class="replace-right-col">
+ <input type="text" size="40" name="replace_new[]" class="code" placeholder="New value" value="<?php echo ( isset( $loaded_profile['replace_new'][$i] ) ? $loaded_profile['replace_new'][$i] : '' ); ?>" autocomplete="off" />
+ <?php if ( ! $this->lock_url_find_replace_row || ( $this->lock_url_find_replace_row && $i != 1 ) ) : ?>
+ <span style="display: none;" class="replace-remove-row" data-profile-id="0"></span>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <?php
+ ++$i;
+ endforeach; ?>
+ <?php endif; ?>
+ <tr class="pin">
+ <td colspan="4"><a class="button add-row">Add Row</a></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <div id="new-url-missing-warning" class="warning inline-message missing-replace"><?php printf( __( '<strong>New URL Missing</strong> — Please enter the protocol-relative URL of the remote website in the "New URL" field. If you are unsure of what this URL should be, please consult <a href="%s" target="_blank">our documentation</a> on find and replace fields.', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/documentation/#find-and-replace' ); ?></div>
+ <div id="new-path-missing-warning" class="warning inline-message missing-replace"><?php printf( __( '<strong>New File Path Missing</strong> — Please enter the root file path of the remote website in the "New file path" field. If you are unsure of what the file path should be, please consult <a href="%s" target="_blank">our documentation</a> on find and replace fields.', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/documentation/#find-and-replace' ); ?></div>
+
+ </div>
+
+ <?php $this->template_part( array( 'select_tables', 'exclude_post_types' ), $loaded_profile ); ?>
+
+ <div class="option-section">
+ <div class="header-expand-collapse clearfix">
+ <div class="expand-collapse-arrow collapsed">▼</div>
+ <div class="option-heading tables-header"><?php _e( 'Advanced Options', 'wp-migrate-db' ); ?></div>
+ </div>
+
+ <div class="indent-wrap expandable-content">
+
+ <ul>
+ <li>
+ <label for="replace-guids">
+ <input id="replace-guids" type="checkbox" value="1" name="replace_guids"<?php $this->maybe_checked( $loaded_profile['replace_guids'] ); ?> />
+ <?php _e( 'Replace GUIDs', 'wp-migrate-db' ); ?>
+ </label>
+
+ <a href="#" class="general-helper replace-guid-helper js-action-link"></a>
+
+ <div class="replace-guids-info helper-message">
+ <?php printf( __( 'Although the <a href="%s" target="_blank">WordPress Codex emphasizes</a> that GUIDs should not be changed, this is limited to sites that are already live. If the site has never been live, I recommend replacing the GUIDs. For example, you may be developing a new site locally at dev.somedomain.com and want to migrate the site live to somedomain.com.', 'wp-migrate-db' ), 'http://codex.wordpress.org/Changing_The_Site_URL#Important_GUID_Note' ); ?>
+ </div>
+ </li>
+ <li>
+ <label for="exclude-spam">
+ <input id="exclude-spam" type="checkbox" autocomplete="off" value="1" name="exclude_spam"<?php $this->maybe_checked( $loaded_profile['exclude_spam'] ); ?> />
+ <?php _e( 'Exclude spam comments', 'wp-migrate-db' ); ?>
+ </label>
+ </li>
+ <li class="keep-active-plugins">
+ <label for="keep-active-plugins">
+ <input id="keep-active-plugins" type="checkbox" value="1" autocomplete="off" name="keep_active_plugins"<?php $this->maybe_checked( $loaded_profile['keep_active_plugins'] ); ?> />
+ <?php _e( 'Do not migrate the \'active_plugins\' setting (i.e. which plugins are activated/deactivated)', 'wp-migrate-db' ); ?>
+ </label>
+ </li>
+ <li>
+ <label for="exclude-transients">
+ <input id="exclude-transients" type="checkbox" value="1" autocomplete="off" name="exclude_transients"<?php $this->maybe_checked( $loaded_profile['exclude_transients'] ); ?> />
+ Exclude <a href="https://codex.wordpress.org/Transients_API" target="_blank">transients</a> (temporary cached data)
+ </label>
+ </li>
+ <?php $this->template_part( array( 'exclude_post_revisions' ), $loaded_profile ); ?>
+ </ul>
+
+ </div>
+ </div>
+
+ <?php $this->template_part( array( 'backup' ), $loaded_profile ); ?>
+
+ <?php do_action( 'wpmdb_after_advanced_options' ); ?>
+
+ <div class="option-section save-migration-profile-wrap">
+ <label for="save-migration-profile" class="save-migration-profile checkbox-label">
+ <input id="save-migration-profile" type="checkbox" value="1" name="save_migration_profile"<?php echo ( ! $is_default_profile ? ' checked="checked"' : '' ); ?> />
+ <?php _e( 'Save Migration Profile', 'wp-migrate-db' ); ?><span class="option-description"><?php _e( 'Save the above settings for the next time you do a similiar migration', 'wp-migrate-db' ); ?></span>
+ </label>
+
+ <div class="indent-wrap expandable-content">
+ <ul class="option-group">
+ <?php
+ foreach( $this->settings['profiles'] as $profile_id => $profile ){ ++$profile_id; ?>
+ <li>
+ <span class="delete-profile" data-profile-id="<?php echo $profile_id; ?>"></span>
+ <label for="profile-<?php echo $profile_id; ?>">
+ <input id="profile-<?php echo $profile_id; ?>" type="radio" value="<?php echo --$profile_id; ?>" name="save_migration_profile_option"<?php echo ( $loaded_profile['name'] == $profile['name'] ) ? ' checked="checked"' : ''; ?> />
+ <?php echo $profile['name']; ?>
+ </label>
+ </li>
+ <?php }
+ ?>
+ <li>
+ <label for="create_new" class="create-new-label">
+ <input id="create_new" type="radio" value="new" name="save_migration_profile_option"<?php echo ( $is_default_profile ? ' checked="checked"' : '' ); ?> />
+ <?php _e( 'Create new profile', 'wp-migrate-db' ); ?>
+ </label>
+ <input type="text" placeholder="e.g. Live Site" name="create_new_profile" class="create-new-profile" />
+ </li>
+ </ul>
+ </div>
+ </div>
+
+ <div class="notification-message warning-notice prefix-notice pull">
+ <h4><?php _e( 'Warning: Different Table Prefixes', 'wp-migrate-db' ); ?></h4>
+
+ <p><?php _e( 'Whoa! We\'ve detected that the database table prefix differs between installations. Clicking the Migrate DB button below will create new database tables in your local database with prefix "<span class="remote-prefix"></span>".', 'wp-migrate-db' ); ?></p>
+
+ <p><?php printf( __( 'However, your local install is configured to use table prefix "%1$s" and will ignore the migrated tables. So, <b>AFTER</b> migration is complete, you will need to edit your local install\'s wp-config.php and change the "%1$s" variable to "<span class="remote-prefix"></span>".', 'wp-migrate-db' ), $wpdb->prefix, $wpdb->prefix ); ?></p>
+
+ <p><?php _e( 'This will allow your local install the use the migrated tables. Once you do this, you shouldn\'t have to do it again.', 'wp-migrate-db' ); ?></p>
+ </div>
+
+ <div class="notification-message warning-notice prefix-notice push">
+ <h4><?php _e( 'Warning: Different Table Prefixes', 'wp-migrate-db' ); ?></h4>
+
+ <p><?php printf( __( 'Whoa! We\'ve detected that the database table prefix differs between installations. Clicking the Migrate DB button below will create new database tables in the remote database with prefix "%s".', 'wp-migrate-db' ), $wpdb->prefix ); ?></p>
+
+ <p><?php printf( __( 'However, your remote install is configured to use table prefix "<span class="remote-prefix"></span>" and will ignore the migrated tables. So, <b>AFTER</b> migration is complete, you will need to edit your remote install\'s wp-config.php and change the "<span class="remote-prefix"></span>" variable to "%s".', 'wp-migrate-db' ), $wpdb->prefix ); ?></p>
+
+ <p><?php _e( 'This will allow your remote install the use the migrated tables. Once you do this, you shouldn\'t have to do it again.', 'wp-migrate-db' ); ?></p>
+ </div>
+
+ <p class="migrate-db">
+ <input type="hidden" class="remote-json-data" name="remote_json_data" autocomplete="off" />
+ <input class="button-primary migrate-db-button" type="submit" value="Migrate DB" name="Submit" autocomplete="off" />
+ <input class="button save-settings-button" type="submit" value="Save Profile" name="submit_save_profile" autocomplete="off" />
+ </p>
+
+ </div>
+
+ <?php if ( count( $this->settings['profiles'] ) > 0 ) : ?>
+ <a href="<?php echo $this->plugin_base; ?>" class="return-to-profile-selection clearfix bottom">
+ ← <?php _e( 'Back to select a saved profile', 'wp-migrate-db' ); ?>
+ </a>
+ <?php endif; ?>
+
+ </form>
+ <?php $this->template( 'migrate-progress' ); ?>
+
+</div> <!-- end .migrate-tab -->
\ No newline at end of file
--- /dev/null
+<div class="wrap wpmdb">
+
+ <div id="icon-tools" class="icon32"><br /></div><h2><?php echo $this->get_plugin_title(); ?></h2>
+
+ <h2 class="nav-tab-wrapper">
+ <?php $this->plugin_tabs(); ?>
+ </h2>
+
+ <?php do_action( 'wpmdb_notices' ); ?>
+
+ <?php
+ $hide_warning = apply_filters( 'wpmdb_hide_safe_mode_warning', false );
+ if ( function_exists( 'ini_get' ) && ini_get( 'safe_mode' ) && !$hide_warning ) { ?>
+ <div class="updated warning inline-message">
+ <?php
+ _e( "<strong>PHP Safe Mode Enabled</strong> — We do not officially support running this plugin in safe mode because <code>set_time_limit()</code> has no effect. Therefore we can't extend the run time of the script and ensure it doesn't time out before the migration completes. We haven't disabled the plugin however, so you're free to cross your fingers and hope for the best. However, if you have trouble, we can't help you until you turn off safe mode.", 'wp-migrate-db' );
+ if ( function_exists( 'ini_get' ) ) {
+ printf( __( 'Your current PHP run time limit is set to %s seconds.', 'wp-migrate-db' ), ini_get( 'max_execution_time' ) );
+ } ?>
+ </div>
+ <?php
+ }
+ ?>
+
+ <div class="updated warning ie-warning inline-message" style="display: none;">
+ <?php _e( "<strong>Internet Explorer Not Supported</strong> — Less than 2% of our customers use IE, so we've decided not to spend time supporting it. We ask that you use Firefox or a Webkit-based browser like Chrome or Safari instead. If this is a problem for you, please let us know.", 'wp-migrate-db' ); ?>
+ </div>
+
+ <?php
+ $hide_warning = apply_filters( 'wpmdb_hide_set_time_limit_warning', false );
+ if ( false == $this->set_time_limit_available() && !$hide_warning && !$safe_mode ) {
+ ?>
+ <div class="updated warning inline-message">
+ <?php
+ _e( "<strong>PHP Function Disabled</strong> — The <code>set_time_limit()</code> function is currently disabled on your server. We use this function to ensure that the migration doesn't time out. We haven't disabled the plugin however, so you're free to cross your fingers and hope for the best. You may want to contact your web host to enable this function.", 'wp-migrate-db' );
+ if ( function_exists( 'ini_get' ) ) {
+ printf( __( 'Your current PHP run time limit is set to %s seconds.', 'wp-migrate-db' ), ini_get( 'max_execution_time' ) );
+ } ?>
+ </div>
+ <?php
+ }
+ ?>
+
+ <div id="wpmdb-main">
+
+ <?php
+ // select profile if more than > 1 profile saved
+ if ( ! empty( $this->settings['profiles'] ) && ! isset( $_GET['wpmdb-profile'] ) ) {
+ $this->template( 'profile' );
+ } else {
+ $this->template( 'migrate' );
+ }
+ $this->template( 'settings' );
+ $this->template( 'addons' );
+ $this->template( 'help' );
+
+ $this->template_part( array( 'sidebar' ) );
+ ?>
+
+ </div> <!-- end #wpmdb-main -->
+
+</div> <!-- end .wrap -->
\ No newline at end of file
--- /dev/null
+<div class="migrate-tab content-tab">
+ <p class="saved-migration-profile-label"><?php _e( 'Would you like to use a saved migration profile?', 'wp-migrate-db' ); ?></p>
+ <ul class="migration-profile-options">
+ <?php foreach( $this->settings['profiles'] as $key => $profile ) { ++$key ?>
+ <li><a href="<?php echo $this->plugin_base . '&wpmdb-profile=' . $key; ?>"><?php printf( '%s - %s', $key, $profile['name'] ); ?></a><span class="main-list-delete-profile-link" data-profile-id="<?php echo $key; ?>">×</span></li>
+ <?php } ?>
+ <li><a href="<?php echo $this->plugin_base . '&wpmdb-profile=-1'; ?>"><?php _e( 'Nope, let\'s start fresh...', 'wp-migrate-db' ); ?></a></li>
+ </ul>
+</div>
\ No newline at end of file
--- /dev/null
+<div class="settings-tab content-tab">
+ <form method="post" id="settings-form" action="#settings" autocomplete="off">
+ <?php $this->template_part( array( 'toggle_remote_requests', 'connection_info', 'compatibility', 'max_request_size' ) ); ?>
+ </form>
+ <?php $this->template_part( array( 'licence' ) ); ?>
+</div> <!-- end .settings-tab -->
\ No newline at end of file
--- /dev/null
+<li>
+ <label for="exclude-post-revisions">
+ <input id="exclude-post-revisions" type="checkbox" autocomplete="off" value="1" name="exclude_post_revisions"<?php echo ( in_array( 'revision', $loaded_profile['select_post_types'] ) ) ? ' checked="checked"' : ''; ?> />
+ <?php _e( 'Exclude post revisions', 'wp-migrate-db' ); ?>
+ </label>
+</li>
\ No newline at end of file
--- /dev/null
+<div class="pro-version">
+ <div class="pro-version-content">
+ <h1><?php _e( 'Seen the PRO version?', 'wp-migrate-db' ); ?></h1>
+ <ul>
+ <li><?php _e( 'One-click in your WordPress dashboard to push your database up to staging/production or pull it down to dev', 'wp-migrate-db' ); ?></li>
+ <li><?php _e( 'Sync the Media Libraries of two sites', 'wp-migrate-db' ); ?></li>
+ <li><?php _e( 'Run migrations from the command line', 'wp-migrate-db' ); ?></li>
+ </ul>
+
+ <p class="pro-quote">
+ <strong>“<?php _e( 'Within a few hours WP Migrate DB Pro has paid for itself!', 'wp-migrate-db' ); ?>”</strong>
+ <span class="pro-quote-author">— Eric Wagner <span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></span>
+ </p>
+
+ <a class="button" href="https://deliciousbrains.com/wp-migrate-db-pro/?utm_source=insideplugin&utm_medium=web&utm_content=progress-bar&utm_campaign=freeplugin" target="_blank"><?php _e( 'More About The Pro Version', 'wp-migrate-db' ); ?> →</a>
+ </div>
+
+ <iframe width="419" height="265" src="//www.youtube.com/embed/IFdHIpf6jjc?rel=0&showinfo=0&autoplay=0&wmode=transparent&theme=light" frameborder="0" allowfullscreen></iframe>
+</div>
\ No newline at end of file
--- /dev/null
+<div id="wpmdb-sidebar">
+
+ <a class="wpmdb-banner" target="_blank" href="https://deliciousbrains.com/wp-migrate-db-pro/?utm_source=insideplugin&utm_medium=web&utm_content=sidebar&utm_campaign=freeplugin"><img src="<?php echo plugins_url( 'asset/img/wp-migrate-db-pro.jpg', $this->plugin_file_path ); ?>" width="292" height="292" alt="<?php _e( 'WP Migrate DB Pro — Push and pull your database from one WordPress install to another in 1-click.', 'wp-migrate-db' ); ?>" /></a>
+
+ <form method="post" action="http://deliciousbrains.createsend.com/t/t/s/virn/" target="_blank" class="subscribe block">
+ <h2><?php _e( 'Get 20% Off!', 'wp-migrate-db' ); ?></h2>
+
+ <?php $user = wp_get_current_user(); ?>
+
+ <p class="interesting">
+ <?php _e( 'Submit your name and email and we’ll send you a coupon for 20% off your upgrade to the pro version.', 'wp-migrate-db' ); ?>
+ </p>
+
+ <div class="field notify-name">
+ <input type="text" name="cm-name" value="<?php echo trim( esc_attr( $user->first_name ) . ' ' . esc_attr( $user->last_name ) ); ?>" placeholder="<?php _e( 'Your Name', 'wp-migrate-db' ); ?>" />
+ </div>
+
+ <div class="field notify-email">
+ <input type="email" name="cm-virn-virn" value="<?php echo esc_attr( $user->user_email ); ?>" placeholder="<?php _e( 'Your Email', 'wp-migrate-db' ); ?>" />
+ </div>
+
+ <div class="field submit-button">
+ <input type="submit" class="button" value="<?php _e( 'Send me the coupon', 'wp-migrate-db' ); ?>" />
+ </div>
+
+ <p class="promise">
+ <?php _e( 'We promise we will not use your email for anything else and you can unsubscribe with <span style="white-space: nowrap;">1-click anytime</span>.', 'wp-migrate-db' ); ?>
+ </p>
+ </form>
+
+ <div class="block testimonial">
+ <p class="stars"><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></p>
+ <p class="quote">“<?php _e( 'WOW. WP Migrate DB Pro has made our local/live development a breeze. What a brilliant plugin. Worth every penny.', 'wp-migrate-db' ); ?>”</p>
+ <p class="author">— Boxy Studio</p>
+ <p class="via"><a target="_blank" href="https://twitter.com/BoxyStudio/status/458965600434675712">via Twitter</a></p>
+ </div>
+</div>
\ No newline at end of file
--- /dev/null
+<div class="support">
+ <h3><?php _e( 'Support', 'wp-migrate-db' ); ?></h3>
+
+ <p><?php _e( 'As this is a free plugin, we do not provide support.', 'wp-migrate-db' ); ?></p>
+
+ <p><?php printf( __( 'You may ask the WordPress community for help by posting to the <a href="%s">WordPress.org support forum</a>. Response time can range from a few days to a few weeks and will likely be from a non-developer.', 'wp-migrate-db' ), 'http://wordpress.org/support/plugin/wp-migrate-db' ); ?></p>
+
+ <p style="font-size:16px; font-weight: bold;"><?php printf( __( 'If you want a <strong>timely response via email from a developer</strong> who works on this plugin, <a href="%s">upgrade to WP Migrate DB Pro</a> and send us an email.', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/?utm_source=insideplugin&utm_medium=web&utm_content=help-tab&utm_campaign=freeplugin' ); ?></p>
+
+ <p><?php printf( __( 'If you\'ve found a bug, please <a href="%s">submit an issue at Github</a>.', 'wp-migrate-db' ), 'https://github.com/bradt/wp-migrate-db/issues' ); ?></p>
+
+</div>
\ No newline at end of file
--- /dev/null
+<?php
+/*
+Plugin Name: WP Migrate DB
+Plugin URI: http://wordpress.org/plugins/wp-migrate-db/
+Description: Exports your database as a MySQL data dump (much like phpMyAdmin), does a find and replace on URLs and file paths, then allows you to save it to your computer.
+Author: Delicious Brains
+Version: 0.6
+Author URI: http://deliciousbrains.com
+Network: True
+Text Domain: wp-migrate-db
+Domain Path: /languages/
+*/
+
+// Copyright (c) 2013 Delicious Brains. All rights reserved.
+//
+// Released under the GPL license
+// http://www.opensource.org/licenses/gpl-license.php
+//
+// **********************************************************************
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// **********************************************************************
+
+$GLOBALS['wpmdb_meta']['wp-migrate-db']['version'] = '0.6';
+
+if ( ! class_exists( 'WPMDB_Utils' ) ) {
+ require dirname( __FILE__ ) . '/class/wpmdb-utils.php';
+}
+
+// Define the directory seperator if it isn't already
+if( !defined( 'DS' ) ) {
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ define('DS', '\\');
+ }
+ else {
+ define('DS', '/');
+ }
+}
+
+function wp_migrate_db_loaded() {
+ // exit quickly unless: standalone admin; multisite network admin; one of our AJAX calls
+ if ( ! is_admin() || ( is_multisite() && ! is_network_admin() && ! WPMDB_Utils::is_ajax() ) ) {
+ return;
+ }
+ wp_migrate_db();
+}
+add_action( 'plugins_loaded', 'wp_migrate_db_loaded' );
+
+function wp_migrate_db_init() {
+ // if neither WordPress admin nor running from wp-cli, exit quickly to prevent performance impact
+ if ( !is_admin() && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) return;
+
+ load_plugin_textdomain( 'wp-migrate-db', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
+}
+add_action( 'init', 'wp_migrate_db_init' );
+
+/**
+ * Populate the $wpmdb global with an instance of the WPMDB class and return it.
+ *
+ * @return WPMDB The one true global instance of the WPMDB class.
+ */
+function wp_migrate_db() {
+ global $wpmdb;
+
+ if ( ! is_null( $wpmdb ) ) {
+ return $wpmdb;
+ }
+
+ $abspath = dirname( __FILE__ );
+
+ require_once $abspath . '/class/wpmdb-base.php';
+ require_once $abspath . '/class/wpmdb.php';
+
+ $wpmdb = new WPMDB( __FILE__ );
+
+ return $wpmdb;
+}