Skip to content

Commit 67496c0

Browse files
committed
rename migrate -> sync
closes wp-sync-db#3
1 parent b6306c2 commit 67496c0

File tree

6 files changed

+67
-67
lines changed

6 files changed

+67
-67
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#WP Migrate DB Media Files
2-
An addon for [WP Migrate DB](https://github.com/slang800/wp-migrate-db) that lets you sync media libraries between WordPress installations.
1+
# 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.
33

4-
<p align="center"><a><img src="https://raw.github.com/slang800/psychic-ninja/master/wp-migrate-db-media-files.png"/></a></p>
4+
<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: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var connection_info;
1717

1818
$(document).ready(function() {
1919

20-
$.wpmdb.add_action( 'ready', function() {
20+
$.wpsdb.add_action( 'ready', function() {
2121
if( migration_type() == 'savefile' ){
2222
$('.media-files-options').hide();
2323
}
@@ -48,7 +48,7 @@ var connection_info;
4848
return;
4949
}
5050

51-
if( typeof remote_connection_data != 'undefined' && wpmdb_media_files_version != remote_connection_data.media_files_version ) {
51+
if( typeof remote_connection_data != 'undefined' && wpsdb_media_files_version != remote_connection_data.media_files_version ) {
5252
$('.media-files-remote-location').html(remote_connection_data.url);
5353
$('.media-file-remote-version').html(remote_connection_data.media_files_version);
5454
$('.media-files-different-plugin-version-notice').show();
@@ -64,7 +64,7 @@ var connection_info;
6464
$('#media-files').attr('data-available', '1');
6565
};
6666

67-
$.wpmdb.add_action( 'move_connection_info_box', function() {
67+
$.wpsdb.add_action( 'move_connection_info_box', function() {
6868
hide_show_options( remote_media_files_unavailable );
6969
$('.remove-scope-1').html('remote');
7070
$('.remove-scope-2').html('local');
@@ -74,13 +74,13 @@ var connection_info;
7474
}
7575
});
7676

77-
$.wpmdb.add_action( 'verify_connection_to_remote_site', function( connection_data ) {
77+
$.wpsdb.add_action( 'verify_connection_to_remote_site', function( connection_data ) {
7878
remote_connection_data = connection_data;
7979
remote_media_files_unavailable = ( typeof connection_data.media_files_available == 'undefined' );
8080
hide_show_options( remote_media_files_unavailable );
8181
});
8282

83-
$.wpmdb.add_filter('wpmdb_before_migration_complete_hooks',function(hooks) {
83+
$.wpsdb.add_filter('wpsdb_before_migration_complete_hooks',function(hooks) {
8484
if( false == is_media_migration() || 'savefile' == migration_type() ) return hooks;
8585
hooks.push( 'determine_media_to_migrate' );
8686
return hooks;
@@ -102,7 +102,7 @@ var connection_info;
102102
dataType: 'text',
103103
cache: false,
104104
data: {
105-
action: 'wpmdbmf_determine_media_to_migrate',
105+
action: 'wpsdbmf_determine_media_to_migrate',
106106
remove_local_media: remove_local_media,
107107
intent: migration_type(),
108108
url: connection_info[0],
@@ -122,7 +122,7 @@ var connection_info;
122122
},
123123
success: function(data){
124124
original_data = data;
125-
data = wpmdb_parse_json( $.trim( data ) );
125+
data = wpsdb_parse_json( $.trim( data ) );
126126
if( false == data ) {
127127
migration_failed( original_data );
128128
return;
@@ -144,9 +144,9 @@ var connection_info;
144144
}
145145

146146
function media_successfully_determined( data ) {
147-
if( typeof data.wpmdb_error != 'undefined' && data.wpmdb_error == 1 ){
147+
if( typeof data.wpsdb_error != 'undefined' && data.wpsdb_error == 1 ){
148148
non_fatal_errors += data.body;
149-
wpmdb_call_next_hook();
149+
wpsdb_call_next_hook();
150150
return;
151151
}
152152

@@ -157,7 +157,7 @@ var connection_info;
157157
args.remote_uploads_url = data.remote_uploads_url;
158158
args.files_to_migrate = data.files_to_migrate;
159159

160-
args.bottleneck = wpmdb_max_request;
160+
args.bottleneck = wpsdb_max_request;
161161

162162
if( Object.size( args.files_to_migrate ) > 0 ) {
163163
$('.progress-bar').width('0px');
@@ -166,14 +166,14 @@ var connection_info;
166166
$('.progress-tables').empty();
167167
$('.progress-tables-hover-boxes').empty();
168168

169-
$('.progress-tables').prepend('<div title="Media Files" style="width: 100%;" class="progress-chunk media_files"><span>Media Files (<span class="media-migration-current-image">0</span> / ' + wpmdb_add_commas( Object.size( args.files_to_migrate ) ) + ')</span></div>');
169+
$('.progress-tables').prepend('<div title="Media Files" style="width: 100%;" class="progress-chunk media_files"><span>Media Files (<span class="media-migration-current-image">0</span> / ' + wpsdb_add_commas( Object.size( args.files_to_migrate ) ) + ')</span></div>');
170170

171171
migrate_media_files_recursive( args );
172172
}
173173

174174
function migrate_media_files_recursive( args ) {
175175
if( 0 == Object.size( args.files_to_migrate ) ) {
176-
wpmdb_call_next_hook();
176+
wpsdb_call_next_hook();
177177
return;
178178
}
179179

@@ -211,7 +211,7 @@ var connection_info;
211211
dataType: 'text',
212212
cache: false,
213213
data: {
214-
action: 'wpmdbmf_migrate_media',
214+
action: 'wpsdbmf_migrate_media',
215215
file_chunk: file_chunk_to_migrate,
216216
remote_uploads_url: args.remote_uploads_url,
217217
intent: migration_type(),
@@ -231,13 +231,13 @@ var connection_info;
231231
},
232232
success: function(data){
233233
original_data = data;
234-
data = wpmdb_parse_json( $.trim( data ) );
234+
data = wpsdb_parse_json( $.trim( data ) );
235235
if( false == data ) {
236236
migration_failed( original_data );
237237
return;
238238
}
239239

240-
if( typeof data.wpmdb_error != 'undefined' && data.wpmdb_error == 1 ){
240+
if( typeof data.wpsdb_error != 'undefined' && data.wpsdb_error == 1 ){
241241
non_fatal_errors += data.body;
242242
}
243243

@@ -248,7 +248,7 @@ var connection_info;
248248
overall_percent = Math.floor(percent);
249249

250250
$('.progress-text').html(overall_percent + '% - Migrating media files');
251-
$('.media-migration-current-image').html( wpmdb_add_commas( args.media_progress_image_number ) );
251+
$('.media-migration-current-image').html( wpsdb_add_commas( args.media_progress_image_number ) );
252252

253253
migrate_media_files_recursive( args );
254254
}

class/wpmdb-media-files.php renamed to class/wpsdb-media-files.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
class WPMDB_Media_Files extends WPMDB_Addon {
2+
class WPSDB_Media_Files extends WPSDB_Addon {
33
protected $files_to_migrate;
44
protected $responding_to_get_remote_media_listing = false;
55

@@ -8,20 +8,20 @@ function __construct( $plugin_file_path ) {
88

99
if( ! $this->meets_version_requirements( '1.3.1' ) ) return;
1010

11-
add_action( 'wpmdb_after_advanced_options', array( $this, 'migration_form_controls' ) );
12-
add_action( 'wpmdb_load_assets', array( $this, 'load_assets' ) );
13-
add_action( 'wpmdb_js_variables', array( $this, 'js_variables' ) );
14-
add_filter( 'wpmdb_accepted_profile_fields', array( $this, 'accepted_profile_fields' ) );
15-
add_filter( 'wpmdb_establish_remote_connection_data', array( $this, 'establish_remote_connection_data' ) );
11+
add_action( 'wpsdb_after_advanced_options', array( $this, 'migration_form_controls' ) );
12+
add_action( 'wpsdb_load_assets', array( $this, 'load_assets' ) );
13+
add_action( 'wpsdb_js_variables', array( $this, 'js_variables' ) );
14+
add_filter( 'wpsdb_accepted_profile_fields', array( $this, 'accepted_profile_fields' ) );
15+
add_filter( 'wpsdb_establish_remote_connection_data', array( $this, 'establish_remote_connection_data' ) );
1616

1717
// internal AJAX handlers
18-
add_action( 'wp_ajax_wpmdbmf_determine_media_to_migrate', array( $this, 'ajax_determine_media_to_migrate' ) );
19-
add_action( 'wp_ajax_wpmdbmf_migrate_media', array( $this, 'ajax_migrate_media' ) );
18+
add_action( 'wp_ajax_wpsdbmf_determine_media_to_migrate', array( $this, 'ajax_determine_media_to_migrate' ) );
19+
add_action( 'wp_ajax_wpsdbmf_migrate_media', array( $this, 'ajax_migrate_media' ) );
2020

2121
// external AJAX handlers
22-
add_action( 'wp_ajax_nopriv_wpmdbmf_get_remote_media_listing', array( $this, 'respond_to_get_remote_media_listing' ) );
23-
add_action( 'wp_ajax_nopriv_wpmdbmf_push_request', array( $this, 'respond_to_push_request' ) );
24-
add_action( 'wp_ajax_nopriv_wpmdbmf_remove_local_attachments', array( $this, 'respond_to_remove_local_attachments' ) );
22+
add_action( 'wp_ajax_nopriv_wpsdbmf_get_remote_media_listing', array( $this, 'respond_to_get_remote_media_listing' ) );
23+
add_action( 'wp_ajax_nopriv_wpsdbmf_push_request', array( $this, 'respond_to_push_request' ) );
24+
add_action( 'wp_ajax_nopriv_wpsdbmf_remove_local_attachments', array( $this, 'respond_to_remove_local_attachments' ) );
2525
}
2626

2727
function get_local_attachments() {
@@ -205,7 +205,7 @@ function process_pull_request() {
205205

206206
if( ! empty( $errors ) ) {
207207
$return = array(
208-
'wpmdb_error' => 1,
208+
'wpsdb_error' => 1,
209209
'body' => implode( '<br />', $errors ) . '<br />'
210210
);
211211
echo json_encode( $return );
@@ -229,7 +229,7 @@ function process_push_request() {
229229
}
230230

231231
$post_args = array(
232-
'action' => 'wpmdbmf_push_request',
232+
'action' => 'wpsdbmf_push_request',
233233
'files' => serialize( $files_to_migrate )
234234
);
235235

@@ -251,7 +251,7 @@ function respond_to_push_request() {
251251
$filtered_post['files'] = stripslashes( $filtered_post['files'] );
252252
if ( ! $this->verify_signature( $filtered_post, $this->settings['key'] ) ) {
253253
$return = array(
254-
'wpmdb_error' => 1,
254+
'wpsdb_error' => 1,
255255
'body' => $this->invalid_content_verification_error . ' (#103mf)',
256256
);
257257
echo serialize( $return );
@@ -260,7 +260,7 @@ function respond_to_push_request() {
260260

261261
if( ! isset( $_FILES['media'] ) ) {
262262
$return = array(
263-
'wpmdb_error' => 1,
263+
'wpsdb_error' => 1,
264264
'body' => '$_FILES is empty, the upload appears to have failed (#106mf)',
265265
);
266266
echo serialize( $return );
@@ -292,7 +292,7 @@ function respond_to_push_request() {
292292
$return = array( 'success' => 1 );
293293
if( ! empty( $errors ) ) {
294294
$return = array(
295-
'wpmdb_error' => 1,
295+
'wpsdb_error' => 1,
296296
'body' => implode( '<br />', $errors ) . '<br />'
297297
);
298298
}
@@ -307,7 +307,7 @@ function ajax_determine_media_to_migrate() {
307307
$local_media = $this->get_local_media();
308308

309309
$data = array();
310-
$data['action'] = 'wpmdbmf_get_remote_media_listing';
310+
$data['action'] = 'wpsdbmf_get_remote_media_listing';
311311
$data['temp_prefix'] = $this->temp_prefix;
312312
$data['intent'] = $_POST['intent'];
313313
$data['sig'] = $this->create_signature( $data, $_POST['key'] );
@@ -340,7 +340,7 @@ function ajax_determine_media_to_migrate() {
340340
}
341341
else {
342342
$data = array();
343-
$data['action'] = 'wpmdbmf_remove_local_attachments';
343+
$data['action'] = 'wpsdbmf_remove_local_attachments';
344344
$data['remote_attachments'] = serialize( $local_attachments );
345345
$data['sig'] = $this->create_signature( $data, $_POST['key'] );
346346
$ajax_url = trailingslashit( $_POST['url'] ) . 'wp-admin/admin-ajax.php';
@@ -358,7 +358,7 @@ function respond_to_remove_local_attachments() {
358358
$filtered_post['remote_attachments'] = stripslashes( $filtered_post['remote_attachments'] );
359359
if ( ! $this->verify_signature( $filtered_post, $this->settings['key'] ) ) {
360360
$return = array(
361-
'wpmdb_error' => 1,
361+
'wpsdb_error' => 1,
362362
'body' => $this->invalid_content_verification_error . ' (#109mf)',
363363
);
364364
echo serialize( $return );
@@ -368,7 +368,7 @@ function respond_to_remove_local_attachments() {
368368
$remote_attachments = @unserialize( $filtered_post['remote_attachments'] );
369369
if( false === $remote_attachments ) {
370370
$return = array(
371-
'wpmdb_error' => 1,
371+
'wpsdb_error' => 1,
372372
'body' => 'Error attempting to unserialize the remote attachment data (#110mf)',
373373
);
374374
echo serialize( $return );
@@ -449,7 +449,7 @@ function respond_to_get_remote_media_listing() {
449449
$filtered_post = $this->filter_post_elements( $_POST, array( 'action', 'temp_prefix', 'intent' ) );
450450
if ( ! $this->verify_signature( $filtered_post, $this->settings['key'] ) ) {
451451
$return = array(
452-
'wpmdb_error' => 1,
452+
'wpsdb_error' => 1,
453453
'body' => $this->invalid_content_verification_error . ' (#100mf)',
454454
);
455455
echo serialize( $return );
@@ -488,7 +488,7 @@ function load_assets() {
488488
$plugins_url = trailingslashit( plugins_url() ) . trailingslashit( $this->plugin_slug );
489489
$src = $plugins_url . 'asset/js/script.js';
490490
$version = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? time() : $this->get_installed_version();
491-
wp_enqueue_script( 'wp-migrate-db-media-files-script', $src, array( 'jquery' ), $version, true );
491+
wp_enqueue_script( 'wp-sync-db-media-files-script', $src, array( 'jquery' ), $version, true );
492492
}
493493

494494
function establish_remote_connection_data( $data ) {
@@ -498,7 +498,7 @@ function establish_remote_connection_data( $data ) {
498498
$max_file_uploads = ini_get( 'max_file_uploads' );
499499
}
500500
$max_file_uploads = ( empty( $max_file_uploads ) ) ? 20 : $max_file_uploads;
501-
$data['media_files_max_file_uploads'] = apply_filters( 'wpmdbmf_max_file_uploads', $max_file_uploads );
501+
$data['media_files_max_file_uploads'] = apply_filters( 'wpsdbmf_max_file_uploads', $max_file_uploads );
502502
return $data;
503503
}
504504

@@ -562,26 +562,26 @@ function download_url( $url, $timeout = 300 ) {
562562

563563
function js_variables() {
564564
?>
565-
var wpmdb_media_files_version = '<?php echo $this->get_installed_version(); ?>';
565+
var wpsdb_media_files_version = '<?php echo $this->get_installed_version(); ?>';
566566
<?php
567567
}
568568

569569
function verify_remote_post_response( $response ) {
570570
if ( false === $response ) {
571-
$return = array( 'wpmdb_error' => 1, 'body' => $this->error );
571+
$return = array( 'wpsdb_error' => 1, 'body' => $this->error );
572572
echo json_encode( $return );
573573
exit;
574574
}
575575

576576
if ( ! is_serialized( trim( $response ) ) ) {
577-
$return = array( 'wpmdb_error' => 1, 'body' => $response );
577+
$return = array( 'wpsdb_error' => 1, 'body' => $response );
578578
echo json_encode( $return );
579579
exit;
580580
}
581581

582582
$response = unserialize( trim( $response ) );
583583

584-
if ( isset( $response['wpmdb_error'] ) ) {
584+
if ( isset( $response['wpsdb_error'] ) ) {
585585
echo json_encode( $response );
586586
exit;
587587
}

template/migrate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
to enable media file&nbsp;migration.
2121
</p>
2222
<p class="media-files-different-plugin-version-notice inline-message warning" style="display: none; margin: 10px 0 0 0;">
23-
<strong>Version Mismatch</strong> &mdash; We've detected you have version <span class="media-file-remote-version"></span> of WP Migrate DB Media Files at <span class="media-files-remote-location"></span> but are using <?php echo $this->get_installed_version(); ?> here. Please go to the <a href="<?php echo network_admin_url( 'plugins.php' ); ?>">Plugins page</a> on both installs and check for updates.
23+
<strong>Version Mismatch</strong> &mdash; We've detected you have version <span class="media-file-remote-version"></span> of WP Sync DB Media Files at <span class="media-files-remote-location"></span> but are using <?php echo $this->get_installed_version(); ?> here. Please go to the <a href="<?php echo network_admin_url( 'plugins.php' ); ?>">Plugins page</a> on both installs and check for updates.
2424
</p>
2525
</div>

wp-migrate-db-media-files.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

wp-sync-db-media-files.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/*
3+
Plugin Name: WP Sync DB Media Files
4+
Description: An extension of WP Sync DB that allows the migration of media files.
5+
Author: Sean Lang
6+
Version: 1.1
7+
Author URI: http://slang.cx
8+
GitHub Plugin URI: wp-sync-db/wp-sync-db-media-files
9+
*/
10+
11+
function wp_sync_db_media_files_init() {
12+
if ( ! is_admin() || ! class_exists( 'WPSDB_Addon' ) ) return;
13+
14+
require_once 'class/wpsdb-media-files.php';
15+
16+
global $wpsdb_media_files;
17+
$wpsdb_media_files = new WPSDB_Media_Files( __FILE__ );
18+
}
19+
20+
add_action( 'admin_init', 'wp_sync_db_media_files_init' );

0 commit comments

Comments
 (0)