| @@ -18,24 +18,9 @@ | ||
| 18 | 18 | 'gut_post_slider', |
| 19 | 19 | 'gut_photo_carousel', |
| 20 | 20 | 'gut_logo_carousel', |
| 21 | 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', | |
| 22 | + 'gut_videos_carousel' | |
| 38 | 23 | ]; |
| 39 | 24 | |
| 40 | 25 | /** |
| 41 | 26 | * Constructor |
| @@ -44,9 +29,8 @@ | ||
| 44 | 29 | add_action('admin_menu', [$this, 'admin_menu'], 20); |
| 45 | 30 | add_action('admin_enqueue_scripts', [$this, 'admin_assets']); |
| 46 | 31 | add_action('admin_init', [$this, 'initialize_admin']); |
| 47 | 32 | add_action('rest_api_init', [$this, 'register_settings']); |
| 48 | - add_action('wp_ajax_gutslider_toggle_block', [$this, 'toggle_block_status']); | |
| 49 | 33 | } |
| 50 | 34 | |
| 51 | 35 | /** |
| 52 | 36 | * Initialize admin functionality |
| @@ -52,8 +36,9 @@ | ||
| 52 | 36 | * Initialize admin functionality |
| 53 | 37 | */ |
| 54 | 38 | public function initialize_admin() { |
| 55 | 39 | $this->register_settings(); |
| 40 | + $this->include_data_sdk(); | |
| 56 | 41 | } |
| 57 | 42 | |
| 58 | 43 | /** |
| 59 | 44 | * Enqueue admin scripts and styles |
| @@ -59,9 +44,9 @@ | ||
| 59 | 44 | * Enqueue admin scripts and styles |
| 60 | 45 | * @param string $screen Current admin screen |
| 61 | 46 | */ |
| 62 | 47 | public function admin_assets($screen) { |
| 63 | - if ($screen !== 'toplevel_page_gutslider-blocks' && $screen !== 'gutslider_page_gutslider-blocks-settings' && $screen !== 'gutslider_page_gutslider-license') { | |
| 48 | + if ($screen !== 'toplevel_page_gutslider-blocks') { | |
| 64 | 49 | return; |
| 65 | 50 | } |
| 66 | 51 | |
| 67 | 52 | $this->enqueue_admin_assets(); |
| @@ -88,314 +73,76 @@ | ||
| 88 | 73 | 'manage_options', |
| 89 | 74 | 'gutslider-blocks', |
| 90 | 75 | array( $this, 'render_admin_page' ) |
| 91 | 76 | ); |
| 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 | 77 | } |
| 103 | - | |
| 78 | + | |
| 104 | 79 | /** |
| 105 | - * Render main admin page | |
| 80 | + * Render admin page | |
| 106 | 81 | */ |
| 107 | 82 | 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 | |
| 83 | + echo '<div id="gutslider"></div>'; | |
| 227 | 84 | } |
| 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 | 85 | |
| 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 | 86 | /** |
| 355 | - * Get blocks data | |
| 87 | + * Register block settings | |
| 356 | 88 | */ |
| 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; | |
| 89 | + public function register_settings() { | |
| 90 | + foreach (self::BLOCK_SETTINGS as $setting) { | |
| 91 | + register_setting('rest-api-settings', $setting, [ | |
| 92 | + 'type' => 'boolean', | |
| 93 | + 'default' => true, | |
| 94 | + 'show_in_rest' => true, | |
| 95 | + 'sanitize_callback' => 'rest_sanitize_boolean', | |
| 96 | + ]); | |
| 361 | 97 | } |
| 362 | - return []; | |
| 363 | 98 | } |
| 364 | 99 | |
| 365 | 100 | /** |
| 366 | - * AJAX handler for toggling block status | |
| 101 | + * Include data SDK | |
| 367 | 102 | */ |
| 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')]); | |
| 103 | + private function include_data_sdk() { | |
| 104 | + require_once dirname(__FILE__) . '/dci/start.php'; | |
| 105 | + | |
| 106 | + dci_dynamic_init([ | |
| 107 | + 'sdk_version' => '1.2.1', | |
| 108 | + 'product_id' => 3, | |
| 109 | + 'plugin_name' => 'GutSlider', | |
| 110 | + 'plugin_title' => 'GutSlider', | |
| 111 | + 'api_endpoint' => 'https://dashboard.codedivo.com/wp-json/dci/v1/data-insights', | |
| 112 | + 'slug' => 'gutslider-blocks', | |
| 113 | + 'core_file' => false, | |
| 114 | + 'plugin_deactivate_id' => false, | |
| 115 | + 'menu' => ['slug' => 'gutslider-blocks'], | |
| 116 | + 'public_key' => 'pk_KxU4qcYXPyqvBDwsyyBkbCfY9Gulc1z5', | |
| 117 | + 'is_premium' => false, | |
| 118 | + 'popup_notice' => false, | |
| 119 | + 'deactivate_feedback' => true, | |
| 120 | + 'delay_time' => ['time' => 3 * DAY_IN_SECONDS], | |
| 121 | + 'text_domain' => 'slider-blocks', | |
| 122 | + '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>', | |
| 123 | + ]); | |
| 384 | 124 | } |
| 385 | 125 | |
| 386 | 126 | /** |
| 387 | - * Register block settings | |
| 127 | + * Get GutSlider changelogs | |
| 128 | + * @return array|false Changelog data or false on failure | |
| 388 | 129 | */ |
| 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 | - ]); | |
| 130 | + private function get_change_logs() { | |
| 131 | + $changelog_file = GUTSLIDER_DIR . '/changelogs.json'; | |
| 132 | + | |
| 133 | + if (!file_exists($changelog_file)) { | |
| 134 | + return false; | |
| 397 | 135 | } |
| 136 | + | |
| 137 | + global $wp_filesystem; | |
| 138 | + if (empty($wp_filesystem)) { | |
| 139 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); | |
| 140 | + WP_Filesystem(); | |
| 141 | + } | |
| 142 | + | |
| 143 | + $changelogs = $wp_filesystem->get_contents($changelog_file); | |
| 144 | + return json_decode($changelogs, true); | |
| 398 | 145 | } |
| 399 | 146 | |
| 400 | 147 | /** |
| 401 | 148 | * Enqueue admin assets |
| @@ -400,16 +147,21 @@ | ||
| 400 | 147 | /** |
| 401 | 148 | * Enqueue admin assets |
| 402 | 149 | */ |
| 403 | 150 | 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); | |
| 151 | + $dependency_file = GUTSLIDER_DIR . '/build/admin/admin.asset.php'; | |
| 152 | + $dependencies = file_exists($dependency_file) ? require_once($dependency_file) : []; | |
| 153 | + | |
| 154 | + wp_enqueue_style('gutslider-admin-style', GUTSLIDER_URL . 'build/admin/style-admin.css', [], GUTSLIDER_VERSION); | |
| 155 | + wp_enqueue_script('gutslider-admin-script', GUTSLIDER_URL . 'build/admin/admin.js', $dependencies['dependencies'], GUTSLIDER_VERSION, true); | |
| 156 | + wp_enqueue_style('wp-components'); | |
| 157 | + | |
| 406 | 158 | wp_localize_script('gutslider-admin-script', 'gutslider', [ |
| 407 | 159 | 'version' => GUTSLIDER_VERSION, |
| 160 | + 'changeLogs' => $this->get_change_logs(), | |
| 408 | 161 | 'nonce' => wp_create_nonce('gutslider_nonce'), |
| 409 | 162 | 'isPro' => defined('GUTSLIDER_PRO_VERSION'), |
| 410 | 163 | 'proVersion' => defined('GUTSLIDER_PRO_VERSION') ? GUTSLIDER_PRO_VERSION : '', |
| 411 | - 'ajaxUrl' => admin_url('admin-ajax.php'), | |
| 412 | 164 | ]); |
| 413 | 165 | } |
| 414 | 166 | } |
| 415 | 167 | } |