Skip to content

Commit 753cae9

Browse files
committed
updates from 1.1.4b
1 parent f221b70 commit 753cae9

File tree

7 files changed

+282
-95
lines changed

7 files changed

+282
-95
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# WP Sync DB Media Files
2-
An addon for [WP Sync DB](https://github.com/slang800/wp-sync-db) that lets you sync media libraries between WordPress installations.
2+
An addon for [WP Sync DB](https://github.com/wp-sync-db/wp-sync-db) that lets you sync media libraries between WordPress installations.
33

44
<p align="center"><a><img src="https://raw.github.com/slang800/psychic-ninja/master/wp-sync-db-media-files.png"/></a></p>

asset/js/script.js

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var determine_media_to_migrate;
33
var remote_media_files_unavailable = false;
44
var remote_connection_data;
55
var connection_info;
6+
var media_successfully_determined;
67

78
(function($) {
89

@@ -18,17 +19,16 @@ var connection_info;
1819

1920
$(document).ready(function() {
2021

21-
$.wpsdb.add_action('ready', function() {
22-
if (migration_type() == 'savefile') {
23-
$('.media-files-options').hide();
24-
}
25-
});
22+
if (migration_type() == 'savefile') {
23+
$('.media-files-options').hide();
24+
}
2625

2726
var disable_media_files_option = function() {
2827
$('#media-files').attr('data-available', '0');
2928
$('#media-files').prop('checked', false);
3029
$('#media-files').attr('disabled', 'disabled');
3130
$('.media-files').addClass('disabled');
31+
$('.media-files-options .expandable-content').hide();
3232
};
3333

3434
var hide_show_options = function(unavailable) {
@@ -94,9 +94,9 @@ var connection_info;
9494
});
9595

9696
determine_media_to_migrate = function() {
97-
connection_info = $.trim($('.pull-push-connection-info').val()).split("\n");
98-
$('.progress-text').html(
99-
'Determining which media files to migrate, please wait...');
97+
connection_info = $.trim($('.pull-push-connection-info').val()).split(
98+
"\n");
99+
$('.progress-text').html(wpsdbmf_strings.determining);
100100

101101
var remove_local_media = 0;
102102

@@ -116,13 +116,12 @@ var connection_info;
116116
url: connection_info[0],
117117
key: connection_info[1],
118118
temp_prefix: connection_data.temp_prefix,
119-
nonce: wpsdb_nonces.determine_media_to_migrate,
119+
nonce: wpsdb_nonces.determine_media_to_migrate,
120120
},
121121
error: function(jqXHR, textStatus, errorThrown) {
122-
$('.progress-title').html('Migration failed');
123-
$('.progress-text').html(
124-
'Error while attempting to determine which media files to migrate. (#101mf)'
125-
);
122+
$('.progress-title').html(wpsdbmf_strings.migration_failed);
123+
$('.progress-text').html(wpsdbmf_strings.error_determining +
124+
' (#101mf)');
126125
$('.progress-text').addClass('migration-error');
127126
console.log(jqXHR);
128127
console.log(textStatus);
@@ -139,23 +138,32 @@ var connection_info;
139138
return;
140139
}
141140

142-
media_successfully_determined(data);
141+
next_step_in_migration = {
142+
fn: media_successfully_determined,
143+
args: [data]
144+
};
145+
execute_next_step();
143146
}
147+
144148
});
149+
145150
}
146151

147152
function migration_failed(data) {
148-
$('.progress-title').html('Migration failed');
153+
$('.progress-title').html(wpsdbmf_strings.migration_failed);
149154
$('.progress-text').html(data);
150155
$('.progress-text').addClass('migration-error');
151156
migration_error = true;
152157
migration_complete_events();
153158
}
154159

155-
function media_successfully_determined(data) {
160+
media_successfully_determined = function(data) {
156161
if (typeof data.wpsdb_error != 'undefined' && data.wpsdb_error == 1) {
157162
non_fatal_errors += data.body;
158-
wpsdb_call_next_hook();
163+
next_step_in_migration = {
164+
fn: wpsdb_call_next_hook
165+
};
166+
execute_next_step();
159167
return;
160168
}
161169

@@ -175,12 +183,18 @@ var connection_info;
175183
$('.progress-tables').empty();
176184
$('.progress-tables-hover-boxes').empty();
177185

178-
$('.progress-tables').prepend(
179-
'<div title="Media Files" style="width: 100%;" class="progress-chunk media_files"><span>Media Files (<span class="media-migration-current-image">0</span> / ' +
186+
$('.progress-tables').prepend('<div title="' + wpsdbmf_strings.media_files +
187+
'" style="width: 100%;" class="progress-chunk media_files"><span>' +
188+
wpsdbmf_strings.media_files +
189+
' (<span class="media-migration-current-image">0</span> / ' +
180190
wpsdb_add_commas(Object.size(args.files_to_migrate)) +
181191
')</span></div>');
182192

183-
migrate_media_files_recursive(args);
193+
next_step_in_migration = {
194+
fn: migrate_media_files_recursive,
195+
args: [args]
196+
};
197+
execute_next_step();
184198
}
185199

186200
function migrate_media_files_recursive(args) {
@@ -215,7 +229,8 @@ var connection_info;
215229
}
216230
});
217231

218-
var connection_info = $.trim($('.pull-push-connection-info').val()).split("\n");
232+
var connection_info = $.trim($('.pull-push-connection-info').val()).split(
233+
"\n");
219234

220235
$.ajax({
221236
url: ajaxurl,
@@ -229,13 +244,12 @@ var connection_info;
229244
intent: migration_type(),
230245
url: connection_info[0],
231246
key: connection_info[1],
232-
nonce: wpsdb_nonces.migrate_media,
247+
nonce: wpsdb_nonces.migrate_media,
233248
},
234249
error: function(jqXHR, textStatus, errorThrown) {
235250
$('.progress-title').html('Migration failed');
236-
$('.progress-text').html(
237-
'A problem occurred when migrating the media files. (#102mf)'
238-
);
251+
$('.progress-text').html(wpsdbmf_strings.problem_migrating_media +
252+
' (#102mf)');
239253
$('.progress-text').addClass('migration-error');
240254
console.log(jqXHR);
241255
console.log(textStatus);
@@ -252,7 +266,8 @@ var connection_info;
252266
return;
253267
}
254268

255-
if (typeof data.wpsdb_error != 'undefined' && data.wpsdb_error == 1) {
269+
if (typeof data.wpsdb_error != 'undefined' && data.wpsdb_error ==
270+
1) {
256271
non_fatal_errors += data.body;
257272
}
258273

@@ -262,10 +277,15 @@ var connection_info;
262277
$('.progress-bar').width(percent + '%');
263278
overall_percent = Math.floor(percent);
264279

265-
$('.progress-text').html(overall_percent + '% - Migrating media files');
280+
$('.progress-text').html(overall_percent + '% - ' +
281+
wpsdbmf_strings.migrating_media_files);
266282
$('.media-migration-current-image').html(wpsdb_add_commas(args.media_progress_image_number));
267283

268-
migrate_media_files_recursive(args);
284+
next_step_in_migration = {
285+
fn: migrate_media_files_recursive,
286+
args: [args]
287+
};
288+
execute_next_step();
269289
}
270290
});
271291
}

0 commit comments

Comments
 (0)