PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.10.0
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.10.0
3.1.0 3.0.0 2.13.2 2.13.1 2.13.0 trunk 1.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.12.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.1 2.5.3 2.5.4 2.5.5 2.6.1 All 56 releases
slider-blocks / admin / admin.php

admin.php in GutSlider – All in One Slider and Carousel Blocks for Gutenberg 2.10.0, at admin/admin.php

444 lines 25.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Admin Page
4 * @package GutSliderBlocks
5 */
6
7 if (!defined('ABSPATH')) exit;
8
9 if (!class_exists('GutSlider_Admin')) {
10 class GutSlider_Admin {
11 /**
12 * Slider block settings
13 */
14 private const BLOCK_SETTINGS = [
15 'gut_fixed_content_slider',
16 'gut_any_content_slider',
17 'gut_testimonial_slider',
18 'gut_post_slider',
19 'gut_photo_carousel',
20 'gut_logo_carousel',
21 'gut_before_after_slider',
22 'gut_videos_carousel',
23 'gut_shader_slider',
24 'gut_shutters_slider',
25 'gut_slicer_slider',
26 'gut_fashion_slider',
27 'gut_triple_slider',
28 'gut_spring_carousel',
29 'gut_panorama_carousel',
30 'gut_three_d_carousel',
31 'gut_card_slider',
32 'gut_marquee_carousel',
33 'gut_material_carousel',
34 'gut_tinder_slider',
35 'gut_hover_slider',
36 'gut_product_carousel',
37 'gut_product_categories_carousel',
38 ];
39
40 /**
41 * Constructor
42 */
43 public function __construct() {
44 add_action('admin_menu', [$this, 'admin_menu'], 20);
45 add_action('admin_enqueue_scripts', [$this, 'admin_assets']);
46 add_action('admin_init', [$this, 'initialize_admin']);
47 add_action('rest_api_init', [$this, 'register_settings']);
48 add_action('wp_ajax_gutslider_toggle_block', [$this, 'toggle_block_status']);
49 }
50
51 /**
52 * Initialize admin functionality
53 */
54 public function initialize_admin() {
55 $this->register_settings();
56 $this->include_data_sdk();
57 }
58
59 /**
60 * Enqueue admin scripts and styles
61 * @param string $screen Current admin screen
62 */
63 public function admin_assets($screen) {
64 if ($screen !== 'toplevel_page_gutslider-blocks' && $screen !== 'gutslider_page_gutslider-blocks-settings' && $screen !== 'gutslider_page_gutslider-license') {
65 return;
66 }
67
68 $this->enqueue_admin_assets();
69 }
70
71 /**
72 * Add admin menu
73 */
74 public function admin_menu() {
75 add_menu_page(
76 __('GutSlider', 'slider-blocks'),
77 __('GutSlider', 'slider-blocks'),
78 'manage_options',
79 'gutslider-blocks',
80 [$this, 'render_admin_page'],
81 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iMTIiIGZpbGw9IiNEOUQ5RDkiLz4KPHBhdGggZD0iTTE1IDdIMTEuODIzNUg5VjE3SDE1VjEyLjQxNjdIMTIuODgyNEgxMS44MjM1IiBzdHJva2U9IiMxRDIzMjciIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+Cjwvc3ZnPgo=',
82 100
83 );
84
85 add_submenu_page(
86 'gutslider-blocks',
87 __( 'Welcome', 'slider-blocks' ),
88 __( 'Welcome', 'slider-blocks' ),
89 'manage_options',
90 'gutslider-blocks',
91 array( $this, 'render_admin_page' )
92 );
93
94 add_submenu_page(
95 'gutslider-blocks',
96 __( 'Blocks', 'slider-blocks' ),
97 __( 'Blocks', 'slider-blocks' ),
98 'manage_options',
99 'gutslider-blocks-settings',
100 array( $this, 'render_blocks_page' )
101 );
102
103 }
104
105 /**
106 * Render main admin page
107 */
108 public function render_admin_page() {
109 $has_pro = defined('GUTSLIDER_PRO_VERSION');
110 ?>
111 <div class="header bg-white box-shadow">
112 <div class="container flex align-center">
113 <div class="header-content flex flex-1 align-center">
114 <div class="logo-area flex align-center gap-8">
115 <img src="<?php echo esc_url( GUTSLIDER_URL . 'admin/img/gutslider.svg' ); ?>" alt="<?php esc_attr_e('GutSlider Logo', 'slider-blocks'); ?>" class="logo-img"/>
116 </div>
117 <div class="nav flex align-center">
118 <a href="<?php echo esc_url( admin_url('admin.php?page=gutslider-blocks') ); ?>" class="nav-link"><?php esc_html_e('Welcome', 'slider-blocks'); ?></a>
119 <span class="dot"></span>
120 <a href="<?php echo esc_url( admin_url('admin.php?page=gutslider-blocks-settings') ); ?>" class="nav-link"><?php esc_html_e('Blocks', 'slider-blocks'); ?></a>
121 <span class="dot"></span>
122 <a href="<?php echo $has_pro ? esc_url( admin_url('admin.php?page=gutslider-license') ) : esc_url('https://gutslider.com/pricing'); ?>" class="nav-link" target="<?php echo $has_pro ? esc_attr('_self') : esc_attr('_blank'); ?>">
123 <?php if( $has_pro): ?>
124 <?php esc_html_e('License', 'slider-blocks'); ?>
125 <?php else: ?>
126 <?php esc_html_e('Get License', 'slider-blocks'); ?>
127 <?php endif; ?>
128 </a>
129 </div>
130 </div>
131 <div class="header-actions flex align-center gap-8">
132 <?php if ( ! $has_pro ) : ?>
133 <a href="https://gutslider.com/pricing" target="_blank" class="header-btn pro-btn"><?php esc_html_e('Get Pro', 'slider-blocks'); ?></a>
134 <?php endif; ?>
135 <a href="https://gutslider.com/docs" target="_blank" class="log-btn">
136 <span class="dashicons dashicons-external"></span>
137 </a>
138 </div>
139 </div>
140 </div>
141 <div class="content-area">
142 <div class="container">
143 <div class="supports-area m50 flex gap-16">
144 <div class="gp-card bg-white p20">
145 <div class="icon flex align-center gap-8">
146 <span class="dashicons dashicons-sos"></span>
147 <h3 class="support-title"><?php esc_html_e('Need Help?', 'slider-blocks'); ?></h3>
148 </div>
149 <div class="content">
150 <p class="support-desc"><?php esc_html_e('Check out our documentation or reach out to our support team for assistance.', 'slider-blocks'); ?></p>
151 <a href="https://gutslider.com/docs" target="_blank" class="support-link"><?php esc_html_e('View Documentation', 'slider-blocks'); ?></a>
152 </div>
153 </div>
154 <div class="gp-card p20 bg-white">
155 <div class="icon flex align-center gap-8">
156 <span class="dashicons dashicons-tickets-alt"></span>
157 <h3 class="support-title"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></h3>
158 </div>
159 <div class="content">
160 <p class="support-desc"><?php esc_html_e('If you need further assistance, please submit a support ticket.', 'slider-blocks'); ?></p>
161 <a href="https://gutslider.com/support" target="_blank" class="support-link"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></a>
162 </div>
163 </div>
164 <div class="gp-card p20 bg-white">
165 <div class="icon flex align-center gap-8">
166 <span class="dashicons dashicons-share-alt2"></span>
167 <h3 class="support-title"><?php esc_html_e('Spread Your Love', 'slider-blocks'); ?></h3>
168 </div>
169 <div class="content">
170 <p class="support-desc"><?php esc_html_e('If you love GutSlider, please consider sharing it with your friends and colleagues!', 'slider-blocks'); ?></p>
171 <a href="https://wordpress.org/support/plugin/slider-blocks/reviews/" target="_blank" class="support-link"><?php esc_html_e('Write a Review', 'slider-blocks'); ?></a>
172 </div>
173 </div>
174 </div>
175 <div class="welcome-area flex gap-30">
176 <div class="video-area bg-white p30 border rounded">
177 <h3 class="video-title">
178 <?php esc_html_e('Welcome to GutSlider Blocks', 'slider-blocks'); ?>
179 </h3>
180 <p class="support-desc">
181 <?php esc_html_e('Watch the video below to get started with GutSlider and learn how to create stunning sliders using our blocks.', 'slider-blocks'); ?>
182 </p>
183 <iframe width="560" height="315" src="https://www.youtube.com/embed/P9Zj4bSVq4I?si=HnOCmeQxQ-96hdG9" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
184 </div>
185 <div class="our-products">
186 <div class="gp-card bg-white p20">
187 <div class="icon flex align-center gap-8">
188 <span class="dashicons dashicons-layout"></span>
189 <h3 class="support-title"><?php esc_html_e('GutenLayouts', 'slider-blocks'); ?></h3>
190 </div>
191 <div class="content">
192 <p class="support-desc"><?php esc_html_e('Design stunning layouts with our pre-built templates and patterns with core blocks.', 'slider-blocks'); ?></p>
193 <a href="https://gutenlayouts.com" target="_blank" class="support-link"><?php esc_html_e('Check it out', 'slider-blocks'); ?></a>
194 </div>
195 </div>
196 <div class="gp-card p20 bg-white">
197 <div class="icon flex align-center gap-8">
198 <span class="dashicons dashicons-admin-plugins"></span>
199 <h3 class="support-title"><?php esc_html_e('Easy Accordion', 'slider-blocks'); ?></h3>
200 </div>
201 <div class="content">
202 <p class="support-desc"><?php esc_html_e('Create beautiful and responsive accordions with ease using our Easy Accordion block.', 'slider-blocks'); ?></p>
203 <a href="https://accordion.gutenbergkits.com" target="_blank" class="support-link"><?php esc_html_e('Check it out', 'slider-blocks'); ?></a>
204 </div>
205 </div>
206 <div class="gp-card p20 bg-white">
207 <div class="icon flex align-center gap-8">
208 <span class="dashicons dashicons-admin-plugins"></span>
209 <h3 class="support-title"><?php esc_html_e('Gmap Block', 'slider-blocks'); ?></h3>
210 </div>
211 <div class="content">
212 <p class="support-desc"><?php esc_html_e('Display interactive Google Maps with ease using our Gmap Block.', 'slider-blocks'); ?></p>
213 <a href="https://gmap.gutenbergkits.com" target="_blank" class="support-link"><?php esc_html_e('Check it out', 'slider-blocks'); ?></a>
214 </div>
215 </div>
216 </div>
217 </div>
218 <?php if( ! $has_pro ) : ?>
219 <div class="welcome-box bg-white p20 mt50 border rounded">
220 <h3 class="video-title"><?php esc_html_e('Get Started with GutSlider Pro', 'slider-blocks'); ?></h3>
221 <p class="support-desc"><?php esc_html_e('Unlock the full potential of GutSlider by upgrading to the Pro version. Enjoy premium blocks, advanced features, and priority support.', 'slider-blocks'); ?></p>
222 <a href="https://gutslider.com/pricing" target="_blank" class="welcome-link pro-btn"><?php esc_html_e('Upgrade to Pro', 'slider-blocks'); ?></a>
223 </div>
224 <?php endif; ?>
225 </div>
226 </div>
227 <?php
228 }
229
230 /**
231 * Render blocks page
232 */
233 public function render_blocks_page() {
234 $blocks = $this->get_blocks();
235 $has_pro = defined('GUTSLIDER_PRO_VERSION');
236 ?>
237 <div class="gutslider-admin-wrap">
238 <div class="header bg-white box-shadow">
239 <div class="container flex align-center">
240 <div class="header-content flex flex-1 align-center">
241 <div class="logo-area flex align-center gap-8">
242 <img src="<?php echo esc_url( GUTSLIDER_URL . 'admin/img/gutslider.svg' ); ?>" alt="<?php esc_attr_e('GutSlider Logo', 'slider-blocks'); ?>" class="logo-img"/>
243 </div>
244 <div class="nav flex align-center">
245 <a href="<?php echo esc_url( admin_url('admin.php?page=gutslider-blocks') ); ?>" class="nav-link"><?php esc_html_e('Welcome', 'slider-blocks'); ?></a>
246 <span class="dot"></span>
247 <a href="<?php echo esc_url( admin_url('admin.php?page=gutslider-blocks-settings') ); ?>" class="nav-link"><?php esc_html_e('Blocks', 'slider-blocks'); ?></a>
248 <span class="dot"></span>
249 <a href="<?php echo $has_pro ? esc_url( admin_url('admin.php?page=gutslider-license') ) : esc_url('https://gutslider.com/pricing'); ?>" class="nav-link" target="<?php echo $has_pro ? esc_attr('_self') : esc_attr('_blank'); ?>">
250 <?php if( $has_pro): ?>
251 <?php esc_html_e('License', 'slider-blocks'); ?>
252 <?php else: ?>
253 <?php esc_html_e('Get License', 'slider-blocks'); ?>
254 <?php endif; ?>
255 </a>
256 </div>
257 </div>
258 <div class="header-actions flex align-center gap-8">
259 <?php if ( ! $has_pro ) : ?>
260 <a href="https://gutslider.com/pricing" target="_blank" class="header-btn pro-btn"><?php esc_html_e('Get Pro', 'slider-blocks'); ?></a>
261 <?php endif; ?>
262 <a href="https://gutslider.com/docs" target="_blank" class="log-btn">
263 <span class="dashicons dashicons-external"></span>
264 </a>
265 </div>
266 </div>
267 </div>
268 <div class="content-area">
269 <div class="container">
270 <div class="supports-area m50 flex gap-16">
271 <div class="gp-card bg-white p20">
272 <div class="icon flex align-center gap-8">
273 <span class="dashicons dashicons-sos"></span>
274 <h3 class="support-title"><?php esc_html_e('Need Help?', 'slider-blocks'); ?></h3>
275 </div>
276 <div class="content">
277 <p class="support-desc"><?php esc_html_e('Check out our documentation or reach out to our support team for assistance.', 'slider-blocks'); ?></p>
278 <a href="https://gutslider.com/docs" target="_blank" class="support-link"><?php esc_html_e('View Documentation', 'slider-blocks'); ?></a>
279 </div>
280 </div>
281 <div class="gp-card p20 bg-white">
282 <div class="icon flex align-center gap-8">
283 <span class="dashicons dashicons-tickets-alt"></span>
284 <h3 class="support-title"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></h3>
285 </div>
286 <div class="content">
287 <p class="support-desc"><?php esc_html_e('If you need further assistance, please submit a support ticket.', 'slider-blocks'); ?></p>
288 <a href="https://gutslider.com/support" target="_blank" class="support-link"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></a>
289 </div>
290 </div>
291 <div class="gp-card p20 bg-white">
292 <div class="icon flex align-center gap-8">
293 <span class="dashicons dashicons-share-alt2"></span>
294 <h3 class="support-title"><?php esc_html_e('Spread Your Love', 'slider-blocks'); ?></h3>
295 </div>
296 <div class="content">
297 <p class="support-desc"><?php esc_html_e('If you love GutSlider, please consider sharing it with your friends and colleagues!', 'slider-blocks'); ?></p>
298 <a href="https://wordpress.org/support/plugin/slider-blocks/reviews/" target="_blank" class="support-link"><?php esc_html_e('Write a Review', 'slider-blocks'); ?></a>
299 </div>
300 </div>
301 </div>
302 <h2 class="page-title mb30"><?php esc_html_e('Manage GutSlider Blocks', 'slider-blocks'); ?></h2>
303 <div class="gutslider-blocks-grid">
304 <?php foreach ($blocks as $block): ?>
305 <?php
306 $is_pro = isset($block['is_pro']) && $block['is_pro'];
307 $is_active = isset($block['active']) && $block['active'];
308 $block_key = 'gut_' . str_replace('-', '_', $block['name']);
309 $saved_status = get_option($block_key, true);
310 $is_checked = $saved_status ? 'checked' : '';
311 $demo_url = 'https://demos.gutslider.com/' . $block['demo_slug'];
312 ?>
313 <div class="gutslider-block-card <?php echo $is_pro ? 'pro-block' : ''; ?>">
314 <?php if ($is_pro): ?>
315 <span class="pro-badge"><?php esc_html_e('PRO', 'slider-blocks'); ?></span>
316 <?php else: ?>
317 <span class="pro-badge free-badge"><?php esc_html_e('FREE', 'slider-blocks'); ?></span>
318 <?php endif; ?>
319
320 <div class="block-header">
321 <h3 class="block-title"><?php echo esc_html($block['title']); ?></h3>
322 </div>
323
324 <p class="block-description"><?php echo esc_html($block['description']); ?></p>
325
326 <div class="block-footer">
327 <a href="<?php echo esc_url($demo_url); ?>"
328 class="demo-link"
329 target="_blank"
330 rel="noopener noreferrer">
331 <?php esc_html_e('View Demo', 'slider-blocks'); ?>
332 <span class="dashicons dashicons-external"></span>
333 </a>
334 <label class="toggle-switch">
335 <input
336 type="checkbox"
337 class="block-toggle"
338 data-block="<?php echo esc_attr($block['name']); ?>"
339 data-key="<?php echo esc_attr($block_key); ?>"
340 <?php echo $is_checked; ?>
341 <?php echo $is_pro && !defined('GUTSLIDER_PRO_VERSION') ? 'disabled' : ''; ?>
342 >
343 <span class="toggle-slider"></span>
344 </label>
345 </div>
346 </div>
347 <?php endforeach; ?>
348 </div>
349 </div>
350 </div>
351 </div>
352 <?php
353 }
354
355 /**
356 * Get blocks data
357 */
358 private function get_blocks() {
359 $blocks_file = GUTSLIDER_DIR . '/includes/api/blocks.php';
360 if (file_exists($blocks_file)) {
361 return include $blocks_file;
362 }
363 return [];
364 }
365
366 /**
367 * AJAX handler for toggling block status
368 */
369 public function toggle_block_status() {
370 check_ajax_referer('gutslider_nonce', 'nonce');
371
372 if (!current_user_can('manage_options')) {
373 wp_send_json_error(['message' => __('Permission denied', 'slider-blocks')]);
374 }
375
376 $block_key = isset($_POST['block_key']) ? sanitize_text_field($_POST['block_key']) : '';
377 $status = isset($_POST['status']) ? rest_sanitize_boolean($_POST['status']) : false;
378
379 if (empty($block_key)) {
380 wp_send_json_error(['message' => __('Invalid block key', 'slider-blocks')]);
381 }
382
383 update_option($block_key, $status);
384 wp_send_json_success(['message' => __('Block status updated', 'slider-blocks')]);
385 }
386
387 /**
388 * Register block settings
389 */
390 public function register_settings() {
391 foreach (self::BLOCK_SETTINGS as $setting) {
392 register_setting('rest-api-settings', $setting, [
393 'type' => 'boolean',
394 'default' => true,
395 'show_in_rest' => true,
396 'sanitize_callback' => 'rest_sanitize_boolean',
397 ]);
398 }
399 }
400
401 /**
402 * Include data SDK
403 */
404 private function include_data_sdk() {
405 require_once dirname(__FILE__) . '/dci/start.php';
406
407 dci_dynamic_init([
408 'sdk_version' => '1.2.1',
409 'product_id' => 3,
410 'plugin_name' => 'GutSlider',
411 'plugin_title' => 'GutSlider',
412 'api_endpoint' => 'https://dashboard.codedivo.com/wp-json/dci/v1/data-insights',
413 'slug' => 'gutslider-blocks',
414 'core_file' => false,
415 'plugin_deactivate_id' => false,
416 'menu' => ['slug' => 'gutslider-blocks'],
417 'public_key' => 'pk_KxU4qcYXPyqvBDwsyyBkbCfY9Gulc1z5',
418 'is_premium' => false,
419 'popup_notice' => false,
420 'deactivate_feedback' => true,
421 'delay_time' => ['time' => 3 * DAY_IN_SECONDS],
422 'text_domain' => 'slider-blocks',
423 'plugin_msg' => '<p>Thank you for using GutSlider! 🎉</p><p>We collect some non-sensitive data to improve our product and decide which features to build next.</p>',
424 ]);
425 }
426
427 /**
428 * Enqueue admin assets
429 */
430 private function enqueue_admin_assets() {
431 wp_enqueue_script('gutslider-admin-script', GUTSLIDER_URL . 'admin/js/admin.js', array('jquery'), GUTSLIDER_VERSION, true);
432 wp_enqueue_style('gutslider-admin-style', GUTSLIDER_URL . 'admin/css/admin.css', [], GUTSLIDER_VERSION);
433 wp_localize_script('gutslider-admin-script', 'gutslider', [
434 'version' => GUTSLIDER_VERSION,
435 'nonce' => wp_create_nonce('gutslider_nonce'),
436 'isPro' => defined('GUTSLIDER_PRO_VERSION'),
437 'proVersion' => defined('GUTSLIDER_PRO_VERSION') ? GUTSLIDER_PRO_VERSION : '',
438 'ajaxUrl' => admin_url('admin-ajax.php'),
439 ]);
440 }
441 }
442 }
443
444 new GutSlider_Admin();