Added dependency plugins
This commit is contained in:
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/css/plugin-update-styles.css
vendored
Normal file
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/css/plugin-update-styles.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.check-licence-spinner{left:5px;position:relative;top:2px;margin-bottom:-2px;width:16px;height:16px}.wpmdb-original-update-row{display:none}.plugin-update-tr.wpmdbpro-custom-visible .update-message.pre-shiny-updates,.plugin-update-tr.wpmdbpro-custom .update-message.pre-shiny-updates{padding-left:40px}.plugin-update-tr.wpmdbpro-custom-visible .update-message.pre-shiny-updates::before,.plugin-update-tr.wpmdbpro-custom .update-message.pre-shiny-updates::before{margin-left:-30px;float:left}.plugin-update-tr.wpmdbpro-custom-visible .update-message.pre-shiny-updates p,.plugin-update-tr.wpmdbpro-custom .update-message.pre-shiny-updates p{display:inline-block;margin:0}.plugin-update-tr.wpmdbpro-custom-visible .update-message.pre-shiny-updates span,.plugin-update-tr.wpmdbpro-custom .update-message.pre-shiny-updates span{display:block}.plugin-update-tr.wpmdbpro-custom-visible .update-message.post-shiny-updates p::before,.plugin-update-tr.wpmdbpro-custom .update-message.post-shiny-updates p::before{position:absolute}.plugin-update-tr.wpmdbpro-custom-visible .update-message.post-shiny-updates p span,.plugin-update-tr.wpmdbpro-custom .update-message.post-shiny-updates p span{margin-left:30px;display:block}.plugins #the-list tr.wpmdbpro-has-message td,.plugins #the-list tr.wpmdbpro-has-message th{box-shadow:none;-webkit-box-shadow:none}
|
||||
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/css/styles.css
vendored
Normal file
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/css/styles.css
vendored
Normal file
File diff suppressed because one or more lines are too long
8
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/icon-cli.svg
vendored
Normal file
8
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/icon-cli.svg
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="412px" height="365px" viewBox="0 0 412 365" enable-background="new 0 0 412 365" xml:space="preserve">
|
||||
<path id="window-command-icon" fill="#dddddd" d="M0,0v365h412V0H0z M362,315H50V97h312V315z M191.458,206.895l-75.999,76.397
|
||||
L87.998,255.96l48.801-49.065L87.93,157.761l27.461-27.329L191.458,206.895z M326,244.027H212.5v38H326V244.027z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 721 B |
13
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/icon-media-files.svg
vendored
Normal file
13
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/icon-media-files.svg
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="412px" height="318.25px" viewBox="0 0 412 318.25" enable-background="new 0 0 412 318.25" xml:space="preserve">
|
||||
<path id="photo-camera-4-icon" fill="#FFFFFF" d="M289.652,180.604c0,29.392-23.909,53.3-53.3,53.3
|
||||
c-29.39,0-53.297-23.908-53.297-53.3c0-29.389,23.909-53.296,53.297-53.296C265.742,127.307,289.652,151.215,289.652,180.604z
|
||||
M412,51.25v267H0v-267h113.219c11.253,0,21.56-6.297,26.694-16.31L157.832,0h153.665l19.819,35.785
|
||||
c5.284,9.543,15.335,15.465,26.242,15.465H412z M104.831,109.5c0-11.322-9.178-20.5-20.5-20.5c-11.322,0-20.5,9.178-20.5,20.5
|
||||
s9.178,20.5,20.5,20.5C95.653,130,104.831,120.822,104.831,109.5z M335.5,180.604c0-54.667-44.477-96.854-99.146-96.854
|
||||
c-54.667,0-99.146,42.185-99.146,96.854c0,54.671,44.477,99.146,99.146,99.146C291.023,279.75,335.5,235.273,335.5,180.604z
|
||||
M92.331,7.75h-65.5v27h65.5V7.75z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
28
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/icon-multisite-tools.svg
vendored
Normal file
28
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/icon-multisite-tools.svg
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="14em" height="15em" viewBox="64.684 51 382.628 410" enable-background="new 64.684 51 382.628 410"
|
||||
xml:space="preserve">
|
||||
<path id="network-6-icon" fill="#ffffff" d="M225.741,122.262c-10.096-4.89-19.027-8.84-27.496-12.287C211.636,74.43,230.974,51,256.001,51
|
||||
c24.381,0,43.363,22.232,56.707,56.239c-8.562,3.61-17.354,7.632-27.344,12.62C275.139,93.088,263.473,81,256.001,81
|
||||
C248.31,81,236.177,93.811,225.741,122.262z M256.001,431c-7.471,0-19.135-12.088-29.361-38.859
|
||||
c-10.084,5.035-18.803,9.016-27.346,12.62C212.64,438.767,231.62,461,256.001,461c25.028,0,44.365-23.43,57.758-58.974
|
||||
c-8.438-3.437-17.34-7.367-27.495-12.288C275.827,418.19,263.691,431,256.001,431z M174.112,393.154
|
||||
c-33.35,12.045-83.111,23.779-102.887-5.42c-9.77-14.428-13.416-42.164,24.695-92.377c10.111-13.321,21.816-26.407,33.689-38.418
|
||||
c26.635-26.545,56.641-52.097,95.738-78.553c-18.822-10.192-39.367-19.936-59.412-27.187c-20.52-7.424-38.586-11.535-52.428-11.535
|
||||
c-8.842,0-15.404,1.843-17.553,4.93c-2.285,3.281-2.398,13.373,7.744,31.476c1.201-0.132,2.418-0.206,3.652-0.206
|
||||
c18.225,0,33,14.775,33,33c0,18.227-14.775,33-33,33s-33-14.773-33-33c0-5.902,1.559-11.439,4.273-16.233
|
||||
c-19.311-33.481-15.328-53.631-7.291-65.177c5.648-8.115,17.551-17.789,42.174-17.789c43.723,0,102.635,28.356,140.564,50.322
|
||||
C292.58,136.708,353.492,106,398.49,106c24.723,0,36.639,9.932,42.281,18.264c9.77,14.428,13.416,42.164-24.693,92.377
|
||||
C362.44,287.316,255.792,363.652,174.112,393.154z M392.185,198.504c26.183-34.497,26.984-52.643,23.75-57.418
|
||||
c-2.188-3.232-8.545-5.086-17.44-5.086c-33.951,0-85.664,24.93-115.436,41.803c21.981,14.287,42.518,29.346,61.239,44.701
|
||||
c-7.084,7.058-14.51,13.981-22.102,20.68c-20.783-16.807-43.886-33.264-67.833-48.011c-27.5,17.708-55.186,38.509-80.055,60.672
|
||||
c18.705,16.243,40.973,33.295,64.725,49.076c-9.086,5.654-18.26,11.073-28.729,16.744c-0.004-0.003-0.006-0.005-0.01-0.007
|
||||
c-0.078-0.055-0.154-0.109-0.232-0.164c-19.885-13.854-39.51-29.055-57.662-44.965c-49.02,49.168-62.828,84.795-56.336,94.383
|
||||
c2.189,3.232,8.549,5.088,17.443,5.088c40.871,0,105.748-34.459,144.129-59.173C304.759,286.484,358.495,242.895,392.185,198.504z
|
||||
M433.524,319.63c2.44-4.604,3.829-9.854,3.829-15.432c0-18.226-14.774-33-33-33c-18.225,0-33,14.774-33,33
|
||||
c0,18.227,14.775,33,33,33c1.521,0,3.017-0.112,4.48-0.312c9.611,17.505,9.453,27.296,7.209,30.519
|
||||
c-2.148,3.087-8.709,4.93-17.551,4.93c-27.856,0-66.664-16.141-91.65-28.324c-8.357,5.84-18.73,12.77-28.846,19.122
|
||||
c33.494,17.718,82.752,39.202,120.496,39.202c24.621,0,36.522-9.674,42.172-17.788C448.683,373.029,452.663,352.955,433.524,319.63z
|
||||
"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
BIN
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/mor10.png
vendored
Normal file
BIN
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/mor10.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/mor10@2x.png
vendored
Normal file
BIN
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/mor10@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
BIN
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/welcome.jpg
vendored
Normal file
BIN
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/img/welcome.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
195
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/common-172.js
vendored
Normal file
195
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/common-172.js
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
// global vars
|
||||
var wpmdb = wpmdb || {};
|
||||
wpmdb.common = {
|
||||
hooks: [],
|
||||
call_stack: [],
|
||||
non_fatal_errors: '',
|
||||
migration_error: false
|
||||
};
|
||||
wpmdb.functions = {};
|
||||
|
||||
/**
|
||||
* Toggle proper translated strings based on migration type selected.
|
||||
*
|
||||
* To show the properly translated strings for the selected push or pull
|
||||
* migration type, we need to hide all strings then show the right
|
||||
* translated strings based on the migration type selected.
|
||||
*
|
||||
* @see https://github.com/deliciousbrains/wp-migrate-db-pro/issues/764
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wpmdb_toggle_migration_action_text() {
|
||||
jQuery( '.action-text' ).hide();
|
||||
jQuery( '.action-text.' + jQuery( 'input[name=action]:checked' ).val() ).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the currently selected migration type selected.
|
||||
*
|
||||
* @return string Will return `push`, `pull`, `savefile`, or `` for exporting as a file.
|
||||
*/
|
||||
function wpmdb_migration_type() {
|
||||
var action = jQuery( 'input[name=action]:checked' );
|
||||
if ( 0 === action.length ) {
|
||||
return '';
|
||||
}
|
||||
return action.val();
|
||||
}
|
||||
|
||||
function wpmdb_call_next_hook() {
|
||||
if ( !wpmdb.common.call_stack.length ) {
|
||||
wpmdb.common.call_stack = wpmdb.common.hooks;
|
||||
}
|
||||
|
||||
var func = wpmdb.common.call_stack[ 0 ];
|
||||
wpmdb.common.call_stack.shift();
|
||||
func.call( this );
|
||||
}
|
||||
|
||||
function wpmdb_add_commas( number_string ) {
|
||||
number_string += '';
|
||||
var number_parts = number_string.split( '.' );
|
||||
var integer = number_parts[ 0 ];
|
||||
var decimal = 1 < number_parts.length ? '.' + number_parts[ 1 ] : '';
|
||||
var rgx = /(\d+)(\d{3})/;
|
||||
while ( rgx.test( integer ) ) {
|
||||
integer = integer.replace( rgx, '$1' + ',' + '$2' );
|
||||
}
|
||||
return integer + decimal;
|
||||
}
|
||||
|
||||
function wpmdb_parse_json( maybe_json ) {
|
||||
var json_object = {};
|
||||
try {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global error method for detecting PHP or other errors in AJAX response
|
||||
*
|
||||
* @param title - the error title if not a PHP error
|
||||
* @param code - the error code if not a PHP error
|
||||
* @param text - the AJAX response text to sniff for errors
|
||||
* @param jqXHR - optional AJAX object used to enrich the error message
|
||||
*
|
||||
* @returns {string} - html error string with view error toggle element
|
||||
*/
|
||||
function wpmdbGetAjaxErrors( title, code, text, jqXHR ) {
|
||||
var jsonErrors = false;
|
||||
var html = '';
|
||||
|
||||
var validJson = wpmdb_parse_json( text );
|
||||
if ( false === validJson ) {
|
||||
jsonErrors = true;
|
||||
title = wpmdb_strings.ajax_json_message;
|
||||
code = '(#144)';
|
||||
var originalText = text;
|
||||
text = wpmdb_strings.ajax_json_errors + ' ' + code;
|
||||
text += '<br><a class="show-errors-toggle" href="#">' + wpmdb_strings.view_error_messages + '</a> ';
|
||||
text += '<div class="migration-php-errors">' + originalText + '</div>';
|
||||
}
|
||||
|
||||
// Only add local connection issue if php errors (#144) or jqXHR has been provided
|
||||
if ( jsonErrors || 'undefined' !== jqXHR ) {
|
||||
html += '<strong>' + title + '</strong>' + ' — ';
|
||||
}
|
||||
|
||||
// Only add extra error details if not php errors (#144) and jqXHR has been provided
|
||||
if ( !jsonErrors && 'undefined' !== jqXHR ) {
|
||||
html += wpmdb_strings.status + ': ' + jqXHR.status + ' ' + jqXHR.statusText;
|
||||
html += '<br /><br />' + wpmdb_strings.response + ':<br />';
|
||||
}
|
||||
|
||||
// Add code to the end of the error text if not json errors
|
||||
if ( !jsonErrors ) {
|
||||
text += ' ' + code;
|
||||
}
|
||||
|
||||
// Finally add the error message to the output
|
||||
html += text;
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
wpmdb.preg_quote = function( str, delimiter ) {
|
||||
|
||||
// discuss at: http://phpjs.org/functions/preg_quote/
|
||||
// original by: booeyOH
|
||||
// improved by: Ates Goral (http://magnetiq.com)
|
||||
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// improved by: Brett Zamir (http://brett-zamir.me)
|
||||
// bugfixed by: Onno Marsman
|
||||
// example 1: preg_quote("$40");
|
||||
// returns 1: '\\$40'
|
||||
// example 2: preg_quote("*RRRING* Hello?");
|
||||
// returns 2: '\\*RRRING\\* Hello\\?'
|
||||
// example 3: preg_quote("\\.+*?[^]$(){}=!<>|:");
|
||||
// returns 3: '\\\\\\.\\+\\*\\?\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:'
|
||||
|
||||
return String( str )
|
||||
.replace( new RegExp( '[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + ( delimiter || '' ) + '-]', 'g' ), '\\$&' );
|
||||
};
|
||||
|
||||
wpmdb.table_is = function( table_prefix, desired_table, given_table ) {
|
||||
if ( ( table_prefix + desired_table ).toLowerCase() === given_table.toLowerCase() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var escaped_given_table = wpmdb.preg_quote( given_table );
|
||||
var regex = new RegExp( table_prefix + '([0-9]+)_' + desired_table, 'i' );
|
||||
var results = regex.exec( escaped_given_table );
|
||||
return null != results;
|
||||
};
|
||||
|
||||
wpmdb.subsite_for_table = function( table_prefix, table_name ) {
|
||||
var escaped_table_name = wpmdb.preg_quote( table_name );
|
||||
var regex = new RegExp( table_prefix + '([0-9]+)_', 'i' );
|
||||
var results = regex.exec( escaped_table_name );
|
||||
|
||||
if ( null === results ) {
|
||||
return 1;
|
||||
} else {
|
||||
return results[ 1 ];
|
||||
}
|
||||
};
|
||||
|
||||
wpmdb.functions.convertKBSizeToHR = function( size, dec, kbSize, retArray ) {
|
||||
var retVal, units;
|
||||
kbSize = kbSize || 1000;
|
||||
dec = dec || 2;
|
||||
size = parseInt( size );
|
||||
|
||||
if ( kbSize > Math.abs( size ) ) {
|
||||
retVal = [ size.toFixed( 0 ), 'KB' ];
|
||||
} else {
|
||||
units = [ 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ];
|
||||
var u = -1;
|
||||
do {
|
||||
size /= kbSize;
|
||||
++u;
|
||||
} while ( Math.abs( size ) >= kbSize && u < units.length - 1 );
|
||||
retVal = [ Math.round( size * Math.pow( 10, dec ) ) / Math.pow( 10, dec ), units[ u ] ];
|
||||
}
|
||||
|
||||
if ( ! retArray ) {
|
||||
retVal = retVal[0] + ' ' + retVal[1];
|
||||
}
|
||||
return retVal;
|
||||
};
|
||||
|
||||
wpmdb.functions.convertKBSizeToHRFixed = function( size, dec, kbSize ) {
|
||||
dec = dec || 2;
|
||||
var hrSizeArray = wpmdb.functions.convertKBSizeToHR( size, dec, kbSize, true );
|
||||
if ( 'KB' !== hrSizeArray[1] ) {
|
||||
return hrSizeArray[ 0 ].toFixed( 2 ) + ' ' + hrSizeArray[ 1 ];
|
||||
}
|
||||
return hrSizeArray[ 0 ] + ' ' + hrSizeArray[ 1 ];
|
||||
};
|
||||
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/common-172.min.js
vendored
Normal file
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/common-172.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
function wpmdb_toggle_migration_action_text(){jQuery(".action-text").hide(),jQuery(".action-text."+jQuery("input[name=action]:checked").val()).show()}function wpmdb_migration_type(){var a=jQuery("input[name=action]:checked");return 0===a.length?"":a.val()}function wpmdb_call_next_hook(){wpmdb.common.call_stack.length||(wpmdb.common.call_stack=wpmdb.common.hooks);var a=wpmdb.common.call_stack[0];wpmdb.common.call_stack.shift(),a.call(this)}function wpmdb_add_commas(a){a+="";for(var b=a.split("."),c=b[0],d=1<b.length?"."+b[1]:"",e=/(\d+)(\d{3})/;e.test(c);)c=c.replace(e,"$1,$2");return c+d}function wpmdb_parse_json(a){var b={};try{b=jQuery.parseJSON(a)}catch(a){return!1}return b}function wpmdbGetAjaxErrors(a,b,c,d){var e=!1,f="",g=wpmdb_parse_json(c);if(!1===g){e=!0,a=wpmdb_strings.ajax_json_message,b="(#144)";var h=c;c=wpmdb_strings.ajax_json_errors+" "+b,c+='<br><a class="show-errors-toggle" href="#">'+wpmdb_strings.view_error_messages+"</a> ",c+='<div class="migration-php-errors">'+h+"</div>"}return(e||"undefined"!==d)&&(f+="<strong>"+a+"</strong> — "),e||"undefined"===d||(f+=wpmdb_strings.status+": "+d.status+" "+d.statusText,f+="<br /><br />"+wpmdb_strings.response+":<br />"),e||(c+=" "+b),f+=c}var wpmdb=wpmdb||{};wpmdb.common={hooks:[],call_stack:[],non_fatal_errors:"",migration_error:!1},wpmdb.functions={},wpmdb.preg_quote=function(a,b){return String(a).replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\"+(b||"")+"-]","g"),"\\$&")},wpmdb.table_is=function(a,b,c){if((a+b).toLowerCase()===c.toLowerCase())return!0;var d=wpmdb.preg_quote(c),e=new RegExp(a+"([0-9]+)_"+b,"i"),f=e.exec(d);return null!=f},wpmdb.subsite_for_table=function(a,b){var c=wpmdb.preg_quote(b),d=new RegExp(a+"([0-9]+)_","i"),e=d.exec(c);return null===e?1:e[1]},wpmdb.functions.convertKBSizeToHR=function(a,b,c,d){var e,f;if(c=c||1e3,b=b||2,a=parseInt(a),c>Math.abs(a))e=[a.toFixed(0),"KB"];else{f=["MB","GB","TB","PB","EB","ZB","YB"];var g=-1;do a/=c,++g;while(Math.abs(a)>=c&&g<f.length-1);e=[Math.round(a*Math.pow(10,b))/Math.pow(10,b),f[g]]}return d||(e=e[0]+" "+e[1]),e},wpmdb.functions.convertKBSizeToHRFixed=function(a,b,c){b=b||2;var d=wpmdb.functions.convertKBSizeToHR(a,b,c,!0);return"KB"!==d[1]?d[0].toFixed(2)+" "+d[1]:d[0]+" "+d[1]};
|
||||
64
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/hook-172.js
vendored
Normal file
64
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/hook-172.js
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
(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; 0 < i; i-- ) {
|
||||
if ( undefined === tag || tag === hooks[i].tag ) {
|
||||
hooks.splice( i, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})( jQuery );
|
||||
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/hook-172.min.js
vendored
Normal file
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/hook-172.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a){a.wpmdb={hooks:{action:{},filter:{}},add_action:function(a,b,c){jQuery.wpmdb.add_hook("action",a,b,c)},add_filter:function(a,b,c){jQuery.wpmdb.add_hook("filter",a,b,c)},do_action:function(a,b){jQuery.wpmdb.do_hook("action",a,null,b)},apply_filters:function(a,b,c){return jQuery.wpmdb.do_hook("filter",a,b,c)},remove_action:function(a,b){jQuery.wpmdb.remove_hook("action",a,b)},remove_filter:function(a,b){jQuery.wpmdb.remove_hook("filter",a,b)},add_hook:function(a,b,c,d){void 0===jQuery.wpmdb.hooks[a][b]&&(jQuery.wpmdb.hooks[a][b]=[]);var e=jQuery.wpmdb.hooks[a][b];void 0===d&&(d=b+"_"+e.length),jQuery.wpmdb.hooks[a][b].push({tag:d,callable:c})},do_hook:function(a,b,c,d){if(void 0!==jQuery.wpmdb.hooks[a][b])for(var e=jQuery.wpmdb.hooks[a][b],f=0;f<e.length;f++)"action"===a?e[f].callable(d):c=e[f].callable(c,d);if("filter"===a)return c},remove_hook:function(a,b,c){if(void 0!==jQuery.wpmdb.hooks[a][b])for(var d=jQuery.wpmdb.hooks[a][b],e=d.length-1;0<e;e--)void 0!==c&&c!==d[e].tag||d.splice(e,1)}}}(jQuery);
|
||||
34
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/multisite-172.js
vendored
Normal file
34
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/multisite-172.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
var wpmdb = wpmdb || {};
|
||||
|
||||
wpmdb.multisite = {};
|
||||
|
||||
(function( $, wpmdb ) {
|
||||
wpmdb.multisite.update_multiselect = function( element, subsites, selected_subsite_ids ) {
|
||||
$( element ).empty();
|
||||
|
||||
if ( 0 < Object.keys( subsites ).length ) {
|
||||
var table_prefix = $.wpmdb.apply_filters( 'wpmdb_get_table_prefix', null, null );
|
||||
var site_selected = false;
|
||||
$.each( subsites, function( blog_id, subsite_path ) {
|
||||
if ( $.wpmdb.apply_filters( 'wpmdb_exclude_subsite', false, blog_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = ' ';
|
||||
if ( ( undefined === selected_subsite_ids || null === selected_subsite_ids || 0 === selected_subsite_ids.length ) ||
|
||||
( undefined !== selected_subsite_ids && null !== selected_subsite_ids && 0 < selected_subsite_ids.length && -1 !== $.inArray( blog_id, selected_subsite_ids ) )
|
||||
) {
|
||||
selected = ' selected="selected" ';
|
||||
site_selected = true;
|
||||
}
|
||||
subsite_path += ' (' + table_prefix + ( ( '1' !== blog_id ) ? blog_id + '_' : '' ) + ')';
|
||||
$( element ).append( '<option' + selected + 'value="' + blog_id + '">' + subsite_path + '</option>' );
|
||||
} );
|
||||
|
||||
// If nothing selected (maybe IDs differ between saved profile and current config) revert to default of all selected.
|
||||
if ( false === site_selected ) {
|
||||
wpmdb.multisite.update_multiselect( element, subsites, [] );
|
||||
}
|
||||
}
|
||||
};
|
||||
})( jQuery, wpmdb );
|
||||
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/multisite-172.min.js
vendored
Normal file
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/multisite-172.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var wpmdb=wpmdb||{};wpmdb.multisite={},function(a,b){b.multisite.update_multiselect=function(c,d,e){if(a(c).empty(),0<Object.keys(d).length){var f=a.wpmdb.apply_filters("wpmdb_get_table_prefix",null,null),g=!1;a.each(d,function(b,d){if(!a.wpmdb.apply_filters("wpmdb_exclude_subsite",!1,b)){var h=" ";(void 0===e||null===e||0===e.length||void 0!==e&&null!==e&&0<e.length&&-1!==a.inArray(b,e))&&(h=' selected="selected" ',g=!0),d+=" ("+f+("1"!==b?b+"_":"")+")",a(c).append("<option"+h+'value="'+b+'">'+d+"</option>")}}),!1===g&&b.multisite.update_multiselect(c,d,[])}}}(jQuery,wpmdb);
|
||||
83
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/plugin-update-172.js
vendored
Normal file
83
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/plugin-update-172.js
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
(function( $ ) {
|
||||
|
||||
var doing_check_licence = false;
|
||||
var fade_duration = 650;
|
||||
|
||||
var admin_url = ajaxurl.replace( '/admin-ajax.php', '' );
|
||||
var spinner_url = admin_url + '/images/spinner';
|
||||
var spinner;
|
||||
if ( 2 < window.devicePixelRatio ) {
|
||||
spinner_url += '-2x';
|
||||
}
|
||||
spinner_url += '.gif';
|
||||
spinner = $( '<img src="' + spinner_url + '" alt="" class="check-licence-spinner" />' );
|
||||
|
||||
$( document ).ready( function() {
|
||||
|
||||
$( 'body' ).on( 'click', '.check-my-licence-again', function( e ) {
|
||||
e.preventDefault();
|
||||
$( this ).blur();
|
||||
|
||||
if ( doing_check_licence ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
doing_check_licence = true;
|
||||
|
||||
$( this ).hide();
|
||||
spinner.insertAfter( this );
|
||||
|
||||
var check_again_link = ' <a class="check-my-licence-again" href="#">' + wpmdb_update_strings.check_license_again + '</a>';
|
||||
|
||||
$.ajax( {
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
data: {
|
||||
action: 'wpmdb_check_licence',
|
||||
nonce: wpmdb_nonces.check_licence,
|
||||
context: 'update'
|
||||
},
|
||||
error: function( jqXHR, textStatus, errorThrown ) {
|
||||
doing_check_licence = false;
|
||||
$( '.wpmdb-licence-error-notice' ).fadeOut( fade_duration, function() {
|
||||
$( '.wpmdb-licence-error-notice' ).empty()
|
||||
.html( wpmdb_update_strings.license_check_problem + check_again_link )
|
||||
.fadeIn( fade_duration );
|
||||
} );
|
||||
},
|
||||
success: function( data ) {
|
||||
doing_check_licence = false;
|
||||
if ( 'undefined' !== typeof data.errors ) {
|
||||
var msg = '';
|
||||
for ( var key in data.errors ) {
|
||||
msg += data.errors[ key ];
|
||||
}
|
||||
$( '.wpmdb-licence-error-notice' ).fadeOut( fade_duration, function() {
|
||||
$( '.check-licence-spinner' ).remove();
|
||||
$( '.wpmdb-licence-error-notice' ).empty()
|
||||
.html( msg )
|
||||
.fadeIn( fade_duration );
|
||||
} );
|
||||
} else {
|
||||
|
||||
// Success
|
||||
// Fade out, empty wpmdb custom error content, swap back in the original wordpress upgrade message, fade in
|
||||
$( '.wpmdbpro-custom-visible' ).fadeOut( fade_duration, function() {
|
||||
$( '.check-licence-spinner' ).remove();
|
||||
$( '.wpmdbpro-custom-visible' ).empty()
|
||||
.html( $( '.wpmdb-original-update-row' ).html() )
|
||||
.fadeIn( fade_duration );
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
$( '.wpmdbpro-custom' ).prev().addClass( 'wpmdbpro-has-message' );
|
||||
|
||||
} );
|
||||
|
||||
})( jQuery );
|
||||
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/plugin-update-172.min.js
vendored
Normal file
1
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/plugin-update-172.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(a){var b,c=!1,d=650,e=ajaxurl.replace("/admin-ajax.php",""),f=e+"/images/spinner";2<window.devicePixelRatio&&(f+="-2x"),f+=".gif",b=a('<img src="'+f+'" alt="" class="check-licence-spinner" />'),a(document).ready(function(){a("body").on("click",".check-my-licence-again",function(e){if(e.preventDefault(),a(this).blur(),c)return!1;c=!0,a(this).hide(),b.insertAfter(this);var f=' <a class="check-my-licence-again" href="#">'+wpmdb_update_strings.check_license_again+"</a>";a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_check_licence",nonce:wpmdb_nonces.check_licence,context:"update"},error:function(b,e,g){c=!1,a(".wpmdb-licence-error-notice").fadeOut(d,function(){a(".wpmdb-licence-error-notice").empty().html(wpmdb_update_strings.license_check_problem+f).fadeIn(d)})},success:function(b){if(c=!1,"undefined"!=typeof b.errors){var e="";for(var f in b.errors)e+=b.errors[f];a(".wpmdb-licence-error-notice").fadeOut(d,function(){a(".check-licence-spinner").remove(),a(".wpmdb-licence-error-notice").empty().html(e).fadeIn(d)})}else a(".wpmdbpro-custom-visible").fadeOut(d,function(){a(".check-licence-spinner").remove(),a(".wpmdbpro-custom-visible").empty().html(a(".wpmdb-original-update-row").html()).fadeIn(d)})}})}),a(".wpmdbpro-custom").prev().addClass("wpmdbpro-has-message")})}(jQuery);
|
||||
4049
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/script-172.js
vendored
Normal file
4049
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/script-172.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/script-172.min.js
vendored
Normal file
3
wordpress/wp-content/plugins/wp-migrate-db-pro/asset/dist/js/script-172.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2061
wordpress/wp-content/plugins/wp-migrate-db-pro/class/wpmdb-base.php
Normal file
2061
wordpress/wp-content/plugins/wp-migrate-db-pro/class/wpmdb-base.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,702 @@
|
||||
<?php
|
||||
|
||||
class WPMDB_CLI extends WPMDB_Base {
|
||||
|
||||
/**
|
||||
* Instance of WPMDB.
|
||||
*
|
||||
* @var WPMDB
|
||||
*/
|
||||
protected $wpmdb;
|
||||
|
||||
/**
|
||||
* Migration profile.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $profile;
|
||||
|
||||
/**
|
||||
* Data to post during migration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $post_data = array();
|
||||
|
||||
/**
|
||||
* Required PHP version
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $php_version_required;
|
||||
|
||||
/**
|
||||
* Migration Data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $migration;
|
||||
|
||||
function __construct( $plugin_file_path ) {
|
||||
parent::__construct( $plugin_file_path );
|
||||
|
||||
if ( ! version_compare( PHP_VERSION, $this->php_version_required, '>=' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wpmdb;
|
||||
$this->wpmdb = $wpmdb;
|
||||
|
||||
add_filter( 'wpmdb_cli_finalize_migration_response', array( $this, 'finalize_ajax' ), 10, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks profile data before CLI migration.
|
||||
*
|
||||
* @param int|array $profile Profile key or array.
|
||||
*
|
||||
* @return mixed|WP_Error
|
||||
*/
|
||||
public function pre_cli_migration_check( $profile ) {
|
||||
if ( ! version_compare( PHP_VERSION, $this->php_version_required, '>=' ) ) {
|
||||
return $this->cli_error( sprintf( __( 'CLI addon requires PHP %1$s+', 'wp-migrate-db-cli' ), $this->php_version_required ) );
|
||||
}
|
||||
|
||||
if ( is_array( $profile ) ) {
|
||||
$query_str = http_build_query( $profile );
|
||||
$profile = $this->wpmdb->parse_migration_form_data( $query_str );
|
||||
$profile = wp_parse_args( $profile, array(
|
||||
'save_computer' => '0',
|
||||
'gzip_file' => '0',
|
||||
'replace_guids' => '0',
|
||||
'exclude_transients' => '0',
|
||||
'exclude_spam' => '0',
|
||||
'keep_active_plugins' => '0',
|
||||
'compatibility_older_mysql' => '0',
|
||||
) );
|
||||
}
|
||||
|
||||
$this->profile = $profile = apply_filters( 'wpmdb_cli_profile_before_migration', $profile );
|
||||
|
||||
if ( is_wp_error( $profile ) ) {
|
||||
return $profile;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs CLI migration given a profile data.
|
||||
*
|
||||
* @param int|array $profile Profile key or array.
|
||||
*
|
||||
* @return bool|WP_Error Returns true if succeed or WP_Error if failed.
|
||||
*/
|
||||
public function cli_migration( $profile ) {
|
||||
$pre_check = $this->pre_cli_migration_check( $profile );
|
||||
if ( is_wp_error( $pre_check ) ) {
|
||||
return $pre_check;
|
||||
}
|
||||
|
||||
// At this point, $profile has been checked a retrieved into $this->profile, so should not be used in this function any further.
|
||||
if ( empty( $this->profile ) ) {
|
||||
return $this->cli_error( __( 'Profile not found or unable to be generated from params.', 'wp-migrate-db-cli' ) );
|
||||
}
|
||||
unset( $profile );
|
||||
|
||||
$this->set_time_limit();
|
||||
$this->wpmdb->set_cli_migration();
|
||||
|
||||
if ( 'savefile' === $this->profile['action'] ) {
|
||||
$this->post_data['intent'] = 'savefile';
|
||||
if ( ! empty( $this->profile['export_dest'] ) ) {
|
||||
$this->post_data['export_dest'] = $this->profile['export_dest'];
|
||||
} else {
|
||||
$this->post_data['export_dest'] = 'ORIGIN';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'find_replace' === $this->profile['action'] ) {
|
||||
$this->post_data['intent'] = 'find_replace';
|
||||
}
|
||||
|
||||
// Ensure local site_details available.
|
||||
$this->post_data['site_details']['local'] = $this->site_details();
|
||||
|
||||
// Check for tables specified in migration profile that do not exist in the source database
|
||||
if ( ! empty( $this->profile['select_tables'] ) ) {
|
||||
$source_tables = apply_filters( 'wpmdb_cli_filter_source_tables', $this->get_tables() );
|
||||
|
||||
if ( ! empty( $source_tables ) ) {
|
||||
// Return error if selected tables do not exist in source database
|
||||
$nonexistent_tables = array();
|
||||
foreach ( $this->profile['select_tables'] as $table ) {
|
||||
if ( ! in_array( $table, $source_tables ) ) {
|
||||
$nonexistent_tables[] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $nonexistent_tables ) ) {
|
||||
$local_or_remote = ( 'pull' === $this->profile['action'] ) ? 'remote' : 'local';
|
||||
|
||||
return $this->cli_error( sprintf( __( 'The following table(s) do not exist in the %1$s database: %2$s', 'wp-migrate-db-cli' ), $local_or_remote, implode( ', ', $nonexistent_tables ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->profile = apply_filters( 'wpmdb_cli_filter_before_cli_initiate_migration', $this->profile );
|
||||
if ( is_wp_error( $this->profile ) ) {
|
||||
return $this->profile;
|
||||
}
|
||||
|
||||
do_action( 'wpmdb_cli_before_migration', $this->post_data, $this->profile );
|
||||
$this->migration = $this->cli_initiate_migration();
|
||||
|
||||
if ( is_wp_error( $this->migration ) ) {
|
||||
return $this->migration;
|
||||
}
|
||||
|
||||
$this->post_data['migration_state_id'] = $this->migration['migration_state_id'];
|
||||
|
||||
$tables_to_process = $this->migrate_tables();
|
||||
if ( is_wp_error( $tables_to_process ) ) {
|
||||
return $tables_to_process;
|
||||
}
|
||||
|
||||
$this->post_data['tables'] = implode( ',', $tables_to_process );
|
||||
|
||||
$finalize = $this->finalize_migration();
|
||||
if ( is_wp_error( $finalize ) || 'savefile' === $this->profile['action'] ) {
|
||||
return $finalize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify CLI response from endpoint.
|
||||
*
|
||||
* @param string $response Response from endpoint.
|
||||
* @param string $function_name Name of called function.
|
||||
*
|
||||
* @return WP_Error|string
|
||||
*/
|
||||
function verify_cli_response( $response, $function_name ) {
|
||||
$response = trim( $response );
|
||||
if ( false === $response ) {
|
||||
return $this->cli_error( $this->error );
|
||||
}
|
||||
|
||||
if ( false === $this->wpmdb->is_json( $response ) ) {
|
||||
return $this->cli_error( sprintf( __( 'We were expecting a JSON response, instead we received: %2$s (function name: %1$s)', 'wp-migrate-db-cli' ), $function_name, $response ) );
|
||||
}
|
||||
|
||||
$response = json_decode( $response, true );
|
||||
if ( isset( $response['wpmdb_error'] ) ) {
|
||||
return $this->cli_error( $response['body'] );
|
||||
}
|
||||
|
||||
// Display warnings and non fatal error messages as CLI warnings without aborting.
|
||||
if ( isset( $response['wpmdb_warning'] ) || isset( $response['wpmdb_non_fatal_error'] ) ) {
|
||||
$body = ( isset ( $response['cli_body'] ) ) ? $response['cli_body'] : $response['body'];
|
||||
$messages = maybe_unserialize( $body );
|
||||
foreach ( ( array ) $messages as $message ) {
|
||||
if ( $message ) {
|
||||
WP_CLI::warning( self::cleanup_message( $message ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return instance of WP_Error.
|
||||
*
|
||||
* @param string $message Error message.
|
||||
*
|
||||
* @return WP_Error.
|
||||
*/
|
||||
function cli_error( $message ) {
|
||||
return new WP_Error( 'wpmdb_cli_error', self::cleanup_message( $message ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup message, replacing <br> with \n and removing HTML.
|
||||
*
|
||||
* @param string $message Error message.
|
||||
*
|
||||
* @return string $message.
|
||||
*/
|
||||
static function cleanup_message( $message ) {
|
||||
$message = html_entity_decode( $message, ENT_QUOTES );
|
||||
$message = preg_replace( '#<br\s*/?>#', "\n", $message );
|
||||
$message = trim( strip_tags( $message ) );
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates migration and verifies result
|
||||
*
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
function cli_initiate_migration() {
|
||||
do_action( 'wpmdb_cli_before_initiate_migration', $this->profile );
|
||||
|
||||
WP_CLI::log( __( 'Initiating migration...', 'wp-migrate-db-cli' ) );
|
||||
|
||||
$migration_args = $this->post_data;
|
||||
$migration_args['form_data'] = http_build_query( $this->profile );
|
||||
$migration_args['stage'] = 'migrate';
|
||||
$migration_args['site_details']['local'] = $this->site_details();
|
||||
|
||||
if ( 'find_replace' === $this->profile['action'] ) {
|
||||
$migration_args['stage'] = 'find_replace';
|
||||
|
||||
}
|
||||
|
||||
$this->post_data = apply_filters( 'wpmdb_cli_initiate_migration_args', $migration_args, $this->profile );
|
||||
|
||||
$this->post_data['site_details'] = json_encode( $this->post_data['site_details'] );
|
||||
|
||||
$response = $this->initiate_migration( $this->post_data );
|
||||
|
||||
$initiate_migration_response = $this->verify_cli_response( $response, 'initiate_migration()' );
|
||||
if ( ! is_wp_error( $initiate_migration_response ) ) {
|
||||
$initiate_migration_response = apply_filters( 'wpmdb_cli_initiate_migration_response', $initiate_migration_response );
|
||||
}
|
||||
|
||||
return $initiate_migration_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine which tables to migrate
|
||||
*
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
function get_tables_to_migrate() {
|
||||
$tables_to_migrate = $this->get_tables( 'prefix' );
|
||||
|
||||
return apply_filters( 'wpmdb_cli_tables_to_migrate', $tables_to_migrate, $this->profile, $this->migration );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a WP-CLI progress bar instance
|
||||
*
|
||||
* @param array $tables
|
||||
* @param int $stage
|
||||
*
|
||||
* @return \cli\progress\Bar
|
||||
*/
|
||||
function get_progress_bar( $tables, $stage ) {
|
||||
|
||||
$progress_label = __( 'Exporting tables', 'wp-migrate-db-cli' );
|
||||
|
||||
if ( 'find_replace' === $this->profile['action'] ) {
|
||||
$progress_label = __( 'Running find & replace', 'wp-migrate-db-cli' );
|
||||
}
|
||||
|
||||
$progress_label = apply_filters( 'wpmdb_cli_progress_label', $progress_label, $stage, $tables );
|
||||
|
||||
$progress_label = str_pad( $progress_label, 20, ' ' );
|
||||
|
||||
$count = $this->get_total_rows_from_table_list( $tables, $stage );
|
||||
|
||||
return new \cli\progress\Bar( $progress_label, $count );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns total rows from list of tables
|
||||
*
|
||||
* @param array $tables
|
||||
* @param int $stage
|
||||
*
|
||||
* @return Int
|
||||
*/
|
||||
function get_total_rows_from_table_list( $tables, $stage ) {
|
||||
static $cached_results = array();
|
||||
|
||||
if ( isset( $cached_results[ $stage ] ) ) {
|
||||
return $cached_results[ $stage ];
|
||||
}
|
||||
|
||||
$table_rows = $this->get_row_counts_from_table_list( $tables, $stage );
|
||||
$cached_results[ $stage ] = array_sum( array_intersect_key( $table_rows, array_flip( $tables ) ) );
|
||||
|
||||
return $cached_results[ $stage ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns row counts from list of tables
|
||||
*
|
||||
* @param array $tables
|
||||
* @param int $stage
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function get_row_counts_from_table_list( $tables, $stage ) {
|
||||
static $cached_results = array();
|
||||
|
||||
if ( isset( $cached_results[ $stage ] ) ) {
|
||||
return $cached_results[ $stage ];
|
||||
}
|
||||
|
||||
$local_table_rows = $this->wpmdb->get_table_row_count();
|
||||
$cached_results[ $stage ] = apply_filters( 'wpmdb_cli_get_row_counts_from_table_list', $local_table_rows, $stage );
|
||||
|
||||
return $cached_results[ $stage ];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed|string|void|WP_Error
|
||||
*/
|
||||
function migrate_tables() {
|
||||
$tables_to_migrate = $this->get_tables_to_migrate();
|
||||
|
||||
$tables = $tables_to_migrate;
|
||||
$stage_iterator = 2;
|
||||
|
||||
$filtered_vars = apply_filters( 'wpmdb_cli_filter_before_migrate_tables', array(
|
||||
'tables' => $tables,
|
||||
'stage_iterator' => $stage_iterator,
|
||||
) );
|
||||
if ( ! is_array( $filtered_vars ) ) {
|
||||
return $filtered_vars;
|
||||
} else {
|
||||
extract( $filtered_vars, EXTR_OVERWRITE );
|
||||
}
|
||||
|
||||
if ( empty( $tables ) ) {
|
||||
return $this->cli_error( __( 'No tables selected for migration.', 'wp-migrate-db' ) );
|
||||
}
|
||||
|
||||
$table_rows = $this->get_row_counts_from_table_list( $tables, $stage_iterator );
|
||||
|
||||
do_action( 'wpmdb_cli_before_migrate_tables', $this->profile, $this->migration );
|
||||
|
||||
$notify = $this->get_progress_bar( $tables, $stage_iterator );
|
||||
$args = $this->post_data;
|
||||
|
||||
do {
|
||||
$migration_progress = 0;
|
||||
|
||||
foreach ( $tables as $key => $table ) {
|
||||
$current_row = -1;
|
||||
$primary_keys = '';
|
||||
$table_progress = 0;
|
||||
$table_progress_last = 0;
|
||||
|
||||
$args['table'] = $table;
|
||||
$args['last_table'] = ( $key == count( $tables ) - 1 ) ? '1' : '0';
|
||||
|
||||
do {
|
||||
// reset the current chunk
|
||||
$this->wpmdb->empty_current_chunk();
|
||||
|
||||
$args['current_row'] = $current_row;
|
||||
$args['primary_keys'] = $primary_keys;
|
||||
$args = apply_filters( 'wpmdb_cli_migrate_table_args', $args, $this->profile, $this->migration );
|
||||
|
||||
$response = $this->migrate_table( $args );
|
||||
|
||||
$migrate_table_response = $this->verify_cli_response( $response, 'migrate_table()' );
|
||||
|
||||
if ( is_wp_error( $migrate_table_response ) ) {
|
||||
return $migrate_table_response;
|
||||
}
|
||||
|
||||
$migrate_table_response = apply_filters( 'wpmdb_cli_migrate_table_response', $migrate_table_response, $_POST, $this->profile, $this->migration );
|
||||
|
||||
$current_row = $migrate_table_response['current_row'];
|
||||
$primary_keys = $migrate_table_response['primary_keys'];
|
||||
|
||||
$last_migration_progress = $migration_progress;
|
||||
|
||||
if ( -1 == $current_row ) {
|
||||
$migration_progress -= $table_progress;
|
||||
$migration_progress += $table_rows[ $table ];
|
||||
} else {
|
||||
if ( 0 === $table_progress_last ) {
|
||||
$table_progress_last = $current_row;
|
||||
$table_progress = $table_progress_last;
|
||||
$migration_progress += $table_progress_last;
|
||||
} else {
|
||||
$iteration_progress = $current_row - $table_progress_last;
|
||||
$table_progress_last = $current_row;
|
||||
$table_progress += $iteration_progress;
|
||||
$migration_progress += $iteration_progress;
|
||||
}
|
||||
}
|
||||
|
||||
$increment = $migration_progress - $last_migration_progress;
|
||||
|
||||
$notify->tick( $increment );
|
||||
|
||||
} while ( -1 != $current_row );
|
||||
}
|
||||
|
||||
$notify->finish();
|
||||
|
||||
++$stage_iterator;
|
||||
$args['stage'] = 'migrate';
|
||||
$tables = $tables_to_migrate;
|
||||
$table_rows = $this->get_row_counts_from_table_list( $tables, $stage_iterator );
|
||||
|
||||
if ( $stage_iterator < 3 ) {
|
||||
$notify = $this->get_progress_bar( $tables, $stage_iterator );
|
||||
}
|
||||
} while ( $stage_iterator < 3 );
|
||||
|
||||
$this->post_data = $args;
|
||||
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize migration
|
||||
*
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
function finalize_migration() {
|
||||
do_action( 'wpmdb_cli_before_finalize_migration', $this->profile, $this->migration );
|
||||
|
||||
WP_CLI::log( __( 'Cleaning up...', 'wp-migrate-db-cli' ) );
|
||||
|
||||
$finalize = apply_filters( 'wpmdb_cli_finalize_migration', true, $this->profile, $this->migration );
|
||||
if ( is_wp_error( $finalize ) ) {
|
||||
return $finalize;
|
||||
}
|
||||
|
||||
$this->post_data = apply_filters( 'wpmdb_cli_finalize_migration_args', $this->post_data, $this->profile, $this->migration );
|
||||
|
||||
if ( 'savefile' === $this->post_data['intent'] ) {
|
||||
return $this->finalize_export();
|
||||
}
|
||||
|
||||
$response = null;
|
||||
$response = apply_filters( 'wpmdb_cli_finalize_migration_response', $response );
|
||||
if ( ! empty( $response ) && '1' !== $response ) {
|
||||
return $this->cli_error( $response );
|
||||
}
|
||||
|
||||
do_action( 'wpmdb_cli_after_finalize_migration', $this->profile, $this->migration );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub for ajax_initiate_migration()
|
||||
*
|
||||
* @param array|bool $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function initiate_migration( $args = false ) {
|
||||
$_POST = $args;
|
||||
$response = $this->wpmdb->ajax_initiate_migration();
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* stub for ajax_migrate_table()
|
||||
*
|
||||
* @param array|bool $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function migrate_table( $args = false ) {
|
||||
$_POST = $args;
|
||||
$response = $this->wpmdb->ajax_migrate_table();
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub for ajax_finalize_migration()
|
||||
* hooks on: wpmdb_cli_finalize_migration_response
|
||||
*
|
||||
* @param string $response
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function finalize_ajax( $response ) {
|
||||
// don't send redundant POST variables
|
||||
$args = $this->filter_post_elements( $this->post_data, array( 'action', 'migration_state_id', 'prefix', 'tables' ) );
|
||||
$_POST = $args;
|
||||
$response = $this->wpmdb->ajax_finalize_migration();
|
||||
|
||||
return trim( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize Export by moving file to specified destination
|
||||
*
|
||||
* @return string|error
|
||||
*/
|
||||
function finalize_export() {
|
||||
$state_data = $this->wpmdb->state_data;
|
||||
$temp_file = $state_data['dump_path'];
|
||||
if ( 'ORIGIN' === $state_data['export_dest'] ) {
|
||||
$response = $temp_file;
|
||||
} else {
|
||||
$dest_file = $state_data['export_dest'];
|
||||
if ( file_exists( $temp_file ) && rename( $temp_file, $dest_file ) ) {
|
||||
$response = $dest_file;
|
||||
} else {
|
||||
$response = $this->cli_error( __( 'Unable to move exported file.', 'wp-migrate-db' ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
/**
|
||||
* Returns array of CLI options that are unknown to plugin and addons.
|
||||
*
|
||||
* @param array $assoc_args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_unknown_args( $assoc_args = array() ) {
|
||||
$unknown_args = array();
|
||||
|
||||
if ( empty( $assoc_args ) ) {
|
||||
return $unknown_args;
|
||||
}
|
||||
|
||||
$known_args = array(
|
||||
'action',
|
||||
'export_dest',
|
||||
'find',
|
||||
'replace',
|
||||
'exclude-spam',
|
||||
'gzip-file',
|
||||
'exclude-post-revisions',
|
||||
'skip-replace-guids',
|
||||
'include-transients',
|
||||
);
|
||||
|
||||
$known_args = apply_filters( 'wpmdb_cli_filter_get_extra_args', $known_args );
|
||||
$unknown_args = array_diff( array_keys( $assoc_args ), $known_args );
|
||||
|
||||
return $unknown_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile data from CLI args.
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $assoc_args
|
||||
*
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
public function get_profile_data_from_args( $args, $assoc_args ) {
|
||||
|
||||
//load correct cli class
|
||||
if ( function_exists( 'wp_migrate_db_pro_cli_addon' ) ) {
|
||||
$wpmdb_cli = wp_migrate_db_pro_cli_addon();
|
||||
} elseif ( function_exists( 'wpmdb_pro_cli' ) ) {
|
||||
$wpmdb_cli = wpmdb_pro_cli();
|
||||
} else {
|
||||
$wpmdb_cli = wpmdb_cli();
|
||||
}
|
||||
|
||||
$unknown_args = $this->get_unknown_args( $assoc_args );
|
||||
|
||||
if ( ! empty( $unknown_args ) ) {
|
||||
$message = __( 'Parameter errors: ', 'wp-migrate-db-cli' );
|
||||
foreach ( $unknown_args as $unknown_arg ) {
|
||||
$message .= "\n " . sprintf( __( 'unknown %s parameter', 'wp-migrate-db-cli' ), '--' . $unknown_arg );
|
||||
}
|
||||
|
||||
if ( is_a( $wpmdb_cli, 'WPMDBPro_CLI' ) ) {
|
||||
$message .= "\n" . __( 'Please make sure that you have activated the appropriate addons for WP Migrate DB Pro.', 'wp-migrate-db-cli' );
|
||||
}
|
||||
|
||||
return $wpmdb_cli->cli_error( $message );
|
||||
}
|
||||
|
||||
if ( empty( $assoc_args['action'] ) ) {
|
||||
return $wpmdb_cli->cli_error( __( 'Missing action parameter', 'wp-migrate-db-cli' ) );
|
||||
}
|
||||
|
||||
if ( 'savefile' === $assoc_args['action'] && ! empty( $assoc_args['export_dest'] ) ) {
|
||||
$export_dest = $assoc_args['export_dest'];
|
||||
}
|
||||
|
||||
$action = $assoc_args['action'];
|
||||
|
||||
// --find=<old> and --replace=<new>
|
||||
$replace_old = array();
|
||||
$replace_new = array();
|
||||
if ( ! empty( $assoc_args['find'] ) ) {
|
||||
$replace_old = str_getcsv( $assoc_args['find'] );
|
||||
} else {
|
||||
if ( 'find_replace' === $assoc_args['action'] ) {
|
||||
return $wpmdb_cli->cli_error( __( 'Missing find and replace values.', 'wp-migrate-db-cli' ) );
|
||||
}
|
||||
}
|
||||
if ( ! empty( $assoc_args['replace'] ) ) {
|
||||
$replace_new = str_getcsv( $assoc_args['replace'] );
|
||||
}
|
||||
if ( count( $replace_old ) !== count( $replace_new ) ) {
|
||||
return $wpmdb_cli->cli_error( sprintf( __( '%1$s and %2$s must contain the same number of values', 'wp-migrate-db-cli' ), '--find', '--replace' ) );
|
||||
}
|
||||
array_unshift( $replace_old, '' );
|
||||
array_unshift( $replace_new, '' );
|
||||
|
||||
// --exclude-spam
|
||||
$exclude_spam = intval( isset( $assoc_args['exclude-spam'] ) );
|
||||
|
||||
// --gzip-file
|
||||
$gzip_file = intval( isset( $assoc_args['gzip-file'] ) );
|
||||
|
||||
$select_post_types = array();
|
||||
|
||||
// --exclude-post-revisions
|
||||
if ( ! empty( $assoc_args['exclude-post-revisions'] ) ) {
|
||||
$select_post_types[] = 'revision';
|
||||
}
|
||||
|
||||
$exclude_post_types = count( $select_post_types ) > 0 ? 1 : 0;
|
||||
|
||||
// --skip-replace-guids
|
||||
$replace_guids = 1;
|
||||
if ( isset( $assoc_args['skip-replace-guids'] ) ) {
|
||||
$replace_guids = 0;
|
||||
}
|
||||
|
||||
$select_tables = array();
|
||||
$table_migrate_option = 'migrate_only_with_prefix';
|
||||
|
||||
// --include-transients.
|
||||
$exclude_transients = intval( ! isset( $assoc_args['include-transients'] ) );
|
||||
|
||||
//cleanup filename for exports
|
||||
if ( ! empty( $export_dest ) ) {
|
||||
if ( $gzip_file ) {
|
||||
if ( 'gz' !== pathinfo( $export_dest, PATHINFO_EXTENSION ) ) {
|
||||
if ( 'sql' === pathinfo( $export_dest, PATHINFO_EXTENSION ) ) {
|
||||
$export_dest .= '.gz';
|
||||
} else {
|
||||
$export_dest .= '.sql.gz';
|
||||
}
|
||||
}
|
||||
} elseif ( 'sql' !== pathinfo( $export_dest, PATHINFO_EXTENSION ) ) {
|
||||
$export_dest = preg_replace( '/(\.sql)?(\.gz)?$/i', '', $export_dest ) . '.sql';
|
||||
}
|
||||
|
||||
// ensure export destination is writable
|
||||
if ( ! @touch( $export_dest ) ) {
|
||||
return $wpmdb_cli->cli_error( sprintf( __( 'Cannot write to file "%1$s". Please ensure that the specified directory exists and is writable.', 'wp-migrate-db-cli' ), $export_dest ) );
|
||||
}
|
||||
}
|
||||
|
||||
$profile = compact( 'action', 'replace_old', 'table_migrate_option', 'replace_new', 'select_tables', 'exclude_post_types', 'select_post_types', 'replace_guids', 'exclude_spam', 'gzip_file', 'exclude_transients', 'export_dest' );
|
||||
|
||||
$profile = apply_filters( 'wpmdb_cli_filter_get_profile_data_from_args', $profile, $args, $assoc_args );
|
||||
|
||||
return $profile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Migrate your DB using WP Migrate DB.
|
||||
*/
|
||||
class WPMDB_Command extends WP_CLI_Command {
|
||||
|
||||
/**
|
||||
* Export local DB to file.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* <output-file>
|
||||
* : A file path to export to. Filename will be modified to end in .sql or
|
||||
* .sql.gz if necessary.
|
||||
*
|
||||
* [--find=<strings>]
|
||||
* : A comma separated list of strings to find when performing a string find
|
||||
* and replace across the database.
|
||||
*
|
||||
* Table names should be quoted as needed, i.e. when using a comma in the
|
||||
* find/replace string.
|
||||
*
|
||||
* The --replace=<strings> argument should be used in conjunction to specify
|
||||
* the replace values for the strings found using this argument. The number
|
||||
* of strings specified in this argument should match the number passed into
|
||||
* --replace=<strings> argument.
|
||||
*
|
||||
* [--replace=<strings>]
|
||||
* : A comma separated list of replace value strings to implement when
|
||||
* performing a string find & replace across the database.
|
||||
*
|
||||
* Should be used in conjunction with the --find=<strings> argument, see it's
|
||||
* documentation for further explanation of the find & replace functionality.
|
||||
*
|
||||
* [--exclude-post-revisions]
|
||||
* : Exclude post revisions from export.
|
||||
*
|
||||
* [--skip-replace-guids]
|
||||
* : Do not perform a find & replace on the guid column in the wp_posts table.
|
||||
*
|
||||
* [--exclude-spam]
|
||||
* : Exclude spam comments.
|
||||
*
|
||||
* [--gzip-file]
|
||||
* : GZip compress export file.
|
||||
*
|
||||
* [--include-transients]
|
||||
* : Include transients (temporary cached data).
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp migratedb export ./migratedb.sql \
|
||||
* --find=http://dev.bradt.ca,/Users/bradt/home/bradt.ca
|
||||
* --replace=http://bradt.ca,/home/bradt.ca
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $assoc_args
|
||||
*/
|
||||
public function export( $args, $assoc_args ) {
|
||||
|
||||
$assoc_args['action'] = 'savefile';
|
||||
$assoc_args['export_dest'] = trim( $args[0] );
|
||||
|
||||
if ( empty( $assoc_args['export_dest'] ) ) {
|
||||
WP_CLI::error( WPMDB_CLI::cleanup_message( __( 'You must provide a destination filename.', 'wp-migrate-db-cli' ) ) );
|
||||
}
|
||||
|
||||
$profile = $this->_get_profile_data_from_args( $args, $assoc_args );
|
||||
|
||||
if ( is_wp_error( $profile ) ) {
|
||||
WP_CLI::error( $profile );
|
||||
}
|
||||
|
||||
$this->_perform_cli_migration( $profile );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a find/replace on the database.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* [--find=<strings>]
|
||||
* : A comma separated list of strings to find when performing a string find
|
||||
* and replace across the database.
|
||||
*
|
||||
* Table names should be quoted as needed, i.e. when using a comma in the
|
||||
* find/replace string.
|
||||
*
|
||||
* The --replace=<strings> argument should be used in conjunction to specify
|
||||
* the replace values for the strings found using this argument. The number
|
||||
* of strings specified in this argument should match the number passed into
|
||||
* --replace=<strings> argument.
|
||||
*
|
||||
* [--replace=<strings>]
|
||||
* : A comma separated list of replace value strings to implement when
|
||||
* performing a string find & replace across the database.
|
||||
*
|
||||
* Should be used in conjunction with the --find=<strings> argument, see it's
|
||||
* documentation for further explanation of the find & replace functionality.
|
||||
*
|
||||
* [--exclude-post-revisions]
|
||||
* : Exclude post revisions from the find & replace.
|
||||
*
|
||||
* [--skip-replace-guids]
|
||||
* : Do not perform a find & replace on the guid column in the wp_posts table.
|
||||
*
|
||||
* [--exclude-spam]
|
||||
* : Exclude spam comments.
|
||||
*
|
||||
* [--include-transients]
|
||||
* : Include transients (temporary cached data).
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp migratedb find-replace
|
||||
* --find=http://dev.bradt.ca,/Users/bradt/home/bradt.ca
|
||||
* --replace=http://bradt.ca,/home/bradt.ca
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $assoc_args
|
||||
*
|
||||
* @subcommand find-replace
|
||||
*/
|
||||
public function find_replace( $args, $assoc_args ) {
|
||||
|
||||
$assoc_args['action'] = 'find_replace';
|
||||
|
||||
$profile = $this->_get_profile_data_from_args( $args, $assoc_args );
|
||||
|
||||
if ( is_wp_error( $profile ) ) {
|
||||
WP_CLI::error( $profile );
|
||||
}
|
||||
|
||||
$this->_perform_cli_migration( $profile );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile data from CLI args.
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $assoc_args
|
||||
*
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
protected function _get_profile_data_from_args( $args, $assoc_args ) {
|
||||
// Load the correct CLI class
|
||||
if ( function_exists( 'wpmdb_pro_cli' ) ) {
|
||||
if ( function_exists( 'wp_migrate_db_pro_cli_addon' ) ) {
|
||||
$wpmdb_cli = wp_migrate_db_pro_cli_addon();
|
||||
} else {
|
||||
$wpmdb_cli = wpmdb_pro_cli();
|
||||
}
|
||||
} else {
|
||||
$wpmdb_cli = wpmdb_cli();
|
||||
}
|
||||
|
||||
return $wpmdb_cli->get_profile_data_from_args( $args, $assoc_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform CLI migration.
|
||||
*
|
||||
* @param mixed $profile Profile key or array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _perform_cli_migration( $profile ) {
|
||||
$wpmdb_cli = null;
|
||||
|
||||
//load correct cli class
|
||||
if ( function_exists( 'wpmdb_pro_cli' ) ) {
|
||||
$wpmdb_cli = wpmdb_pro_cli();
|
||||
} else {
|
||||
$wpmdb_cli = wpmdb_cli();
|
||||
}
|
||||
|
||||
if ( empty( $wpmdb_cli ) ) {
|
||||
WP_CLI::error( __( 'WP Migrate DB CLI class not available.', 'wp-migrate-db-cli' ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$result = $wpmdb_cli->cli_migration( $profile );
|
||||
|
||||
if ( ! is_wp_error( $result ) ) {
|
||||
$success_msg = sprintf( __( 'Export saved to: %s', 'wp-migrate-db-cli' ), $result );
|
||||
|
||||
if ( 'find_replace' === $profile['action'] ) {
|
||||
$success_msg = __( 'Find & Replace complete', 'wp-migrate-db-cli' );
|
||||
}
|
||||
|
||||
WP_CLI::success( $success_msg );
|
||||
} elseif ( is_wp_error( $result ) ) {
|
||||
WP_CLI::error( WPMDB_CLI::cleanup_message( $result->get_error_message() ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WP_CLI::add_command( 'migratedb', 'WPMDB_Command' );
|
||||
@@ -0,0 +1,561 @@
|
||||
<?php
|
||||
|
||||
class WPMDB_Filesystem {
|
||||
|
||||
private $wp_filesystem;
|
||||
private $credentials;
|
||||
private $use_filesystem = false;
|
||||
private $chmod_dir;
|
||||
private $chmod_file;
|
||||
|
||||
/**
|
||||
* Pass `true` when instantiating to skip using WP_Filesystem
|
||||
*
|
||||
* @param bool $force_no_fs
|
||||
*/
|
||||
public function __construct( $force_no_fs = false ) {
|
||||
if ( ! $force_no_fs && function_exists( 'request_filesystem_credentials' ) ) {
|
||||
if ( ( defined( 'WPMDB_WP_FILESYSTEM' ) && WPMDB_WP_FILESYSTEM ) || ! defined( 'WPMDB_WP_FILESYSTEM' ) ) {
|
||||
$this->maybe_init_wp_filesystem();
|
||||
}
|
||||
}
|
||||
|
||||
// Set default permissions
|
||||
if ( defined( 'FS_CHMOD_DIR' ) ) {
|
||||
$this->chmod_dir = FS_CHMOD_DIR;
|
||||
} else {
|
||||
$this->chmod_dir = ( fileperms( ABSPATH ) & 0777 | 0755 );
|
||||
}
|
||||
|
||||
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
||||
$this->chmod_file = FS_CHMOD_FILE;
|
||||
} else {
|
||||
$this->chmod_file = ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the instantiated WP_Filesystem
|
||||
*
|
||||
* @return WP_Filesystem|false
|
||||
*
|
||||
* This should be used carefully since $wp_filesystem won't always have a value.
|
||||
*/
|
||||
public function get_wp_filesystem() {
|
||||
if ( $this->use_filesystem ) {
|
||||
return $this->wp_filesystem;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is WP_Filesystem being used?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function using_wp_filesystem() {
|
||||
return $this->use_filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to use the correct path for the FS method being used
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_sanitized_path( $abs_path ) {
|
||||
if ( $this->using_wp_filesystem() ) {
|
||||
return str_replace( ABSPATH, $this->wp_filesystem->abspath(), $abs_path );
|
||||
}
|
||||
|
||||
return $abs_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to initiate WP_Filesystem
|
||||
*
|
||||
* If this fails, $use_filesystem is set to false and all methods in this class should use native php fallbacks
|
||||
* Thwarts `request_filesystem_credentials()` attempt to display a form for obtaining creds from users
|
||||
*
|
||||
* TODO: provide notice and input in wp-admin for users when this fails
|
||||
*/
|
||||
public function maybe_init_wp_filesystem() {
|
||||
ob_start();
|
||||
$this->credentials = request_filesystem_credentials( '', '', false, false, null );
|
||||
$ob_contents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if ( wp_filesystem( $this->credentials ) ) {
|
||||
global $wp_filesystem;
|
||||
$this->wp_filesystem = $wp_filesystem;
|
||||
$this->use_filesystem = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create file if not exists then set mtime and atime on file
|
||||
*
|
||||
* @param string $abs_path
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function touch( $abs_path, $time = 0, $atime = 0 ) {
|
||||
if ( 0 == $time ) {
|
||||
$time = time();
|
||||
}
|
||||
if ( 0 == $atime ) {
|
||||
$atime = time();
|
||||
}
|
||||
|
||||
$return = @touch( $abs_path, $time, $atime );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->touch( $abs_path, $time, $atime );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* file_put_contents with chmod
|
||||
*
|
||||
* @param string $abs_path
|
||||
* @param string $contents
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function put_contents( $abs_path, $contents ) {
|
||||
$return = @file_put_contents( $abs_path, $contents );
|
||||
$this->chmod( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->put_contents( $abs_path, $contents, $this->chmod_file );
|
||||
}
|
||||
|
||||
return (bool) $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the specified file or dir exist
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function file_exists( $abs_path ) {
|
||||
$return = file_exists( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->exists( $abs_path );
|
||||
}
|
||||
|
||||
return (bool) $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file's size
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function filesize( $abs_path ) {
|
||||
$return = filesize( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->size( $abs_path );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contents of a file as a string
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_contents( $abs_path ) {
|
||||
$return = @file_get_contents( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->get_contents( $abs_path );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function unlink( $abs_path ) {
|
||||
$return = @unlink( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->delete( $abs_path, false, false );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* chmod a file
|
||||
*
|
||||
* @param string $abs_path
|
||||
* @param int $perms
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* Leave $perms blank to use $this->chmod_file/DIR or pass value like 0777
|
||||
*/
|
||||
public function chmod( $abs_path, $perms = null ) {
|
||||
if ( is_null( $perms ) ) {
|
||||
$perms = $this->is_file( $abs_path ) ? $this->chmod_file : $this->chmod_dir;
|
||||
}
|
||||
|
||||
$return = @chmod( $abs_path, $perms );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->chmod( $abs_path, $perms, false );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the specified pat a directory?
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir( $abs_path ) {
|
||||
$return = is_dir( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->is_dir( $abs_path );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the specified path a file?
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file( $abs_path ) {
|
||||
$return = is_file( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->is_file( $abs_path );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the specified path readable
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable( $abs_path ) {
|
||||
$return = is_readable( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->is_readable( $abs_path );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the specified path writable
|
||||
*
|
||||
* @param string $abs_path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable( $abs_path ) {
|
||||
$return = is_writable( $abs_path );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
$return = $this->wp_filesystem->is_writable( $abs_path );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive mkdir
|
||||
*
|
||||
* @param string $abs_path
|
||||
* @param int $perms
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir( $abs_path, $perms = null ) {
|
||||
if ( is_null( $perms ) ) {
|
||||
$perms = $this->chmod_dir;
|
||||
}
|
||||
|
||||
if ( $this->is_dir( $abs_path ) ) {
|
||||
$this->chmod( $perms );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$mkdirp = wp_mkdir_p( $abs_path );
|
||||
} catch ( Exception $e ) {
|
||||
$mkdirp = false;
|
||||
}
|
||||
|
||||
if ( $mkdirp ) {
|
||||
$this->chmod( $perms );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$return = @mkdir( $abs_path, $perms, true );
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
|
||||
if ( $this->is_dir( $abs_path ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// WP_Filesystem doesn't offer a recursive mkdir()
|
||||
$abs_path = str_replace( '//', '/', $abs_path );
|
||||
$abs_path = rtrim( $abs_path, '/' );
|
||||
if ( empty( $abs_path ) ) {
|
||||
$abs_path = '/';
|
||||
}
|
||||
|
||||
$dirs = explode( '/', ltrim( $abs_path, '/' ) );
|
||||
$current_dir = '';
|
||||
|
||||
foreach ( $dirs as $dir ) {
|
||||
$current_dir .= '/' . $dir;
|
||||
if ( ! $this->is_dir( $current_dir ) ) {
|
||||
$this->wp_filesystem->mkdir( $current_dir, $perms );
|
||||
}
|
||||
}
|
||||
|
||||
$return = $this->is_dir( $abs_path );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a directory
|
||||
*
|
||||
* @param string $abs_path
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir( $abs_path, $recursive = false ) {
|
||||
if ( ! $this->is_dir( $abs_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// taken from WP_Filesystem_Direct
|
||||
if ( ! $recursive ) {
|
||||
$return = @rmdir( $abs_path );
|
||||
} else {
|
||||
|
||||
// At this point it's a folder, and we're in recursive mode
|
||||
$abs_path = trailingslashit( $abs_path );
|
||||
$filelist = $this->scandir( $abs_path );
|
||||
|
||||
$return = true;
|
||||
if ( is_array( $filelist ) ) {
|
||||
foreach ( $filelist as $filename => $fileinfo ) {
|
||||
|
||||
if ( 'd' === $fileinfo['type'] ) {
|
||||
$return = $this->rmdir( $abs_path . $filename, $recursive );
|
||||
} else {
|
||||
$return = $this->unlink( $abs_path . $filename );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( file_exists( $abs_path ) && ! @rmdir( $abs_path ) ) {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
|
||||
return $this->wp_filesystem->rmdir( $abs_path, $recursive );
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of files/folders under specified directory
|
||||
*
|
||||
* @param $abs_path
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function scandir( $abs_path ) {
|
||||
|
||||
$dirlist = @scandir( $abs_path );
|
||||
if ( false === $dirlist ) {
|
||||
if ( $this->use_filesystem ) {
|
||||
$abs_path = $this->get_sanitized_path( $abs_path );
|
||||
|
||||
return $this->wp_filesystem->dirlist( $abs_path, true, false );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$return = array();
|
||||
|
||||
// normalize return to look somewhat like the return value for WP_Filesystem::dirlist
|
||||
foreach ( $dirlist as $entry ) {
|
||||
if ( '.' === $entry || '..' === $entry ) {
|
||||
continue;
|
||||
}
|
||||
$return[ $entry ] = array(
|
||||
'name' => $entry,
|
||||
'type' => $this->is_dir( $abs_path . '/' . $entry ) ? 'd' : 'f',
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Light wrapper for move_uploaded_file with chmod
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $destination
|
||||
* @param int $perms
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* TODO: look into replicating more functionality from wp_handle_upload()
|
||||
*/
|
||||
public function move_uploaded_file( $file, $destination, $perms = null ) {
|
||||
$return = @move_uploaded_file( $file, $destination );
|
||||
|
||||
if ( $return ) {
|
||||
$this->chmod( $destination, $perms );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file
|
||||
*
|
||||
* @param string $source_abs_path
|
||||
* @param string $destination_abs_path
|
||||
* @param bool $overwrite
|
||||
* @param int $perms
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* Taken from WP_Filesystem_Direct
|
||||
*/
|
||||
public function copy( $source_abs_path, $destination_abs_path, $overwrite = true, $perms = false ) {
|
||||
|
||||
// error if source file doesn't exist
|
||||
if ( ! $this->file_exists( $source_abs_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $overwrite && $this->file_exists( $destination_abs_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$return = copy( $source_abs_path, $destination_abs_path );
|
||||
if ( $perms && $return ) {
|
||||
$this->chmod( $destination_abs_path, $perms );
|
||||
}
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$source_abs_path = $this->get_sanitized_path( $source_abs_path );
|
||||
$destination_abs_path = $this->get_sanitized_path( $destination_abs_path );
|
||||
$return = $this->wp_filesystem->copy( $source_abs_path, $destination_abs_path, $overwrite, $perms );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a file
|
||||
*
|
||||
* @param string $source_abs_path
|
||||
* @param string $destination_abs_path
|
||||
* @param bool $overwrite
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function move( $source_abs_path, $destination_abs_path, $overwrite = true ) {
|
||||
|
||||
// error if source file doesn't exist
|
||||
if ( ! $this->file_exists( $source_abs_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try using rename first. if that fails (for example, source is read only) try copy.
|
||||
// Taken in part from WP_Filesystem_Direct
|
||||
if ( ! $overwrite && $this->file_exists( $destination_abs_path ) ) {
|
||||
return false;
|
||||
} elseif ( @rename( $source_abs_path, $destination_abs_path ) ) {
|
||||
return true;
|
||||
} else {
|
||||
if ( $this->copy( $source_abs_path, $destination_abs_path, $overwrite ) && $this->file_exists( $destination_abs_path ) ) {
|
||||
$this->unlink( $source_abs_path );
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$return = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $return && $this->use_filesystem ) {
|
||||
$source_abs_path = $this->get_sanitized_path( $source_abs_path );
|
||||
$destination_abs_path = $this->get_sanitized_path( $destination_abs_path );
|
||||
|
||||
$return = $this->wp_filesystem->move( $source_abs_path, $destination_abs_path, $overwrite );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
|
||||
class WPMDB_Migration_State {
|
||||
const OPTION_PREFIX = 'wpmdb_state_';
|
||||
const TIMEOUT_PREFIX = 'wpmdb_state_timeout_';
|
||||
const EXPIRATION = 86400; // 60s * 60m * 24h
|
||||
|
||||
private $_value = null;
|
||||
private $_id = null;
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*/
|
||||
function __construct( $id = '' ) {
|
||||
if ( ! empty( $id ) ) {
|
||||
$value = get_site_option( $this->_option( $id ), false, false );
|
||||
|
||||
if ( false !== $value ) {
|
||||
$this->_id = $id;
|
||||
$this->_value = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique id of the instance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function id() {
|
||||
if ( empty( $this->_id ) ) {
|
||||
$this->_id = uniqid();
|
||||
}
|
||||
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the site option string used to save the migration state.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _option( $id = null ) {
|
||||
if ( empty( $id ) ) {
|
||||
$id = $this->id();
|
||||
}
|
||||
|
||||
return self::OPTION_PREFIX . $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the site option string used to save the migration state timeout.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _timeout_option( $id = null ) {
|
||||
if ( empty( $id ) ) {
|
||||
$id = $this->id();
|
||||
}
|
||||
|
||||
return self::TIMEOUT_PREFIX . $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the migration state.
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function set( $value ) {
|
||||
if ( $this->_update_timeout() && update_site_option( $this->_option(), $value ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If nothing changed it's still OK.
|
||||
if ( $this->get() === $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the companion timeout setting to the current migration state option.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function _update_timeout() {
|
||||
$value = time() + self::EXPIRATION;
|
||||
|
||||
if ( update_site_option( $this->_timeout_option(), $value ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If nothing changed it's still OK.
|
||||
if ( get_site_option( $this->_timeout_option(), false, false ) == $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current saved migration state.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function get() {
|
||||
return get_site_option( $this->_option(), false, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the site options for migration state and its companion timeout record.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function _delete_id( $id ) {
|
||||
if ( false === get_site_option( self::OPTION_PREFIX . $id, false, false ) || delete_site_option( self::OPTION_PREFIX . $id ) ) {
|
||||
delete_site_option( self::TIMEOUT_PREFIX . $id );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the current migration state.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function delete() {
|
||||
return $this->_delete_id( $this->id() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all migration state ids that have timed out.
|
||||
*
|
||||
* @param int $timeout Optional UNIX timestamp for timeout, default of 0 uses current timestamp.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function _timed_out_ids( $timeout = 0 ) {
|
||||
global $wpdb;
|
||||
|
||||
$ids = array();
|
||||
|
||||
if ( empty( $timeout ) ) {
|
||||
$timeout = time();
|
||||
}
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$timeout_keys = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT meta_key FROM {$wpdb->sitemeta} WHERE site_id = %d AND meta_key like %s AND meta_value < %d",
|
||||
$wpdb->siteid,
|
||||
addcslashes( self::TIMEOUT_PREFIX, '_' ) . '%',
|
||||
$timeout
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$timeout_keys = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s and option_value < %d",
|
||||
addcslashes( self::TIMEOUT_PREFIX, '_' ) . '%',
|
||||
$timeout
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $timeout_keys ) ) {
|
||||
$id_start = strlen( self::TIMEOUT_PREFIX );
|
||||
|
||||
foreach ( $timeout_keys as $timeout_key ) {
|
||||
$ids[] = substr( $timeout_key, $id_start );
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all migration state ids that have no time out companion.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function _orphaned_ids() {
|
||||
global $wpdb;
|
||||
|
||||
$ids = array();
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$keys = $wpdb->get_col(
|
||||
$wpdb->prepare( "
|
||||
SELECT meta_key
|
||||
FROM {$wpdb->sitemeta}
|
||||
WHERE site_id = %d
|
||||
AND meta_key LIKE %s
|
||||
AND meta_key NOT LIKE %s
|
||||
AND meta_key NOT IN (
|
||||
SELECT CONCAT(%s, SUBSTR(meta_key, %d))
|
||||
FROM {$wpdb->sitemeta}
|
||||
WHERE site_id = %d
|
||||
AND meta_key LIKE %s
|
||||
)
|
||||
",
|
||||
$wpdb->siteid,
|
||||
addcslashes( self::OPTION_PREFIX, '_' ) . '%',
|
||||
addcslashes( self::TIMEOUT_PREFIX, '_' ) . '%',
|
||||
self::OPTION_PREFIX,
|
||||
strlen( self::TIMEOUT_PREFIX ) + 1,
|
||||
$wpdb->siteid,
|
||||
addcslashes( self::TIMEOUT_PREFIX, '_' ) . '%'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$keys = $wpdb->get_col(
|
||||
$wpdb->prepare( "
|
||||
SELECT option_name
|
||||
FROM $wpdb->options
|
||||
WHERE option_name LIKE %s
|
||||
AND option_name NOT LIKE %s
|
||||
AND option_name NOT IN (
|
||||
SELECT CONCAT(%s, SUBSTR(option_name, %d))
|
||||
FROM $wpdb->options
|
||||
WHERE option_name LIKE %s
|
||||
)
|
||||
",
|
||||
addcslashes( self::OPTION_PREFIX, '_' ) . '%',
|
||||
addcslashes( self::TIMEOUT_PREFIX, '_' ) . '%',
|
||||
self::OPTION_PREFIX,
|
||||
strlen( self::TIMEOUT_PREFIX ) + 1,
|
||||
addcslashes( self::TIMEOUT_PREFIX, '_' ) . '%'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $keys ) ) {
|
||||
$id_start = strlen( self::OPTION_PREFIX );
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
$ids[] = substr( $key, $id_start );
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns count of all migration state records that have timed out.
|
||||
*
|
||||
* @param int $timeout Optional UNIX timestamp for timeout, default of 0 uses current timestamp.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
static function cleanup_count( $timeout = 0 ) {
|
||||
return count( self::_timed_out_ids( $timeout ) ) + count( self::_orphaned_ids() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all migration state records that have timed out or are orphaned from their timeout companion.
|
||||
*
|
||||
* @param int $timeout Optional UNIX timestamp for timeout, default of 0 uses current timestamp.
|
||||
*
|
||||
* @return int Count of successfully cleaned up options.
|
||||
*/
|
||||
static function cleanup( $timeout = 0 ) {
|
||||
$count = 0;
|
||||
|
||||
$timed_out_ids = self::_timed_out_ids( $timeout );
|
||||
|
||||
if ( ! empty( $timed_out_ids ) ) {
|
||||
foreach ( $timed_out_ids as $id ) {
|
||||
if ( self::_delete_id( $id ) ) {
|
||||
$count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$orphaned_ids = self::_orphaned_ids();
|
||||
|
||||
if ( ! empty( $orphaned_ids ) ) {
|
||||
foreach ( $orphaned_ids as $id ) {
|
||||
if ( self::_delete_id( $id ) ) {
|
||||
$count ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
<?php
|
||||
|
||||
final class WPMDB_Replace {
|
||||
protected $search;
|
||||
protected $replace;
|
||||
protected $subdomain_replaces_on;
|
||||
protected $wpmdb;
|
||||
protected $intent;
|
||||
protected $base_domain;
|
||||
protected $site_domain;
|
||||
protected $site_details;
|
||||
protected $source_protocol;
|
||||
protected $destination_protocol;
|
||||
protected $destination_url;
|
||||
protected $is_protocol_mismatch = false;
|
||||
|
||||
private $table;
|
||||
private $column;
|
||||
private $row;
|
||||
|
||||
function __construct( $args ) {
|
||||
$keys = array( 'table', 'search', 'replace', 'intent', 'base_domain', 'site_domain', 'wpmdb', 'site_details' );
|
||||
|
||||
if ( ! is_array( $args ) ) {
|
||||
throw new InvalidArgumentException( 'WPMDB_Replace constructor expects the argument to be an array' );
|
||||
}
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
if ( ! isset( $args[ $key ] ) ) {
|
||||
throw new InvalidArgumentException( "WPMDB_Replace constructor expects '$key' key to be present in the array argument" );
|
||||
}
|
||||
}
|
||||
|
||||
$this->table = $args['table'];
|
||||
$this->search = $args['search'];
|
||||
$this->replace = $args['replace'];
|
||||
$this->intent = $args['intent'];
|
||||
$this->base_domain = $args['base_domain'];
|
||||
$this->site_domain = $args['site_domain'];
|
||||
$this->wpmdb = $args['wpmdb'];
|
||||
$this->site_details = $args['site_details'];
|
||||
|
||||
// Detect a protocol mismatch between the remote and local sites involved in the migration
|
||||
$this->detect_protocol_mismatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() && is_subdomain_install() && ! $this->has_same_base_domain() && apply_filters( 'wpmdb_subdomain_replace', true ) );
|
||||
}
|
||||
|
||||
return $this->subdomain_replaces_on;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the replacement has the same base domain as the search. Produces doubled replacement strings
|
||||
* otherwise.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function has_same_base_domain() {
|
||||
$destination_url = isset( $this->destination_url ) ? $this->destination_url : $this->site_details['local']['site_url'];
|
||||
if ( stripos( $destination_url, $this->site_domain ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param $new
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function subdomain_replaces( $new ) {
|
||||
if ( empty( $this->base_domain ) ) {
|
||||
return $new;
|
||||
}
|
||||
|
||||
$pattern = '|//(.*?)\\.' . preg_quote( $this->site_domain, '|' ) . '|';
|
||||
$replacement = '//$1.' . trim( $this->base_domain );
|
||||
$new = preg_replace( $pattern, $replacement, $new );
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect a protocol mismatch between the remote and local sites involved in the migration
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function detect_protocol_mismatch() {
|
||||
if ( ! isset( $this->site_details['remote'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the site_urls used to check if there is a protocol mismatch.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
$wpmdb_home_urls = apply_filters( 'wpmdb_replace_site_urls', array(
|
||||
// TODO: rewrite unit tests that only pass site_url so that we can rely on home_url's existence
|
||||
'local' => isset( $this->site_details['local']['home_url'] ) ? $this->site_details['local']['home_url'] : $this->site_details['local']['site_url'],
|
||||
'remote' => isset( $this->site_details['remote']['home_url'] ) ? $this->site_details['remote']['home_url'] : $this->site_details['remote']['site_url'],
|
||||
)
|
||||
);
|
||||
|
||||
$local_url_is_https = false === stripos( $wpmdb_home_urls['local'], 'https' ) ? false : true;
|
||||
$remote_url_is_https = false === stripos( $wpmdb_home_urls['remote'], 'https' ) ? false : true;
|
||||
$local_protocol = $local_url_is_https ? 'https' : 'http';
|
||||
$remote_protocol = $remote_url_is_https ? 'https' : 'http';
|
||||
|
||||
if ( ( $local_url_is_https && ! $remote_url_is_https ) || ( ! $local_url_is_https && $remote_url_is_https ) ) {
|
||||
$this->is_protocol_mismatch = true;
|
||||
}
|
||||
|
||||
if ( 'push' === $this->intent ) {
|
||||
$this->destination_protocol = $remote_protocol;
|
||||
$this->source_protocol = $local_protocol;
|
||||
$this->destination_url = $wpmdb_home_urls['remote'];
|
||||
} else {
|
||||
$this->destination_protocol = $local_protocol;
|
||||
$this->source_protocol = $remote_protocol;
|
||||
$this->destination_url = $wpmdb_home_urls['local'];
|
||||
}
|
||||
|
||||
return $this->is_protocol_mismatch;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Handles replacing the protocol if the local and destination don't have matching protocols (http > https and
|
||||
* vice-versa).
|
||||
*
|
||||
* Can be filtered to disable entirely.
|
||||
*
|
||||
* @param $new
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function do_protocol_replace( $new ) {
|
||||
/**
|
||||
* Filters $do_protocol_replace, return false to prevent protocol replacement.
|
||||
*
|
||||
* @param bool true If the replace should be skipped.
|
||||
* @param string $this->destination_url The URL of the target site.
|
||||
*/
|
||||
$do_protocol_replace = apply_filters( 'wpmdb_replace_destination_protocol', true, $this->destination_url );
|
||||
|
||||
if ( true !== $do_protocol_replace ) {
|
||||
return $new;
|
||||
}
|
||||
|
||||
$parsed_destination = wp_parse_url( $this->destination_url );
|
||||
unset( $parsed_destination['scheme'] );
|
||||
|
||||
$protocol_search = $this->source_protocol . '://' . implode( '', $parsed_destination );
|
||||
$protocol_replace = $this->destination_url;
|
||||
$new = str_ireplace( $protocol_search, $protocol_replace, $new, $count );
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies find/replace pairs to a given string.
|
||||
*
|
||||
* @param string $subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apply_replaces( $subject ) {
|
||||
$new = str_ireplace( $this->search, $this->replace, $subject, $count );
|
||||
if ( $this->is_subdomain_replaces_on() ) {
|
||||
$new = $this->subdomain_replaces( $new );
|
||||
}
|
||||
|
||||
if ( true === $this->is_protocol_mismatch ) {
|
||||
$new = $this->do_protocol_replace( $new );
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 mixed $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
|
||||
* @param bool $filtered Should we apply before and after filters successively
|
||||
*
|
||||
* @return mixed The original array with all elements replaced as needed.
|
||||
*/
|
||||
function recursive_unserialize_replace( $data, $serialized = false, $parent_serialized = false, $filtered = true ) {
|
||||
$pre = apply_filters( 'wpmdb_pre_recursive_unserialize_replace', false, $data, $this );
|
||||
if ( false !== $pre ) {
|
||||
return $pre;
|
||||
}
|
||||
|
||||
$is_json = false;
|
||||
$before_fired = false;
|
||||
$successive_filter = $filtered;
|
||||
|
||||
if ( true === $filtered ) {
|
||||
list( $data, $before_fired, $successive_filter ) = apply_filters( 'wpmdb_before_replace_custom_data', array( $data, $before_fired, $successive_filter ), $this );
|
||||
}
|
||||
|
||||
// some unserialized data cannot be re-serialized eg. SimpleXMLElements
|
||||
try {
|
||||
if ( is_string( $data ) && ( $unserialized = WPMDB_Utils::unserialize( $data, __METHOD__ ) ) !== 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, $successive_filter );
|
||||
} elseif ( is_array( $data ) ) {
|
||||
$_tmp = array();
|
||||
foreach ( $data as $key => $value ) {
|
||||
$_tmp[ $key ] = $this->recursive_unserialize_replace( $value, false, $parent_serialized, $successive_filter );
|
||||
}
|
||||
|
||||
$data = $_tmp;
|
||||
unset( $_tmp );
|
||||
} elseif ( is_object( $data ) ) { // Submitted by Tina Matter
|
||||
$_tmp = clone $data;
|
||||
foreach ( $data as $key => $value ) {
|
||||
// Integer properties are crazy and the best thing we can do is to just ignore them.
|
||||
// see http://stackoverflow.com/a/10333200 and https://github.com/deliciousbrains/wp-migrate-db-pro/issues/853
|
||||
if ( is_int( $key ) ) {
|
||||
continue;
|
||||
}
|
||||
$_tmp->$key = $this->recursive_unserialize_replace( $value, false, $parent_serialized, $successive_filter );
|
||||
}
|
||||
|
||||
$data = $_tmp;
|
||||
unset( $_tmp );
|
||||
} elseif ( $this->wpmdb->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, $successive_filter );
|
||||
}
|
||||
|
||||
$data = $_tmp;
|
||||
unset( $_tmp );
|
||||
$is_json = true;
|
||||
} elseif ( is_string( $data ) ) {
|
||||
list( $data, $do_replace ) = apply_filters( 'wpmdb_replace_custom_data', array( $data, true ), $this );
|
||||
|
||||
if ( $do_replace ) {
|
||||
$data = $this->apply_replaces( $data );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_json ) {
|
||||
$data = json_encode( $data );
|
||||
}
|
||||
|
||||
if ( $serialized ) {
|
||||
$data = serialize( $data );
|
||||
}
|
||||
} catch ( Exception $error ) {
|
||||
$error_msg = __( 'Failed attempting to do the recursive unserialize replace. Please contact support.', 'wp-migrate-db' );
|
||||
$error_details = $error->getMessage() . "\n\n";
|
||||
$error_details .= var_export( $data, true );
|
||||
$this->wpmdb->log_error( $error_msg, $error_details );
|
||||
}
|
||||
|
||||
if ( true === $filtered ) {
|
||||
$data = apply_filters( 'wpmdb_after_replace_custom_data', $data, $before_fired, $this );
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the $table class property.
|
||||
*
|
||||
* @return string Name of the table currently being processed in the migration.
|
||||
*/
|
||||
public function get_table() {
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the $column class property.
|
||||
*
|
||||
* @return string Name of the column currently being processed in the migration.
|
||||
*/
|
||||
public function get_column() {
|
||||
return $this->column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the $row class property.
|
||||
*
|
||||
* @return string Name of the row currently being processed in the migration.
|
||||
*/
|
||||
public function get_row() {
|
||||
return $this->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the $column class property.
|
||||
*
|
||||
* @param string $column Name of the column currently being processed in the migration.
|
||||
*/
|
||||
public function set_column( $column ) {
|
||||
$this->column = $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the $row class property.
|
||||
*
|
||||
* @param string $row Name of the row currently being processed in the migration.
|
||||
*/
|
||||
public function set_row( $row ) {
|
||||
$this->row = $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multsite safe way of comparing the table currently being processed in the migration against a desired table.
|
||||
*
|
||||
* The table prefix should be omitted, example:
|
||||
*
|
||||
* $is_posts = $this->table_is( 'posts' );
|
||||
*
|
||||
* @param string $desired_table Name of the desired table, table prefix omitted.
|
||||
*
|
||||
* @return boolean Whether or not the desired table is the table currently being processed.
|
||||
*/
|
||||
public function table_is( $desired_table ) {
|
||||
return $this->wpmdb->table_is( $desired_table, $this->table );
|
||||
}
|
||||
|
||||
/**
|
||||
* Intent of the current replace migration.
|
||||
*
|
||||
* Helpful for hookers who need to know what intent they are working on.
|
||||
*
|
||||
* @return string Intent of the current migration
|
||||
*/
|
||||
public function get_intent() {
|
||||
return $this->intent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
class WPMDB_Sanitize {
|
||||
/**
|
||||
* Sanitize and validate data.
|
||||
*
|
||||
* @param string|array $data The data to the sanitized.
|
||||
* @param string|array $key_rules The keys in the data (if data is an array) and the sanitization rule(s) to apply for each key.
|
||||
* @param string $context Additional context data for messages etc.
|
||||
*
|
||||
* @return mixed The sanitized data, the data if no key rules supplied or `false` if an unrecognized rule supplied.
|
||||
*/
|
||||
static function sanitize_data( $data, $key_rules, $context ) {
|
||||
if ( empty( $data ) || empty( $key_rules ) ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return WPMDB_Sanitize::_sanitize_data( $data, $key_rules, $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize and validate data.
|
||||
*
|
||||
* @param string|array $data The data to the sanitized.
|
||||
* @param string|array $key_rules The keys in the data (if data is an array) and the sanitization rule(s) to apply for each key.
|
||||
* @param string $context Additional context data for messages etc.
|
||||
* @param int $recursion_level How deep in the recursion are we? Optional, defaults to 0.
|
||||
*
|
||||
* @return mixed The sanitized data, the data if no key rules supplied or `false` if an unrecognized rule supplied.
|
||||
*/
|
||||
private static function _sanitize_data( $data, $key_rules, $context, $recursion_level = 0 ) {
|
||||
if ( empty( $data ) || empty( $key_rules ) ) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ( 0 === $recursion_level && is_array( $data ) ) {
|
||||
// We always expect associative arrays.
|
||||
if ( ! is_array( $key_rules ) ) {
|
||||
wp_die( sprintf( __( '%1$s was not expecting data to be an array.', 'wp-db-migrate-pro' ), $context ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
foreach ( $data as $key => $value ) {
|
||||
// If a key does not have a rule it's not ours and can be removed.
|
||||
// We should not fail if there is extra data as plugins like Polylang add their own data to each ajax request.
|
||||
if ( ! array_key_exists( $key, $key_rules ) ) {
|
||||
unset( $data[ $key ] );
|
||||
continue;
|
||||
}
|
||||
$data[ $key ] = WPMDB_Sanitize::_sanitize_data( $value, $key_rules[ $key ], $context, ( $recursion_level + 1 ) );
|
||||
}
|
||||
} elseif ( is_array( $key_rules ) ) {
|
||||
foreach ( $key_rules as $rule ) {
|
||||
$data = WPMDB_Sanitize::_sanitize_data( $data, $rule, $context, ( $recursion_level + 1 ) );
|
||||
}
|
||||
} else {
|
||||
// Neither $data or $key_rules are a first level array so can be analysed.
|
||||
if ( 'array' == $key_rules ) {
|
||||
if ( ! is_array( $data ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting an array but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
} elseif ( 'string' == $key_rules ) {
|
||||
if ( ! is_string( $data ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting a string but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
} elseif ( 'key' == $key_rules ) {
|
||||
$key_name = sanitize_key( $data );
|
||||
if ( $key_name !== $data ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting a valid key but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = $key_name;
|
||||
} elseif ( 'text' == $key_rules ) {
|
||||
$text = sanitize_text_field( $data );
|
||||
if ( $text !== $data ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting text but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = $text;
|
||||
} elseif ( 'serialized' == $key_rules ) {
|
||||
if ( ! is_string( $data ) || ! is_serialized( $data ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting serialized data but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
} elseif ( 'json_array' == $key_rules ) {
|
||||
if ( ! is_string( $data ) || ! WPMDB::is_json( $data ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting JSON data but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = json_decode( $data, true );
|
||||
} elseif ( 'json' == $key_rules ) {
|
||||
if ( ! is_string( $data ) || ! WPMDB::is_json( $data ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting JSON data but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
} elseif ( 'numeric' == $key_rules ) {
|
||||
if ( ! is_numeric( $data ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting a valid numeric but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
} elseif ( 'int' == $key_rules ) {
|
||||
// As we are sanitizing form data, even integers are within a string.
|
||||
if ( ! is_numeric( $data ) || (int) $data != $data ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting an integer but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = (int) $data;
|
||||
} elseif ( 'positive_int' == $key_rules ) {
|
||||
if ( ! is_numeric( $data ) || (int) $data != $data || 0 > $data ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting a positive number (int) but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = floor( $data );
|
||||
} elseif ( 'negative_int' == $key_rules ) {
|
||||
if ( ! is_numeric( $data ) || (int) $data != $data || 0 < $data ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting a negative number (int) but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = ceil( $data );
|
||||
} elseif ( 'zero_int' == $key_rules ) {
|
||||
if ( ! is_numeric( $data ) || (int) $data != $data || 0 !== $data ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting 0 (int) but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = 0;
|
||||
} elseif ( 'empty' == $key_rules ) {
|
||||
if ( ! empty( $data ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting an empty value but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
} elseif ( 'url' == $key_rules ) {
|
||||
$url = esc_url_raw( $data );
|
||||
if ( empty( $url ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting a URL but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = $url;
|
||||
} elseif ( 'bool' == $key_rules ) {
|
||||
$bool = sanitize_key( $data );
|
||||
if ( empty( $bool ) || ! in_array( $bool, array( 'true', 'false' ) ) ) {
|
||||
wp_die( sprintf( __( '%1$s was expecting a bool but got something else: "%2$s"', 'wp-db-migrate-pro' ), $context, $data ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
$data = $bool;
|
||||
} else {
|
||||
wp_die( sprintf( __( 'Unknown sanitization rule "%1$s" supplied by %2$s', 'wp-db-migrate-pro' ), $key_rules, $context ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if another version of WPMDB(Pro) is active and deactivates it.
|
||||
* To be hooked on `activated_plugin` so other plugin is deactivated when current plugin is activated.
|
||||
*
|
||||
* @param string $plugin
|
||||
*
|
||||
*/
|
||||
public static 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 ( basename( $plugin ) == $plugin_to_deactivate ) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return unserialized object or array
|
||||
*
|
||||
* @param string $serialized_string Serialized string.
|
||||
* @param string $method The name of the caller method.
|
||||
*
|
||||
* @return mixed, false on failure
|
||||
*/
|
||||
public static function unserialize( $serialized_string, $method = '' ) {
|
||||
if ( ! is_serialized( $serialized_string ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$serialized_string = trim( $serialized_string );
|
||||
$unserialized_string = @unserialize( $serialized_string );
|
||||
|
||||
if ( false === $unserialized_string && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
|
||||
$scope = $method ? sprintf( __( 'Scope: %s().', 'wp-migrate-db' ), $method ) : false;
|
||||
$error = sprintf( __( 'WPMDB Error: Data cannot be unserialized. %s', 'wp-migrate-db' ), $scope );
|
||||
error_log( $error );
|
||||
}
|
||||
|
||||
return $unserialized_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use wp_unslash if available, otherwise fall back to stripslashes_deep
|
||||
*
|
||||
* @param string|array $arg
|
||||
*
|
||||
* @return string|array
|
||||
*/
|
||||
public static function safe_wp_unslash( $arg ){
|
||||
if ( function_exists( 'wp_unslash' ) ) {
|
||||
return wp_unslash( $arg );
|
||||
} else {
|
||||
return stripslashes_deep( $arg );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
3692
wordpress/wp-content/plugins/wp-migrate-db-pro/class/wpmdb.php
Normal file
3692
wordpress/wp-content/plugins/wp-migrate-db-pro/class/wpmdb.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
class WPMDBPro_Addon extends WPMDB_Base {
|
||||
protected $version_required;
|
||||
|
||||
function __construct( $plugin_file_path ) {
|
||||
$this->is_addon = true;
|
||||
parent::__construct( $plugin_file_path );
|
||||
}
|
||||
|
||||
function meets_version_requirements( $version_required ) {
|
||||
$wpmdb_pro_version = $GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['version'];
|
||||
$result = version_compare( $wpmdb_pro_version, $version_required, '>=' );
|
||||
$this->version_required = $version_required;
|
||||
|
||||
if ( false == $result ) {
|
||||
$this->hook_version_requirement_actions();
|
||||
}
|
||||
|
||||
if ( $result ) {
|
||||
// If pre-1.1.2 version of Media Files addon,
|
||||
// then it's not supported by this version of core
|
||||
if ( empty( $this->plugin_version ) ) {
|
||||
$result = false;
|
||||
} else { // Check that this version of core supports the addon version
|
||||
$plugin_basename = sprintf( '%1$s/%1$s.php', $this->plugin_slug );
|
||||
$required_addon_version = $this->addons[ $plugin_basename ]['required_version'];
|
||||
$result = version_compare( $this->plugin_version, $required_addon_version, '>=' );
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function hook_version_requirement_actions() {
|
||||
add_action( 'wpmdb_notices', array( $this, 'version_requirement_actions' ) );
|
||||
}
|
||||
|
||||
function version_requirement_actions() {
|
||||
$addon_requirement_check = get_site_option( 'wpmdb_addon_requirement_check', array() );
|
||||
|
||||
// we only want to delete the transients once, here we keep track of which versions we've checked
|
||||
if ( ! isset( $addon_requirement_check[ $this->plugin_slug ] ) || $addon_requirement_check[ $this->plugin_slug ] != $GLOBALS['wpmdb_meta'][ $this->plugin_slug ]['version'] ) {
|
||||
delete_site_transient( 'wpmdb_upgrade_data' );
|
||||
delete_site_transient( 'update_plugins' );
|
||||
$addon_requirement_check[ $this->plugin_slug ] = $GLOBALS['wpmdb_meta'][ $this->plugin_slug ]['version'];
|
||||
update_site_option( 'wpmdb_addon_requirement_check', $addon_requirement_check );
|
||||
}
|
||||
|
||||
$this->version_requirement_warning();
|
||||
}
|
||||
|
||||
function version_requirement_warning() { ?>
|
||||
<div class="updated warning inline-message below-h2">
|
||||
<strong>Update Required</strong> — <?php
|
||||
$addon_name = $this->get_plugin_name();
|
||||
$required = $this->version_required;
|
||||
$installed = $GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['version'];
|
||||
$wpmdb_basename = sprintf( '%s/%s.php', $GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['folder'], 'wp-migrate-db' );
|
||||
$update = wp_nonce_url( network_admin_url( 'update.php?action=upgrade-plugin&plugin=' . urlencode( $wpmdb_basename ) ), 'upgrade-plugin_' . $wpmdb_basename );
|
||||
printf( __( '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>', 'wp-migrate-db' ), $addon_name, $required, $installed, $update ); ?>
|
||||
</div> <?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/wpmdb-cli.php';
|
||||
|
||||
class WPMDBPro_CLI_Export extends WPMDB_CLI {
|
||||
|
||||
/**
|
||||
* Instance of WPMDBPro.
|
||||
*
|
||||
* @var WPMDBPro
|
||||
*/
|
||||
protected $wpmdbpro;
|
||||
|
||||
function __construct( $plugin_file_path ) {
|
||||
parent::__construct( $plugin_file_path );
|
||||
|
||||
global $wpmdbpro;
|
||||
$this->wpmdb = &$this->wpmdbpro;
|
||||
$this->wpmdbpro = $wpmdbpro;
|
||||
|
||||
// add support for extra args
|
||||
add_filter( 'wpmdb_cli_filter_get_extra_args', array( $this, 'filter_extra_args_cli_export' ), 10, 1 );
|
||||
add_filter( 'wpmdb_cli_filter_get_profile_data_from_args', array( $this, 'add_extra_args_for_pro_export' ), 10, 3 );
|
||||
|
||||
// extend get_tables_to_migrate with migrate_select
|
||||
add_filter( 'wpmdb_cli_tables_to_migrate', array( $this, 'tables_to_migrate_include_select' ), 10, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add extra CLI args used by this plugin.
|
||||
*
|
||||
* @param array $args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function filter_extra_args_cli_export( $args = array() ) {
|
||||
$args[] = 'include-tables';
|
||||
$args[] = 'exclude-post-types';
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add support for extra args in export
|
||||
*
|
||||
* @param array $profile
|
||||
* @param array $args
|
||||
* @param array $assoc_args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function add_extra_args_for_pro_export( $profile, $args, $assoc_args ) {
|
||||
if ( ! is_array( $profile ) ) {
|
||||
return $profile;
|
||||
}
|
||||
|
||||
// --include-tables=<tables>
|
||||
if ( ! empty( $assoc_args['include-tables'] ) ) {
|
||||
$table_migrate_option = 'migrate_select';
|
||||
$select_tables = explode( ',', $assoc_args['include-tables'] );
|
||||
} else {
|
||||
$select_tables = array();
|
||||
$table_migrate_option = 'migrate_only_with_prefix';
|
||||
}
|
||||
|
||||
// --exclude-post-types=<post-types>
|
||||
$select_post_types = array();
|
||||
if ( ! empty( $assoc_args['exclude-post-types'] ) ) {
|
||||
$select_post_types = explode( ',', $assoc_args['exclude-post-types'] );
|
||||
}
|
||||
|
||||
$filtered_profile = compact(
|
||||
'table_migrate_option',
|
||||
'select_post_types',
|
||||
'select_tables'
|
||||
);
|
||||
|
||||
return array_merge( $profile, $filtered_profile );
|
||||
}
|
||||
|
||||
/**
|
||||
* Use tables from --include-tables assoc arg if available
|
||||
*
|
||||
* @param array $tables_to_migrate
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function tables_to_migrate_include_select( $tables_to_migrate ) {
|
||||
if ( in_array( $this->profile['action'], array( 'find_replace', 'savefile' ) ) ) {
|
||||
if ( 'migrate_select' === $this->profile['table_migrate_option'] && ! empty( $this->profile['select_tables'] ) ) {
|
||||
$tables_to_migrate = array_intersect( $this->profile['select_tables'], $this->get_tables() );
|
||||
}
|
||||
}
|
||||
|
||||
return $tables_to_migrate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Migrate your DB using WP Migrate DB Pro.
|
||||
*/
|
||||
|
||||
//require wpmdb-command.php from wp-migrate-db-pro
|
||||
require_once __DIR__ . '/wpmdb-command.php';
|
||||
|
||||
class WPMDBPro_Command extends WPMDB_Command {
|
||||
/**
|
||||
* Export local DB to file.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* <output-file>
|
||||
* : A file path to export to. Filename will be modified to end in .sql or
|
||||
* .sql.gz if necessary.
|
||||
*
|
||||
* [--find=<strings>]
|
||||
* : A comma separated list of strings to find when performing a string find
|
||||
* and replace across the database.
|
||||
*
|
||||
* Table names should be quoted as needed, i.e. when using a comma in the
|
||||
* find/replace string.
|
||||
*
|
||||
* The --replace=<strings> argument should be used in conjunction to specify
|
||||
* the replace values for the strings found using this argument. The number
|
||||
* of strings specified in this argument should match the number passed into
|
||||
* --replace=<strings> argument.
|
||||
*
|
||||
* [--replace=<strings>]
|
||||
* : A comma separated list of replace value strings to implement when
|
||||
* performing a string find & replace across the database.
|
||||
*
|
||||
* Should be used in conjunction with the --find=<strings> argument, see it's
|
||||
* documentation for further explanation of the find & replace functionality.
|
||||
*
|
||||
* [--include-tables=<tables>]
|
||||
* : The comma separated list of tables to migrate. Excluding this parameter
|
||||
* will migrate all tables in your database that begin with your
|
||||
* installation's table prefix, e.g. wp_.
|
||||
*
|
||||
* [--exclude-post-types=<post-types>]
|
||||
* : A comma separated list of post types to exclude. Excluding this parameter
|
||||
* will migrate all post types.
|
||||
*
|
||||
* [--skip-replace-guids]
|
||||
* : Do not perform a find & replace on the guid column in the wp_posts table.
|
||||
*
|
||||
* [--exclude-spam]
|
||||
* : Exclude spam comments.
|
||||
*
|
||||
* [--gzip-file]
|
||||
* : GZip compress export file.
|
||||
*
|
||||
* [--include-transients]
|
||||
* : Include transients (temporary cached data).
|
||||
*
|
||||
* [--subsite=<blog-id|subsite-url>]
|
||||
* : Export the given subsite as a single site install. Requires the Multisite Tools addon.
|
||||
*
|
||||
* [--prefix=<new-table-prefix>]
|
||||
* : A new table prefix to be used for a subsite export.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp migratedb export ./migratedb.sql \
|
||||
* --find=http://dev.bradt.ca,/Users/bradt/home/bradt.ca
|
||||
* --replace=http://bradt.ca,/home/bradt.ca
|
||||
* --include-tables=wp_posts,wp_postmeta
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $assoc_args
|
||||
*/
|
||||
public function export( $args, $assoc_args ) {
|
||||
parent::export( $args, $assoc_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a find/replace on the database.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* [--find=<strings>]
|
||||
* : A comma separated list of strings to find when performing a string find
|
||||
* and replace across the database.
|
||||
*
|
||||
* Table names should be quoted as needed, i.e. when using a comma in the
|
||||
* find/replace string.
|
||||
*
|
||||
* The --replace=<strings> argument should be used in conjunction to specify
|
||||
* the replace values for the strings found using this argument. The number
|
||||
* of strings specified in this argument should match the number passed into
|
||||
* --replace=<strings> argument.
|
||||
*
|
||||
* [--replace=<strings>]
|
||||
* : A comma separated list of replace value strings to implement when
|
||||
* performing a string find & replace across the database.
|
||||
*
|
||||
* Should be used in conjunction with the --find=<strings> argument, see it's
|
||||
* documentation for further explanation of the find & replace functionality.
|
||||
*
|
||||
* [--include-tables=<tables>]
|
||||
* : The comma separated list of tables to search. Excluding this parameter
|
||||
* will run a find & replace on all tables in your database that begin with your
|
||||
* installation's table prefix, e.g. wp_.
|
||||
*
|
||||
* [--exclude-post-types=<post-types>]
|
||||
* : A comma separated list of post types to exclude from the find & replace.
|
||||
* Excluding this parameter will run a find & replace on all post types.
|
||||
*
|
||||
* [--skip-replace-guids]
|
||||
* : Do not perform a find & replace on the guid column in the wp_posts table.
|
||||
*
|
||||
* [--exclude-spam]
|
||||
* : Exclude spam comments.
|
||||
*
|
||||
* [--include-transients]
|
||||
* : Include transients (temporary cached data).
|
||||
*
|
||||
* [--subsite=<blog-id|subsite-url>]
|
||||
* : Run a find & replace on the given subsite. Requires the Multisite Tools addon.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp migratedb find-replace
|
||||
* --find=http://dev.bradt.ca,/Users/bradt/home/bradt.ca
|
||||
* --replace=http://bradt.ca,/home/bradt.ca
|
||||
* --include-tables=wp_posts,wp_postmeta
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $assoc_args
|
||||
*
|
||||
* @subcommand find-replace
|
||||
*/
|
||||
public function find_replace( $args, $assoc_args ) {
|
||||
parent::find_replace( $args, $assoc_args );
|
||||
}
|
||||
}
|
||||
|
||||
WP_CLI::add_command( 'migratedb', 'WPMDBPro_Command' );
|
||||
1660
wordpress/wp-content/plugins/wp-migrate-db-pro/class/wpmdbpro.php
Normal file
1660
wordpress/wp-content/plugins/wp-migrate-db-pro/class/wpmdbpro.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,145 @@
|
||||
<?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.1
|
||||
Author URI: http://deliciousbrains.com
|
||||
*/
|
||||
|
||||
$GLOBALS['wpmdb_compatibility'] = true;
|
||||
|
||||
/**
|
||||
* Remove TGM Plugin Activation 'force_activation' admin_init action hook if present.
|
||||
*
|
||||
* This is to stop excluded plugins being deactivated after a migration, when a theme uses TGMPA to require a plugin to be always active.
|
||||
*/
|
||||
function wpmdbc_tgmpa_compatibility() {
|
||||
$remove_function = false;
|
||||
|
||||
// run on wpmdb page
|
||||
if ( isset( $_GET['page'] ) && 'wp-migrate-db-pro' == $_GET['page'] ) {
|
||||
$remove_function = true;
|
||||
}
|
||||
// run on wpmdb ajax requests
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && false !== strpos( $_POST['action'], 'wpmdb' ) ) {
|
||||
$remove_function = true;
|
||||
}
|
||||
|
||||
if ( $remove_function ) {
|
||||
global $wp_filter;
|
||||
$admin_init_functions = $wp_filter['admin_init'];
|
||||
foreach ( $admin_init_functions as $priority => $functions ) {
|
||||
foreach ( $functions as $key => $function ) {
|
||||
// searching for function this way as can't rely on the calling class being named TGM_Plugin_Activation
|
||||
if ( false !== strpos( $key, 'force_activation' ) ) {
|
||||
unset( $wp_filter['admin_init'][ $priority ][ $key ] );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'wpmdbc_tgmpa_compatibility', 1 );
|
||||
|
||||
/**
|
||||
* remove blog-active plugins
|
||||
*
|
||||
* @param array $plugins numerically keyed array of plugin names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wpmdbc_exclude_plugins( $plugins ) {
|
||||
if ( ! is_array( $plugins ) || empty( $plugins ) ) {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
if ( ! wpmdbc_is_compatibility_mode_request() ) {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
$blacklist_plugins = wpmdbc_get_blacklist_plugins();
|
||||
|
||||
if ( ! empty( $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 ( ! is_array( $plugins ) || empty( $plugins ) ) {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
if ( ! wpmdbc_is_compatibility_mode_request() ) {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
$blacklist_plugins = wpmdbc_get_blacklist_plugins();
|
||||
|
||||
if ( ! empty( $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' );
|
||||
|
||||
/**
|
||||
* Should the current request be processed by Compatibility Mode?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function wpmdbc_is_compatibility_mode_request() {
|
||||
if ( ! defined( 'DOING_AJAX' ) ||
|
||||
! DOING_AJAX ||
|
||||
! isset( $_POST['action'] ) ||
|
||||
false === strpos( $_POST['action'], 'wpmdb' ) ||
|
||||
in_array( $_POST['action'], array( 'wpmdb_flush', 'wpmdb_remote_flush' ) )
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of plugin slugs to be blacklisted.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wpmdbc_get_blacklist_plugins() {
|
||||
$blacklist_plugins = array();
|
||||
|
||||
$wpmdb_settings = get_site_option( 'wpmdb_settings' );
|
||||
|
||||
if ( ! empty( $wpmdb_settings['blacklist_plugins'] ) ) {
|
||||
$blacklist_plugins = array_flip( $wpmdb_settings['blacklist_plugins'] );
|
||||
}
|
||||
|
||||
return $blacklist_plugins;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
$licence = $this->get_licence_key();
|
||||
?>
|
||||
<div class="addons-tab content-tab">
|
||||
<div class="addons-content">
|
||||
<?php if ( ! empty( $licence ) && $this->is_pro ) : ?>
|
||||
<p><?php _e( 'Fetching addon details, please wait...', 'wp-migrate-db' ); ?></p>
|
||||
<?php else : ?>
|
||||
|
||||
<?php if ( $this->is_pro ) : ?>
|
||||
<p class="inline-message warning">
|
||||
<strong><?php _ex( 'Activate Your License', 'License must be activated to use addons', 'wp-migrate-db' ); ?></strong> – <?php _e( 'Please switch to the Settings tab and activate your license. If your license includes the addons below, you will be able to install them from here with one-click.', 'wp-migrate-db' ); ?>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
<p class="inline-message warning">
|
||||
<strong><?php _ex( 'Get Addons', 'Addons are available with a developer license and better', 'wp-migrate-db' ); ?></strong> – <?php printf( __( 'The following addons are available with the WP Migrate DB Pro Developer license and better. Visit <a href="%s" target="_blank">deliciousbrains.com</a> to purchase in just a few clicks.', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/?utm_source=insideplugin&utm_medium=web&utm_content=addons-tab&utm_campaign=freeplugin' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<article class="addon wp-migrate-db-pro-media-files">
|
||||
<div class="desc">
|
||||
<h1><?php _e( 'Media Files', 'wp-migrate-db' ); ?></h1>
|
||||
<p><?php printf( __( 'Allows you to push and pull your files in the Media Library between two WordPress installs. It can compare both libraries and only migrate those missing or updated, or it can do a complete copy of one site\'s library to another. <a href="%s">More Details →</a>', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/doc/media-files-addon/' ); ?></p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="addon wp-migrate-db-pro-cli">
|
||||
<div class="desc">
|
||||
<h1><?php _e( 'CLI', 'wp-migrate-db' ); ?></h1>
|
||||
<p><?php printf( __( 'Integrates WP Migrate DB Pro with WP-CLI allowing you to run migrations from the command line: %s <a href="%s">More Details →</a>', 'wp-migrate-db' ), '<code>wp migratedb <push|pull> <url> <secret-key></code> <code>[--find=<strings>] [--replace=<strings>] ...</code>', 'https://deliciousbrains.com/wp-migrate-db-pro/doc/cli-addon/' ); ?></p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="addon wp-migrate-db-pro-multisite-tools">
|
||||
<div class="desc">
|
||||
<h1><?php _e( 'Multisite Tools', 'wp-migrate-db' ); ?></h1>
|
||||
<p><?php printf( __( 'Export a subsite as an SQL file that can then be imported as a single site install. <a href="%s">More Details →</a>', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/doc/multisite-tools-addon/' ); ?></p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
if ( count( $this->settings['profiles'] ) > 0 ) :
|
||||
$profile_name = $is_default_profile ? _x( 'New Profile', 'Default profile loaded', 'wp-migrate-db' ) : $loaded_profile['name'];
|
||||
?>
|
||||
|
||||
<div class="crumbs">
|
||||
|
||||
<a class="crumb" href="<?php echo $this->plugin_base; ?>" class="return-to-profile-selection clearfix">
|
||||
<?php _e( 'Saved Profiles', 'wp-migrate-db' ); ?>
|
||||
</a>
|
||||
|
||||
<span class="crumb"><?php echo esc_html( $profile_name ); ?></span>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$value = ( isset( $value ) ) ? $value : $this->settings[$key];
|
||||
$class = ( isset( $class ) ) ? 'class="' . $class . '"' : '';
|
||||
$disabled = ( isset( $disabled ) && $disabled ) ? ' disabled' : '';
|
||||
?>
|
||||
<div id="<?php echo $key; ?>-wrap" data-checkbox="<?php echo $key; ?>" class="wpmdb-switch<?php echo $disabled . $value ? ' on' : ''; ?>">
|
||||
<span class="on <?php echo $value ? 'checked' : ''; ?>">ON</span>
|
||||
<span class="off <?php echo ! $value ? 'checked' : ''; ?>">OFF</span>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="0" />
|
||||
<input type="checkbox" name="<?php echo $key; ?>" value="1" id="<?php echo $key; ?>" <?php checked( $value ); ?> <?php echo $class ?>/>
|
||||
</div>
|
||||
@@ -0,0 +1,46 @@
|
||||
<tr class="wpmdb-setting-title">
|
||||
<td colspan="2"><h3><?php _e( 'Compatibility', 'wp-migrate-db' ); ?></h3></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php $this->template( 'checkbox', 'common', array( 'key' => 'plugin-compatibility', 'value' => $plugin_compatibility_checked ) ); ?></td>
|
||||
<td>
|
||||
<h4>
|
||||
<?php _e( 'Plugin Compatibility Mode', 'wp-migrate-db' ); ?> <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>
|
||||
<span class="setting-status"></span>
|
||||
</h4>
|
||||
<p><?php _e( 'Avoid plugin conflicts and improve performance by not loading plugins for migration requests.', 'wp-migrate-db' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="plugin-compatibility-section">
|
||||
<td colspan="2">
|
||||
<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( (array) $this->settings['blacklist_plugins'] );
|
||||
foreach ( get_plugins() as $key => $plugin ) {
|
||||
if ( 0 === strpos( $key, '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>
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="debug">
|
||||
<h3><?php _e( 'Diagnostic Info & Error Log', 'wp-migrate-db' ); ?></h3>
|
||||
<textarea class="debug-log-textarea" autocomplete="off" readonly></textarea>
|
||||
<a href="<?php echo network_admin_url( $this->plugin_base . '&nonce=' . wp_create_nonce( 'wpmdb-download-log' ) . '&wpmdb-download-log=1' ); ?>" class="button"><?php _ex( 'Download', 'Download to your computer', 'wp-migrate-db' ); ?></a>
|
||||
<a class="button clear-log js-action-link"><?php _e( 'Clear Error Log', 'wp-migrate-db' ); ?></a>
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php if ( $this->is_pro ) return; ?>
|
||||
|
||||
<tr class="option-section slider-outer-wrapper max-request-size">
|
||||
<td colspan="2">
|
||||
<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>
|
||||
</div>
|
||||
<div class="slider"></div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="help-tab content-tab">
|
||||
<?php $this->template_part( array( 'wordpress_org_support', 'licence_info', 'debug_info', 'videos' ) ); ?>
|
||||
</div> <!-- end .help-tab -->
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="progress-content progress-overlay-container">
|
||||
<span class="close-progress-content close-progress-content-button">×</span>
|
||||
|
||||
<div class="progress-wrapper-primary">
|
||||
<div class="progress-info-wrapper clearfix">
|
||||
<h2 class="progress-title"><?php _e( 'Please wait while migration is running…', 'wp-migrate-db' ); ?></h2>
|
||||
<div class="progress-text"><?php _e( 'Establishing Connection', 'wp-migrate-db' ); ?></div>
|
||||
<span class="timer">00:00:00</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="stage-tabs"></div>
|
||||
<div class="migration-progress-stages"></div>
|
||||
|
||||
<div class="migration-controls">
|
||||
<span class="pause-resume button"><?php _ex( 'Pause', 'Temporarily stop migrating', 'wp-migrate-db' ); ?></span>
|
||||
<span class="cancel button"><?php _ex( 'Cancel', 'Stop the migration', 'wp-migrate-db' ); ?></span>
|
||||
<span class="pause-before-finalize">
|
||||
<input id="pause-before-finalize" type="checkbox" name="pause_before_finalize" value="1" />
|
||||
<label id="pause-before-finalize-label" for="pause-before-finalize">
|
||||
<?php _e( 'Pause before replacing migrated tables', 'wp-migrate-db' ); ?>
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
</div> <!-- end .progress-content -->
|
||||
@@ -0,0 +1,379 @@
|
||||
<?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 functionality 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 trickier.
|
||||
* $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 );
|
||||
$breadcrumbs_params = array(
|
||||
'loaded_profile' => $loaded_profile,
|
||||
'is_default_profile' => $is_default_profile,
|
||||
);
|
||||
?>
|
||||
<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 $this->template( 'breadcrumbs', 'common', $breadcrumbs_params ); ?>
|
||||
|
||||
<div class="option-section">
|
||||
|
||||
<ul class="option-group migrate-selection">
|
||||
<li>
|
||||
<label for="savefile">
|
||||
<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 ); ?>
|
||||
<li>
|
||||
<label for="find_replace">
|
||||
<input id="find_replace" type="radio" value="find_replace" name="action"<?php echo ( 'find_replace' === $loaded_profile['action'] ) ? ' checked="checked"' : ''; ?> />
|
||||
<?php _e( 'Find & Replace', 'wp-migrate-db' ); ?><span class="option-description"><?php _e( 'Run a find & replace on this site\'s db', 'wp-migrate-db' ); ?></span>
|
||||
</label>
|
||||
</li>
|
||||
</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 esc_html( 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 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 esc_html( $this->get_upload_info( 'path' ) );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="step-two">
|
||||
|
||||
<?php do_action( 'wpmdb_before_migration_options' ); ?>
|
||||
|
||||
<div class="option-section">
|
||||
<div class="header-wrapper clearfix">
|
||||
<div class="option-heading find-heading"><?php _ex( 'Find', 'Source text to be replaced', 'wp-migrate-db' ); ?></div>
|
||||
<div class="option-heading replace-heading"><?php _ex( 'Replace', 'Text to replace in source', 'wp-migrate-db' ); ?></div>
|
||||
</div>
|
||||
|
||||
<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" title="Copy Find to Replace">
|
||||
<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" />
|
||||
|
||||
</td>
|
||||
<td class="row-action-buttons">
|
||||
<span class="replace-remove-row" data-profile-id="0"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $is_default_profile ) : ?>
|
||||
<tr class="replace-row<?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 esc_url( preg_replace( '#^https?:#', '', home_url() ) ); ?>" autocomplete="off"<?php echo ( $this->lock_url_find_replace_row ) ? ' readonly' : ''; ?> />
|
||||
</td>
|
||||
<td class="arrow-col" title="Copy Find to Replace">
|
||||
<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" />
|
||||
</td>
|
||||
<td class="row-action-buttons">
|
||||
<?php $style = $this->lock_url_find_replace_row ? 'display: none;' : ''; ?>
|
||||
<span class="replace-remove-row" data-profile-id="0" style="<?php echo $style; ?>"></span>
|
||||
<a href="#" class="general-helper domain-replace-helper js-action-link"></a>
|
||||
<div class="domain-replace-info helper-message bottom">
|
||||
<?php printf( __( 'This find & replace will find the domain name of your remote site and replace it with the domain name of this site. We\'ve left out the protocol so that both http:// and https:// will be found and replaced. <a href="%s" target="_blank">Find & Replace Documentation</a>', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/doc/find-and-replace/' ); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="replace-row">
|
||||
<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 esc_attr( $this->get_absolute_root_file_path() ); ?>" autocomplete="off" />
|
||||
</td>
|
||||
<td class="arrow-col" title="Copy Find to Replace">
|
||||
<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" />
|
||||
</td>
|
||||
<td class="row-action-buttons">
|
||||
<span class="replace-remove-row" data-profile-id="0"></span>
|
||||
<a href="#" class="general-helper path-replace-helper js-action-link"></a>
|
||||
<div class="path-replace-info helper-message bottom">
|
||||
<?php printf( __( 'This find and replace is mostly for 3rd party plugins that store the website’s root file path in the database. This set of fields will ensure that these values are updated to the correct root file path during the migration. <a href="%s" target="_blank">Find & Replace Documentation</a>', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/doc/find-and-replace/' ); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php else :
|
||||
$i = 1;
|
||||
foreach ( $loaded_profile['replace_old'] as $replace_old ) : ?>
|
||||
<tr class="replace-row<?php echo ( 1 == $i && $this->lock_url_find_replace_row ) ? ' pin' : ''; ?>">
|
||||
<?php
|
||||
$replace_new = ( ! empty( $loaded_profile['replace_new'][ $i ] ) ) ? $loaded_profile['replace_new'][ $i ] : '';
|
||||
?>
|
||||
<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 esc_attr( $replace_old ); ?>" autocomplete="off"<?php echo ( 1 == $i && $this->lock_url_find_replace_row ) ? ' readonly' : ''; ?> />
|
||||
</td>
|
||||
<td class="arrow-col" title="Copy Find to Replace">
|
||||
<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 esc_attr( $replace_new ); ?>" autocomplete="off" />
|
||||
</td>
|
||||
<td class="row-action-buttons">
|
||||
<?php if ( ! $this->lock_url_find_replace_row || ( $this->lock_url_find_replace_row && $i != 1 ) ) : ?>
|
||||
<span 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>
|
||||
|
||||
<?php
|
||||
$new_url_missing_warning = __( '<strong>New URL Missing</strong> — Please enter the protocol-relative URL of the remote website in the "New URL" field or remove the whole row entirely. 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' );
|
||||
if ( $is_default_profile && $this->lock_url_find_replace_row ) {
|
||||
$new_url_missing_warning = __( '<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' );
|
||||
}
|
||||
?>
|
||||
<div id="new-url-missing-warning" class="warning inline-message missing-replace"><?php printf( $new_url_missing_warning, 'https://deliciousbrains.com/wp-migrate-db-pro/doc/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 or remove the whole row entirely. 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/doc/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, we 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>
|
||||
<li class="compatibility-older-mysql">
|
||||
<label for="compatibility-older-mysql">
|
||||
<input id="compatibility-older-mysql" type="checkbox" value="1" autocomplete="off" name="compatibility_older_mysql"<?php $this->maybe_checked( $loaded_profile['compatibility_older_mysql'] ); ?> />
|
||||
<?php _e( 'Compatible with older versions of MySQL (pre-5.5)', 'wp-migrate-db' ); ?>
|
||||
</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 esc_attr( $profile_id ); ?>"></span>
|
||||
<label for="profile-<?php echo esc_attr( $profile_id ); ?>">
|
||||
<input id="profile-<?php echo esc_attr( $profile_id ); ?>" type="radio" value="<?php echo esc_attr( -- $profile_id ); ?>" name="save_migration_profile_option"<?php echo ( $loaded_profile['name'] == $profile['name'] ) ? ' checked="checked"' : ''; ?> />
|
||||
<?php echo esc_html( $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 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->base_prefix, $wpdb->base_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 button below will create new database tables in the remote database with prefix "%s".', 'wp-migrate-db' ), $wpdb->base_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->base_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>
|
||||
|
||||
<div class="notification-message warning-notice mixed-case-table-name-notice pull">
|
||||
<?php echo $this->mixed_case_table_name_warning( 'pull' ); ?>
|
||||
</div>
|
||||
|
||||
<div class="notification-message warning-notice mixed-case-table-name-notice push">
|
||||
<?php echo $this->mixed_case_table_name_warning( 'push' ); ?>
|
||||
</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="<?php echo esc_attr_x( 'Export', 'Download a copy of the database', 'wp-migrate-db' ); ?>" name="Submit" autocomplete="off"/>
|
||||
<input class="button save-settings-button" type="submit" value="<?php echo esc_attr_x( 'Save Profile', 'Save current migration settings', 'wp-migrate-db' ); ?>" name="submit_save_profile" autocomplete="off"/>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<?php $this->template( 'migrate-progress' ); ?>
|
||||
|
||||
<?php $this->template_part( array( 'progress_upgrade' ) ); ?>
|
||||
|
||||
</div> <!-- end .migrate-tab -->
|
||||
@@ -0,0 +1,9 @@
|
||||
<div class="wrap wpmdb">
|
||||
|
||||
<?php /* This is a hack to get sitewide notices to appear above the visible title. https://github.com/deliciousbrains/wp-migrate-db-pro/issues/1436 */ ?>
|
||||
<h1 style="display:none;"></h1>
|
||||
|
||||
<h1><?php echo esc_html( $this->get_plugin_title() ); ?></h1>
|
||||
|
||||
<p><?php printf( esc_html__( '%1$s only runs at the Network Admin level. As there is no Tools menu in the Network Admin, the %2$s menu item is located under Settings.', 'wp-migrate-db' ), esc_html( $this->get_plugin_title() ), sprintf( '"<a href="%s">%s</a>"', esc_url( network_admin_url( 'settings.php?page=' . $this->core_slug ) ), esc_html( $this->get_plugin_title() ) ) ); ?></p>
|
||||
</div>
|
||||
@@ -0,0 +1,69 @@
|
||||
<div class="wrap wpmdb">
|
||||
|
||||
<?php /* This is a hack to get sitewide notices to appear above the visible title. https://github.com/deliciousbrains/wp-migrate-db-pro/issues/1436 */ ?>
|
||||
<h1 style="display:none;"></h1>
|
||||
|
||||
<div id="icon-tools" class="icon32"><br/></div>
|
||||
<h1><?php echo $this->get_plugin_title(); ?></h1>
|
||||
|
||||
<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 );
|
||||
$safe_mode = ( function_exists( 'ini_get' ) && ini_get( 'safe_mode' ) );
|
||||
if ( $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 -->
|
||||
@@ -0,0 +1,53 @@
|
||||
<div class="option-section backup-options" style="display: block;">
|
||||
<label for="create-backup" class="backup-checkbox checkbox-label">
|
||||
<input type="checkbox" id="create-backup" value="1" autocomplete="off" name="create_backup"<?php $this->maybe_checked( $loaded_profile['create_backup'] ); ?> />
|
||||
<span class="action-text pull"><?php _e( 'Backup the local database before replacing it', 'wp-migrate-db' ); ?></span>
|
||||
<span class="action-text push"><?php _e( 'Backup the remote database before replacing it', 'wp-migrate-db' ); ?></span>
|
||||
<span class="action-text find_replace"><?php _e( 'Backup the database before running the find & replace', 'wp-migrate-db' ); ?></span>
|
||||
<br/>
|
||||
<span class="option-description backup-description"><?php _e( 'An SQL file will be saved to', 'wp-migrate-db' ); ?> <span class="uploads-dir"><?php echo $this->get_short_uploads_dir(); ?></span></span>
|
||||
</label>
|
||||
|
||||
<div class="indent-wrap expandable-content">
|
||||
<ul>
|
||||
<li>
|
||||
<label for="backup-only-with-prefix">
|
||||
<input type="radio" id="backup-only-with-prefix" value="backup_only_with_prefix" name="backup_option"<?php echo( $loaded_profile['backup_option'] == 'backup_only_with_prefix' ? ' checked="checked"' : '' ); ?> >
|
||||
<?php _e( 'Backup all tables with prefix', 'wp-migrate-db' ); ?> "<span class="backup-table-prefix"><?php echo $wpdb->base_prefix; ?></span>"
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label for="backup-selected">
|
||||
<input type="radio" id="backup-selected" value="backup_selected" name="backup_option"<?php echo( $loaded_profile['backup_option'] == 'backup_selected' ? ' checked="checked"' : '' ); ?> >
|
||||
<?php _e( 'Backup only tables selected for migration', 'wp-migrate-db' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label for="backup-manual-select">
|
||||
<input type="radio" id="backup-manual-select" value="backup_manual_select" name="backup_option"<?php echo( $loaded_profile['backup_option'] == 'backup_manual_select' ? ' checked="checked"' : '' ); ?> >
|
||||
<?php _e( 'Backup only selected tables below', 'wp-migrate-db' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="backup-tables-wrap select-wrap">
|
||||
<select multiple="multiple" name="select_backup[]" id="select-backup" class="multiselect">
|
||||
<?php foreach ( $this->get_table_sizes( 'backup' ) as $table => $size ) :
|
||||
$size = (int) $size * 1024;
|
||||
if ( ! empty( $loaded_profile['select_backup'] ) && in_array( $table, $loaded_profile['select_backup'] ) ) {
|
||||
printf( '<option value="%1$s" selected="selected">%1$s (%2$s)</option>', $table, size_format( $size ) );
|
||||
} else {
|
||||
printf( '<option value="%1$s">%1$s (%2$s)</option>', $table, size_format( $size ) );
|
||||
}
|
||||
endforeach; ?>
|
||||
</select>
|
||||
<br/>
|
||||
<a href="#" class="multiselect-select-all js-action-link"><?php _e( 'Select All', 'wp-migrate-db' ); ?></a>
|
||||
<span class="select-deselect-divider">/</span>
|
||||
<a href="#" class="multiselect-deselect-all js-action-link"><?php _e( 'Deselect All', 'wp-migrate-db' ); ?></a>
|
||||
<span class="select-deselect-divider">/</span>
|
||||
<a href="#" class="multiselect-invert-selection js-action-link"><?php _e( 'Invert Selection', 'wp-migrate-db' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="backup-option-disabled inline-message error-notice notification-message" style="display: none;"><?php printf( __( 'The backup option has been disabled as your local uploads directory is currently not writeable. The following directory should have 755 permissions: <span class="upload-directory-location">%s</span></p>', 'wp-migrate-db' ), $this->get_upload_info( 'path' ) ); ?>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="updated warning inline-message">
|
||||
<p>
|
||||
<?php
|
||||
printf( __( 'We\'ve detected that <code>WP_HTTP_BLOCK_EXTERNAL</code> is enabled which will prevent WP Migrate DB Pro from functioning properly. You should either disable <code>WP_HTTP_BLOCK_EXTERNAL</code> or add any sites that you\'d like to migrate to or from with WP Migrate DB Pro to <code>WP_ACCESSIBLE_HOSTS</code> (api.deliciousbrains.com must be added to <code>WP_ACCESSIBLE_HOSTS</code> for the API to work). More information on this can be found <a href="%s" target="_blank">here</a>.', 'wp-migrate-db' ), 'https://deliciousbrains.com/wp-migrate-db-pro/doc/wp_http_block_external/' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
/* translators: 1: Remind Me Later, 2: Dismiss */
|
||||
printf( _x( '%1$s | %2$s', 'Block External actions', 'wp-migrate-db' ), $reminder, $dismiss );
|
||||
?>
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
<tr class="wpmdb-setting-title">
|
||||
<td colspan="2"><h3><?php _e( 'Connection Info', 'wp-migrate-db' ); ?></h3></td>
|
||||
</tr>
|
||||
<tr class="option-section connecton-info-wrap">
|
||||
<td colspan="2">
|
||||
<textarea id="connection_info" class="connection-info" readonly><?php echo $connection_info; ?></textarea>
|
||||
|
||||
<div class="reset-button-wrap clearfix">
|
||||
<a class="button copy-api-key js-action-link">
|
||||
<?php _e( 'Copy to Clipboard', 'wp-migrate-db' ); ?>
|
||||
<span class="copy-api-key-confirmation"><?php _e( 'Copied', 'wp-migrate-db' ); ?></span>
|
||||
</a>
|
||||
<a class="button reset-api-key js-action-link"><?php _e( 'Reset Secret Key', 'wp-migrate-db' ); ?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<div class="option-section" style="display: block;">
|
||||
<label for="exclude-post-types" class="exclude-post-types-checkbox checkbox-label">
|
||||
<input type="checkbox" id="exclude-post-types" value="1" autocomplete="off" name="exclude_post_types"<?php $this->maybe_checked( $loaded_profile['exclude_post_types'] ); ?> />
|
||||
<?php _e( 'Exclude Post Types', 'wp-migrate-db' ); ?>
|
||||
</label>
|
||||
|
||||
<div class="indent-wrap expandable-content post-type-select-wrap" style="display: none;">
|
||||
<div class="select-post-types-wrap select-wrap">
|
||||
<div class="exclude-post-types-warning" style="display: none; opacity: 0;">
|
||||
<p>
|
||||
<span class="migrate-msg"><?php _e( 'WARNING: All of the following post types will be absent in the destination posts table after migration:', 'wp-migrate-db' ); ?></span>
|
||||
<span class="find-replace-msg"><?php _e( 'WARNING: The following post types will not be included in the find & replace:', 'wp-migrate-db' ); ?></span>
|
||||
<br>
|
||||
<span class="excluded-post-types">
|
||||
<?php
|
||||
if ( ! empty( $loaded_profile['select_post_types'] ) ) {
|
||||
echo '<code>' . implode( '</code>, <code>', array_map( 'esc_html', $loaded_profile['select_post_types'] ) ) . '</code>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<select multiple="multiple" name="select_post_types[]" id="select-post-types" class="multiselect" autocomplete="off">
|
||||
<?php foreach ( $this->get_post_types() as $post_type ) :
|
||||
if ( ! empty( $loaded_profile['select_post_types'] ) && in_array( $post_type, $loaded_profile['select_post_types'] ) ) {
|
||||
printf( '<option value="%1$s" selected="selected">%1$s</option>', $post_type );
|
||||
} else {
|
||||
printf( '<option value="%1$s">%1$s</option>', $post_type );
|
||||
}
|
||||
endforeach; ?>
|
||||
</select>
|
||||
<br/>
|
||||
<a href="#" class="multiselect-select-all js-action-link"><?php _e( 'Select All', 'wp-migrate-db' ); ?></a>
|
||||
<span class="select-deselect-divider">/</span>
|
||||
<a href="#" class="multiselect-deselect-all js-action-link"><?php _e( 'Deselect All', 'wp-migrate-db' ); ?></a>
|
||||
<span class="select-deselect-divider">/</span>
|
||||
<a href="#" class="multiselect-invert-selection js-action-link"><?php _e( 'Invert Selection', 'wp-migrate-db' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
<div class="notification-message warning-notice inline-message invalid-licence">
|
||||
<?php echo $this->get_licence_status_message(); ?>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="support">
|
||||
<h3><?php _e( 'Email Support', 'wp-migrate-db' ); ?></h3>
|
||||
|
||||
<div class="support-content">
|
||||
<?php if ( ! empty( $licence ) ) : ?>
|
||||
<p><?php _e( 'Fetching license 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 your support details.', 'wp-migrate-db' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,24 @@
|
||||
<tr class="wpmdb-setting-title">
|
||||
<td colspan="2"><h3><?php _e( 'Your License', 'wp-migrate-db' ); ?></h3></td>
|
||||
</tr>
|
||||
<tr class="licence-form option-section licence-wrap" method="post" action="#settings">
|
||||
<td colspan="2">
|
||||
<?php if ( $this->is_licence_constant() ) : ?>
|
||||
<p>
|
||||
<?php _e( 'The license key is currently defined in wp-config.php.', 'wp-migrate-db' ); ?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<?php if ( ! empty( $licence ) ) :
|
||||
echo $this->get_formatted_masked_licence();
|
||||
?>
|
||||
<p class="licence-status"></p>
|
||||
<?php else : ?>
|
||||
<div class="licence-not-entered">
|
||||
<input type="text" class="licence-input" autocomplete="off"/>
|
||||
<button class="button register-licence" type="button"><?php _e( 'Activate License', 'wp-migrate-db' ); ?></button>
|
||||
<p class="licence-status"></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
foreach ( $this->addons as $addon_basename => $addon ) :
|
||||
if ( false == $this->is_addon_outdated( $addon_basename ) || false == is_plugin_active( $addon_basename ) ) {
|
||||
continue;
|
||||
}
|
||||
$update_url = wp_nonce_url( network_admin_url( 'update.php?action=upgrade-plugin&plugin=' . urlencode( $addon_basename ) ), 'upgrade-plugin_' . $addon_basename );
|
||||
$addon_slug = current( explode( '/', $addon_basename ) );
|
||||
if ( isset( $GLOBALS['wpmdb_meta'][ $addon_slug ]['version'] ) ) {
|
||||
$version = ' (' . $GLOBALS['wpmdb_meta'][ $addon_slug ]['version'] . ')';
|
||||
} else {
|
||||
$version = '';
|
||||
}
|
||||
?>
|
||||
<div class="updated warning inline-message">
|
||||
<strong>Update Required</strong> —
|
||||
<?php printf( __( '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>', 'wp-migrate-db' ), $addon['name'], $version, $update_url ); ?>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
@@ -0,0 +1,18 @@
|
||||
<li class="pull-list">
|
||||
<label for="pull"<?php echo ( $this->is_valid_licence() ) ? '' : ' class="disabled"'; ?>>
|
||||
<input id="pull" type="radio" value="pull" name="action"<?php echo ( $loaded_profile['action'] == 'pull' && $this->is_pro ) ? ' checked="checked"' : ''; ?><?php echo ( $this->is_valid_licence() ) ? '' : ' disabled="disabled"'; ?> />
|
||||
<?php _ex( 'Pull', 'Import data from remote database', 'wp-migrate-db' ); ?><span class="option-description"><?php _e( 'Replace this site\'s db with remote db', 'wp-migrate-db' ); ?></span>
|
||||
</label>
|
||||
<ul>
|
||||
<li></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="push-list">
|
||||
<label for="push"<?php echo ( $this->is_valid_licence() ) ? '' : ' class="disabled"'; ?>>
|
||||
<input id="push" type="radio" value="push" name="action"<?php echo ( $loaded_profile['action'] == 'push' && $this->is_pro ) ? ' checked="checked"' : ''; ?><?php echo ( $this->is_valid_licence() ) ? '' : ' disabled="disabled"'; ?> />
|
||||
<?php _ex( 'Push', 'Export data to remote database', 'wp-migrate-db' ); ?><span class="option-description"><?php _e( 'Replace remote db with this site\'s db', 'wp-migrate-db' ); ?></span>
|
||||
</label>
|
||||
<ul>
|
||||
<li></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -0,0 +1,54 @@
|
||||
<tr class="wpmdb-setting-title">
|
||||
<td colspan="2"><h3><?php _e( 'Request Settings', 'wp-migrate-db' ); ?></h3></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<?php $this->template( 'checkbox', 'common', array( 'key' => 'verify_ssl' ) ); ?>
|
||||
</td>
|
||||
<td>
|
||||
<h4><?php _e( 'Certificate Verification', 'wp-migrate-db' ); ?> <a href="#" class="general-helper replace-guid-helper js-action-link"></a>
|
||||
<div class="ssl-verify-message helper-message">
|
||||
<?php _e( '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.', 'wp-migrate-db' ); ?>
|
||||
</div>
|
||||
<span class="setting-status"></span>
|
||||
</h4>
|
||||
<p><?php _e( 'Verify the authenticity of the remote server’s TLS certificate. ', 'wp-migrate-db' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div class="slider-outer-wrapper max-request-size">
|
||||
<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>
|
||||
</div>
|
||||
<div class="slider"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="option-section">
|
||||
<td colspan="2">
|
||||
<div class="slider-outer-wrapper delay-between-requests">
|
||||
<div class="clearfix slider-label-wrapper">
|
||||
<div class="slider-label"><span><?php _e( 'Delay Between Requests', 'wp-migrate-db' ); ?></span>
|
||||
<a class="general-helper slider-helper js-action-link" href="#"></a>
|
||||
|
||||
<div class="slider-message helper-message">
|
||||
<?php printf( __( 'Some servers have rate limits which the plugin can hit when performing migrations. If you\'re experiencing migration failures due to server rate limits, you should set this to one or more seconds to alleviate the problem.', 'wp-migrate-db' ) ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="amount"></div>
|
||||
</div>
|
||||
<div class="slider"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,9 @@
|
||||
<div class="updated warning inline-message">
|
||||
<strong><?php _e( 'Improve Security', 'wp-migrate-db' ); ?></strong> —
|
||||
<?php printf( __( 'We have implemented a more secure method of secret key generation since your key was generated. We recommend you <a href="%s">visit the Settings tab</a> and reset your secret key.', 'wp-migrate-db' ), '#settings' ); ?>
|
||||
<br/>
|
||||
<?php
|
||||
/* translators: 1: Remind Me Later, 2: Dismiss */
|
||||
printf( _x( '%1$s | %2$s', 'Improve Security actions', 'wp-migrate-db' ), $reminder, $dismiss );
|
||||
?>
|
||||
</div>
|
||||
@@ -0,0 +1,50 @@
|
||||
<div class="option-section">
|
||||
<div class="header-expand-collapse clearfix">
|
||||
<div class="expand-collapse-arrow collapsed">▼</div>
|
||||
<div class="option-heading tables-header"><?php _ex( 'Tables', 'Database tables', 'wp-migrate-db' ); ?></div>
|
||||
</div>
|
||||
|
||||
<div class="indent-wrap expandable-content table-select-wrap" style="display: none;">
|
||||
|
||||
<ul class="option-group table-migrate-options">
|
||||
<li>
|
||||
<label for="migrate-only-with-prefix">
|
||||
<input id="migrate-only-with-prefix" class="multiselect-toggle" type="radio" value="migrate_only_with_prefix" name="table_migrate_option"<?php echo( $loaded_profile['table_migrate_option'] == 'migrate_only_with_prefix' ? ' checked="checked"' : '' ); ?> />
|
||||
<?php _e( 'Migrate all tables with prefix', 'wp-migrate-db' ); ?> "<span class="table-prefix"><?php echo esc_html( $wpdb->base_prefix ); ?></span>"
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label for="migrate-selected">
|
||||
<input id="migrate-selected" class="multiselect-toggle show-multiselect" type="radio" value="migrate_select" name="table_migrate_option"<?php echo( $loaded_profile['table_migrate_option'] == 'migrate_select' ? ' checked="checked"' : '' ); ?> />
|
||||
<?php _e( 'Migrate only selected tables below', 'wp-migrate-db' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="select-tables-wrap select-wrap">
|
||||
<select multiple="multiple" name="select_tables[]" id="select-tables" class="multiselect" autocomplete="off">
|
||||
<?php
|
||||
$table_sizes = $this->get_table_sizes();
|
||||
$temp_prefix_length = strlen( $this->temp_prefix );
|
||||
foreach ( $this->get_tables() as $table ) :
|
||||
if( ! isset( $table_sizes[ $table ] ) || $this->temp_prefix === substr( $table, 0, $temp_prefix_length ) ) {
|
||||
continue;
|
||||
}
|
||||
$size = (int) $table_sizes[ $table ] * 1024;
|
||||
if ( ! empty( $loaded_profile['select_tables'] ) && in_array( $table, $loaded_profile['select_tables'] ) ) {
|
||||
printf( '<option value="%1$s" selected="selected">%1$s (%2$s)</option>', esc_html( $table ), size_format( $size ) );
|
||||
} else {
|
||||
printf( '<option value="%1$s">%1$s (%2$s)</option>', esc_html( $table ), size_format( $size ) );
|
||||
}
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
<br/>
|
||||
<a href="#" class="multiselect-select-all js-action-link"><?php _e( 'Select All', 'wp-migrate-db' ); ?></a>
|
||||
<span class="select-deselect-divider">/</span>
|
||||
<a href="#" class="multiselect-deselect-all js-action-link"><?php _e( 'Deselect All', 'wp-migrate-db' ); ?></a>
|
||||
<span class="select-deselect-divider">/</span>
|
||||
<a href="#" class="multiselect-invert-selection js-action-link"><?php _e( 'Invert Selection', 'wp-migrate-db' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
<tr class="wpmdb-setting-title">
|
||||
<td colspan="2"><h3><?php _e( 'Permissions', 'wp-migrate-db' ); ?></h3></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php $this->template( 'checkbox', 'common', array( 'key' => 'allow_pull' ) ); ?></td>
|
||||
<td>
|
||||
<h4><?php _e( 'Pull', 'wp-migrate-db' ); ?> <span class="setting-status"></span></h4>
|
||||
<p><?php _e( 'Process requests to pull data from this install, copying it elsewhere.', 'wp-migrate-db' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="option-section">
|
||||
<td><?php $this->template( 'checkbox', 'common', array( 'key' => 'allow_push' ) ); ?></td>
|
||||
<td>
|
||||
<h4><?php _e( 'Push', 'wp-migrate-db' ); ?> <span class="setting-status"></span></h4>
|
||||
<p><?php _e( 'Process requests to push data to this install, overwriting its data.', 'wp-migrate-db' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="videos">
|
||||
<h3><?php _ex( 'Videos', 'Tutorial videos', 'wp-migrate-db' ); ?></h3>
|
||||
|
||||
<iframe class="video-viewer" style="display: none;" width="640" height="360" src="" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $videos as $id => $video ) : ?>
|
||||
<li class="video" data-video-id="<?php echo $id; ?>">
|
||||
<a href="//www.youtube.com/watch?v=<?php echo $id; ?>" target="_blank"><img src="//img.youtube.com/vi/<?php echo $id; ?>/0.jpg" alt=""/></a>
|
||||
|
||||
<h4><?php echo $video['title']; ?></h4>
|
||||
|
||||
<p>
|
||||
<?php echo $video['desc']; ?>
|
||||
</p>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
<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, esc_html( $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>
|
||||
@@ -0,0 +1,7 @@
|
||||
<div class="settings-tab content-tab">
|
||||
<form method="post" id="settings-form" action="#settings" autocomplete="off">
|
||||
<table class="form-table">
|
||||
<?php $this->template_part( array( 'connection_info', 'toggle_remote_requests', 'licence', 'request_settings', 'compatibility', 'max_request_size' ) ); ?>
|
||||
</table>
|
||||
</form>
|
||||
</div> <!-- end .settings-tab -->
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: WP Migrate DB Pro
|
||||
Plugin URI: http://deliciousbrains.com/wp-migrate-db-pro/
|
||||
Description: Export, push, and pull to migrate your WordPress databases.
|
||||
Author: Delicious Brains
|
||||
Version: 1.7.2
|
||||
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-pro']['version'] = '1.7.2';
|
||||
$GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['folder'] = basename( plugin_dir_path( __FILE__ ) );
|
||||
$GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['abspath'] = dirname( __FILE__ );
|
||||
|
||||
if ( ! class_exists( 'WPMDB_Utils' ) ) {
|
||||
require dirname( __FILE__ ) . '/class/wpmdb-utils.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* once all plugins are loaded, load up the rest of this plugin
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function wp_migrate_db_pro_loaded() {
|
||||
|
||||
// load if it is wp-cli, so that version update will show in wp-cli
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
||||
wp_migrate_db_pro();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// exit quickly unless: standalone admin; one of our AJAX calls
|
||||
if ( ! is_admin() || ( is_multisite() && ! current_user_can( 'manage_network_options' ) && ! WPMDB_Utils::is_ajax() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wp_migrate_db_pro();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
add_action( 'plugins_loaded', 'wp_migrate_db_pro_loaded' );
|
||||
|
||||
/**
|
||||
* Populate the $wpmdbpro global with an instance of the WPMDBPro class and return it.
|
||||
*
|
||||
* @return WPMDBPro The one true global instance of the WPMDBPro class.
|
||||
*/
|
||||
function wp_migrate_db_pro() {
|
||||
global $wpmdbpro;
|
||||
|
||||
if ( ! is_null( $wpmdbpro ) ) {
|
||||
return $wpmdbpro;
|
||||
}
|
||||
|
||||
$abspath = dirname( __FILE__ );
|
||||
|
||||
require_once $abspath . '/class/wpmdb-base.php';
|
||||
require_once $abspath . '/class/wpmdbpro-addon.php';
|
||||
require_once $abspath . '/class/wpmdb.php';
|
||||
require_once $abspath . '/class/wpmdb-replace.php';
|
||||
require_once $abspath . '/class/wpmdbpro.php';
|
||||
require_once $abspath . '/class/wpmdb-sanitize.php';
|
||||
require_once $abspath . '/class/wpmdb-migration-state.php';
|
||||
require_once $abspath . '/class/wpmdb-filesystem.php';
|
||||
|
||||
$wpmdbpro = new WPMDBPro( __FILE__ );
|
||||
|
||||
return $wpmdbpro;
|
||||
}
|
||||
|
||||
function wpmdb_pro_cli_loaded() {
|
||||
// register with wp-cli if it's running, and command hasn't already been defined elsewhere
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI && ! class_exists( 'WPMDB_Command' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/class/wpmdbpro-command.php';
|
||||
}
|
||||
}
|
||||
add_action( 'plugins_loaded', 'wpmdb_pro_cli_loaded', 20 );
|
||||
|
||||
function wpmdb_pro_cli() {
|
||||
global $wpmdbpro_cli;
|
||||
|
||||
if ( ! is_null( $wpmdbpro_cli ) ) {
|
||||
return $wpmdbpro_cli;
|
||||
}
|
||||
|
||||
if ( function_exists( 'wp_migrate_db_pro' ) ) {
|
||||
wp_migrate_db_pro();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
do_action( 'wp_migrate_db_pro_cli_before_load' );
|
||||
|
||||
require_once dirname( __FILE__ ) . '/class/wpmdbpro-cli-export.php';
|
||||
$wpmdbpro_cli = new WPMDBPro_CLI_Export( __FILE__ );
|
||||
|
||||
do_action( 'wp_migrate_db_pro_cli_after_load' );
|
||||
|
||||
return $wpmdbpro_cli;
|
||||
}
|
||||
|
||||
add_action( 'activated_plugin', array( 'WPMDB_Utils', 'deactivate_other_instances' ) );
|
||||
Reference in New Issue
Block a user