PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.2
4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / views / _main / newsfeed.php
wp-staging / views / _main Last commit date
partials 1 day ago contact-us-basic.php 1 year ago contact-us-pro.php 3 months ago contact-us.php 1 year ago darkmode-toggle-button.php 4 months ago faq.php 3 months ago footer.php 2 weeks ago general-error-modal.php 1 year ago header.php 1 day ago main-navigation.php 1 year ago newsfeed.php 1 day ago
newsfeed.php
162 lines
1 <?php
2
3 /**
4 * Newsfeed view template
5 *
6 * Renders the newsfeed section in the WP Staging admin sidebar.
7 * Data is fetched from remote JSON files and rendered using this template.
8 * Collapsible state is managed via localStorage in JavaScript.
9 */
10
11 use WPStaging\Core\WPStaging;
12 use WPStaging\Framework\Language\Language;
13 use WPStaging\Framework\Newsfeed\NewsfeedProvider;
14
15 $provider = WPStaging::make(NewsfeedProvider::class);
16 $data = $provider->getNewsfeedData();
17
18 if (empty($data)) {
19 return;
20 }
21
22 $proFeatureCount = $provider->countProFeatures($data);
23
24 /**
25 * Render tip text with embedded link
26 *
27 * @param array $tip Tip data with text, link, and link_text
28 * @return string Rendered HTML
29 */
30 $renderTipText = function (array $tip): string {
31 if (empty($tip['link']) || empty($tip['link_text'])) {
32 return esc_html($tip['text'] ?? '');
33 }
34
35 $link = '<a href="' . esc_url($tip['link']) . '" target="_blank">' . esc_html($tip['link_text']) . '</a>';
36 $text = $tip['text'] ?? '';
37
38 // Replace {link} placeholder with actual link
39 if (strpos($text, '{link}') !== false) {
40 $parts = explode('{link}', $text);
41 return esc_html($parts[0]) . $link . esc_html($parts[1] ?? '');
42 }
43
44 // If no placeholder, append link at end
45 return esc_html($text) . ' ' . $link;
46 };
47 ?>
48
49 <div class="wpstg-newsfeed-container wpstg-u-block" id="wpstg-newsfeed-container">
50 <!-- Unified Header (Always Visible, Clickable) -->
51 <div class="wpstg-newsfeed-collapsed-header" data-version="<?php echo esc_attr($data['version']); ?>" role="button" aria-expanded="true">
52 <div class="wpstg-newsfeed-collapsed-left">
53 <span class="wpstg-newsfeed-version">v.<?php echo esc_html($data['version']); ?></span>
54 <span class="wpstg-newsfeed-date"><?php
55 $timestamp = !empty($data['date']) ? strtotime($data['date']) : false;
56 echo esc_html($timestamp !== false ? date_i18n('M j, Y', $timestamp) : __('Unknown date', 'wp-staging'));
57 ?></span>
58 <span class="wpstg-newsfeed-new-badge" style="display: none;"><?php esc_html_e('NEW', 'wp-staging'); ?></span>
59 <?php if (!empty($data['intro']['description'])) : ?>
60 <span class="wpstg-newsfeed-intro-brief">
61 <?php echo esc_html($data['intro']['description']); ?>
62 </span>
63 <?php endif; ?>
64 <?php if ($proFeatureCount > 0) : ?>
65 <span class="wpstg-newsfeed-pro-teaser"> <?php
66 // translators: %d is the number of Pro features
67 printf(esc_html(_n('%d new Pro feature', '%d new Pro features', $proFeatureCount, 'wp-staging')), absint($proFeatureCount));
68 ?></span>
69 <?php endif; ?>
70 </div>
71 <div class="wpstg-newsfeed-collapsed-right">
72 <span class="wpstg-newsfeed-toggle-link">
73 <span class="wpstg-toggle-text"><?php esc_html_e('View Details', 'wp-staging'); ?></span>
74 <span class="wpstg-toggle-icon"></span>
75 </span>
76 </div>
77 </div>
78
79 <!-- Collapsible Content -->
80 <div class="wpstg-newsfeed-content" style="display: none;">
81 <?php if (!empty($data['highlights'])) : ?>
82 <div class="wpstg-newsfeed-section wpstg-newsfeed-highlights">
83 <h3 class="wpstg-newsfeed-section-title"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#3498db" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="wpstg-newsfeed-icon"><path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"></path><path d="M20 3v4"></path><path d="M22 5h-4"></path><path d="M4 17v2"></path><path d="M5 18H3"></path></svg> <?php esc_html_e('New & Improved', 'wp-staging'); ?></h3>
84 <ul class="wpstg-newsfeed-list">
85 <?php foreach ($data['highlights'] as $item) : ?>
86 <li class="wpstg-newsfeed-item">
87 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="wpstg-newsfeed-check-icon"><path d="M20 6 9 17l-5-5"></path></svg>
88 <span class="wpstg-newsfeed-item-text">
89 <?php if (!empty($item['pro_only'])) : ?>
90 <span class="wpstg-newsfeed-badge-pro">PRO</span>
91 <?php endif; ?>
92 <strong><?php echo esc_html(rtrim($item['title'] ?? '', '.')); ?></strong><?php
93 if (!empty($item['description'])) :
94 ?>: <?php echo esc_html($item['description']);
95 endif;
96 ?>
97 </span>
98 </li>
99 <?php endforeach; ?>
100 </ul>
101 </div>
102 <?php endif; ?>
103
104 <?php if (!empty($data['fixes'])) : ?>
105 <div class="wpstg-newsfeed-section wpstg-newsfeed-fixes">
106 <h3 class="wpstg-newsfeed-section-title"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#e74c3c" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="wpstg-newsfeed-icon"><path d="m8 2 1.88 1.88"></path><path d="M14.12 3.88 16 2"></path><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"></path><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"></path><path d="M12 20v-9"></path><path d="M6.53 9C4.6 8.8 3 7.1 3 5"></path><path d="M6 13H2"></path><path d="M3 21c0-2.1 1.7-3.9 3.8-4"></path><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"></path><path d="M22 13h-4"></path><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"></path></svg> <?php esc_html_e('Bug Fixes', 'wp-staging'); ?></h3>
107 <ul class="wpstg-newsfeed-grid">
108 <?php foreach ($data['fixes'] as $fix) : ?>
109 <li>
110 <?php if (!empty($fix['pro_only'])) : ?>
111 <span class="wpstg-newsfeed-badge-pro">PRO</span>
112 <?php endif; ?>
113 <?php echo esc_html($fix['description'] ?? ''); ?>
114 </li>
115 <?php endforeach; ?>
116 </ul>
117 </div>
118 <?php endif; ?>
119
120 <?php if (WPStaging::isBasic()) : ?>
121 <!-- Upgrade Banner (Free Version Only) -->
122 <div class="wpstg-newsfeed-upgrade-banner">
123 <span class="wpstg-upgrade-banner-text">
124 <?php if ($proFeatureCount > 0) : ?>
125 <?php
126 // translators: %d is the number of Pro features
127 printf(esc_html__('Unlock %d Pro features', 'wp-staging'), absint($proFeatureCount));
128 ?>
129 <?php else : ?>
130 <?php esc_html_e('Unlock all Pro features', 'wp-staging'); ?>
131 <?php endif; ?>
132 </span>
133 <a href="<?php echo esc_url(Language::getUpgradeUrl('newsfeed')); ?>" target="_blank" rel="noopener" class="wpstg-upgrade-banner-btn">
134 <?php esc_html_e('Upgrade to Pro', 'wp-staging'); ?>
135 </a>
136 </div>
137 <?php endif; ?>
138 </div>
139
140 <!-- Footer (Always Visible) -->
141 <div class="wpstg-newsfeed-footer">
142 <?php if (!empty($data['tips'])) : ?>
143 <div class="wpstg-newsfeed-tips">
144 <?php foreach ($data['tips'] as $tip) : ?>
145 <div class="wpstg-newsfeed-tip-item">
146 <strong><?php echo esc_html(($tip['icon'] ?? '') . ' ' . ($tip['label'] ?? '')); ?>:</strong>
147 <?php
148 // phpcs:ignore WPStagingCS.Security.EscapeOutput.OutputNotEscaped -- Output is escaped in $renderTipText
149 echo $renderTipText($tip);
150 ?>
151 </div>
152 <?php endforeach; ?>
153 </div>
154 <?php endif; ?>
155 <div class="wpstg-newsfeed-history-link">
156 <a href="<?php echo esc_url($data['changelog_url'] ?? 'https://wp-staging.com/wp-staging-pro-changelog/'); ?>" target="_blank">
157 <?php esc_html_e('View changelog', 'wp-staging'); ?> &rarr;
158 </a>
159 </div>
160 </div>
161 </div>
162