From 398482fdd8e4dc0aca7d6b866985c8318f95fc4c Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 12 Mar 2024 10:46:43 +0200 Subject: [PATCH 1/2] feat: add tag parsing for feed source generated by endpoint When `full_content` magic tag is present, the endpoint will create a single feed with all the data. The feed is enhanced with custom tags under `feedzy` tag namespace. --- feedzy-rss-feed.php | 1 + includes/abstract/feedzy-rss-feeds-admin-abstract.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/feedzy-rss-feed.php b/feedzy-rss-feed.php index 9a5c362e..e079f18a 100644 --- a/feedzy-rss-feed.php +++ b/feedzy-rss-feed.php @@ -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. diff --git a/includes/abstract/feedzy-rss-feeds-admin-abstract.php b/includes/abstract/feedzy-rss-feeds-admin-abstract.php index 32770a68..a6bd6aa7 100644 --- a/includes/abstract/feedzy-rss-feeds-admin-abstract.php +++ b/includes/abstract/feedzy-rss-feeds-admin-abstract.php @@ -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(); From 5b671eb9badd2065ab9b1e0a6f1a6d1da6d4dc16 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 12 Mar 2024 10:56:15 +0200 Subject: [PATCH 2/2] chore: phpcs and phpdoc --- .../abstract/feedzy-rss-feeds-admin-abstract.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/abstract/feedzy-rss-feeds-admin-abstract.php b/includes/abstract/feedzy-rss-feeds-admin-abstract.php index a6bd6aa7..1e7c78e9 100644 --- a/includes/abstract/feedzy-rss-feeds-admin-abstract.php +++ b/includes/abstract/feedzy-rss-feeds-admin-abstract.php @@ -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 Urls of the feeds. */ public function normalize_urls( $raw ) { $feeds = apply_filters( 'feedzy_process_feed_source', $raw ); @@ -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 */ @@ -1515,7 +1515,7 @@ private function get_feed_item_filter( $sc, $sizes, $item, $feed_url, $index, $i // multiple sources? $is_multiple = is_array( $feed_url ); - + $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'] ) ) {