PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.15.0
Import WP – CSV & XML Import Export for WordPress v2.15.0
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
← All changes | class/Common/Attachment/Attachment.php +12 -9 2.7.14 → 2.15.0 View file →
@@ -85,18 +85,21 @@
85 85
86 86 $results = $wpdb->get_results($sql);
87 87 $post_id = null;
88 88
89 - if ($results) {
90 - // Use the first available result, but prefer a case-sensitive match, if exists.
91 - $post_id = reset($results)->post_id;
89 + if (count($results) > 0) {
90 + $contains_slash = strpos($path, '/');
92 91
93 - if (count($results) > 1) {
94 - foreach ($results as $result) {
95 - if ($path === $result->meta_value) {
96 - $post_id = $result->post_id;
97 - break;
98 - }
92 + foreach ($results as $result) {
93 + if ($path === $result->meta_value) {
94 +
95 + // escape if we have a direct match, if not return
96 + $post_id = $result->post_id;
97 + break;
98 + } elseif (!$contains_slash && $path === basename($result->meta_value)) {
99 +
100 + // escape if we are only matching the filename
101 + $post_id = $result->post_id;
99 102 }
100 103 }
101 104 }
102 105