PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.5.6
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.5.6
4.5.6 4.5.5 4.5.4 4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 All 148 releases
← All changes | admin/admin-feeds.php +33 -58 4.1.1 → 4.5.6 View file →
@@ -56,62 +56,12 @@
56 56 /**
57 57 * Display RSS Feeds Content
58 58 */
59 59 public function display_rss_feeds_content() {
60 - $feeds = $this->get_remote_feeds_data();
61 - if ( is_array( $feeds ) ) {
62 - foreach ( $feeds as $feed ) {
63 - ?>
64 - <div class="activity-block">
65 - <a href="<?php echo esc_url( $feed->demo_link ); ?>" target="_blank" style="margin-bottom:10px; display: inline-block;">
66 - <img src="<?php echo esc_url( $feed->image ); ?>" style="width:100%;min-height:240px;">
67 - </a>
68 - <p>
69 - <?php echo wp_kses_post( wp_trim_words( wp_strip_all_tags( $feed->content ), 50 ) ); ?>
70 - <a href="<?php echo esc_url( $feed->demo_link ); ?>" target="_blank">
71 - <?php esc_html_e( 'Learn more...', $this->settings['text_domain'] ); ?>
72 - </a>
73 - </p>
74 - </div>
75 - <?php
76 - }
77 - }
78 60 echo wp_kses_post( $this->get_rss_posts_data() );
79 61 }
80 62
81 63 /**
82 - * Get Remote Feeds Data
83 - *
84 - * @return array|mixed
85 - */
86 - private function get_remote_feeds_data() {
87 - $transient_key = $this->settings['transient_key'];
88 - $cached_data = get_transient( $transient_key );
89 -
90 - if ( ! empty( $cached_data ) ) {
91 - return json_decode( $cached_data );
92 - }
93 -
94 - $response = wp_remote_get( $this->settings['remote_feed_link'],
95 - array(
96 - 'timeout' => 30,
97 - 'headers' => array(
98 - 'Accept' => 'application/json',
99 - ),
100 - )
101 - );
102 -
103 - if ( is_wp_error( $response ) ) {
104 - return [];
105 - }
106 -
107 - $response_body = wp_remote_retrieve_body( $response );
108 - set_transient( $transient_key, $response_body, 6 * HOUR_IN_SECONDS );
109 -
110 - return json_decode( $response_body );
111 - }
112 -
113 - /**
114 64 * Get RSS Posts Data
115 65 *
116 66 * @return string
117 67 */
@@ -129,9 +79,9 @@
129 79
130 80 $rss = fetch_feed( $this->settings['feed_link'] );
131 81
132 82 if ( is_wp_error( $rss ) ) {
133 - return '<li>' . esc_html__( 'Items Not Found', $this->settings['text_domain'] ) . '.</li>';
83 + return '<li>' . esc_html__( 'Items Not Found', 'ultimate-post-kit' ) . '.</li>';
134 84 }
135 85
136 86 $maxitems = $rss->get_item_quantity( 5 );
137 87 $rss_items = $rss->get_items( 0, $maxitems );
@@ -153,23 +103,26 @@
153 103 }
154 104
155 105 ob_start();
156 106 ?>
157 - <div class="rss-widget">
107 + <div class="bdt-widget">
158 108 <ul>
159 109 <?php if ( empty( $rss_items ) ) : ?>
160 - <li><?php esc_html_e( 'Items Not Found', $this->settings['text_domain'] ); ?>.</li>
110 + <li><?php esc_html_e( 'Items Not Found', 'ultimate-post-kit' ); ?>.</li>
161 111 <?php else : ?>
162 112 <?php foreach ( $rss_items as $item ) : ?>
163 113 <li>
164 114 <a target="_blank" href="<?php echo esc_url( $item['link'] ); ?>"
165 115 title="<?php echo esc_html( $item['date'] ); ?>">
116 + <?php if ( $this->is_feed_item_new( $item['date'] ) ) : ?>
117 + <span class="bdt-feed-badge bdt-feed-badge--new"><?php esc_html_e( 'New', 'ultimate-post-kit' ); ?></span>
118 + <?php endif; ?>
166 119 <?php echo esc_html( $item['title'] ); ?>
167 120 </a>
168 - <span class="rss-date" style="display: block; margin: 0;">
169 - <?php echo esc_html( human_time_diff( $item['date'], current_time( 'timestamp' ) ) . ' ' . __( 'ago', $this->settings['text_domain'] ) ); ?>
121 + <span class="bdt-date" style="display: block; margin: 0;">
122 + <?php echo esc_html( human_time_diff( $item['date'], current_time( 'timestamp' ) ) . ' ' . __( 'ago', 'ultimate-post-kit' ) ); ?>
170 123 </span>
171 - <div class="rss-summary">
124 + <div class="bdt-summary">
172 125 <?php echo esc_html( wp_html_excerpt( $item['content'], 120 ) . ' [...]' ); ?>
173 126 </div>
174 127 </li>
175 128 <?php endforeach; ?>
@@ -193,15 +146,30 @@
193 146 </p>
194 147 <?php
195 148 return ob_get_clean();
196 149 }
150 +
151 + /**
152 + * Check if a feed item is "new" (published within the last 7 days).
153 + *
154 + * @param int|string $date Unix timestamp.
155 + * @return bool
156 + */
157 + private function is_feed_item_new( $date ) {
158 + $timestamp = is_numeric( $date ) ? (int) $date : strtotime( $date );
159 + if ( ! $timestamp ) {
160 + return false;
161 + }
162 + $cutoff = time() - ( 7 * DAY_IN_SECONDS );
163 + return $timestamp >= $cutoff;
164 + }
197 165 }
198 166
167 +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- local settings array for this admin feed file.
199 168 $settings = array(
200 169 'feed_title' => 'BdThemes News & Updates',
201 170 'transient_key' => 'bdthemes_product_feeds',
202 171 'feed_link' => 'https://bdthemes.com/feed',
203 - 'remote_feed_link' => 'https://dashboard.bdthemes.io/wp-json/bdthemes/v1/product-feed/?product_category=element-pack',
204 172 'text_domain' => 'bdthemes',
205 173 'footer_links' => [
206 174 [
207 175 'url' => 'https://bdthemes.com/blog/',
@@ -221,6 +189,13 @@
221 189 ],
222 190 ],
223 191 );
224 192
225 -new Admin_Feeds( $settings );
193 +/**
194 + * The dashboard news widget contacts an external BdThemes server, so it is strictly
195 + * opt-in: it stays disabled until the site administrator enables "BdThemes News &
196 + * Updates" under Ultimate Post Kit > Other Settings. No request is made otherwise.
197 + */
198 +if ( 'on' === \ultimate_post_kit_option( 'news_feed', 'ultimate_post_kit_other_settings', 'off' ) ) {
199 + new Admin_Feeds( $settings );
200 +}
226 201