@@ -84,7 +84,7 @@ public static function upload_images_to_wp_media_library( $image_urls, $post_id
84
84
self ::connect_to_filesystem ();
85
85
86
86
$ uploaded_image_urls = array ();
87
- $ total_images = count ( $ image_urls );
87
+ $ total_images = count ( $ image_urls );
88
88
$ successful_uploads = 0 ;
89
89
90
90
try {
@@ -204,19 +204,19 @@ public static function update_post_content_with_new_image_urls( $post_id, $url_m
204
204
if ( ! empty ( $ new_url ) ) {
205
205
// Use str_replace for exact URL replacement
206
206
$ new_content = str_replace ( $ original_url , $ new_url , $ content );
207
-
207
+
208
208
// If no replacement happened, try with HTML entity encoded version
209
209
if ( $ new_content === $ content ) {
210
210
$ encoded_url = htmlspecialchars ( $ original_url , ENT_QUOTES | ENT_HTML5 , 'UTF-8 ' );
211
211
$ new_content = str_replace ( $ encoded_url , $ new_url , $ content );
212
212
}
213
-
213
+
214
214
// If still no replacement, try with double-encoded version (common in WordPress)
215
215
if ( $ new_content === $ content ) {
216
216
$ double_encoded_url = htmlspecialchars ( htmlspecialchars ( $ original_url , ENT_QUOTES | ENT_HTML5 , 'UTF-8 ' ), ENT_QUOTES | ENT_HTML5 , 'UTF-8 ' );
217
- $ new_content = str_replace ( $ double_encoded_url , $ new_url , $ content );
217
+ $ new_content = str_replace ( $ double_encoded_url , $ new_url , $ content );
218
218
}
219
-
219
+
220
220
if ( $ new_content !== $ content ) {
221
221
$ content = $ new_content ;
222
222
$ updated = true ;
0 commit comments