Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tag parsing for feed source generated by endpoint #903

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions feedzy-rss-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function run_feedzy_rss_feeds() {
define( 'FEEDZY_REST_VERSION', '1' );
// to redirect all themeisle_log_event to error log.
define( 'FEEDZY_LOCAL_DEBUG', false );
define( 'FEEDZY_FEED_CUSTOM_TAG_NAMESPACE', 'http://feedzy.themeisle.com' );

// always make this true before testing
// also used in gutenberg.
Expand Down
22 changes: 14 additions & 8 deletions includes/abstract/feedzy-rss-feeds-admin-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public function get_short_code_attributes( $atts ) {
*
* @param string $raw Url or list of urls.
*
* @return mixed|void Urls of the feeds.
* @return string|array<string> Urls of the feeds.
*/
public function normalize_urls( $raw ) {
$feeds = apply_filters( 'feedzy_process_feed_source', $raw );
Expand Down Expand Up @@ -1412,12 +1412,12 @@ public function get_feed_array( $feed_items, $sc, $feed, $feed_url, $sizes ) {
* @since 3.0.0
* @access private
*
* @param array $sc The shorcode attributes array.
* @param array $sizes The sizes array.
* @param object $item The feed item object.
* @param string $feed_url The feed url.
* @param int $index The item number (may not be the same as the item_index).
* @param int $item_index The real index of this items in the feed (maybe be different from $index if filters are used).
* @param array $sc The shorcode attributes array.
* @param array $sizes The sizes array.
* @param \SimplePie_Item $item The feed item object.
* @param string $feed_url The feed url.
* @param int $index The item number (may not be the same as the item_index).
* @param int $item_index The real index of this items in the feed (maybe be different from $index if filters are used).
*
* @return array
*/
Expand Down Expand Up @@ -1515,8 +1515,14 @@ private function get_feed_item_filter( $sc, $sizes, $item, $feed_url, $index, $i

// multiple sources?
$is_multiple = is_array( $feed_url );
$feed_source = $item->get_feed()->get_title();

$feed_source = '';
$feed_source_tags = $item->get_item_tags( FEEDZY_FEED_CUSTOM_TAG_NAMESPACE, 'parent-source' );
if ( ! empty( $feed_source_tags ) && ! empty( $feed_source_tags[0]['data'] ) ) {
$feed_source = $feed_source_tags[0]['data'];
} else {
$feed_source = $item->get_feed()->get_title();
}
// author.
if ( $item->get_author() && $meta_args['author'] ) {
$author = $item->get_author();
Expand Down
Loading