Skip to content

Commit

Permalink
fix: feed image when using chained actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Jun 4, 2024
1 parent 6104e3d commit 759ba43
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) ) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit 759ba43

Please sign in to comment.