| @@ -405,8 +405,12 @@ | ||
| 405 | 405 | ) { |
| 406 | 406 | return false; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | + if ( ! apply_filters( 'wpmcs_push_to_url_pairs', true, $item_source['id'], $item_source['source_type'] ) ) { | |
| 410 | + return false; | |
| 411 | + } | |
| 412 | + | |
| 409 | 413 | $base = trailingslashit($upload_dir['baseurl']); |
| 410 | 414 | $backward_replacement = apply_filters('wpmcs_enable_backward_url_replacement', false); |
| 411 | 415 | |
| 412 | 416 | $source_server_file = Utils::remove_scheme($base.$item['source_path']); |
| @@ -626,18 +630,23 @@ | ||
| 626 | 630 | } |
| 627 | 631 | |
| 628 | 632 | if ( ! empty( $wpmcsItems ) ) { |
| 629 | 633 | foreach ( $wpmcsItems as $item ) { |
| 630 | - // Each returned item may have matched on either the source_path or original_source_path. | |
| 634 | + // Each returned item may have matched on either the source_path or original_source_path | |
| 635 | + // (or, in backward-compatibility mode, key or original_key — $paths above is keyed by | |
| 636 | + // whichever field type get_attachment_source_path() was asked for, so the lookup below | |
| 637 | + // must compare against that same field, not always source_path). | |
| 631 | 638 | // Because the base image file name of a thumbnail might match the primary rather scaled or rotated full image |
| 632 | 639 | // it's possible that both source paths are used by separate URLs. |
| 633 | 640 | $source_id = (int)$item['source_id']; |
| 634 | 641 | $source_type = $item['source_type']; |
| 635 | - $source_paths = [ $item['source_path'] ]; | |
| 642 | + $path_field = $reverse_compatibility ? 'key' : 'source_path'; | |
| 643 | + $original_field = $reverse_compatibility ? 'original_key' : 'original_source_path'; | |
| 644 | + $source_paths = [ $item[ $path_field ] ]; | |
| 636 | 645 | |
| 637 | - // If original_source_path is set, add it to source_paths. | |
| 638 | - if(isset($item['original_source_path']) && !Utils::is_empty($item['original_source_path'])) { | |
| 639 | - $source_paths[] = $item['original_source_path']; | |
| 646 | + // If the original path/key is set, add it to source_paths. | |
| 647 | + if(isset($item[ $original_field ]) && !Utils::is_empty($item[ $original_field ])) { | |
| 648 | + $source_paths[] = $item[ $original_field ]; | |
| 640 | 649 | } |
| 641 | 650 | |
| 642 | 651 | foreach ( $source_paths as $source_path ) { |
| 643 | 652 | if ( ! empty( $paths[ $source_path ] ) ) { |