Added dependency plugins

This commit is contained in:
Moris Zen
2018-06-25 00:00:37 +02:00
parent 720a1c31a4
commit f069f6782f
698 changed files with 289637 additions and 1 deletions

View 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>' + ' &mdash; ';
}
// 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 ];
};

View 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> &mdash; "),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]};

View 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 );

View 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);

View 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 );

View 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);

View 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 );

View 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);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long