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

152 lines 5.6 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 *
5 */
6
7 if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
9 if( ! class_exists( 'GutSlider_Admin' ) ) {
10
11 class GutSlider_Admin {
12
13 /**
14 * Constructor
15 * return void
16 */
17 public function __construct() {
18 // include admin notice
19 $this->include_admin_notice();
20
21 add_action( 'admin_menu', [ $this, 'admin_menu' ] );
22 add_action( 'admin_enqueue_scripts', [ $this, 'admin_assests' ] );
23
24 // register settings
25 add_action('admin_init', [ $this, 'custom_register_settings' ]);
26 add_action( 'rest_api_init', [ $this, 'custom_register_settings' ] );
27
28 // include admin data SDk
29 add_action( 'plugins_loaded', [ $this, 'dci_plugin_gutslider' ] );
30 }
31
32 /**
33 * Include admin notice
34 */
35 public function include_admin_notice() {
36 require_once trailingslashit( GUTSLIDER_DIR ) . '/admin/notice/notice.php';
37 }
38
39 /**
40 * Include data SDK
41 */
42 public function dci_plugin_gutslider() {
43 // Include DCI SDK.
44 require_once dirname( __FILE__ ) . '/dci/start.php';
45 dci_dynamic_init( array(
46 'sdk_version' => '1.0.0',
47 'plugin_title' => 'GutSlider',
48 'product_id' => 3,
49 'api_endpoint' => 'https://dashboard.gutenbergkits.com/wp-json/dci/v1/data-insights',
50 'slug' => 'slider-blocks',
51 'public_key' => 'pk_KxU4qcYXPyqvBDwsyyBkbCfY9Gulc1z5',
52 'is_premium' => false,
53 'menu' => array(
54 'slug' => 'gutslider-blocks',
55 ),
56 ) );
57 }
58
59 /**
60 * Enqueue admin scripts
61 */
62 public function admin_assests( $screen ) {
63
64 if( $screen === 'toplevel_page_gutslider-blocks' ){
65
66 $dependencyFile = trailingslashit( GUTSLIDER_DIR ) . '/build/admin/admin.asset.php';
67 $dependencies = file_exists( $dependencyFile ) ? require_once $dependencyFile : [];
68
69 wp_enqueue_style( 'gutslider-admin-style', trailingslashit( GUTSLIDER_URL ) . 'build/admin/style-admin.css', [], GUTSLIDER_VERSION );
70 wp_enqueue_script( 'gutslider-admin-script', trailingslashit( GUTSLIDER_URL ) . 'build/admin/admin.js', $dependencies[ 'dependencies' ] , GUTSLIDER_VERSION, true );
71
72 // enqueue wp-style
73 wp_enqueue_style( 'wp-components' );
74
75 }
76 }
77
78 /**
79 * Add admin menu
80 */
81 public function admin_menu() {
82 add_menu_page( __( 'GutSlider', 'slider-blocks' ), __( 'GutSlider', 'slider-blocks' ), 'manage_options', 'gutslider-blocks', [ $this, 'gutslider_admin_page' ], 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iMTIiIGZpbGw9IiNEOUQ5RDkiLz4KPHBhdGggZD0iTTE1IDdIMTEuODIzNUg5VjE3SDE1VjEyLjQxNjdIMTIuODgyNEgxMS44MjM1IiBzdHJva2U9IiMxRDIzMjciIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+Cjwvc3ZnPgo=', 100 );
83 }
84
85 /**
86 * Admin page
87 */
88 public function gutslider_admin_page() {
89 ?>
90 <div id="gutslider"></div>
91 <?php
92 }
93
94 /**
95 * Register settings
96 * return void
97 */
98 public function custom_register_settings() {
99
100 // assets registration
101 register_setting('rest-api-settings', 'swiper_scripts', array(
102 'type' => 'boolean',
103 'default' => true,
104 'show_in_rest' => true,
105 'sanitize_callback' => 'rest_sanitize_boolean',
106 ));
107
108 // fixed content slider
109 register_setting('rest-api-settings', 'gut_fixed_content_slider', array(
110 'type' => 'boolean',
111 'default' => true,
112 'show_in_rest' => true,
113 'sanitize_callback' => 'rest_sanitize_boolean',
114 ));
115
116 // any content
117 register_setting('rest-api-settings', 'gut_any_content_slider', array(
118 'type' => 'boolean',
119 'default' => true,
120 'show_in_rest' => true,
121 'sanitize_callback' => 'rest_sanitize_boolean',
122 ));
123
124 // testimonial slider
125 register_setting('rest-api-settings', 'gut_testimonial_slider', array(
126 'type' => 'boolean',
127 'default' => true,
128 'show_in_rest' => true,
129 'sanitize_callback' => 'rest_sanitize_boolean',
130 ));
131
132 // post slider
133 register_setting('rest-api-settings', 'gut_post_slider', array(
134 'type' => 'boolean',
135 'default' => true,
136 'show_in_rest' => true,
137 'sanitize_callback' => 'rest_sanitize_boolean',
138 ));
139
140 // photo carousel
141 register_setting('rest-api-settings', 'gut_photo_carousel', array(
142 'type' => 'boolean',
143 'default' => true,
144 'show_in_rest' => true,
145 'sanitize_callback' => 'rest_sanitize_boolean',
146 ));
147 }
148 }
149 }
150
151
152 new GutSlider_Admin(); // initialize the class