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

169 lines 6.2 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 // localize script
76 wp_localize_script(
77 'gutslider-admin-script',
78 'gutslider',
79 [
80 'version' => GUTSLIDER_VERSION,
81 ]
82 );
83
84 }
85 }
86
87 /**
88 * Add admin menu
89 */
90 public function admin_menu() {
91 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 );
92 }
93
94 /**
95 * Admin page
96 */
97 public function gutslider_admin_page() {
98 ?>
99 <div id="gutslider"></div>
100 <?php
101 }
102
103 /**
104 * Register settings
105 * return void
106 */
107 public function custom_register_settings() {
108
109 // fixed content slider
110 register_setting('rest-api-settings', 'gut_fixed_content_slider', array(
111 'type' => 'boolean',
112 'default' => true,
113 'show_in_rest' => true,
114 'sanitize_callback' => 'rest_sanitize_boolean',
115 ));
116
117 // any content
118 register_setting('rest-api-settings', 'gut_any_content_slider', array(
119 'type' => 'boolean',
120 'default' => true,
121 'show_in_rest' => true,
122 'sanitize_callback' => 'rest_sanitize_boolean',
123 ));
124
125 // testimonial slider
126 register_setting('rest-api-settings', 'gut_testimonial_slider', array(
127 'type' => 'boolean',
128 'default' => true,
129 'show_in_rest' => true,
130 'sanitize_callback' => 'rest_sanitize_boolean',
131 ));
132
133 // post slider
134 register_setting('rest-api-settings', 'gut_post_slider', array(
135 'type' => 'boolean',
136 'default' => true,
137 'show_in_rest' => true,
138 'sanitize_callback' => 'rest_sanitize_boolean',
139 ));
140
141 // photo carousel
142 register_setting('rest-api-settings', 'gut_photo_carousel', array(
143 'type' => 'boolean',
144 'default' => true,
145 'show_in_rest' => true,
146 'sanitize_callback' => 'rest_sanitize_boolean',
147 ));
148
149 // logo carousel
150 register_setting('rest-api-settings', 'gut_logo_carousel', array(
151 'type' => 'boolean',
152 'default' => true,
153 'show_in_rest' => true,
154 'sanitize_callback' => 'rest_sanitize_boolean',
155 ));
156
157 // before after
158 register_setting('rest-api-settings', 'gut_before_after_slider', array(
159 'type' => 'boolean',
160 'default' => true,
161 'show_in_rest' => true,
162 'sanitize_callback' => 'rest_sanitize_boolean',
163 ));
164 }
165 }
166 }
167
168
169 new GutSlider_Admin(); // initialize the class