PluginProbe
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets / 4.0.9
Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets v4.0.9
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
ultimate-post-kit / includes / setup-wizard / views / integration.php

integration.php in Ultimate Post Kit – Elementor Post Grid, Post Carousel, Post Slider & Blog Layout Widgets 4.0.9, at includes/setup-wizard/views/integration.php

269 lines 12.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Integration Step
4 */
5
6 namespace UltimatePostKit\SetupWizard;
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 // Include the plugin API fetcher and helper
13 require_once __DIR__ . '/../class-plugin-api-fetcher.php';
14 require_once __DIR__ . '/../class-plugin-integration-helper.php';
15
16 // Function to format date in human-readable format
17 function format_last_updated($date_string) {
18 if (empty($date_string)) {
19 return '';
20 }
21
22 // Try to parse the date
23 $date = strtotime($date_string);
24 if ($date === false) {
25 return $date_string; // Return original if parsing fails
26 }
27
28 // Calculate time difference
29 $now = time();
30 $diff = $now - $date;
31
32 // Convert to human-readable format
33 if ($diff < 60) {
34 return __('just now', 'ultimate-post-kit');
35 } elseif ($diff < 3600) {
36 $minutes = floor($diff / 60);
37 return sprintf(_n('%d minute ago', '%d minutes ago', $minutes, 'ultimate-post-kit'), $minutes);
38 } elseif ($diff < 86400) {
39 $hours = floor($diff / 3600);
40 return sprintf(_n('%d hour ago', '%d hours ago', $hours, 'ultimate-post-kit'), $hours);
41 } elseif ($diff < 2592000) { // 30 days
42 $days = floor($diff / 86400);
43 return sprintf(_n('%d day ago', '%d days ago', $days, 'ultimate-post-kit'), $days);
44 } elseif ($diff < 31536000) { // 1 year
45 $months = floor($diff / 2592000);
46 return sprintf(_n('%d month ago', '%d months ago', $months, 'ultimate-post-kit'), $months);
47 } else {
48 $years = floor($diff / 31536000);
49 return sprintf(_n('%d year ago', '%d years ago', $years, 'ultimate-post-kit'), $years);
50 }
51 }
52
53 // Function to generate fallback URLs for plugin logos
54 function get_plugin_fallback_urls($plugin_slug) {
55 // Handle different plugin slug formats
56 if (strpos($plugin_slug, '/') !== false) {
57 // If it's a file path like 'plugin-name/plugin-name.php', extract directory
58 $plugin_slug_clean = dirname($plugin_slug);
59 } else {
60 // If it's just the plugin directory name, use it directly
61 $plugin_slug_clean = $plugin_slug;
62 }
63
64 // Custom icon URLs for specific plugins that might not be on WordPress.org
65 $custom_icons = [
66 'bdthemes-element-pack-lite' => [
67 'https://ps.w.org/bdthemes-element-pack-lite/assets/icon-256x256.png',
68 'https://ps.w.org/bdthemes-element-pack-lite/assets/icon-128x128.png',
69 ],
70 'live-copy-paste' => [
71 'https://ps.w.org/live-copy-paste/assets/icon-256x256.png',
72 'https://ps.w.org/live-copy-paste/assets/icon-128x128.png',
73 ],
74 'spin-wheel' => [
75 'https://ps.w.org/spin-wheel/assets/icon-256x256.png',
76 'https://ps.w.org/spin-wheel/assets/icon-128x128.png',
77 ],
78 'ai-image' => [
79 'https://ps.w.org/ai-image/assets/icon-256x256.png',
80 'https://ps.w.org/ai-image/assets/icon-128x128.png',
81 ],
82 'smart-admin-assistant' => [
83 'https://ps.w.org/smart-admin-assistant/assets/icon-256x256.png',
84 'https://ps.w.org/smart-admin-assistant/assets/icon-128x128.png',
85 ],
86 'website-accessibility' => [
87 'https://ps.w.org/website-accessibility/assets/icon-256x256.png',
88 'https://ps.w.org/website-accessibility/assets/icon-128x128.png',
89 ],
90 ];
91
92 // Return custom icons if available, otherwise use default WordPress.org URLs
93 if (isset($custom_icons[$plugin_slug_clean])) {
94 return $custom_icons[$plugin_slug_clean];
95 }
96
97 return [
98 "https://ps.w.org/{$plugin_slug_clean}/assets/icon-256x256.gif", // Try GIF first
99 "https://ps.w.org/{$plugin_slug_clean}/assets/icon-256x256.png", // Then PNG
100 "https://ps.w.org/{$plugin_slug_clean}/assets/icon-128x128.gif", // Medium GIF
101 "https://ps.w.org/{$plugin_slug_clean}/assets/icon-128x128.png", // Medium PNG
102 ];
103 }
104
105 // Define plugin slugs to fetch data for
106 $plugin_slugs = array(
107 'bdthemes-element-pack-lite',
108 'bdthemes-prime-slider-lite',
109 'ultimate-store-kit',
110 'zoloblocks',
111 'pixel-gallery',
112 'live-copy-paste',
113 'spin-wheel',
114 'ai-image',
115 'dark-reader',
116 'ar-viewer',
117 'smart-admin-assistant',
118 'website-accessibility',
119
120 // Add more plugin slugs here as needed
121 );
122
123 // Get plugin data using the helper
124 $upk_plugins = Plugin_Integration_Helper::build_plugin_data($plugin_slugs);
125 ?>
126
127 <div class="bdt-wizard-step bdt-setup-wizard-integration" data-step="integration">
128 <h2><?php esc_html_e('Add More Firepower', 'ultimate-post-kit'); ?></h2>
129 <p><?php esc_html_e('You can onboard additional powerful plugins to extend your web design capabilities.', 'ultimate-post-kit'); ?></p>
130
131 <div class="progress-bar-container">
132 <div id="plugin-install-progress" class="progress-bar"></div>
133 </div>
134
135 <form method="POST" id="upk-install-plugins">
136 <div class="bdt-plugin-list">
137 <?php
138 foreach ($upk_plugins as $plugin) :
139 $is_active = is_plugin_active($plugin['slug']);
140 $is_recommended = $plugin['recommended'] && !$is_active;
141 ?>
142 <label class="plugin-item" data-slug="<?php echo esc_attr($plugin['slug']); ?>">
143 <span class="bdt-flex bdt-flex-middle bdt-flex-between bdt-margin-small-bottom">
144 <span class="bdt-plugin-logo">
145 <?php
146 $logo_url = $plugin['logo'] ?? '';
147 $plugin_name = $plugin['name'] ?? '';
148 $plugin_slug = $plugin['slug'] ?? '';
149
150 if (!empty($logo_url) && filter_var($logo_url, FILTER_VALIDATE_URL)) {
151 // Show the original logo from API
152 echo '<img src="' . esc_url($logo_url) . '" alt="' . esc_attr($plugin_name) . '" onerror="this.style.display=\'none\'; this.nextElementSibling.style.display=\'flex\';">';
153 echo '<div class="default-plugin-icon" style="display:none;">📦</div>';
154 } else {
155 // Generate fallback URLs for WordPress.org
156 // Extract the actual plugin slug from the file path format
157 $actual_slug = str_replace('.php', '', basename($plugin_slug));
158 $fallback_urls = get_plugin_fallback_urls($actual_slug);
159
160 echo '<img src="' . esc_url($fallback_urls[0]) . '" alt="' . esc_attr($plugin_name) . '" onerror="this.style.display=\'none\'; this.nextElementSibling.style.display=\'flex\';">';
161 echo '<div class="default-plugin-icon" style="display:none;">📦</div>';
162 }
163 ?>
164 </span>
165
166 <div class="bdt-plugin-badge-switch-wrap">
167
168 <?php if ($is_recommended) : ?>
169 <span class="recommended-badge"><?php esc_html_e('Recommended', 'ultimate-post-kit'); ?></span>
170 <?php endif; ?>
171
172 <?php if ($is_active) : ?>
173 <span class="active-badge"><?php esc_html_e('ACTIVE', 'ultimate-post-kit'); ?></span>
174 <?php endif; ?>
175 <?php
176 if (!$is_active) : ?>
177 <label class="switch">
178 <input type="checkbox" class="plugin-slider-checkbox" <?php echo wp_kses_post($plugin['recommended']) ? 'checked' : ''; ?>
179 name="plugins[]<?php echo isset($plugin['slug']) ? wp_kses_post($plugin['slug']) : ''; ?>">
180 <span class="slider round"></span>
181 </label>
182 <?php
183 endif;
184 ?>
185 </div>
186 </span>
187 <div class="bdt-flex bdt-flex-middle">
188 <span class="bdt-plugin-name">
189 <?php echo wp_kses_post($plugin['name']); ?>
190 </span>
191 </div>
192
193 <!-- <span class="plugin-text">
194 <?php //echo wp_kses_post($plugin['description']); ?>
195 </span> -->
196 <span class="active-installs">
197 <?php esc_html_e('Active Installs: ', 'ultimate-post-kit');
198 // echo wp_kses_post($plugin['active_installs'] ?? '0');
199 if (isset($plugin['active_installs_count']) && $plugin['active_installs_count'] > 0) {
200 echo ' <span class="installs-count">' . number_format($plugin['active_installs_count']) . '+' . '</span>';
201 }
202 ?>
203 </span>
204
205 <?php if (isset($plugin['downloaded_formatted']) && !empty($plugin['downloaded_formatted'])): ?>
206 <span class="downloads"><?php esc_html_e('Downloads: ', 'ultimate-post-kit'); echo wp_kses_post($plugin['downloaded_formatted']); ?></span>
207 <?php endif; ?>
208
209 <div class="rating-section">
210 <!-- <span class="rating-label"><?php //esc_html_e('Ratings', 'ultimate-post-kit'); ?></span> -->
211 <div class="wporg-ratings" title="<?php echo esc_attr($plugin['rating'] ?? '0'); ?> out of 5 stars" style="color:var(--wp--preset--color--pomegrade-1, #e26f56);">
212 <?php
213 $rating = floatval($plugin['rating'] ?? 0);
214 $full_stars = floor($rating);
215 $has_half_star = ($rating - $full_stars) >= 0.5;
216 $empty_stars = 5 - $full_stars - ($has_half_star ? 1 : 0);
217
218 // Full stars
219 for ($i = 0; $i < $full_stars; $i++) {
220 echo '<span class="dashicons dashicons-star-filled"></span>';
221 }
222
223 // Half star
224 if ($has_half_star) {
225 echo '<span class="dashicons dashicons-star-half"></span>';
226 }
227
228 // Empty stars
229 for ($i = 0; $i < $empty_stars; $i++) {
230 echo '<span class="dashicons dashicons-star-empty"></span>';
231 }
232 ?>
233 </div>
234 <span class="rating-text">
235 <?php echo esc_html($plugin['rating'] ?? '0'); ?> out of 5 stars.
236 <?php if (isset($plugin['num_ratings']) && $plugin['num_ratings'] > 0): ?>
237 <span class="rating-count">(<?php echo number_format($plugin['num_ratings']); ?> ratings)</span>
238 <?php endif; ?>
239 </span>
240 </div>
241
242
243
244 <?php if (isset($plugin['last_updated']) && !empty($plugin['last_updated'])): ?>
245 <span class="last-updated"><?php esc_html_e('Last Updated: ', 'ultimate-post-kit'); echo esc_html(format_last_updated($plugin['last_updated'])); ?></span>
246 <?php endif; ?>
247
248
249 </label>
250 <?php
251 endforeach; ?>
252 </div>
253
254 <div class="wizard-navigation bdt-margin-top">
255 <button class="bdt-button bdt-button-primary d-none" type="submit" id="upk-install-plugins-btn">
256 <?php esc_html_e('Install and Continue', 'ultimate-post-kit'); ?>
257 </button>
258 <div class="bdt-close-button bdt-margin-left bdt-wizard-next" data-step="finish"><?php esc_html_e('Skip', 'ultimate-post-kit'); ?></div>
259 </div>
260 </form>
261
262 <div class="bdt-wizard-navigation">
263 <button class="bdt-button bdt-button-secondary bdt-wizard-prev" data-step="features">
264 <span><i class="dashicons dashicons-arrow-left-alt"></i></span>
265 <?php esc_html_e('Previous Step', 'ultimate-post-kit'); ?>
266 </button>
267 </div>
268 </div>
269