1
1
<?php
2
- class WPMDB_Media_Files extends WPMDB_Addon {
2
+ class WPSDB_Media_Files extends WPSDB_Addon {
3
3
protected $ files_to_migrate ;
4
4
protected $ responding_to_get_remote_media_listing = false ;
5
5
@@ -8,20 +8,20 @@ function __construct( $plugin_file_path ) {
8
8
9
9
if ( ! $ this ->meets_version_requirements ( '1.3.1 ' ) ) return ;
10
10
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 ' ) );
16
16
17
17
// 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 ' ) );
20
20
21
21
// 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 ' ) );
25
25
}
26
26
27
27
function get_local_attachments () {
@@ -205,7 +205,7 @@ function process_pull_request() {
205
205
206
206
if ( ! empty ( $ errors ) ) {
207
207
$ return = array (
208
- 'wpmdb_error ' => 1 ,
208
+ 'wpsdb_error ' => 1 ,
209
209
'body ' => implode ( '<br /> ' , $ errors ) . '<br /> '
210
210
);
211
211
echo json_encode ( $ return );
@@ -229,7 +229,7 @@ function process_push_request() {
229
229
}
230
230
231
231
$ post_args = array (
232
- 'action ' => 'wpmdbmf_push_request ' ,
232
+ 'action ' => 'wpsdbmf_push_request ' ,
233
233
'files ' => serialize ( $ files_to_migrate )
234
234
);
235
235
@@ -251,7 +251,7 @@ function respond_to_push_request() {
251
251
$ filtered_post ['files ' ] = stripslashes ( $ filtered_post ['files ' ] );
252
252
if ( ! $ this ->verify_signature ( $ filtered_post , $ this ->settings ['key ' ] ) ) {
253
253
$ return = array (
254
- 'wpmdb_error ' => 1 ,
254
+ 'wpsdb_error ' => 1 ,
255
255
'body ' => $ this ->invalid_content_verification_error . ' (#103mf) ' ,
256
256
);
257
257
echo serialize ( $ return );
@@ -260,7 +260,7 @@ function respond_to_push_request() {
260
260
261
261
if ( ! isset ( $ _FILES ['media ' ] ) ) {
262
262
$ return = array (
263
- 'wpmdb_error ' => 1 ,
263
+ 'wpsdb_error ' => 1 ,
264
264
'body ' => '$_FILES is empty, the upload appears to have failed (#106mf) ' ,
265
265
);
266
266
echo serialize ( $ return );
@@ -292,7 +292,7 @@ function respond_to_push_request() {
292
292
$ return = array ( 'success ' => 1 );
293
293
if ( ! empty ( $ errors ) ) {
294
294
$ return = array (
295
- 'wpmdb_error ' => 1 ,
295
+ 'wpsdb_error ' => 1 ,
296
296
'body ' => implode ( '<br /> ' , $ errors ) . '<br /> '
297
297
);
298
298
}
@@ -307,7 +307,7 @@ function ajax_determine_media_to_migrate() {
307
307
$ local_media = $ this ->get_local_media ();
308
308
309
309
$ data = array ();
310
- $ data ['action ' ] = 'wpmdbmf_get_remote_media_listing ' ;
310
+ $ data ['action ' ] = 'wpsdbmf_get_remote_media_listing ' ;
311
311
$ data ['temp_prefix ' ] = $ this ->temp_prefix ;
312
312
$ data ['intent ' ] = $ _POST ['intent ' ];
313
313
$ data ['sig ' ] = $ this ->create_signature ( $ data , $ _POST ['key ' ] );
@@ -340,7 +340,7 @@ function ajax_determine_media_to_migrate() {
340
340
}
341
341
else {
342
342
$ data = array ();
343
- $ data ['action ' ] = 'wpmdbmf_remove_local_attachments ' ;
343
+ $ data ['action ' ] = 'wpsdbmf_remove_local_attachments ' ;
344
344
$ data ['remote_attachments ' ] = serialize ( $ local_attachments );
345
345
$ data ['sig ' ] = $ this ->create_signature ( $ data , $ _POST ['key ' ] );
346
346
$ ajax_url = trailingslashit ( $ _POST ['url ' ] ) . 'wp-admin/admin-ajax.php ' ;
@@ -358,7 +358,7 @@ function respond_to_remove_local_attachments() {
358
358
$ filtered_post ['remote_attachments ' ] = stripslashes ( $ filtered_post ['remote_attachments ' ] );
359
359
if ( ! $ this ->verify_signature ( $ filtered_post , $ this ->settings ['key ' ] ) ) {
360
360
$ return = array (
361
- 'wpmdb_error ' => 1 ,
361
+ 'wpsdb_error ' => 1 ,
362
362
'body ' => $ this ->invalid_content_verification_error . ' (#109mf) ' ,
363
363
);
364
364
echo serialize ( $ return );
@@ -368,7 +368,7 @@ function respond_to_remove_local_attachments() {
368
368
$ remote_attachments = @unserialize ( $ filtered_post ['remote_attachments ' ] );
369
369
if ( false === $ remote_attachments ) {
370
370
$ return = array (
371
- 'wpmdb_error ' => 1 ,
371
+ 'wpsdb_error ' => 1 ,
372
372
'body ' => 'Error attempting to unserialize the remote attachment data (#110mf) ' ,
373
373
);
374
374
echo serialize ( $ return );
@@ -449,7 +449,7 @@ function respond_to_get_remote_media_listing() {
449
449
$ filtered_post = $ this ->filter_post_elements ( $ _POST , array ( 'action ' , 'temp_prefix ' , 'intent ' ) );
450
450
if ( ! $ this ->verify_signature ( $ filtered_post , $ this ->settings ['key ' ] ) ) {
451
451
$ return = array (
452
- 'wpmdb_error ' => 1 ,
452
+ 'wpsdb_error ' => 1 ,
453
453
'body ' => $ this ->invalid_content_verification_error . ' (#100mf) ' ,
454
454
);
455
455
echo serialize ( $ return );
@@ -488,7 +488,7 @@ function load_assets() {
488
488
$ plugins_url = trailingslashit ( plugins_url () ) . trailingslashit ( $ this ->plugin_slug );
489
489
$ src = $ plugins_url . 'asset/js/script.js ' ;
490
490
$ 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 );
492
492
}
493
493
494
494
function establish_remote_connection_data ( $ data ) {
@@ -498,7 +498,7 @@ function establish_remote_connection_data( $data ) {
498
498
$ max_file_uploads = ini_get ( 'max_file_uploads ' );
499
499
}
500
500
$ 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 );
502
502
return $ data ;
503
503
}
504
504
@@ -562,26 +562,26 @@ function download_url( $url, $timeout = 300 ) {
562
562
563
563
function js_variables () {
564
564
?>
565
- var wpmdb_media_files_version = '<?php echo $ this ->get_installed_version (); ?> ';
565
+ var wpsdb_media_files_version = '<?php echo $ this ->get_installed_version (); ?> ';
566
566
<?php
567
567
}
568
568
569
569
function verify_remote_post_response ( $ response ) {
570
570
if ( false === $ response ) {
571
- $ return = array ( 'wpmdb_error ' => 1 , 'body ' => $ this ->error );
571
+ $ return = array ( 'wpsdb_error ' => 1 , 'body ' => $ this ->error );
572
572
echo json_encode ( $ return );
573
573
exit ;
574
574
}
575
575
576
576
if ( ! is_serialized ( trim ( $ response ) ) ) {
577
- $ return = array ( 'wpmdb_error ' => 1 , 'body ' => $ response );
577
+ $ return = array ( 'wpsdb_error ' => 1 , 'body ' => $ response );
578
578
echo json_encode ( $ return );
579
579
exit ;
580
580
}
581
581
582
582
$ response = unserialize ( trim ( $ response ) );
583
583
584
- if ( isset ( $ response ['wpmdb_error ' ] ) ) {
584
+ if ( isset ( $ response ['wpsdb_error ' ] ) ) {
585
585
echo json_encode ( $ response );
586
586
exit ;
587
587
}
0 commit comments