|
10 | 10 | use Cloudinary\Component\Setup; |
11 | 11 | use Cloudinary\Media\Filter; |
12 | 12 | use Cloudinary\Media\Global_Transformations; |
| 13 | +use Cloudinary\Sync; |
13 | 14 | use Cloudinary\String_Replace; |
14 | 15 | use Cloudinary\UI\Component\HTML; |
15 | 16 | use WP_Post; |
@@ -40,6 +41,13 @@ class Delivery implements Setup { |
40 | 41 | */ |
41 | 42 | protected $filter; |
42 | 43 |
|
| 44 | + /** |
| 45 | + * Holds the Sync component. |
| 46 | + * |
| 47 | + * @var Sync |
| 48 | + */ |
| 49 | + protected $sync; |
| 50 | + |
43 | 51 | /** |
44 | 52 | * Hold the Post ID. |
45 | 53 | * |
@@ -118,6 +126,8 @@ public function get_current_post_id() { |
118 | 126 | */ |
119 | 127 | public function setup() { |
120 | 128 | $this->filter = $this->media->filter; |
| 129 | + $this->sync = $this->media->sync; |
| 130 | + |
121 | 131 | // Add filters. |
122 | 132 | add_action( 'save_post', array( $this, 'remove_replace_cache' ) ); |
123 | 133 | add_action( 'cloudinary_string_replace', array( $this, 'catch_urls' ) ); |
@@ -218,7 +228,9 @@ public function find_attachment_size_urls( $urls ) { |
218 | 228 | $results = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.NotPrepared |
219 | 229 | if ( $results ) { |
220 | 230 | foreach ( $results as $result ) { |
221 | | - $found = array_merge( $found, $this->get_attachment_size_urls( $result->post_id ) ); |
| 231 | + if ( $this->sync->is_synced( $result->post_id ) ) { |
| 232 | + $found = array_merge( $found, $this->get_attachment_size_urls( $result->post_id ) ); |
| 233 | + } |
222 | 234 | } |
223 | 235 | } |
224 | 236 | $cached = $found; |
@@ -251,7 +263,7 @@ public function convert_tags( $content ) { |
251 | 263 | $attachment_id = $this->filter->get_id_from_tag( $element ); |
252 | 264 | $this->current_post_id = $this->filter->get_id_from_tag( $element, 'wp-post-' ); |
253 | 265 |
|
254 | | - if ( empty( $attachment_id ) ) { |
| 266 | + if ( empty( $attachment_id ) || ! $this->sync->is_synced( $attachment_id ) ) { |
255 | 267 | continue; |
256 | 268 | } |
257 | 269 | // Register replacement. |
|
0 commit comments