From 759ba432f23866c5a4c40f7bc5e2ba0ddde6b1db Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 4 Jun 2024 15:21:21 +0300 Subject: [PATCH] fix: feed image when using chained actions --- includes/admin/feedzy-rss-feeds-import.php | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 15753f95..178ced3a 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1663,20 +1663,20 @@ private function run_job( $job, $max ) { $image_source_url = ''; $img_success = true; $new_post_id = 0; - $default_img_tag = ! empty( $import_featured_img ) && is_string( $import_featured_img ) ? $import_featured_img : ''; + $feed_img_tag = ! empty( $import_featured_img ) && is_string( $import_featured_img ) ? $import_featured_img : ''; // image tag - if ( strpos( $default_img_tag, '[#item_image]' ) !== false ) { + if ( strpos( $feed_img_tag, '[#item_image]' ) !== false ) { // image exists in item if ( ! empty( $item['item_img_path'] ) ) { - $image_source_url = str_replace( '[#item_image]', $item['item_img_path'], $default_img_tag ); + $image_source_url = str_replace( '[#item_image]', $item['item_img_path'], $feed_img_tag ); } else { $img_success = false; } - } elseif ( strpos( $default_img_tag, '[#item_custom' ) !== false ) { + } elseif ( strpos( $feed_img_tag, '[#item_custom' ) !== false ) { // custom image tag if ( $this->feedzy_is_business() || $this->feedzy_is_personal() ) { - $value = apply_filters( 'feedzy_parse_custom_tags', $default_img_tag, $item_obj ); + $value = apply_filters( 'feedzy_parse_custom_tags', $feed_img_tag, $item_obj ); } if ( ! empty( $value ) && strpos( $value, '[#item_custom' ) === false ) { @@ -1685,7 +1685,7 @@ private function run_job( $job, $max ) { $img_success = false; } } else { - $image_source_url = $default_img_tag; + $image_source_url = $feed_img_tag; } if ( ! empty( $image_source_url ) ) { @@ -1770,23 +1770,22 @@ function( $term ) { do_action( 'feedzy_import_extra', $job, $item_obj, $new_post_id, $import_errors, $import_info ); - $default_img_tag = ! empty( $import_featured_img ) && is_string( $import_featured_img ) ? $import_featured_img : ''; - if ( ! empty( $default_img_tag ) && 'attachment' !== $import_post_type ) { + if ( ! empty( $import_featured_img ) && 'attachment' !== $import_post_type ) { $image_source_url = ''; $img_success = true; - // image tag - if ( strpos( $default_img_tag, '[#item_image]' ) !== false ) { + $feed_img_tag = false === strpos( $import_featured_img, '[[{"value":' ) ? $import_featured_img : '[#item_image]'; // Use feed default image when we are using chained actions. + if ( strpos( $feed_img_tag, '[#item_image]' ) !== false ) { // image exists in item if ( ! empty( $item['item_img_path'] ) ) { - $image_source_url = str_replace( '[#item_image]', $item['item_img_path'], $default_img_tag ); + $image_source_url = str_replace( '[#item_image]', $item['item_img_path'], $feed_img_tag ); } else { $img_success = false; } - } elseif ( strpos( $default_img_tag, '[#item_custom' ) !== false ) { + } elseif ( strpos( $feed_img_tag, '[#item_custom' ) !== false ) { // custom image tag if ( $this->feedzy_is_business() || $this->feedzy_is_personal() ) { - $value = apply_filters( 'feedzy_parse_custom_tags', $default_img_tag, $item_obj ); + $value = apply_filters( 'feedzy_parse_custom_tags', $feed_img_tag, $item_obj ); } if ( ! empty( $value ) && strpos( $value, '[#item_custom' ) === false ) { $image_source_url = $value; @@ -1845,7 +1844,7 @@ function( $term ) { $import_featured_img = trim( $import_featured_img ); $img_action = $this->get_actions_runner( $import_featured_img, 'item_image' ); // Item image action process. - $image_source_url = $img_action->run_action_job( $import_featured_img, $import_translation_lang, $job, $language_code, $item, $image_source_url ); + $image_source_url = $img_action->run_action_job( $img_action->get_serialized_actions(), $import_translation_lang, $job, $language_code, $item, $image_source_url ); if ( ! empty( $image_source_url ) ) { if ( 'yes' === $import_item_img_url ) {