Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
#### Fixes
- Fix broken image issues with certain feeds
- Adds new line character support for import content
- Fix import on custom values when full content is used
  • Loading branch information
selul authored Sep 6, 2021
2 parents 482c688 + e95fec4 commit a6d2e56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion includes/abstract/feedzy-rss-feeds-admin-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] ) ) {
Expand Down
19 changes: 14 additions & 5 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1201,8 +1205,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 );
Expand Down Expand Up @@ -1294,7 +1303,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 );
Expand Down Expand Up @@ -1351,7 +1360,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 );
Expand Down Expand Up @@ -1484,7 +1493,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 ) && 'attachment' !== $import_post_type ) {
$image_url = '';
Expand All @@ -1500,7 +1509,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 {
Expand Down

0 comments on commit a6d2e56

Please sign in to comment.