PluginProbe
Ultimate Post Kit / trunk
Ultimate Post Kit vtrunk
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 4.1.3 4.1.4 4.1.5 All 145 releases
ultimate-post-kit / admin / admin-settings.php

admin-settings.php in Ultimate Post Kit trunk, at admin/admin-settings.php

2,261 lines 86.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use UltimatePostKit\Notices;
4 use UltimatePostKit\Utils;
5 use UltimatePostKit\Admin\ModuleService;
6 use Elementor\Modules\Usage\Module;
7 use Elementor\Tracker;
8
9 if (!defined('ABSPATH')) {
10 exit; // Exit if accessed directly.
11 }
12
13
14 /**
15 * Ultimate Post Kit Admin Settings Class
16 */
17
18 class UltimatePostKit_Admin_Settings {
19
20 public static $modules_list = null;
21 public static $modules_names = null;
22
23 public static $modules_list_only_widgets = null;
24 public static $modules_names_only_widgets = null;
25
26 public static $modules_list_only_3rdparty = null;
27 public static $modules_names_only_3rdparty = null;
28
29 const PAGE_ID = 'ultimate_post_kit_options';
30
31 private $settings_api;
32
33 public $responseObj;
34 public $licenseMessage;
35 public $showMessage = false;
36 private $is_activated = false;
37
38 /**
39 * Rollback version instance
40 *
41 * @var Rollback_Version
42 */
43 public $rollback_version;
44
45 function __construct() {
46 $this->settings_api = new UltimatePostKit_Settings_API;
47
48 if (!defined('BDTUPK_HIDE')) {
49 add_action('admin_init', [$this, 'admin_init']);
50 add_action('admin_menu', [$this, 'admin_menu'], 201);
51 }
52
53 // Plugin installation (admin only)
54 add_action('wp_ajax_upk_install_plugin', [$this, 'install_plugin_ajax']);
55
56
57
58 if (_is_upk_pro_activated()) {
59 // Initialize rollback version functionality
60 add_action('admin_init', [$this, 'rollback_init']);
61 }
62
63 }
64
65 public function rollback_init() {
66 if ( class_exists('\UltimatePostKitPro\Rollback_Version') ) {
67 $this->rollback_version = new \UltimatePostKitPro\Rollback_Version();
68 }
69 }
70
71 /**
72 * Get used widgets.
73 *
74 * @access public
75 * @return array
76 * @since 6.0.0
77 *
78 */
79 public static function get_used_widgets() {
80
81 $used_widgets = array();
82
83 if (class_exists('Elementor\Modules\Usage\Module')) {
84
85 $module = Module::instance();
86
87 $elements = $module->get_formatted_usage('raw');
88
89 $upk_widgets = self::get_upk_widgets_names();
90
91 if (is_array($elements) || is_object($elements)) {
92
93 foreach ($elements as $post_type => $data) {
94 foreach ($data['elements'] as $element => $count) {
95 if (in_array($element, $upk_widgets, true)) {
96 if (isset($used_widgets[$element])) {
97 $used_widgets[$element] += $count;
98 } else {
99 $used_widgets[$element] = $count;
100 }
101 }
102 }
103 }
104 }
105 }
106
107 return $used_widgets;
108 }
109
110 /**
111 * Get used separate widgets.
112 *
113 * @access public
114 * @return array
115 * @since 6.0.0
116 *
117 */
118
119 public static function get_used_only_widgets() {
120
121 $used_widgets = array();
122
123 if (class_exists('Elementor\Modules\Usage\Module')) {
124
125 $module = Module::instance();
126
127 $elements = $module->get_formatted_usage('raw');
128
129 $upk_widgets = self::get_upk_only_widgets();
130
131 if (is_array($elements) || is_object($elements)) {
132
133 foreach ($elements as $post_type => $data) {
134 foreach ($data['elements'] as $element => $count) {
135 if (in_array($element, $upk_widgets, true)) {
136 if (isset($used_widgets[$element])) {
137 $used_widgets[$element] += $count;
138 } else {
139 $used_widgets[$element] = $count;
140 }
141 }
142 }
143 }
144 }
145 }
146
147 return $used_widgets;
148 }
149
150 /**
151 * Get unused widgets.
152 *
153 * @access public
154 * @return array
155 * @since 6.0.0
156 *
157 */
158
159 public static function get_unused_widgets() {
160
161 if (!current_user_can('install_plugins')) {
162 die();
163 }
164
165 $upk_widgets = self::get_upk_widgets_names();
166
167 $used_widgets = self::get_used_widgets();
168
169 $unused_widgets = array_diff($upk_widgets, array_keys($used_widgets));
170
171 return $unused_widgets;
172 }
173
174 /**
175 * Get unused separate widgets.
176 *
177 * @access public
178 * @return array
179 * @since 6.0.0
180 *
181 */
182
183 public static function get_unused_only_widgets() {
184
185 if (!current_user_can('install_plugins')) {
186 die();
187 }
188
189 $upk_widgets = self::get_upk_only_widgets();
190
191 $used_widgets = self::get_used_only_widgets();
192
193 $unused_widgets = array_diff($upk_widgets, array_keys($used_widgets));
194
195 return $unused_widgets;
196 }
197
198 /**
199 * Get widgets name
200 *
201 * @access public
202 * @return array
203 * @since 6.0.0
204 *
205 */
206
207 public static function get_upk_widgets_names() {
208 $names = self::$modules_names;
209
210 if (null === $names) {
211 $names = array_map(
212 function ($item) {
213 return isset($item['name']) ? 'upk-' . str_replace('_', '-', $item['name']) : 'none';
214 },
215 self::$modules_list
216 );
217 }
218
219 return $names;
220 }
221
222 /**
223 * Get separate widgets name
224 *
225 * @access public
226 * @return array
227 * @since 6.0.0
228 *
229 */
230
231 public static function get_upk_only_widgets() {
232 $names = self::$modules_names_only_widgets;
233
234 if (null === $names) {
235 $names = array_map(
236 function ($item) {
237 return isset($item['name']) ? 'upk-' . str_replace('_', '-', $item['name']) : 'none';
238 },
239 self::$modules_list_only_widgets
240 );
241 }
242
243 return $names;
244 }
245
246 /**
247 * Get separate 3rdParty widgets name
248 *
249 * @access public
250 * @return array
251 * @since 6.0.0
252 *
253 */
254
255 public static function get_upk_only_3rdparty_names() {
256 $names = self::$modules_names_only_3rdparty;
257
258 if (null === $names) {
259 $names = array_map(
260 function ($item) {
261 return isset($item['name']) ? 'upk-' . str_replace('_', '-', $item['name']) : 'none';
262 },
263 self::$modules_list_only_3rdparty
264 );
265 }
266
267 return $names;
268 }
269
270 /**
271 * Get URL with page id
272 *
273 * @access public
274 *
275 */
276
277 public static function get_url() {
278 return admin_url('admin.php?page=' . self::PAGE_ID);
279 }
280
281 /**
282 * Init settings API
283 *
284 * @access public
285 *
286 */
287
288 public function admin_init() {
289
290 //set the settings
291 $this->settings_api->set_sections($this->get_settings_sections());
292 $this->settings_api->set_fields($this->ultimate_post_kit_admin_settings());
293
294 //initialize settings
295 $this->settings_api->admin_init();
296 $this->upk_redirect_to_get_pro();
297 if (true === _is_upk_pro_activated()) {
298 $this->bdt_redirect_to_renew_link();
299 }
300 }
301
302 /**
303 * Add Plugin Menus
304 *
305 * @access public
306 *
307 */
308
309 // Redirect to Ultimate Post Kit Pro pricing page
310 public function upk_redirect_to_get_pro() {
311 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check of the current admin page slug for display routing, no form data processed.
312 if (isset($_GET['page']) && $_GET['page'] === self::PAGE_ID . '_get_pro') {
313 // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Intentional redirect to a fixed, hardcoded external URL; wp_safe_redirect would block off-site hosts.
314 wp_redirect('https://postkit.pro/pricing/');
315 exit;
316 }
317 }
318
319 /**
320 * Redirect to license renewal page
321 *
322 * @access public
323 *
324 */
325 public function bdt_redirect_to_renew_link() {
326 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check of the current admin page slug for display routing, no form data processed.
327 if (isset($_GET['page']) && $_GET['page'] === self::PAGE_ID . '_license_renew') {
328 // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Intentional redirect to a fixed, hardcoded external URL; wp_safe_redirect would block off-site hosts.
329 wp_redirect('https://account.bdthemes.com/');
330 exit;
331 }
332 }
333
334 /**
335 * Add Plugin Menus
336 *
337 * @access public
338 *
339 */
340
341 public function admin_menu() {
342 add_menu_page(
343 BDTUPK_TITLE . ' ' . esc_html__('Dashboard', 'ultimate-post-kit'),
344 BDTUPK_TITLE,
345 'manage_options',
346 self::PAGE_ID,
347 [$this, 'plugin_page'],
348 $this->ultimate_post_kit_icon(),
349 58
350 );
351
352 add_submenu_page(
353 self::PAGE_ID,
354 BDTUPK_TITLE,
355 esc_html__('Core Widgets', 'ultimate-post-kit'),
356 'manage_options',
357 self::PAGE_ID . '#ultimate_post_kit_active_modules',
358 [$this, 'plugin_page']
359 );
360
361 add_submenu_page(
362 self::PAGE_ID,
363 BDTUPK_TITLE,
364 esc_html__('Extensions', 'ultimate-post-kit'),
365 'manage_options',
366 self::PAGE_ID . '#ultimate_post_kit_elementor_extend',
367 [$this, 'plugin_page']
368 );
369
370 add_submenu_page(
371 self::PAGE_ID,
372 BDTUPK_TITLE,
373 esc_html__('Special Features', 'ultimate-post-kit'),
374 'manage_options',
375 self::PAGE_ID . '#ultimate_post_kit_other_settings',
376 [$this, 'plugin_page']
377 );
378
379 add_submenu_page(
380 self::PAGE_ID,
381 BDTUPK_TITLE,
382 esc_html__('API Settings', 'ultimate-post-kit'),
383 'manage_options',
384 self::PAGE_ID . '#ultimate_post_kit_api_settings',
385 [$this, 'plugin_page']
386 );
387
388 add_submenu_page(
389 self::PAGE_ID,
390 BDTUPK_TITLE,
391 esc_html__('System Status', 'ultimate-post-kit'),
392 'manage_options',
393 self::PAGE_ID . '#ultimate_post_kit_analytics_system_req',
394 [$this, 'plugin_page']
395 );
396
397 add_submenu_page(
398 self::PAGE_ID,
399 BDTUPK_TITLE,
400 esc_html__('Other Plugins', 'ultimate-post-kit'),
401 'manage_options',
402 self::PAGE_ID . '#ultimate_post_kit_other_plugins',
403 [$this, 'plugin_page']
404 );
405
406 // add_submenu_page(
407 // self::PAGE_ID,
408 // BDTUPK_TITLE,
409 // esc_html__('Get Up to 60%', 'ultimate-post-kit'),
410 // 'manage_options',
411 // self::PAGE_ID . '#ultimate_post_kit_affiliate',
412 // [$this, 'plugin_page']
413 // );
414
415 if (true == _is_upk_pro_activated()) {
416 add_submenu_page(
417 self::PAGE_ID,
418 BDTUPK_TITLE,
419 esc_html__('Rollback Version', 'ultimate-post-kit'),
420 'manage_options',
421 self::PAGE_ID . '#ultimate_post_kit_rollback_version',
422 [$this, 'plugin_page']
423 );
424
425 add_submenu_page(
426 self::PAGE_ID,
427 BDTUPK_TITLE,
428 esc_html__('Template Builder', 'ultimate-post-kit'),
429 'edit_pages',
430 'edit.php?post_type=upk-template-builder',
431 );
432 }
433
434 }
435
436 /**
437 * Get SVG Icons of Ultimate Post Kit
438 *
439 * @access public
440 * @return string
441 */
442
443 public function ultimate_post_kit_icon() {
444 return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyNC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCA5MDkuMyA4ODMuOCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgOTA5LjMgODgzLjg7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+DQoJLnN0MHtmaWxsOiNBN0FBQUQ7fQ0KPC9zdHlsZT4NCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik04MTEuMiwyNzIuOUg2ODEuNnYxMjkuN2MwLDEzLjYtMTEsMjQuNy0yNC43LDI0LjdoLTEwNWMtMTMuNiwwLTI0LjctMTEtMjQuNy0yNC43YzAsMCwwLDAsMCwwdi0xMDUNCgljMC0xMy42LDExLTI0LjcsMjQuNi0yNC43YzAsMCwwLDAsMCwwaDEyOS43VjE0My4zYzAtMTMuNi0xMS0yNC43LTI0LjctMjQuN0gzOTcuNmMtMTMuNiwwLTI0LjcsMTEtMjQuNywyNC43YzAsMCwwLDAsMCwwdjQ3MS41DQoJYzAsMTMuNi0xMSwyNC42LTI0LjYsMjQuN2MwLDAsMCwwLDAsMGgtMTA1Yy0xMy42LDAtMjQuNy0xMS0yNC43LTI0Ljd2LTM3NWMwLTEzLjYtMTEtMjQuNy0yNC43LTI0LjdIODljLTEzLjYsMC0yNC43LDExLTI0LjcsMjQuNw0KCWMwLDAsMCwwLDAsMHY1MjkuNGMwLDEzLjYsMTEsMjQuNywyNC43LDI0LjdoNDEzLjZjMTMuNiwwLDI0LjctMTEuMSwyNC43LTI0LjdWNjA2LjJjMC0xMy42LDExLTI0LjcsMjQuNy0yNC43aDI1OS4zDQoJYzEzLjYsMCwyNC43LTExLDI0LjctMjQuN1YyOTcuNkM4MzUuOSwyODQsODI0LjksMjczLDgxMS4yLDI3Mi45QzgxMS4yLDI3Mi45LDgxMS4yLDI3Mi45LDgxMS4yLDI3Mi45eiIvPg0KPHJlY3QgeD0iNzMyIiB5PSI4Mi42IiBjbGFzcz0ic3QwIiB3aWR0aD0iMzQuOCIgaGVpZ2h0PSIzNC44Ii8+DQo8cmVjdCB4PSI3OTEiIHk9IjE0OS43IiBjbGFzcz0ic3QwIiB3aWR0aD0iMjMuOSIgaGVpZ2h0PSIyMy45Ii8+DQo8cmVjdCB4PSI4MDMiIHk9IjgyLjYiIGNsYXNzPSJzdDAiIHdpZHRoPSIxNy44IiBoZWlnaHQ9IjE3LjgiLz4NCjxyZWN0IHg9Ijg2Ni43IiB5PSIxNTUuOCIgY2xhc3M9InN0MCIgd2lkdGg9IjE3LjgiIGhlaWdodD0iMTcuOCIvPg0KPHJlY3QgeD0iODI4LjkiIHk9IjQ0LjMiIGNsYXNzPSJzdDAiIHdpZHRoPSI4LjkiIGhlaWdodD0iOC45Ii8+DQo8cmVjdCB4PSI4NzcuNCIgeT0iMzgiIGNsYXNzPSJzdDAiIHdpZHRoPSI3LjIiIGhlaWdodD0iNy4yIi8+DQo8cmVjdCB4PSI4NTIuNiIgeT0iODciIGNsYXNzPSJzdDAiIHdpZHRoPSI4LjkiIGhlaWdodD0iOC45Ii8+DQo8cmVjdCB4PSI3MzUuNCIgeT0iMTgyLjgiIGNsYXNzPSJzdDAiIHdpZHRoPSIxOS43IiBoZWlnaHQ9IjE5LjciLz4NCjxyZWN0IHg9IjgyNi4zIiB5PSIyMDQuNiIgY2xhc3M9InN0MCIgd2lkdGg9IjE0LjEiIGhlaWdodD0iMTQuMSIvPg0KPC9zdmc+DQo=';
445 }
446
447 /**
448 * Get SVG Icons of Element Pack
449 *
450 * @access public
451 * @return array
452 */
453
454 public function get_settings_sections() {
455 $sections = [
456 [
457 'id' => 'ultimate_post_kit_active_modules',
458 'title' => esc_html__('Core Widgets', 'ultimate-post-kit'),
459 'icon' => 'dashicons dashicons-screenoptions',
460 ],
461 [
462 'id' => 'ultimate_post_kit_elementor_extend',
463 'title' => esc_html__('Extensions', 'ultimate-post-kit'),
464 'icon' => 'dashicons dashicons-screenoptions',
465 ],
466 [
467 'id' => 'ultimate_post_kit_other_settings',
468 'title' => esc_html__('Special Features', 'ultimate-post-kit'),
469 'icon' => 'dashicons dashicons-screenoptions',
470 ],
471 [
472 'id' => 'ultimate_post_kit_api_settings',
473 'title' => esc_html__('API Settings', 'ultimate-post-kit'),
474 'icon' => 'dashicons dashicons-admin-settings',
475 ],
476 ];
477
478 return $sections;
479 }
480
481 /**
482 * Merge Admin Settings
483 *
484 * @access protected
485 * @return array
486 */
487
488 protected function ultimate_post_kit_admin_settings() {
489
490 return ModuleService::get_widget_settings(function ($settings) {
491 $settings_fields = $settings['settings_fields'];
492
493 self::$modules_list = $settings_fields['ultimate_post_kit_active_modules'];
494 self::$modules_list_only_widgets = $settings_fields['ultimate_post_kit_active_modules'];
495
496 return $settings_fields;
497 });
498 }
499
500 /**
501 * Get Welcome Panel
502 *
503 * @access public
504 * @return void
505 */
506
507 public function ultimate_post_kit_welcome() {
508
509 ?>
510
511 <div class="upk-dashboard-panel"
512 bdt-scrollspy="target: > div > div > .bdt-card; cls: bdt-animation-slide-bottom-small; delay: 300">
513
514 <div class="upk-dashboard-welcome-container">
515
516 <div class="upk-dashboard-item upk-dashboard-welcome bdt-card bdt-card-body">
517 <h1 class="upk-feature-title upk-dashboard-welcome-title">
518 <?php esc_html_e('Welcome to Ultimate Post Kit!', 'ultimate-post-kit'); ?>
519 </h1>
520 <p class="upk-dashboard-welcome-desc">
521 <?php esc_html_e('Empower your web creation with powerful widgets, advanced extensions, ready templates and more.', 'ultimate-post-kit'); ?>
522 </p>
523 <a href="<?php echo esc_url( admin_url( '?upk_setup_wizard=show' ) ); ?>"
524 class="bdt-button bdt-welcome-button bdt-margin-small-top"
525 target="_blank"><?php esc_html_e('Setup Ultimate Post Kit', 'ultimate-post-kit'); ?></a>
526
527 <div class="upk-dashboard-compare-section">
528 <h4 class="upk-feature-sub-title">
529 <?php
530 /* translators: 1: opening strong tag, 2: closing strong tag */
531 printf(esc_html__('Unlock %1$sPremium Features%2$s', 'ultimate-post-kit'), '<strong class="upk-highlight-text">', '</strong>'); ?>
532 </h4>
533 <h1 class="upk-feature-title upk-dashboard-compare-title">
534 <?php esc_html_e('Create Your Sleek Website with Ultimate Post Kit Pro!', 'ultimate-post-kit'); ?>
535 </h1>
536 <p><?php esc_html_e('Don\'t need more plugins. This pro addon helps you build complex or professional websites—visually stunning, functional and customizable.', 'ultimate-post-kit'); ?>
537 </p>
538 <ul>
539 <li><?php esc_html_e('Dynamic Content and Integrations', 'ultimate-post-kit'); ?></li>
540 <li><?php esc_html_e('Live Copy Paste', 'ultimate-post-kit'); ?></li>
541 <li><?php esc_html_e('Template Builder', 'ultimate-post-kit'); ?></li>
542 <li><?php esc_html_e('Custom Meta Fields - Category Image, Audio Link, Video Link', 'ultimate-post-kit'); ?></li>
543 <li><?php esc_html_e('Powerful Widgets and Advanced Extensions', 'ultimate-post-kit'); ?>
544 </li>
545 </ul>
546 <div class="upk-dashboard-compare-section-buttons">
547 <a href="https://postkit.pro/pricing/"
548 class="bdt-button bdt-welcome-button bdt-margin-small-right"
549 target="_blank"><?php esc_html_e('Compare Free Vs Pro', 'ultimate-post-kit'); ?></a>
550 <a href="https://store.bdthemes.com/ultimate-post-kit?utm_source=UltimatePostKit&utm_medium=PluginPage&utm_campaign=UltimatePostKit&coupon=FREETOPRO"
551 class="bdt-button bdt-dashboard-sec-btn"
552 target="_blank"><?php esc_html_e('Get Premium at 30% OFF', 'ultimate-post-kit'); ?></a>
553 </div>
554 </div>
555 </div>
556
557 <div class="upk-dashboard-item upk-dashboard-template-quick-access bdt-card bdt-card-body">
558 <div class="upk-dashboard-template-section">
559 <img src="<?php echo esc_url( BDTUPK_ADMIN_URL . 'assets/images/template.jpg' ); ?>"
560 alt="<?php echo esc_attr__( 'Ultimate Post Kit Dashboard Template', 'ultimate-post-kit' ); ?>">
561 <h1 class="upk-feature-title ">
562 <?php esc_html_e('Faster Web Creation with Sleek and Ready-to-Use Templates!', 'ultimate-post-kit'); ?>
563 </h1>
564 <p><?php esc_html_e('Build your wordpress websites of any niche—not from scratch and in a single click.', 'ultimate-post-kit'); ?>
565 </p>
566 <a href="https://postkit.pro/"
567 class="bdt-button bdt-dashboard-sec-btn bdt-margin-small-top"
568 target="_blank"><?php esc_html_e('View Templates', 'ultimate-post-kit'); ?></a>
569 </div>
570
571 <div class="upk-dashboard-quick-access bdt-margin-medium-top">
572 <img src="<?php echo esc_url( BDTUPK_ADMIN_URL . 'assets/images/support.jpg' ); ?>"
573 alt="<?php echo esc_attr__( 'Ultimate Post Kit Dashboard Template', 'ultimate-post-kit' ); ?>">
574 <h1 class="upk-feature-title">
575 <?php esc_html_e('Getting Started with Quick Access', 'ultimate-post-kit'); ?>
576 </h1>
577 <ul>
578 <li><a href="https://postkit.pro/contact/"
579 target="_blank"><?php esc_html_e('Contact Us', 'ultimate-post-kit'); ?></a></li>
580 <li><a href="https://bdthemes.com/support/"
581 target="_blank"><?php esc_html_e('Help Centre', 'ultimate-post-kit'); ?></a></li>
582 <li><a href="https://feedback.bdthemes.com/b/6vr2250l/feature-requests/idea/new"
583 target="_blank"><?php esc_html_e('Request a Feature', 'ultimate-post-kit'); ?></a>
584 </li>
585 </ul>
586 <div class="upk-dashboard-support-section">
587 <h1 class="upk-feature-title">
588 <i class="dashicons dashicons-phone"></i>
589 <?php esc_html_e('24/7 Support', 'ultimate-post-kit'); ?>
590 </h1>
591 <p><?php esc_html_e('Helping you get real-time solutions related to web creation with WordPress, Elementor, and Ultimate Post Kit.', 'ultimate-post-kit'); ?>
592 </p>
593 <a href="https://bdthemes.com/support/" class="bdt-margin-small-top"
594 target="_blank"><?php esc_html_e('Get Your Support', 'ultimate-post-kit'); ?></a>
595 </div>
596 </div>
597 </div>
598
599 <div class="upk-dashboard-item upk-dashboard-request-feature bdt-card bdt-card-body">
600 <h1 class="upk-feature-title upk-dashboard-template-quick-title">
601 <?php esc_html_e('What\'s Stacking You?', 'ultimate-post-kit'); ?>
602 </h1>
603 <p><?php esc_html_e('We are always here to help you. If you have any feature request, please let us know.', 'ultimate-post-kit'); ?>
604 </p>
605 <a href="https://feedback.bdthemes.com/b/6vr2250l/feature-requests/idea/new"
606 class="bdt-button bdt-dashboard-sec-btn bdt-margin-small-top"
607 target="_blank"><?php esc_html_e('Request Your Features', 'ultimate-post-kit'); ?></a>
608 </div>
609
610 <a href="https://www.youtube.com/watch?v=zNeoRz94cPw&list=PLP0S85GEw7DNBnZCb4RtJzlf38GCJ7z1b" target="_blank"
611 class="upk-dashboard-item upk-dashboard-footer-item upk-dashboard-video-tutorial bdt-card bdt-card-body bdt-card-small">
612 <span class="upk-dashboard-footer-item-icon">
613 <i class="dashicons dashicons-video-alt3"></i>
614 </span>
615 <h1 class="upk-feature-title"><?php esc_html_e('Watch Video Tutorials', 'ultimate-post-kit'); ?></h1>
616 <p><?php esc_html_e('An invaluable resource for mastering WordPress, Elementor, and Web Creation', 'ultimate-post-kit'); ?>
617 </p>
618 </a>
619 <a href="https://bdthemes.com/knowledge-base/ultimate-post-kit/" target="_blank"
620 class="upk-dashboard-item upk-dashboard-footer-item upk-dashboard-documentation bdt-card bdt-card-body bdt-card-small">
621 <span class="upk-dashboard-footer-item-icon">
622 <i class="dashicons dashicons-admin-tools"></i>
623 </span>
624 </span>
625 <h1 class="upk-feature-title"><?php esc_html_e('Read Easy Documentation', 'ultimate-post-kit'); ?></h1>
626 <p><?php esc_html_e('A way to eliminate the challenges you might face', 'ultimate-post-kit'); ?></p>
627 </a>
628 <a href="https://www.facebook.com/bdthemes" target="_blank"
629 class="upk-dashboard-item upk-dashboard-footer-item upk-dashboard-community bdt-card bdt-card-body bdt-card-small">
630 <span class="upk-dashboard-footer-item-icon">
631 <i class="dashicons dashicons-admin-users"></i>
632 </span>
633 <h1 class="upk-feature-title"><?php esc_html_e('Join Our Community', 'ultimate-post-kit'); ?></h1>
634 <p><?php esc_html_e('A platform for the opportunity to network, collaboration and innovation', 'ultimate-post-kit'); ?>
635 </p>
636 </a>
637 <a href="https://wordpress.org/plugins/ultimate-post-kit/#reviews" target="_blank"
638 class="upk-dashboard-item upk-dashboard-footer-item upk-dashboard-review bdt-card bdt-card-body bdt-card-small">
639 <span class="upk-dashboard-footer-item-icon">
640 <i class="dashicons dashicons-star-filled"></i>
641 </span>
642 <h1 class="upk-feature-title"><?php esc_html_e('Show Your Love', 'ultimate-post-kit'); ?></h1>
643 <p><?php esc_html_e('A way of the assessment of code', 'ultimate-post-kit'); ?></p>
644 </a>
645 </div>
646
647 </div>
648
649 <?php
650 }
651
652 /**
653 * Get Pro
654 *
655 * @access public
656 * @return void
657 */
658
659 function ultimate_post_kit_get_pro() {
660 ?>
661 <div class="upk-dashboard-panel" bdt-scrollspy="target: > div > div > .bdt-card; cls: bdt-animation-slide-bottom-small; delay: 300">
662
663 <div class="bdt-grid" bdt-grid bdt-height-match="target: > div > .bdt-card" style="max-width: 800px; margin-left: auto; margin-right: auto;">
664 <div class="bdt-width-1-1@m upk-comparision bdt-text-center">
665
666 <div class="bdt-flex bdt-flex-between bdt-flex-middle">
667 <div class="bdt-text-left">
668 <h1 class="bdt-text-bold">
669 <?php echo esc_html_x('WHY GO WITH PRO?', 'Frontend', 'ultimate-post-kit'); ?>
670 </h1>
671 <h2>
672 <?php echo esc_html_x('Just Compare With Ultimate Post Kit Free Vs Pro', 'Frontend', 'ultimate-post-kit'); ?>
673 </h2>
674
675 </div>
676 <?php if (true !== _is_upk_pro_activated()) : ?>
677 <div class="upk-purchase-button">
678 <a href="https://postkit.pro/pricing/" target="_blank">
679 <?php echo esc_html_x('Purchase Now', 'Frontend', 'ultimate-post-kit'); ?>
680 </a>
681 </div>
682 <?php endif; ?>
683 </div>
684
685
686 <div>
687
688 <ul class="bdt-list bdt-list-divider bdt-text-left bdt-text-normal" style="font-size: 15px;">
689
690
691 <li class="bdt-text-bold">
692 <div class="bdt-grid">
693 <div class="bdt-width-expand@m">
694 <?php echo esc_html_x('Features', 'Frontend', 'ultimate-post-kit'); ?>
695 </div>
696 <div class="bdt-width-auto@m">
697 <?php echo esc_html_x('Free', 'Frontend', 'ultimate-post-kit'); ?>
698 </div>
699 <div class="bdt-width-auto@m">
700 <?php echo esc_html_x('Pro', 'Frontend', 'ultimate-post-kit'); ?>
701 </div>
702 </div>
703 </li>
704 <li class="">
705 <div class="bdt-grid">
706 <div class="bdt-width-expand@m"><span bdt-tooltip="pos: top-left; title: Lite have 35+ Widgets but Pro have 100+ core widgets">
707 <?php echo esc_html_x('Core Widgets', 'Frontend', 'ultimate-post-kit'); ?>
708 </span></div>
709 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
710 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
711 </div>
712 </li>
713 <li class="">
714 <div class="bdt-grid">
715 <div class="bdt-width-expand@m">
716 <?php echo esc_html_x('Theme Compatibility', 'Frontend', 'ultimate-post-kit'); ?>
717 </div>
718 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
719 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
720 </div>
721 </li>
722 <li class="">
723 <div class="bdt-grid">
724 <div class="bdt-width-expand@m">
725 <?php echo esc_html_x('Dynamic Content & Custom Fields Capabilities', 'Frontend', 'ultimate-post-kit'); ?>
726 </div>
727 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
728 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
729 </div>
730 </li>
731 <li class="">
732 <div class="bdt-grid">
733 <div class="bdt-width-expand@m">
734 <?php echo esc_html_x('Proper Documentation', 'Frontend', 'ultimate-post-kit'); ?>
735 </div>
736 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
737 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
738 </div>
739 </li>
740 <li class="">
741 <div class="bdt-grid">
742 <div class="bdt-width-expand@m">
743 <?php echo esc_html_x('Updates & Support', 'Frontend', 'ultimate-post-kit'); ?>
744 </div>
745 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
746 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
747 </div>
748 </li>
749
750 <li class="">
751 <div class="bdt-grid">
752 <div class="bdt-width-expand@m">
753 <?php echo esc_html_x('Ready Made Pages', 'Frontend', 'ultimate-post-kit'); ?>
754 </div>
755 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
756 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
757 </div>
758 </li>
759 <li class="">
760 <div class="bdt-grid">
761 <div class="bdt-width-expand@m">
762 <?php echo esc_html_x('Ready Made Blocks', 'Frontend', 'ultimate-post-kit'); ?>
763 </div>
764 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
765 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
766 </div>
767 </li>
768 <li class="">
769 <div class="bdt-grid">
770 <div class="bdt-width-expand@m">
771 <?php echo esc_html_x('Elementor Extended Widgets', 'Frontend', 'ultimate-post-kit'); ?>
772 </div>
773 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
774 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
775 </div>
776 </li>
777 <li class="">
778 <div class="bdt-grid">
779 <div class="bdt-width-expand@m">
780 <?php echo esc_html_x('Live Copy or Paste', 'Frontend', 'ultimate-post-kit'); ?>
781 </div>
782 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
783 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
784 </div>
785 </li>
786 <li class="">
787 <div class="bdt-grid">
788 <div class="bdt-width-expand@m">
789 <?php echo esc_html_x('Duplicator', 'Frontend', 'ultimate-post-kit'); ?>
790 </div>
791 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
792 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
793 </div>
794 </li>
795 <li class="">
796 <div class="bdt-grid">
797 <div class="bdt-width-expand@m">
798 <?php echo esc_html_x('Video Link Meta', 'Frontend', 'ultimate-post-kit'); ?>
799 </div>
800 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
801 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
802 </div>
803 </li>
804 <li class="">
805 <div class="bdt-grid">
806 <div class="bdt-width-expand@m">
807 <?php echo esc_html_x('Category Image', 'Frontend', 'ultimate-post-kit'); ?>
808 </div>
809 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
810 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
811 </div>
812 </li>
813 <li class="">
814 <div class="bdt-grid">
815 <div class="bdt-width-expand@m">
816 <?php echo esc_html_x('Rooten Theme Pro Features', 'Frontend', 'ultimate-post-kit'); ?>
817 </div>
818 <div class="bdt-width-auto@m"><span class="dashicons dashicons-no"></span></div>
819 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
820 </div>
821 </li>
822 <li class="">
823 <div class="bdt-grid">
824 <div class="bdt-width-expand@m">
825 <?php echo esc_html_x('Priority Support', 'Frontend', 'ultimate-post-kit'); ?>
826 </div>
827 <div class="bdt-width-auto@m"><span class="dashicons dashicons-no"></span></div>
828 <div class="bdt-width-auto@m"><span class="dashicons dashicons-yes"></span></div>
829 </div>
830 </li>
831
832 </ul>
833
834
835 <!-- <div class="upk-dashboard-divider"></div> -->
836
837
838 <div class="upk-more-features bdt-card bdt-card-body bdt-margin-medium-top bdt-padding-large">
839 <ul class="bdt-list bdt-list-divider bdt-text-left" style="font-size: 15px;">
840 <li>
841 <div class="bdt-grid bdt-grid-small">
842 <div class="bdt-width-1-3@m">
843 <span class="dashicons dashicons-heart"></span>
844 <?php echo esc_html_x('Incredibly Advanced', 'Frontend', 'ultimate-post-kit'); ?>
845 </div>
846 <div class="bdt-width-1-3@m">
847 <span class="dashicons dashicons-heart"></span>
848 <?php echo esc_html_x('Refund or Cancel Anytime', 'Frontend', 'ultimate-post-kit'); ?>
849 </div>
850 <div class="bdt-width-1-3@m">
851 <span class="dashicons dashicons-heart"></span>
852 <?php echo esc_html_x('Dynamic Content', 'Frontend', 'ultimate-post-kit'); ?>
853 </div>
854 </div>
855 </li>
856
857 <li>
858 <div class="bdt-grid bdt-grid-small">
859 <div class="bdt-width-1-3@m">
860 <span class="dashicons dashicons-heart"></span>
861 <?php echo esc_html_x('Super-Flexible Widgets', 'Frontend', 'ultimate-post-kit'); ?>
862 </div>
863 <div class="bdt-width-1-3@m">
864 <span class="dashicons dashicons-heart"></span>
865 <?php echo esc_html_x('24/7 Premium Support', 'Frontend', 'ultimate-post-kit'); ?>
866 </div>
867 <div class="bdt-width-1-3@m">
868 <span class="dashicons dashicons-heart"></span>
869 <?php echo esc_html_x('Third Party Plugins', 'Frontend', 'ultimate-post-kit'); ?>
870 </div>
871 </div>
872 </li>
873
874 <li>
875 <div class="bdt-grid bdt-grid-small">
876 <div class="bdt-width-1-3@m">
877 <span class="dashicons dashicons-heart"></span>
878 <?php echo esc_html_x('Special Discount!', 'Frontend', 'ultimate-post-kit'); ?>
879 </div>
880 <div class="bdt-width-1-3@m">
881 <span class="dashicons dashicons-heart"></span>
882 <?php echo esc_html_x('Custom Field Integration', 'Frontend', 'ultimate-post-kit'); ?>
883 </div>
884 <div class="bdt-width-1-3@m">
885 <span class="dashicons dashicons-heart"></span>
886 <?php echo esc_html_x('With Live Chat Support', 'Frontend', 'ultimate-post-kit'); ?>
887 </div>
888 </div>
889 </li>
890
891 <li>
892 <div class="bdt-grid bdt-grid-small">
893 <div class="bdt-width-1-3@m">
894 <span class="dashicons dashicons-heart"></span>
895 <?php echo esc_html_x('Trusted Payment Methods', 'Frontend', 'ultimate-post-kit'); ?>
896 </div>
897 <div class="bdt-width-1-3@m">
898 <span class="dashicons dashicons-heart"></span>
899 <?php echo esc_html_x('Interactive Effects', 'Frontend', 'ultimate-post-kit'); ?>
900 </div>
901 <div class="bdt-width-1-3@m">
902 <span class="dashicons dashicons-heart"></span>
903 <?php echo esc_html_x('Video Tutorial', 'Frontend', 'ultimate-post-kit'); ?>
904 </div>
905 </div>
906 </li>
907 </ul>
908
909 <!-- <div class="upk-dashboard-divider"></div> -->
910
911 <?php if (true !== _is_upk_pro_activated()) : ?>
912 <div class="upk-purchase-button bdt-margin-medium-top">
913 <a href="https://postkit.pro/pricing/" target="_blank">
914 <?php echo esc_html_x('Purchase Now', 'Frontend', 'ultimate-post-kit'); ?>
915 </a>
916 </div>
917 <?php endif; ?>
918
919 </div>
920
921 </div>
922 </div>
923 </div>
924
925 </div>
926 <?php
927 }
928
929 /**
930 * Display Plugin Page
931 *
932 * @access public
933 * @return void
934 */
935
936 public function plugin_page() {
937
938 ?>
939
940 <div class="wrap ultimate-post-kit-dashboard">
941 <h1></h1> <!-- don't remove this div, it's used for the notice container -->
942
943 <div class="upk-dashboard-wrapper bdt-margin-top">
944 <div class="upk-dashboard-header bdt-flex bdt-flex-wrap bdt-flex-between bdt-flex-middle"
945 bdt-sticky="offset: 32; animation: bdt-animation-slide-top-small; duration: 300">
946
947 <div class="bdt-flex bdt-flex-wrap bdt-flex-middle">
948 <!-- Header Shape Elements -->
949 <div class="upk-header-elements">
950 <span class="upk-header-element upk-header-circle"></span>
951 <span class="upk-header-element upk-header-dots"></span>
952 <span class="upk-header-element upk-header-line"></span>
953 <span class="upk-header-element upk-header-square"></span>
954 <span class="upk-header-element upk-header-wave"></span>
955 </div>
956
957 <div class="upk-logo">
958 <?php
959 echo '<img src="' . esc_url( BDTUPK_URL . 'assets/images/logo-with-text.svg' ) . '" alt="' . esc_attr__( 'Ultimate Post Kit Logo', 'ultimate-post-kit' ) . '">';
960 ?>
961 </div>
962 </div>
963
964 <div class="upk-dashboard-new-page-wrapper bdt-flex bdt-flex-wrap bdt-flex-middle">
965
966
967 <!-- Always render save button, JavaScript will control visibility -->
968 <div class="upk-dashboard-save-btn" style="display: none;">
969 <button class="bdt-button bdt-button-primary ultimate-post-kit-settings-save-btn" type="submit">
970 <?php esc_html_e('Save Settings', 'ultimate-post-kit'); ?>
971 </button>
972 </div>
973
974
975 <div class="upk-dashboard-new-page">
976 <a class="bdt-flex bdt-flex-middle" href="<?php echo esc_url(admin_url('post-new.php?post_type=page')); ?>" class=""><i class="dashicons dashicons-admin-page"></i>
977 <?php echo esc_html__('Create New Page', 'ultimate-post-kit') ?>
978 </a>
979 </div>
980 </div>
981 </div>
982
983 <div class="upk-dashboard-container bdt-flex">
984 <div class="upk-dashboard-nav-container-wrapper">
985 <div class="upk-dashboard-nav-container-inner" bdt-sticky="end: !.upk-dashboard-container; offset: 115; animation: bdt-animation-slide-top-small; duration: 300">
986
987 <!-- Navigation Shape Elements -->
988 <div class="upk-nav-elements">
989 <span class="upk-nav-element upk-nav-circle"></span>
990 <span class="upk-nav-element upk-nav-dots"></span>
991 <span class="upk-nav-element upk-nav-line"></span>
992 <span class="upk-nav-element upk-nav-square"></span>
993 <span class="upk-nav-element upk-nav-triangle"></span>
994 <span class="upk-nav-element upk-nav-plus"></span>
995 <span class="upk-nav-element upk-nav-wave"></span>
996 </div>
997
998 <?php $this->settings_api->show_navigation(); ?>
999 </div>
1000 </div>
1001
1002
1003 <div class="bdt-switcher bdt-tab-container bdt-container-xlarge bdt-flex-1">
1004 <div id="ultimate_post_kit_welcome_page" class="upk-option-page group">
1005 <?php $this->ultimate_post_kit_welcome(); ?>
1006 </div>
1007
1008 <?php $this->settings_api->show_forms(); ?>
1009
1010 <div id="ultimate_post_kit_analytics_system_req_page" class="upk-option-page group">
1011 <?php $this->ultimate_post_kit_analytics_system_req_content(); ?>
1012 </div>
1013
1014 <div id="ultimate_post_kit_other_plugins_page" class="upk-option-page group">
1015 <?php $this->ultimate_post_kit_others_plugin(); ?>
1016 </div>
1017
1018 <!-- <div id="ultimate_post_kit_affiliate_page" class="upk-option-page group">
1019 <?php //$this->ultimate_post_kit_affiliate_content(); ?>
1020 </div> -->
1021
1022 <?php if (true == _is_upk_pro_activated()) : ?>
1023 <div id="ultimate_post_kit_rollback_version_page" class="upk-option-page group">
1024 <?php $this->upk_rollback_version_content(); ?>
1025 </div>
1026 <?php endif; ?>
1027
1028 <?php if (_is_upk_pro_activated() !== true) : ?>
1029 <div id="ultimate_post_kit_get_pro" class="upk-option-page group">
1030 <?php $this->ultimate_post_kit_get_pro(); ?>
1031 </div>
1032 <?php endif; ?>
1033
1034 <?php
1035 // Render tab bodies for any add-on-registered dashboard tabs.
1036 // The core plugin provides only this extension point; the tab
1037 // ids/order match the nav items built in show_navigation().
1038 foreach ($this->settings_api->get_extra_dashboard_tabs() as $upk_extra_tab) {
1039 if (empty($upk_extra_tab['id'])) {
1040 continue;
1041 }
1042 echo '<div id="' . esc_attr($upk_extra_tab['id']) . '_page" class="upk-option-page group">';
1043 if (isset($upk_extra_tab['callback']) && is_callable($upk_extra_tab['callback'])) {
1044 call_user_func($upk_extra_tab['callback']);
1045 }
1046 echo '</div>';
1047 }
1048 ?>
1049
1050 <div id="ultimate_post_kit_license_settings_page" class="upk-option-page group">
1051
1052 <?php
1053 if (_is_upk_pro_activated() == true) {
1054 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- established hook name relied on across the plugin family; renaming would break integration.
1055 apply_filters('upk_license_page', '');
1056 }
1057
1058 ?>
1059 </div>
1060
1061 </div>
1062 </div>
1063
1064 <?php if (!defined('BDTUPK_WL') || false == self::license_wl_status()) {
1065 $this->footer_info();
1066 } ?>
1067 </div>
1068
1069 </div>
1070
1071 <?php
1072
1073 $this->script();
1074
1075 }
1076
1077
1078
1079
1080 /**
1081 * Tabbable JavaScript codes & Initiate Color Picker
1082 *
1083 * This code uses localstorage for displaying active tabs
1084 */
1085 function script() {
1086 ?>
1087 <script>
1088 jQuery(document).ready(function() {
1089 jQuery('.upk-no-result').removeClass('bdt-animation-shake');
1090 });
1091
1092 // Selector of the filter controls that are currently active (Free is active by default).
1093 function activeFilterSelector($parent) {
1094 return $parent.find('.upk-widget-filter li.bdt-active')
1095 .map(function() {
1096 var control = jQuery(this).attr('bdt-filter-control') || '';
1097 var matched = control.match(/filter:\s*([^;]+)/);
1098 return matched ? jQuery.trim(matched[1]) : null;
1099 })
1100 .get()
1101 .join('');
1102 }
1103
1104 function filterSearch(e) {
1105 var parentID = '#' + jQuery(e).data('id');
1106 var $parent = jQuery(parentID);
1107 var search = $parent.find('.bdt-search-input').val().toLowerCase();
1108
1109 // Search runs on top of the active filter and only inside its own tab, so clearing
1110 // the search never falls back to showing every widget.
1111 var filterSelector = activeFilterSelector($parent);
1112
1113 $parent.find('.upk-options .upk-option-item').each(function() {
1114 var name = (jQuery(this).attr('data-widget-name') || '').toLowerCase();
1115 var matchesSearch = name.indexOf(search) > -1;
1116 var matchesFilter = !filterSelector || jQuery(this).is(filterSelector);
1117
1118 jQuery(this).toggle(matchesSearch && matchesFilter);
1119 });
1120
1121 if (!search) {
1122 $parent.find('.bdt-search-input').attr('bdt-filter-control', "");
1123 } else {
1124 $parent.find('.bdt-search-input').attr('bdt-filter-control', "filter: [data-widget-name*='" + search + "']");
1125 $parent.find('.bdt-search-input').removeClass('bdt-active'); // Thanks to Bar-Rabbas
1126 }
1127 }
1128
1129 jQuery('.upk-options-parent').each(function(e, item) {
1130 var eachItem = '#' + jQuery(item).attr('id');
1131 jQuery(eachItem).on("beforeFilter", function() {
1132 jQuery(eachItem).find('.upk-no-result').removeClass('bdt-animation-shake');
1133 });
1134
1135 jQuery(eachItem).on("afterFilter", function() {
1136
1137 var isElementVisible = false;
1138 var i = 0;
1139
1140 if (jQuery(eachItem).closest(".upk-options-parent").eq(i).is(":visible")) {} else {
1141 isElementVisible = true;
1142 }
1143
1144 while (!isElementVisible && i < jQuery(eachItem).find(".upk-option-item").length) {
1145 if (jQuery(eachItem).find(".upk-option-item").eq(i).is(":visible")) {
1146 isElementVisible = true;
1147 }
1148 i++;
1149 }
1150
1151 if (isElementVisible === false) {
1152 jQuery(eachItem).find('.upk-no-result').addClass('bdt-animation-shake');
1153 }
1154 });
1155
1156
1157 });
1158
1159
1160 jQuery('.upk-widget-filter-nav li a').on('click', function(e) {
1161 jQuery(this).closest('.bdt-widget-filter-wrapper').find('.bdt-search-input').val('');
1162 jQuery(this).closest('.bdt-widget-filter-wrapper').find('.bdt-search-input').val('').attr('bdt-filter-control', '');
1163 });
1164
1165
1166 jQuery(document).ready(function($) {
1167 'use strict';
1168
1169 function hashHandler() {
1170 var $tab = jQuery('.ultimate-post-kit-dashboard .bdt-tab');
1171 if (window.location.hash) {
1172 var hash = window.location.hash.substring(1);
1173 bdtUIkit.tab($tab).show(jQuery('#bdt-' + hash).data('tab-index'));
1174 }
1175 }
1176
1177 function onWindowLoad() {
1178 hashHandler();
1179 }
1180
1181 if (document.readyState === 'complete') {
1182 onWindowLoad();
1183 } else {
1184 jQuery(window).on('load', onWindowLoad);
1185 }
1186
1187 window.addEventListener("hashchange", hashHandler, true);
1188
1189 jQuery('.toplevel_page_ultimate_post_kit_options > ul > li > a ').on('click', function(event) {
1190 jQuery(this).parent().siblings().removeClass('current');
1191 jQuery(this).parent().addClass('current');
1192 });
1193
1194 jQuery('#ultimate_post_kit_active_modules_page a.upk-active-all-widget').on('click', function(e) {
1195 e.preventDefault();
1196
1197 jQuery('#ultimate_post_kit_active_modules_page .upk-option-item:not(.upk-pro-inactive) .checkbox:visible').each(function() {
1198 jQuery(this).attr('checked', 'checked').prop("checked", true);
1199 });
1200
1201 jQuery(this).addClass('bdt-active');
1202 jQuery('a.upk-deactive-all-widget').removeClass('bdt-active');
1203 });
1204
1205 jQuery('#ultimate_post_kit_active_modules_page a.upk-deactive-all-widget').on('click', function(e) {
1206 e.preventDefault();
1207 jQuery('#ultimate_post_kit_active_modules_page .upk-option-item:not(.upk-pro-inactive) .checkbox:visible').each(function() {
1208 jQuery(this).removeAttr('checked');
1209 });
1210
1211 jQuery(this).addClass('bdt-active');
1212 jQuery('a.upk-active-all-widget').removeClass('bdt-active');
1213 });
1214
1215 jQuery('#ultimate_post_kit_elementor_extend_page a.upk-active-all-widget').on('click', function(e) {
1216 e.preventDefault();
1217
1218 jQuery('#ultimate_post_kit_elementor_extend_page .checkbox:visible').each(function() {
1219 jQuery(this).attr('checked', 'checked').prop("checked", true);
1220 });
1221
1222 jQuery(this).addClass('bdt-active');
1223 jQuery('a.upk-deactive-all-widget').removeClass('bdt-active');
1224 });
1225
1226 jQuery('#ultimate_post_kit_elementor_extend_page a.upk-deactive-all-widget').on('click', function(e) {
1227 e.preventDefault();
1228 jQuery('#ultimate_post_kit_elementor_extend_page .checkbox:visible').each(function() {
1229 jQuery(this).removeAttr('checked');
1230 });
1231
1232 jQuery(this).addClass('bdt-active');
1233 jQuery('a.upk-active-all-widget').removeClass('bdt-active');
1234 });
1235
1236 // Activate/Deactivate all widgets functionality
1237 $('#ultimate_post_kit_active_modules_page a.upk-active-all-widget').on('click', function (e) {
1238 e.preventDefault();
1239
1240 $('#ultimate_post_kit_active_modules_page .upk-option-item:not(.upk-pro-inactive) .checkbox:visible').each(function () {
1241 $(this).attr('checked', 'checked').prop("checked", true);
1242 });
1243
1244 $(this).addClass('bdt-active');
1245 $('#ultimate_post_kit_active_modules_page a.upk-deactive-all-widget').removeClass('bdt-active');
1246
1247 // Ensure save button remains visible
1248 setTimeout(function() {
1249 $('.upk-dashboard-save-btn').show();
1250 }, 100);
1251 });
1252
1253 $('#ultimate_post_kit_active_modules_page a.upk-deactive-all-widget').on('click', function (e) {
1254 e.preventDefault();
1255
1256 $('#ultimate_post_kit_active_modules_page .checkbox:visible').each(function () {
1257 $(this).removeAttr('checked').prop("checked", false);
1258 });
1259
1260 $(this).addClass('bdt-active');
1261 $('#ultimate_post_kit_active_modules_page a.upk-active-all-widget').removeClass('bdt-active');
1262
1263 // Ensure save button remains visible
1264 setTimeout(function() {
1265 $('.upk-dashboard-save-btn').show();
1266 }, 100);
1267 });
1268
1269 $('#ultimate_post_kit_elementor_extend_page a.upk-active-all-widget').on('click', function (e) {
1270 e.preventDefault();
1271
1272 $('#ultimate_post_kit_elementor_extend_page .upk-option-item:not(.upk-pro-inactive) .checkbox:visible').each(function () {
1273 $(this).attr('checked', 'checked').prop("checked", true);
1274 });
1275
1276 $(this).addClass('bdt-active');
1277 $('#ultimate_post_kit_elementor_extend_page a.upk-deactive-all-widget').removeClass('bdt-active');
1278
1279 // Ensure save button remains visible
1280 setTimeout(function() {
1281 $('.upk-dashboard-save-btn').show();
1282 }, 100);
1283 });
1284
1285 $('#ultimate_post_kit_elementor_extend_page a.upk-deactive-all-widget').on('click', function (e) {
1286 e.preventDefault();
1287
1288 $('#ultimate_post_kit_elementor_extend_page .checkbox:visible').each(function () {
1289 $(this).removeAttr('checked').prop("checked", false);
1290 });
1291
1292 $(this).addClass('bdt-active');
1293 $('#ultimate_post_kit_elementor_extend_page a.upk-active-all-widget').removeClass('bdt-active');
1294
1295 // Ensure save button remains visible
1296 setTimeout(function() {
1297 $('.upk-dashboard-save-btn').show();
1298 }, 100);
1299 });
1300
1301 jQuery('#ultimate_post_kit_active_modules_page .upk-pro-inactive .checkbox').each(function() {
1302 jQuery(this).removeAttr('checked');
1303 jQuery(this).attr("disabled", true);
1304 });
1305
1306 });
1307
1308 jQuery(document).ready(function ($) {
1309 const getProLink = $('a[href="admin.php?page=ultimate_post_kit_options_get_pro"]');
1310 if (getProLink.length) {
1311 getProLink.attr('target', '_blank');
1312 }
1313 });
1314
1315 // License Renew Redirect
1316 jQuery(document).ready(function ($) {
1317 const renewalLink = $('a[href="admin.php?page=ultimate_post_kit_options_license_renew"]');
1318 if (renewalLink.length) {
1319 renewalLink.attr('target', '_blank');
1320 }
1321 });
1322
1323 // Dynamic Save Button Control
1324 jQuery(document).ready(function ($) {
1325 // Define pages that need save button - only specific settings pages
1326 const pagesWithSave = [
1327 'ultimate_post_kit_active_modules', // Core widgets
1328 'ultimate_post_kit_elementor_extend', // Extensions
1329 'ultimate_post_kit_other_settings', // Special features
1330 'ultimate_post_kit_api_settings' // API settings
1331 ];
1332
1333 function toggleSaveButton() {
1334 const currentHash = window.location.hash.substring(1);
1335 const saveButton = $('.upk-dashboard-save-btn');
1336
1337 // Check if current page should have save button
1338 if (pagesWithSave.includes(currentHash)) {
1339 saveButton.fadeIn(200);
1340 } else {
1341 saveButton.fadeOut(200);
1342 }
1343 }
1344
1345 // Force save button to be visible for settings pages
1346 function forceSaveButtonVisible() {
1347 const currentHash = window.location.hash.substring(1);
1348 const saveButton = $('.upk-dashboard-save-btn');
1349
1350 if (pagesWithSave.includes(currentHash)) {
1351 saveButton.show();
1352 }
1353 }
1354
1355 // Initial check
1356 toggleSaveButton();
1357
1358 // Listen for hash changes
1359 $(window).on('hashchange', function() {
1360 toggleSaveButton();
1361 });
1362
1363 // Listen for tab clicks
1364 $('.bdt-dashboard-navigation a').on('click', function() {
1365 setTimeout(toggleSaveButton, 100);
1366 });
1367
1368 // Also listen for navigation menu clicks (from show_navigation())
1369 $(document).on('click', '.bdt-tab a, .bdt-subnav a, .upk-dashboard-nav a, [href*="#ultimate_post_kit"]', function() {
1370 setTimeout(toggleSaveButton, 100);
1371 });
1372
1373 // Listen for bulk active/deactive button clicks to maintain save button visibility
1374 $(document).on('click', '.upk-active-all-widget, .upk-deactive-all-widget', function() {
1375 setTimeout(forceSaveButtonVisible, 50);
1376 });
1377
1378 // Listen for individual checkbox changes to maintain save button visibility
1379 $(document).on('change', '#ultimate_post_kit_elementor_extend_page .checkbox, #ultimate_post_kit_active_modules_page .checkbox', function() {
1380 setTimeout(forceSaveButtonVisible, 50);
1381 });
1382
1383 // Update URL when navigation items are clicked
1384 $(document).on('click', '.bdt-tab a, .bdt-subnav a, .upk-dashboard-nav a', function(e) {
1385 const href = $(this).attr('href');
1386 if (href && href.includes('#')) {
1387 const hash = href.substring(href.indexOf('#'));
1388 if (hash && hash.length > 1) {
1389 // Update browser URL with the hash
1390 const currentUrl = window.location.href.split('#')[0];
1391 const newUrl = currentUrl + hash;
1392 window.history.pushState(null, null, newUrl);
1393
1394 // Trigger hash change event for other listeners
1395 $(window).trigger('hashchange');
1396 }
1397 }
1398 });
1399
1400 // Handle save button click
1401 $(document).on('click', '.ultimate-post-kit-settings-save-btn', function(e) {
1402 e.preventDefault();
1403
1404 // Find the active form in the current tab
1405 const currentHash = window.location.hash.substring(1);
1406 let targetForm = null;
1407
1408 // Look for forms in the active tab content
1409 if (currentHash) {
1410 // Try to find form in the specific tab page
1411 targetForm = $('#' + currentHash + '_page form.settings-save');
1412
1413 // If not found, try without _page suffix
1414 if (!targetForm || targetForm.length === 0) {
1415 targetForm = $('#' + currentHash + ' form.settings-save');
1416 }
1417
1418 // Try to find any form in the active tab content
1419 if (!targetForm || targetForm.length === 0) {
1420 targetForm = $('#' + currentHash + '_page form');
1421 }
1422 }
1423
1424 // Fallback to any visible form with settings-save class
1425 if (!targetForm || targetForm.length === 0) {
1426 targetForm = $('form.settings-save:visible').first();
1427 }
1428
1429 // Last fallback - any visible form
1430 if (!targetForm || targetForm.length === 0) {
1431 targetForm = $('.bdt-switcher .group:visible form').first();
1432 }
1433
1434 if (targetForm && targetForm.length > 0) {
1435 // Show loading notification
1436 // bdtUIkit.notification({
1437 // message: '<div bdt-spinner></div> <?php //esc_html_e('Please wait, Saving settings...', 'ultimate-post-kit') ?>',
1438 // timeout: false
1439 // });
1440
1441 // Submit form using AJAX (same logic as existing form submission)
1442 targetForm.ajaxSubmit({
1443 success: function () {
1444 // Show success message using UIkit notification (same as main settings)
1445 bdtUIkit.notification.closeAll();
1446 bdtUIkit.notification({
1447 message: '<span class="dashicons dashicons-yes"></span> <?php esc_html_e('Settings Saved Successfully.', 'ultimate-post-kit') ?>',
1448 status: 'primary',
1449 pos: 'top-center'
1450 });
1451 },
1452 error: function (data) {
1453 bdtUIkit.notification.closeAll();
1454 bdtUIkit.notification({
1455 message: '<span bdt-icon=\'icon: warning\'></span> <?php esc_html_e('Unknown error, make sure access is correct!', 'ultimate-post-kit') ?>',
1456 status: 'warning'
1457 });
1458 }
1459 });
1460 } else {
1461 // Show error if no form found
1462 bdtUIkit.notification({
1463 message: '<span bdt-icon="icon: warning"></span> <?php esc_html_e('No settings form found to save.', 'ultimate-post-kit') ?>',
1464 status: 'warning'
1465 });
1466 }
1467 });
1468
1469 });
1470
1471 // Chart.js initialization for system status canvas charts
1472 function initUltimatePostKitCharts() {
1473 // Wait for Chart.js to be available
1474 if (typeof Chart === 'undefined') {
1475 setTimeout(initUltimatePostKitCharts, 500);
1476 return;
1477 }
1478
1479 // Chart instances storage
1480 window.upkChartInstances = window.upkChartInstances || {};
1481 window.upkChartsInitialized = false;
1482
1483 // Function to create a chart
1484 function createChart(canvasId) {
1485 var canvas = document.getElementById(canvasId);
1486 if (!canvas) {
1487 return;
1488 }
1489
1490 var $canvas = jQuery('#' + canvasId);
1491 var valueStr = $canvas.data('value');
1492 var labelsStr = $canvas.data('labels');
1493 var bgStr = $canvas.data('bg');
1494
1495 if (!valueStr || !labelsStr || !bgStr) {
1496 return;
1497 }
1498
1499 // Parse data
1500 var values = valueStr.toString().split(',').map(v => parseInt(v.trim()) || 0);
1501 var labels = labelsStr.toString().split(',').map(l => l.trim());
1502 var colors = bgStr.toString().split(',').map(c => c.trim());
1503
1504 // Destroy existing chart using Chart.js built-in method
1505 var existingChart = Chart.getChart(canvas);
1506 if (existingChart) {
1507 existingChart.destroy();
1508 }
1509
1510 // Also destroy from our instance storage
1511 if (window.upkChartInstances && window.upkChartInstances[canvasId]) {
1512 window.upkChartInstances[canvasId].destroy();
1513 delete window.upkChartInstances[canvasId];
1514 }
1515
1516 // Create new chart
1517 try {
1518 var newChart = new Chart(canvas, {
1519 type: 'doughnut',
1520 data: {
1521 labels: labels,
1522 datasets: [{
1523 data: values,
1524 backgroundColor: colors,
1525 borderWidth: 0
1526 }]
1527 },
1528 options: {
1529 responsive: true,
1530 maintainAspectRatio: false,
1531 plugins: {
1532 legend: { display: false },
1533 tooltip: { enabled: true }
1534 },
1535 cutout: '60%'
1536 }
1537 });
1538
1539 // Store in our instance storage
1540 if (!window.upkChartInstances) window.upkChartInstances = {};
1541 window.upkChartInstances[canvasId] = newChart;
1542 } catch (error) {
1543 // Do nothing
1544 }
1545 }
1546
1547 // Update total widgets status
1548 function updateTotalStatus() {
1549 var coreCount = jQuery('#ultimate_post_kit_active_modules_page input:checked').length;
1550 var extensionsCount = jQuery('#ultimate_post_kit_elementor_extend_page input:checked').length;
1551
1552 jQuery('#bdt-total-widgets-status-core').text(coreCount);
1553 jQuery('#bdt-total-widgets-status-extensions').text(extensionsCount);
1554 jQuery('#bdt-total-widgets-status-heading').text(coreCount + extensionsCount);
1555
1556 jQuery('#bdt-total-widgets-status').attr('data-value', [coreCount, extensionsCount].join(','));
1557 }
1558
1559 // Initialize all charts once
1560 function initAllCharts() {
1561 // Check if charts already exist and are properly rendered
1562 if (window.upkChartInstances && Object.keys(window.upkChartInstances).length >= 4) {
1563 return;
1564 }
1565
1566 // Update total status first
1567 updateTotalStatus();
1568
1569 // Create all charts
1570 var chartCanvases = [
1571 'bdt-db-total-status',
1572 'bdt-db-only-widget-status',
1573 'bdt-total-widgets-status'
1574 ];
1575
1576 var successfulCharts = 0;
1577 chartCanvases.forEach(function(canvasId) {
1578 var canvas = document.getElementById(canvasId);
1579 if (canvas && canvas.offsetParent !== null) { // Check if canvas is visible
1580 createChart(canvasId);
1581 if (window.upkChartInstances && window.upkChartInstances[canvasId]) {
1582 successfulCharts++;
1583 }
1584 }
1585 });
1586 }
1587
1588 // Check if we're currently on system status tab and initialize
1589 function checkAndInitIfOnSystemStatus() {
1590 if (window.location.hash === '#ultimate_post_kit_analytics_system_req') {
1591 setTimeout(initAllCharts, 300);
1592 }
1593 }
1594
1595 // Initialize charts when DOM is ready
1596 jQuery(document).ready(function() {
1597 // Only initialize if we're on the system status tab
1598 setTimeout(checkAndInitIfOnSystemStatus, 500);
1599 });
1600
1601 // Add click handler for System Status tab to create/refresh charts
1602 jQuery(document).on('click', 'a[href="#ultimate_post_kit_analytics_system_req"], a[href*="ultimate_post_kit_analytics_system_req"]', function() {
1603 setTimeout(function() {
1604 // Always recreate charts when tab is clicked to ensure they're visible
1605 initAllCharts();
1606 }, 200);
1607 });
1608 }
1609
1610 // Start the chart initialization
1611 setTimeout(initUltimatePostKitCharts, 1000);
1612
1613 // Handle plugin installation via AJAX
1614 jQuery(document).on('click', '.upk-install-plugin', function(e) {
1615 e.preventDefault();
1616
1617 var $button = jQuery(this);
1618 var pluginSlug = $button.data('plugin-slug');
1619 var nonce = $button.data('nonce');
1620 var originalText = $button.text();
1621
1622 // Disable button and show loading state
1623 $button.prop('disabled', true)
1624 .text('<?php echo esc_js(__('Installing...', 'ultimate-post-kit')); ?>')
1625 .addClass('bdt-installing');
1626
1627 // Perform AJAX request
1628 jQuery.ajax({
1629 url: '<?php echo esc_url(admin_url('admin-ajax.php')); ?>',
1630 type: 'POST',
1631 data: {
1632 action: 'upk_install_plugin',
1633 plugin_slug: pluginSlug,
1634 nonce: nonce
1635 },
1636 success: function(response) {
1637 if (response.success) {
1638 // Show success message
1639 $button.text('<?php echo esc_js(__('Installed!', 'ultimate-post-kit')); ?>')
1640 .removeClass('bdt-installing')
1641 .addClass('bdt-installed');
1642
1643 // Show success notification
1644 if (typeof bdtUIkit !== 'undefined' && bdtUIkit.notification) {
1645 bdtUIkit.notification({
1646 message: '<span class="dashicons dashicons-yes"></span> ' + response.data.message,
1647 status: 'success'
1648 });
1649 }
1650
1651 // Reload the page after 2 seconds to update button states
1652 setTimeout(function() {
1653 window.location.reload();
1654 }, 2000);
1655
1656 } else {
1657 // Show error message
1658 $button.prop('disabled', false)
1659 .text(originalText)
1660 .removeClass('bdt-installing');
1661
1662 // Show error notification
1663 if (typeof bdtUIkit !== 'undefined' && bdtUIkit.notification) {
1664 bdtUIkit.notification({
1665 message: '<span class="dashicons dashicons-warning"></span> ' + response.data.message,
1666 status: 'danger'
1667 });
1668 }
1669 }
1670 },
1671 error: function() {
1672 // Handle network/server errors
1673 $button.prop('disabled', false)
1674 .text(originalText)
1675 .removeClass('bdt-installing');
1676
1677 // Show error notification
1678 if (typeof bdtUIkit !== 'undefined' && bdtUIkit.notification) {
1679 bdtUIkit.notification({
1680 message: '<span class="dashicons dashicons-warning"></span> <?php echo esc_js(__('Installation failed. Please try again.', 'ultimate-post-kit')); ?>',
1681 status: 'danger'
1682 });
1683 }
1684 }
1685 });
1686 });
1687
1688
1689 </script>
1690 <?php
1691 }
1692
1693 /**
1694 * Display Footer
1695 *
1696 * @access public
1697 * @return void
1698 */
1699
1700 function footer_info() {
1701 ?>
1702
1703 <div class="ultimate-post-kit-footer-info bdt-margin-medium-top">
1704
1705 <div class="bdt-grid ">
1706
1707 <div class="bdt-width-auto@s upk-setting-save-btn">
1708
1709
1710
1711 </div>
1712
1713 <div class="bdt-width-expand@s bdt-text-right">
1714 <p class="">
1715 Ultimate Post Kit Pro plugin made with love by <a target="_blank" href="https://bdthemes.com">BdThemes</a> Team.
1716 <br>All rights reserved by <a target="_blank" href="https://bdthemes.com">BdThemes.com</a>.
1717 </p>
1718 </div>
1719 </div>
1720
1721 </div>
1722
1723 <?php
1724 }
1725
1726 /**
1727 * Get all the pages
1728 *
1729 * @return array page names with key value pairs
1730 */
1731 function get_pages() {
1732 $pages = get_pages();
1733 $pages_options = [];
1734 if ($pages) {
1735 foreach ($pages as $page) {
1736 $pages_options[$page->ID] = $page->post_title;
1737 }
1738 }
1739
1740 return $pages_options;
1741 }
1742
1743
1744 public static function license_wl_status() {
1745 $status = get_option('ultimate_post_kit_license_title_status');
1746
1747 if ($status) {
1748 return true;
1749 }
1750
1751 return false;
1752 }
1753
1754
1755
1756 /**
1757 * Display Analytics and System Requirements
1758 *
1759 * @access public
1760 * @return void
1761 */
1762
1763 public function ultimate_post_kit_analytics_system_req_content() {
1764 ?>
1765 <div class="upk-dashboard-panel"
1766 bdt-scrollspy="target: > div > div > .bdt-card; cls: bdt-animation-slide-bottom-small; delay: 300">
1767 <div class="upk-dashboard-analytics-system">
1768
1769 <?php $this->ultimate_post_kit_widgets_status(); ?>
1770
1771 <div class="bdt-grid bdt-grid-medium bdt-margin-medium-top" bdt-grid
1772 bdt-height-match="target: > div > .bdt-card">
1773 <div class="bdt-width-1-1">
1774 <div class="bdt-card bdt-card-body upk-system-requirement">
1775 <h1 class="upk-feature-title bdt-margin-small-bottom">
1776 <?php esc_html_e('System Requirement', 'ultimate-post-kit'); ?>
1777 </h1>
1778 <?php $this->ultimate_post_kit_system_requirement(); ?>
1779 </div>
1780 </div>
1781 </div>
1782
1783 </div>
1784 </div>
1785 <?php
1786 }
1787
1788 /**
1789 * Others Plugin - Using standalone plugin manager
1790 */
1791 public function ultimate_post_kit_others_plugin() {
1792 // Include and render the standalone others plugin manager
1793 require_once BDTUPK_INC_PATH . 'setup-wizard/ultimate-post-kit-others-plugin.php';
1794
1795 // Call the helper function to render the plugin manager
1796 ultimate_post_kit_others_plugin();
1797 }
1798
1799 /**
1800 * Widgets Status
1801 */
1802
1803 public function ultimate_post_kit_widgets_status() {
1804 $track_nw_msg = '';
1805 if (!Tracker::is_allow_track()) {
1806 $track_nw = esc_html__('This feature is not working because the Elementor Usage Data Sharing feature is Not Enabled.', 'ultimate-post-kit');
1807 $track_nw_msg = 'bdt-tooltip="' . $track_nw . '"';
1808 }
1809 ?>
1810 <div class="upk-dashboard-widgets-status">
1811 <div class="bdt-grid bdt-grid-medium" bdt-grid bdt-height-match="target: > div > .bdt-card">
1812 <div class="bdt-width-1-2@m bdt-width-1-4@xl">
1813 <div class="upk-widget-status bdt-card bdt-card-body" <?php echo wp_kses_post($track_nw_msg); ?>>
1814
1815 <?php
1816 $used_widgets = count(self::get_used_widgets());
1817 $un_used_widgets = count(self::get_unused_widgets());
1818 ?>
1819
1820 <div class="upk-count-canvas-wrap">
1821 <h1 class="upk-feature-title"><?php esc_html_e('All Widgets', 'ultimate-post-kit'); ?></h1>
1822 <div class="bdt-flex bdt-flex-between bdt-flex-middle">
1823 <div class="upk-count-wrap">
1824 <div class="upk-widget-count"><?php esc_html_e('Used:', 'ultimate-post-kit'); ?> <b>
1825 <?php echo esc_html($used_widgets); ?>
1826 </b></div>
1827 <div class="upk-widget-count"><?php esc_html_e('Unused:', 'ultimate-post-kit'); ?> <b>
1828 <?php echo esc_html($un_used_widgets); ?>
1829 </b>
1830 </div>
1831 <div class="upk-widget-count"><?php esc_html_e('Total:', 'ultimate-post-kit'); ?>
1832 <b>
1833 <?php echo esc_html($used_widgets + $un_used_widgets); ?>
1834 </b>
1835 </div>
1836 </div>
1837
1838 <div class="upk-canvas-wrap">
1839 <canvas id="bdt-db-total-status" style="height: 100px; width: 100px;"
1840 data-label="<?php
1841 /* translators: %s: Total number of widgets */
1842 echo esc_attr( sprintf( __( 'Total Widgets Status - (%s)', 'ultimate-post-kit' ), $used_widgets + $un_used_widgets ) ); ?>"
1843 data-labels="<?php echo esc_attr( sprintf( '%1$s, %2$s', __( 'Used', 'ultimate-post-kit' ), __( 'Unused', 'ultimate-post-kit' ) ) ); ?>"
1844 data-value="<?php echo esc_attr($used_widgets) . ',' . esc_attr($un_used_widgets); ?>"
1845 data-bg="#FFD166, #fff4d9" data-bg-hover="#0673e1, #e71522"></canvas>
1846 </div>
1847 </div>
1848 </div>
1849
1850 </div>
1851 </div>
1852 <div class="bdt-width-1-2@m bdt-width-1-4@xl">
1853 <div class="upk-widget-status bdt-card bdt-card-body" <?php echo wp_kses_post($track_nw_msg); ?>>
1854
1855 <?php
1856 $used_only_widgets = count(self::get_used_only_widgets());
1857 $unused_only_widgets = count(self::get_unused_only_widgets());
1858 ?>
1859
1860
1861 <div class="upk-count-canvas-wrap">
1862 <h1 class="upk-feature-title"><?php esc_html_e('Core', 'ultimate-post-kit'); ?></h1>
1863 <div class="bdt-flex bdt-flex-between bdt-flex-middle">
1864 <div class="upk-count-wrap">
1865 <div class="upk-widget-count"><?php esc_html_e('Used:', 'ultimate-post-kit'); ?> <b>
1866 <?php echo esc_html($used_only_widgets); ?>
1867 </b></div>
1868 <div class="upk-widget-count"><?php esc_html_e('Unused:', 'ultimate-post-kit'); ?> <b>
1869 <?php echo esc_html($unused_only_widgets); ?>
1870 </b></div>
1871 <div class="upk-widget-count"><?php esc_html_e('Total:', 'ultimate-post-kit'); ?>
1872 <b>
1873 <?php echo esc_html($used_only_widgets + $unused_only_widgets); ?>
1874 </b>
1875 </div>
1876 </div>
1877
1878 <div class="upk-canvas-wrap">
1879 <canvas id="bdt-db-only-widget-status" style="height: 100px; width: 100px;"
1880 data-label="<?php
1881 /* translators: %s: Total number of core widgets */
1882 echo esc_attr( sprintf( __( 'Core Widgets Status - (%s)', 'ultimate-post-kit' ), $used_only_widgets + $unused_only_widgets ) ); ?>"
1883 data-labels="<?php echo esc_attr( sprintf( '%1$s, %2$s', __( 'Used', 'ultimate-post-kit' ), __( 'Unused', 'ultimate-post-kit' ) ) ); ?>"
1884 data-value="<?php echo esc_attr($used_only_widgets) . ',' . esc_attr($unused_only_widgets); ?>"
1885 data-bg="#EF476F, #ffcdd9" data-bg-hover="#0673e1, #e71522"></canvas>
1886 </div>
1887 </div>
1888 </div>
1889
1890 </div>
1891 </div>
1892
1893 <div class="bdt-width-1-2@m bdt-width-1-4@xl">
1894 <div class="upk-widget-status bdt-card bdt-card-body" <?php echo wp_kses_post($track_nw_msg); ?>>
1895
1896 <div class="upk-count-canvas-wrap">
1897 <h1 class="upk-feature-title"><?php esc_html_e('Active', 'ultimate-post-kit'); ?></h1>
1898 <div class="bdt-flex bdt-flex-between bdt-flex-middle">
1899 <div class="upk-count-wrap">
1900 <div class="upk-widget-count"><?php esc_html_e('Core:', 'ultimate-post-kit'); ?>
1901 <b id="bdt-total-widgets-status-core">0</b>
1902 </div>
1903 <div class="upk-widget-count"><?php esc_html_e('Extensions:', 'ultimate-post-kit'); ?>
1904 <b id="bdt-total-widgets-status-extensions">0</b>
1905 </div>
1906 <div class="upk-widget-count"><?php esc_html_e('Total:', 'ultimate-post-kit'); ?> <b
1907 id="bdt-total-widgets-status-heading">0</b></div>
1908 </div>
1909
1910 <div class="upk-canvas-wrap">
1911 <canvas id="bdt-total-widgets-status" style="height: 100px; width: 100px;"
1912 data-label="<?php echo esc_attr__( 'Total Active Widgets Status', 'ultimate-post-kit' ); ?>"
1913 data-labels="<?php echo esc_attr( sprintf( '%1$s, %2$s', __( 'Core', 'ultimate-post-kit' ), __( 'Extensions', 'ultimate-post-kit' ) ) ); ?>"
1914 data-value="0,0,0"
1915 data-bg="#0680d6, #B0EBFF" data-bg-hover="#0673e1, #B0EBFF">
1916 </canvas>
1917 </div>
1918 </div>
1919 </div>
1920
1921 </div>
1922 </div>
1923 </div>
1924 </div>
1925
1926 <?php if (!Tracker::is_allow_track()): ?>
1927 <div class="bdt-border-rounded bdt-box-shadow-small bdt-alert-warning" bdt-alert>
1928 <a href class="bdt-alert-close" bdt-close></a>
1929 <div class="bdt-text-default">
1930 <?php
1931 printf(
1932 /* translators: 1: opening bold tag, 2: closing bold tag */
1933 esc_html__('To view widgets analytics, Elementor %1$sUsage Data Sharing%2$s feature by Elementor needs to be activated. Please activate the feature to get widget analytics instantly ', 'ultimate-post-kit'),
1934 '<b>', '</b>'
1935 );
1936
1937 echo ' <a href="' . esc_url(admin_url('admin.php?page=elementor-settings')) . '">' . esc_html__('from here.', 'ultimate-post-kit') . '</a>';
1938 ?>
1939 </div>
1940 </div>
1941 <?php endif; ?>
1942
1943 <?php
1944 }
1945
1946 /**
1947 * Display System Requirement
1948 *
1949 * @access public
1950 * @return void
1951 */
1952
1953 public function ultimate_post_kit_system_requirement() {
1954 $php_version = phpversion();
1955 $max_execution_time = ini_get('max_execution_time');
1956 $memory_limit = ini_get('memory_limit');
1957 $post_limit = ini_get('post_max_size');
1958 $uploads = wp_upload_dir();
1959 $upload_path = $uploads['basedir'];
1960 $yes_icon = '<span class="valid"><i class="dashicons-before dashicons-yes"></i></span>';
1961 $no_icon = '<span class="invalid"><i class="dashicons-before dashicons-no-alt"></i></span>';
1962
1963 $environment = Utils::get_environment_info();
1964
1965 ?>
1966 <ul class="check-system-status bdt-grid bdt-child-width-1-2@m bdt-grid-small ">
1967 <li>
1968 <div>
1969 <span class="label1"><?php esc_html_e('PHP Version:', 'ultimate-post-kit'); ?></span>
1970
1971 <?php
1972 if (version_compare($php_version, '7.4.0', '<')) {
1973 echo wp_kses_post($no_icon);
1974 echo '<span class="label2" title="' . esc_attr__('Min: 7.4 Recommended', 'ultimate-post-kit') . '" bdt-tooltip>' . esc_html__('Currently:', 'ultimate-post-kit') . ' ' . esc_html($php_version) . '</span>';
1975 } else {
1976 echo wp_kses_post($yes_icon);
1977 echo '<span class="label2">' . esc_html__('Currently:', 'ultimate-post-kit') . ' ' . esc_html($php_version) . '</span>';
1978 }
1979 ?>
1980 </div>
1981
1982 </li>
1983
1984 <li>
1985 <div>
1986 <span class="label1"><?php esc_html_e('Max execution time:', 'ultimate-post-kit'); ?> </span>
1987 <?php
1988 if ($max_execution_time < '90') {
1989 echo wp_kses_post($no_icon);
1990 echo '<span class="label2" title="' . esc_attr__( 'Min: 90 Recommended', 'ultimate-post-kit' ) . '" bdt-tooltip>' . esc_html__( 'Currently:', 'ultimate-post-kit' ) . ' ' . esc_html( $max_execution_time ) . '</span>';
1991 } else {
1992 echo wp_kses_post($yes_icon);
1993 echo '<span class="label2">' . esc_html__( 'Currently:', 'ultimate-post-kit' ) . ' ' . esc_html( $max_execution_time ) . '</span>';
1994 }
1995 ?>
1996 </div>
1997 </li>
1998 <li>
1999 <div>
2000 <span class="label1"><?php esc_html_e('Memory Limit:', 'ultimate-post-kit'); ?> </span>
2001
2002 <?php
2003 if (intval($memory_limit) < '512') {
2004 echo wp_kses_post($no_icon);
2005 echo '<span class="label2" title="' . esc_attr__( 'Min: 512M Recommended', 'ultimate-post-kit' ) . '" bdt-tooltip>' . esc_html__( 'Currently:', 'ultimate-post-kit' ) . ' ' . esc_html( $memory_limit ) . '</span>';
2006 } else {
2007 echo wp_kses_post($yes_icon);
2008 echo '<span class="label2">' . esc_html__( 'Currently:', 'ultimate-post-kit' ) . ' ' . esc_html( $memory_limit ) . '</span>';
2009 }
2010 ?>
2011 </div>
2012 </li>
2013
2014 <li>
2015 <div>
2016 <span class="label1"><?php esc_html_e('Max Post Limit:', 'ultimate-post-kit'); ?> </span>
2017
2018 <?php
2019 if (intval($post_limit) < '32') {
2020 echo wp_kses_post($no_icon);
2021 echo '<span class="label2" title="' . esc_attr__( 'Min: 32M Recommended', 'ultimate-post-kit' ) . '" bdt-tooltip>' . esc_html__( 'Currently:', 'ultimate-post-kit' ) . ' ' . esc_html( $post_limit ) . '</span>';
2022 } else {
2023 echo wp_kses_post($yes_icon);
2024 echo '<span class="label2">' . esc_html__( 'Currently:', 'ultimate-post-kit' ) . ' ' . esc_html( $post_limit ) . '</span>';
2025 }
2026 ?>
2027 </div>
2028 </li>
2029
2030 <li>
2031 <div>
2032 <span class="label1"><?php esc_html_e('Uploads folder writable:', 'ultimate-post-kit'); ?></span>
2033
2034 <?php
2035 if (!wp_is_writable($upload_path)) {
2036 echo wp_kses_post($no_icon);
2037 } else {
2038 echo wp_kses_post($yes_icon);
2039 }
2040 ?>
2041 </div>
2042
2043 </li>
2044
2045 <li>
2046 <div>
2047 <span class="label1"><?php esc_html_e('MultiSite:', 'ultimate-post-kit'); ?></span>
2048
2049 <?php
2050 if ($environment['wp_multisite']) {
2051 echo wp_kses_post($yes_icon);
2052 echo '<span class="label2">' . esc_html__('MultiSite Enabled', 'ultimate-post-kit') . '</span>';
2053 } else {
2054 echo wp_kses_post($yes_icon);
2055 echo '<span class="label2">' . esc_html__('Single Site', 'ultimate-post-kit') . '</span>';
2056 }
2057 ?>
2058 </div>
2059 </li>
2060
2061 <li>
2062 <div>
2063 <span class="label1"><?php esc_html_e('GZip Enabled:', 'ultimate-post-kit'); ?></span>
2064
2065 <?php
2066 if ($environment['gzip_enabled']) {
2067 echo wp_kses_post($yes_icon);
2068 } else {
2069 echo wp_kses_post($no_icon);
2070 }
2071 ?>
2072 </div>
2073
2074 </li>
2075
2076 <li>
2077 <div>
2078 <span class="label1"><?php esc_html_e('Debug Mode:', 'ultimate-post-kit'); ?></span>
2079 <?php
2080 if ($environment['wp_debug_mode']) {
2081 echo wp_kses_post($no_icon);
2082 echo '<span class="label2">' . esc_html__('Currently Turned On', 'ultimate-post-kit') . '</span>';
2083 } else {
2084 echo wp_kses_post($yes_icon);
2085 echo '<span class="label2">' . esc_html__('Currently Turned Off', 'ultimate-post-kit') . '</span>';
2086 }
2087 ?>
2088 </div>
2089
2090 </li>
2091
2092 </ul>
2093
2094 <div class="bdt-admin-alert">
2095 <strong><?php esc_html_e('Note:', 'ultimate-post-kit'); ?></strong>
2096 <?php
2097 printf(
2098 /* translators: %s: Plugin name 'Ultimate Post Kit' */
2099 esc_html__('If you have multiple addons like %s so you may need to allocate additional memory for other addons as well.', 'ultimate-post-kit'),
2100 '<b>Ultimate Post Kit</b>'
2101 );
2102 ?>
2103 </div>
2104
2105 <?php
2106 }
2107
2108 /**
2109 * Check plugin status (installed, active, or not installed)
2110 *
2111 * @param string $plugin_path Plugin file path
2112 * @return string 'active', 'installed', or 'not_installed'
2113 */
2114 private function get_plugin_status($plugin_path) {
2115 // Check if plugin is active
2116 if (is_plugin_active($plugin_path)) {
2117 return 'active';
2118 }
2119
2120 // Check if plugin is installed but not active
2121 $installed_plugins = get_plugins();
2122 if (isset($installed_plugins[$plugin_path])) {
2123 return 'installed';
2124 }
2125
2126 // Plugin is not installed
2127 return 'not_installed';
2128 }
2129
2130
2131 /**
2132 * Handle AJAX plugin installation
2133 *
2134 * @access public
2135 * @return void
2136 */
2137 public function install_plugin_ajax() {
2138 // Check nonce
2139 $nonce = isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : '';
2140 if (!wp_verify_nonce( $nonce, 'upk_install_plugin_nonce')) {
2141 wp_send_json_error(['message' => __('Security check failed', 'ultimate-post-kit')]);
2142 }
2143
2144 // Check user capability
2145 if (!current_user_can('install_plugins')) {
2146 wp_send_json_error(['message' => __('You do not have permission to install plugins', 'ultimate-post-kit')]);
2147 }
2148
2149 $plugin_slug = isset($_POST['plugin_slug']) ? sanitize_text_field(wp_unslash($_POST['plugin_slug'])) : '';
2150
2151 if (empty($plugin_slug)) {
2152 wp_send_json_error(['message' => __('Plugin slug is required', 'ultimate-post-kit')]);
2153 }
2154
2155 // Include necessary WordPress files
2156 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
2157 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
2158 require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php';
2159
2160 // Get plugin information
2161 $api = plugins_api('plugin_information', [
2162 'slug' => $plugin_slug,
2163 'fields' => [
2164 'sections' => false,
2165 ],
2166 ]);
2167
2168 if (is_wp_error($api)) {
2169 wp_send_json_error(['message' => __('Plugin not found: ', 'ultimate-post-kit') . $api->get_error_message()]);
2170 }
2171
2172 // Install the plugin
2173 $skin = new \WP_Ajax_Upgrader_Skin();
2174 $upgrader = new \Plugin_Upgrader($skin);
2175 $result = $upgrader->install($api->download_link);
2176
2177 if (is_wp_error($result)) {
2178 wp_send_json_error(['message' => __('Installation failed: ', 'ultimate-post-kit') . $result->get_error_message()]);
2179 } elseif ($skin->get_errors()->has_errors()) {
2180 wp_send_json_error(['message' => __('Installation failed: ', 'ultimate-post-kit') . $skin->get_error_messages()]);
2181 } elseif (is_null($result)) {
2182 wp_send_json_error(['message' => __('Installation failed: Unable to connect to filesystem', 'ultimate-post-kit')]);
2183 }
2184
2185 // Get installation status
2186 $install_status = install_plugin_install_status($api);
2187
2188 wp_send_json_success([
2189 'message' => __('Plugin installed successfully!', 'ultimate-post-kit'),
2190 'plugin_file' => $install_status['file'],
2191 'plugin_name' => $api->name
2192 ]);
2193 }
2194
2195 /**
2196 * Extract plugin slug from plugin path
2197 *
2198 * @param string $plugin_path Plugin file path
2199 * @return string Plugin slug
2200 */
2201 private function extract_plugin_slug_from_path($plugin_path) {
2202 $parts = explode('/', $plugin_path);
2203 return isset($parts[0]) ? $parts[0] : '';
2204 }
2205
2206 /**
2207 * Get plugin action button HTML based on plugin status
2208 *
2209 * @param string $plugin_path Plugin file path
2210 * @param string $install_url Plugin installation URL
2211 * @param string $plugin_slug Plugin slug for activation
2212 * @return string Button HTML
2213 */
2214 private function get_plugin_action_button($plugin_path, $install_url, $plugin_slug = '') {
2215 $status = $this->get_plugin_status($plugin_path);
2216
2217 switch ($status) {
2218 case 'active':
2219 return '';
2220
2221 case 'installed':
2222 $activate_url = wp_nonce_url(
2223 add_query_arg([
2224 'action' => 'activate',
2225 'plugin' => $plugin_path
2226 ], admin_url('plugins.php')),
2227 'activate-plugin_' . $plugin_path
2228 );
2229 return '<a class="bdt-button bdt-welcome-button" href="' . esc_url($activate_url) . '">' .
2230 __('Activate', 'ultimate-post-kit') . '</a>';
2231
2232 case 'not_installed':
2233 default:
2234 $plugin_slug = $this->extract_plugin_slug_from_path($plugin_path);
2235 $nonce = wp_create_nonce('upk_install_plugin_nonce');
2236 return '<a class="bdt-button bdt-welcome-button upk-install-plugin"
2237 data-plugin-slug="' . esc_attr($plugin_slug) . '"
2238 data-nonce="' . esc_attr($nonce) . '"
2239 href="#">' .
2240 __('Install', 'ultimate-post-kit') . '</a>';
2241 }
2242 }
2243
2244
2245
2246 /**
2247 * Rollback Version Content
2248 *
2249 * @access public
2250 * @return void
2251 */
2252 public function upk_rollback_version_content() {
2253 // Use the already initialized rollback version instance
2254 $this->rollback_version->upk_rollback_version_content();
2255 }
2256
2257
2258 }
2259
2260 new UltimatePostKit_Admin_Settings();
2261