PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.13.2
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.13.2
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.13.2, at admin/admin.php

417 lines 24.0 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 }
57
58 /**
59 * Enqueue admin scripts and styles
60 * @param string $screen Current admin screen
61 */
62 public function admin_assets($screen) {
63 if ($screen !== 'toplevel_page_gutslider-blocks' && $screen !== 'gutslider_page_gutslider-blocks-settings' && $screen !== 'gutslider_page_gutslider-license') {
64 return;
65 }
66
67 $this->enqueue_admin_assets();
68 }
69
70 /**
71 * Add admin menu
72 */
73 public function admin_menu() {
74 add_menu_page(
75 __('GutSlider', 'slider-blocks'),
76 __('GutSlider', 'slider-blocks'),
77 'manage_options',
78 'gutslider-blocks',
79 [$this, 'render_admin_page'],
80 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iMTIiIGZpbGw9IiNEOUQ5RDkiLz4KPHBhdGggZD0iTTE1IDdIMTEuODIzNUg5VjE3SDE1VjEyLjQxNjdIMTIuODgyNEgxMS44MjM1IiBzdHJva2U9IiMxRDIzMjciIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+Cjwvc3ZnPgo=',
81 100
82 );
83
84 add_submenu_page(
85 'gutslider-blocks',
86 __( 'Welcome', 'slider-blocks' ),
87 __( 'Welcome', 'slider-blocks' ),
88 'manage_options',
89 'gutslider-blocks',
90 array( $this, 'render_admin_page' )
91 );
92
93 add_submenu_page(
94 'gutslider-blocks',
95 __( 'Blocks', 'slider-blocks' ),
96 __( 'Blocks', 'slider-blocks' ),
97 'manage_options',
98 'gutslider-blocks-settings',
99 array( $this, 'render_blocks_page' )
100 );
101
102 }
103
104 /**
105 * Render main admin page
106 */
107 public function render_admin_page() {
108 $has_pro = defined('GUTSLIDER_PRO_VERSION');
109 ?>
110 <div class="header bg-white box-shadow">
111 <div class="container flex align-center">
112 <div class="header-content flex flex-1 align-center">
113 <div class="logo-area flex align-center gap-8">
114 <img src="<?php echo esc_url( GUTSLIDER_URL . 'admin/img/gutslider.svg' ); ?>" alt="<?php esc_attr_e('GutSlider Logo', 'slider-blocks'); ?>" class="logo-img"/>
115 </div>
116 <div class="nav flex align-center">
117 <a href="<?php echo esc_url( admin_url('admin.php?page=gutslider-blocks') ); ?>" class="nav-link"><?php esc_html_e('Welcome', 'slider-blocks'); ?></a>
118 <span class="dot"></span>
119 <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>
120 <span class="dot"></span>
121 <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'); ?>">
122 <?php if( $has_pro): ?>
123 <?php esc_html_e('License', 'slider-blocks'); ?>
124 <?php else: ?>
125 <?php esc_html_e('Get License', 'slider-blocks'); ?>
126 <?php endif; ?>
127 </a>
128 </div>
129 </div>
130 <div class="header-actions flex align-center gap-8">
131 <?php if ( ! $has_pro ) : ?>
132 <a href="https://gutslider.com/pricing" target="_blank" class="header-btn pro-btn"><?php esc_html_e('Get Pro', 'slider-blocks'); ?></a>
133 <?php endif; ?>
134 <a href="https://gutslider.com/docs" target="_blank" class="log-btn">
135 <span class="dashicons dashicons-external"></span>
136 </a>
137 </div>
138 </div>
139 </div>
140 <div class="content-area">
141 <div class="container">
142 <div class="supports-area m50 flex gap-16">
143 <div class="gp-card bg-white p20">
144 <div class="icon flex align-center gap-8">
145 <span class="dashicons dashicons-sos"></span>
146 <h3 class="support-title"><?php esc_html_e('Need Help?', 'slider-blocks'); ?></h3>
147 </div>
148 <div class="content">
149 <p class="support-desc"><?php esc_html_e('Check out our documentation or reach out to our support team for assistance.', 'slider-blocks'); ?></p>
150 <a href="https://gutslider.com/docs" target="_blank" class="support-link"><?php esc_html_e('View Documentation', 'slider-blocks'); ?></a>
151 </div>
152 </div>
153 <div class="gp-card p20 bg-white">
154 <div class="icon flex align-center gap-8">
155 <span class="dashicons dashicons-tickets-alt"></span>
156 <h3 class="support-title"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></h3>
157 </div>
158 <div class="content">
159 <p class="support-desc"><?php esc_html_e('If you need further assistance, please submit a support ticket.', 'slider-blocks'); ?></p>
160 <a href="https://gutslider.com/support" target="_blank" class="support-link"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></a>
161 </div>
162 </div>
163 <div class="gp-card p20 bg-white">
164 <div class="icon flex align-center gap-8">
165 <span class="dashicons dashicons-share-alt2"></span>
166 <h3 class="support-title"><?php esc_html_e('Spread Your Love', 'slider-blocks'); ?></h3>
167 </div>
168 <div class="content">
169 <p class="support-desc"><?php esc_html_e('If you love GutSlider, please consider sharing it with your friends and colleagues!', 'slider-blocks'); ?></p>
170 <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>
171 </div>
172 </div>
173 </div>
174 <div class="welcome-area flex gap-30">
175 <div class="video-area bg-white p30 border rounded">
176 <h3 class="video-title">
177 <?php esc_html_e('Welcome to GutSlider Blocks', 'slider-blocks'); ?>
178 </h3>
179 <p class="support-desc">
180 <?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'); ?>
181 </p>
182 <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>
183 </div>
184 <div class="our-products">
185 <div class="gp-card bg-white p20">
186 <div class="icon flex align-center gap-8">
187 <span class="dashicons dashicons-layout"></span>
188 <h3 class="support-title"><?php esc_html_e('GutenLayouts', 'slider-blocks'); ?></h3>
189 </div>
190 <div class="content">
191 <p class="support-desc"><?php esc_html_e('Design stunning layouts with our pre-built templates and patterns with core blocks.', 'slider-blocks'); ?></p>
192 <a href="https://gutenlayouts.com" target="_blank" class="support-link"><?php esc_html_e('Check it out', 'slider-blocks'); ?></a>
193 </div>
194 </div>
195 <div class="gp-card p20 bg-white">
196 <div class="icon flex align-center gap-8">
197 <span class="dashicons dashicons-admin-plugins"></span>
198 <h3 class="support-title"><?php esc_html_e('Easy Accordion', 'slider-blocks'); ?></h3>
199 </div>
200 <div class="content">
201 <p class="support-desc"><?php esc_html_e('Create beautiful and responsive accordions with ease using our Easy Accordion block.', 'slider-blocks'); ?></p>
202 <a href="https://accordion.gutenbergkits.com" target="_blank" class="support-link"><?php esc_html_e('Check it out', 'slider-blocks'); ?></a>
203 </div>
204 </div>
205 <div class="gp-card p20 bg-white">
206 <div class="icon flex align-center gap-8">
207 <span class="dashicons dashicons-admin-plugins"></span>
208 <h3 class="support-title"><?php esc_html_e('Gmap Block', 'slider-blocks'); ?></h3>
209 </div>
210 <div class="content">
211 <p class="support-desc"><?php esc_html_e('Display interactive Google Maps with ease using our Gmap Block.', 'slider-blocks'); ?></p>
212 <a href="https://gmap.gutenbergkits.com" target="_blank" class="support-link"><?php esc_html_e('Check it out', 'slider-blocks'); ?></a>
213 </div>
214 </div>
215 </div>
216 </div>
217 <?php if( ! $has_pro ) : ?>
218 <div class="welcome-box bg-white p20 mt50 border rounded">
219 <h3 class="video-title"><?php esc_html_e('Get Started with GutSlider Pro', 'slider-blocks'); ?></h3>
220 <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>
221 <a href="https://gutslider.com/pricing" target="_blank" class="welcome-link pro-btn"><?php esc_html_e('Upgrade to Pro', 'slider-blocks'); ?></a>
222 </div>
223 <?php endif; ?>
224 </div>
225 </div>
226 <?php
227 }
228
229 /**
230 * Render blocks page
231 */
232 public function render_blocks_page() {
233 $blocks = $this->get_blocks();
234 $has_pro = defined('GUTSLIDER_PRO_VERSION');
235 ?>
236 <div class="gutslider-admin-wrap">
237 <div class="header bg-white box-shadow">
238 <div class="container flex align-center">
239 <div class="header-content flex flex-1 align-center">
240 <div class="logo-area flex align-center gap-8">
241 <img src="<?php echo esc_url( GUTSLIDER_URL . 'admin/img/gutslider.svg' ); ?>" alt="<?php esc_attr_e('GutSlider Logo', 'slider-blocks'); ?>" class="logo-img"/>
242 </div>
243 <div class="nav flex align-center">
244 <a href="<?php echo esc_url( admin_url('admin.php?page=gutslider-blocks') ); ?>" class="nav-link"><?php esc_html_e('Welcome', 'slider-blocks'); ?></a>
245 <span class="dot"></span>
246 <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>
247 <span class="dot"></span>
248 <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'); ?>">
249 <?php if( $has_pro): ?>
250 <?php esc_html_e('License', 'slider-blocks'); ?>
251 <?php else: ?>
252 <?php esc_html_e('Get License', 'slider-blocks'); ?>
253 <?php endif; ?>
254 </a>
255 </div>
256 </div>
257 <div class="header-actions flex align-center gap-8">
258 <?php if ( ! $has_pro ) : ?>
259 <a href="https://gutslider.com/pricing" target="_blank" class="header-btn pro-btn"><?php esc_html_e('Get Pro', 'slider-blocks'); ?></a>
260 <?php endif; ?>
261 <a href="https://gutslider.com/docs" target="_blank" class="log-btn">
262 <span class="dashicons dashicons-external"></span>
263 </a>
264 </div>
265 </div>
266 </div>
267 <div class="content-area">
268 <div class="container">
269 <div class="supports-area m50 flex gap-16">
270 <div class="gp-card bg-white p20">
271 <div class="icon flex align-center gap-8">
272 <span class="dashicons dashicons-sos"></span>
273 <h3 class="support-title"><?php esc_html_e('Need Help?', 'slider-blocks'); ?></h3>
274 </div>
275 <div class="content">
276 <p class="support-desc"><?php esc_html_e('Check out our documentation or reach out to our support team for assistance.', 'slider-blocks'); ?></p>
277 <a href="https://gutslider.com/docs" target="_blank" class="support-link"><?php esc_html_e('View Documentation', 'slider-blocks'); ?></a>
278 </div>
279 </div>
280 <div class="gp-card p20 bg-white">
281 <div class="icon flex align-center gap-8">
282 <span class="dashicons dashicons-tickets-alt"></span>
283 <h3 class="support-title"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></h3>
284 </div>
285 <div class="content">
286 <p class="support-desc"><?php esc_html_e('If you need further assistance, please submit a support ticket.', 'slider-blocks'); ?></p>
287 <a href="https://gutslider.com/support" target="_blank" class="support-link"><?php esc_html_e('Submit a Ticket', 'slider-blocks'); ?></a>
288 </div>
289 </div>
290 <div class="gp-card p20 bg-white">
291 <div class="icon flex align-center gap-8">
292 <span class="dashicons dashicons-share-alt2"></span>
293 <h3 class="support-title"><?php esc_html_e('Spread Your Love', 'slider-blocks'); ?></h3>
294 </div>
295 <div class="content">
296 <p class="support-desc"><?php esc_html_e('If you love GutSlider, please consider sharing it with your friends and colleagues!', 'slider-blocks'); ?></p>
297 <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>
298 </div>
299 </div>
300 </div>
301 <h2 class="page-title mb30"><?php esc_html_e('Manage GutSlider Blocks', 'slider-blocks'); ?></h2>
302 <div class="gutslider-blocks-grid">
303 <?php foreach ($blocks as $block): ?>
304 <?php
305 $is_pro = isset($block['is_pro']) && $block['is_pro'];
306 $is_active = isset($block['active']) && $block['active'];
307 $block_key = 'gut_' . str_replace('-', '_', $block['name']);
308 $saved_status = get_option($block_key, true);
309 $is_checked = $saved_status ? 'checked' : '';
310 $demo_url = 'https://demos.gutslider.com/' . $block['demo_slug'];
311 ?>
312 <div class="gutslider-block-card <?php echo $is_pro ? 'pro-block' : ''; ?>">
313 <?php if ($is_pro): ?>
314 <span class="pro-badge"><?php esc_html_e('PRO', 'slider-blocks'); ?></span>
315 <?php else: ?>
316 <span class="pro-badge free-badge"><?php esc_html_e('FREE', 'slider-blocks'); ?></span>
317 <?php endif; ?>
318
319 <div class="block-header">
320 <h3 class="block-title"><?php echo esc_html($block['title']); ?></h3>
321 </div>
322
323 <p class="block-description"><?php echo esc_html($block['description']); ?></p>
324
325 <div class="block-footer">
326 <a href="<?php echo esc_url($demo_url); ?>"
327 class="demo-link"
328 target="_blank"
329 rel="noopener noreferrer">
330 <?php esc_html_e('View Demo', 'slider-blocks'); ?>
331 <span class="dashicons dashicons-external"></span>
332 </a>
333 <label class="toggle-switch">
334 <input
335 type="checkbox"
336 class="block-toggle"
337 data-block="<?php echo esc_attr($block['name']); ?>"
338 data-key="<?php echo esc_attr($block_key); ?>"
339 <?php echo esc_attr($is_checked); ?>
340 <?php echo $is_pro && !defined('GUTSLIDER_PRO_VERSION') ? 'disabled' : ''; ?>
341 >
342 <span class="toggle-slider"></span>
343 </label>
344 </div>
345 </div>
346 <?php endforeach; ?>
347 </div>
348 </div>
349 </div>
350 </div>
351 <?php
352 }
353
354 /**
355 * Get blocks data
356 */
357 private function get_blocks() {
358 $blocks_file = GUTSLIDER_DIR . '/includes/api/blocks.php';
359 if (file_exists($blocks_file)) {
360 return include $blocks_file;
361 }
362 return [];
363 }
364
365 /**
366 * AJAX handler for toggling block status
367 */
368 public function toggle_block_status() {
369 check_ajax_referer('gutslider_nonce', 'nonce');
370
371 if (!current_user_can('manage_options')) {
372 wp_send_json_error(['message' => __('Permission denied', 'slider-blocks')]);
373 }
374
375 $block_key = isset($_POST['block_key']) ? sanitize_text_field( wp_unslash($_POST['block_key']) ) : '';
376 $status = isset($_POST['status']) ? rest_sanitize_boolean($_POST['status']) : false;
377
378 if (empty($block_key)) {
379 wp_send_json_error(['message' => __('Invalid block key', 'slider-blocks')]);
380 }
381
382 update_option($block_key, $status);
383 wp_send_json_success(['message' => __('Block status updated', 'slider-blocks')]);
384 }
385
386 /**
387 * Register block settings
388 */
389 public function register_settings() {
390 foreach (self::BLOCK_SETTINGS as $setting) {
391 register_setting('rest-api-settings', $setting, [
392 'type' => 'boolean',
393 'default' => true,
394 'show_in_rest' => true,
395 'sanitize_callback' => 'rest_sanitize_boolean',
396 ]);
397 }
398 }
399
400 /**
401 * Enqueue admin assets
402 */
403 private function enqueue_admin_assets() {
404 wp_enqueue_script('gutslider-admin-script', GUTSLIDER_URL . 'admin/js/admin.js', array('jquery'), GUTSLIDER_VERSION, true);
405 wp_enqueue_style('gutslider-admin-style', GUTSLIDER_URL . 'admin/css/admin.css', [], GUTSLIDER_VERSION);
406 wp_localize_script('gutslider-admin-script', 'gutslider', [
407 'version' => GUTSLIDER_VERSION,
408 'nonce' => wp_create_nonce('gutslider_nonce'),
409 'isPro' => defined('GUTSLIDER_PRO_VERSION'),
410 'proVersion' => defined('GUTSLIDER_PRO_VERSION') ? GUTSLIDER_PRO_VERSION : '',
411 'ajaxUrl' => admin_url('admin-ajax.php'),
412 ]);
413 }
414 }
415 }
416
417 new GutSlider_Admin();