Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- Added support for a custom filter that allows modifications of the item_url tag for imported posts #813
  • Loading branch information
vytisbulkevicius authored Aug 9, 2024
2 parents 74f58e3 + 7747935 commit 08f7ab0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 36 additions & 3 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1470,16 +1470,49 @@ private function run_job( $job, $max ) {
$item_link_txt = apply_filters( 'feedzy_invoke_auto_translate_services', $item_link_txt, '[#item_url]', $import_translation_lang, $job, $language_code, $item );
}

$item_link = '<a href="' . $item['item_url'] . '" target="_blank" class="feedzy-rss-link-icon">' . $item_link_txt . '</a>';
$item_link_data = apply_filters(
'feedzy_item_link',
array(
'text' => $item_link_txt,
'attr' => array(
'href' => $item['item_url'],
'target' => '_blank',
'class' => 'feedzy-rss-link-icon',
),
),
$item,
$job
);

// Remove WordPress default link rel.
$link_rel = isset( $item_link_data['attr']['rel'] ) ? $item_link_data['attr']['rel'] : '';
if ( $link_rel ) {
add_filter(
'wp_targeted_link_rel',
function() use ( $link_rel ) {
return $link_rel;
}
);
}

$item_link_attr = isset( $item_link_data['attr'] ) ? $item_link_data['attr'] : array();
$item_link_attr = array_map(
function ( $attr, $key ) {
return sprintf( '%1$s="%2$s"', $key, esc_attr( $attr ) );
},
$item_link_attr,
array_keys( $item_link_attr )
);

$item_link_txt = isset( $item_link_data['text'] ) ? $item_link_data['text'] : $item_link_txt;
$item_link = '<a ' . implode( ' ', $item_link_attr ) . '>' . $item_link_txt . '</a>';

// Rewriter item title from feedzy API.
if ( $rewrite_service_endabled && false !== strpos( $post_title, '[#title_feedzy_rewrite]' ) ) {
$title_feedzy_rewrite = apply_filters( 'feedzy_invoke_content_rewrite_services', $item['item_title'], '[#title_feedzy_rewrite]', $job, $item );
$post_title = str_replace( '[#title_feedzy_rewrite]', $title_feedzy_rewrite, $post_title );
}

$item_link = '<a href="' . $item['item_url'] . '" target="_blank" class="feedzy-rss-link-icon">' . __( 'Read More', 'feedzy-rss-feeds' ) . '</a>';

$image_html = '';
if ( ! empty( $item['item_img_path'] ) ) {
$image_html = '<img src="' . $item['item_img_path'] . '" title="' . $item['item_title'] . '" />';
Expand Down

0 comments on commit 08f7ab0

Please sign in to comment.