From f305d760eaa41d9b05584e9e8fcf0eb896008c89 Mon Sep 17 00:00:00 2001 From: girishkrishaweb Date: Wed, 30 Jun 2021 15:16:09 +0530 Subject: [PATCH 1/4] Fix import custom value when using #item_full_content shortcode Codeinwp/feedzy-rss-feeds-pro#398 --- includes/admin/feedzy-rss-feeds-import.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 70b0f6fd..d9d03dc1 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1190,8 +1190,13 @@ private function run_job( $job, $max ) { // the array that captures additional information about the import. $import_info = array(); - $results = $this->get_job_feed( $options, $import_content, true ); + + $xml_results = ''; + if ( '[#item_full_content]' === $import_content ) { + $xml_results = $this->get_job_feed( $options, '[#item_content]', true ); + } + if ( is_wp_error( $results ) ) { $import_errors[] = $results->get_error_message(); update_post_meta( $job->ID, 'import_errors', $import_errors ); @@ -1283,7 +1288,7 @@ private function run_job( $job, $max ) { ); if ( $this->feedzy_is_business() ) { - $post_title = apply_filters( 'feedzy_parse_custom_tags', $post_title, $results['feed'], $item['item_index'] ); + $post_title = apply_filters( 'feedzy_parse_custom_tags', $post_title, ! empty( $xml_results ) ? $xml_results['feed'] : $results['feed'], $item['item_index'] ); } $post_title = apply_filters( 'feedzy_invoke_services', $post_title, 'title', $item['item_title'], $job ); @@ -1340,7 +1345,7 @@ private function run_job( $job, $max ) { } if ( $this->feedzy_is_business() ) { - $post_content = apply_filters( 'feedzy_parse_custom_tags', $post_content, $results['feed'], $item['item_index'] ); + $post_content = apply_filters( 'feedzy_parse_custom_tags', $post_content, ! empty( $xml_results ) ? $xml_results['feed'] : $results['feed'], $item['item_index'] ); } $post_content = apply_filters( 'feedzy_invoke_services', $post_content, 'content', $item['item_description'], $job ); @@ -1429,7 +1434,7 @@ private function run_job( $job, $max ) { } } - do_action( 'feedzy_import_extra', $job, $results, $new_post_id, $index, $item['item_index'], $import_errors, $import_info ); + do_action( 'feedzy_import_extra', $job, ! empty( $xml_results ) ? $xml_results : $results, $new_post_id, $index, $item['item_index'], $import_errors, $import_info ); if ( ! empty( $import_featured_img ) ) { $image_url = ''; @@ -1445,7 +1450,7 @@ private function run_job( $job, $max ) { } } elseif ( strpos( $import_featured_img, '[#item_custom' ) !== false ) { // custom image tag - $value = apply_filters( 'feedzy_parse_custom_tags', $import_featured_img, $results['feed'], $index ); + $value = apply_filters( 'feedzy_parse_custom_tags', $import_featured_img, ! empty( $xml_results ) ? $xml_results['feed'] : $results['feed'], $index ); if ( ! empty( $value ) && strpos( $value, '[#item_custom' ) === false ) { $image_url = $value; } else { From 932d827b91026cc75ae741c3477f68d7367023ef Mon Sep 17 00:00:00 2001 From: girishkrishaweb Date: Thu, 2 Sep 2021 19:14:22 +0530 Subject: [PATCH 2/4] Fix broken feed image issue in 3.7.4 #591 --- includes/abstract/feedzy-rss-feeds-admin-abstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/abstract/feedzy-rss-feeds-admin-abstract.php b/includes/abstract/feedzy-rss-feeds-admin-abstract.php index 54b61639..ce3aabee 100644 --- a/includes/abstract/feedzy-rss-feeds-admin-abstract.php +++ b/includes/abstract/feedzy-rss-feeds-admin-abstract.php @@ -1589,7 +1589,7 @@ public function feedzy_return_image( $string ) { * @return string */ public function feedzy_scrape_image( $string, $link = '' ) { - $pattern = '/src=[\'"](.*?:\/\/.*\.(?:jpg|JPG|jpeg|JPEG|jpe|JPE|gif|GIF|png|PNG)+)[\'" >]/'; + $pattern = '/src=[\'"](.*?:\/\/.*\.(?:jpg|JPG|jpeg|JPEG|jpe|JPE|gif|GIF|png|PNG)+)[\'"]/'; $match = $link; preg_match( $pattern, $string, $link ); if ( ! empty( $link ) && isset( $link[1] ) ) { From cf6abfb121f8f7c0f95207230d79d44ce7f1a31f Mon Sep 17 00:00:00 2001 From: girishkrishaweb Date: Fri, 3 Sep 2021 18:30:24 +0530 Subject: [PATCH 3/4] Add new line character support with import content #593 --- includes/admin/feedzy-rss-feeds-import.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index acdeb8f9..9ce263e4 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1123,6 +1123,10 @@ private function run_job( $job, $max ) { $import_remove_duplicates = get_post_meta( $job->ID, 'import_remove_duplicates', true ); $import_selected_language = get_post_meta( $job->ID, 'language', true ); $max = $import_feed_limit; + // Used as a new line character in import content. + $import_content = str_replace( PHP_EOL, "\r\n", $import_content ); + $import_content = trim( $import_content ); + if ( metadata_exists( $import_post_type, $job->ID, 'import_post_status' ) ) { $import_post_status = get_post_meta( $job->ID, 'import_post_status', true ); } else { From 83eeae5fc082dbf0c0b29e01b8f90834d2dd3227 Mon Sep 17 00:00:00 2001 From: girishkrishaweb Date: Mon, 6 Sep 2021 15:10:14 +0530 Subject: [PATCH 4/4] Change regex for less restriction #591 --- includes/abstract/feedzy-rss-feeds-admin-abstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/abstract/feedzy-rss-feeds-admin-abstract.php b/includes/abstract/feedzy-rss-feeds-admin-abstract.php index ce3aabee..c5f9862c 100644 --- a/includes/abstract/feedzy-rss-feeds-admin-abstract.php +++ b/includes/abstract/feedzy-rss-feeds-admin-abstract.php @@ -1589,7 +1589,7 @@ public function feedzy_return_image( $string ) { * @return string */ public function feedzy_scrape_image( $string, $link = '' ) { - $pattern = '/src=[\'"](.*?:\/\/.*\.(?:jpg|JPG|jpeg|JPEG|jpe|JPE|gif|GIF|png|PNG)+)[\'"]/'; + $pattern = '/< *img[^>]*src *= *["\']?([^"\']*)/'; $match = $link; preg_match( $pattern, $string, $link ); if ( ! empty( $link ) && isset( $link[1] ) ) {