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

113 lines 4.1 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
29 /**
30 * Include admin notice
31 */
32 public function include_admin_notice() {
33 require_once trailingslashit( GUTSLIDER_DIR ) . '/admin/notice/notice.php';
34 }
35
36 /**
37 * Enqueue admin scripts
38 */
39 public function admin_assests( $screen ) {
40
41 if( $screen === 'toplevel_page_gutslider-blocks' ){
42
43 $dependencyFile = trailingslashit( GUTSLIDER_DIR ) . '/build/admin/admin.asset.php';
44 $dependencies = file_exists( $dependencyFile ) ? require_once $dependencyFile : [];
45
46 wp_enqueue_style( 'gutslider-admin-style', trailingslashit( GUTSLIDER_URL ) . 'build/admin/style-admin.css', [], GUTSLIDER_VERSION );
47 wp_enqueue_script( 'gutslider-admin-script', trailingslashit( GUTSLIDER_URL ) . 'build/admin/admin.js', $dependencies[ 'dependencies' ] , GUTSLIDER_VERSION, true );
48
49 // enqueue wp-style
50 wp_enqueue_style( 'wp-components' );
51
52 }
53 }
54
55 /**
56 * Add admin menu
57 */
58 public function admin_menu() {
59 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 );
60 }
61
62 /**
63 * Admin page
64 */
65 public function gutslider_admin_page() {
66 ?>
67 <div id="gutslider"></div>
68 <?php
69 }
70
71 /**
72 * Register settings
73 * return void
74 */
75 public function custom_register_settings() {
76
77 // assets registration
78 register_setting('rest-api-settings', 'swiper_scripts', array(
79 'type' => 'boolean',
80 'default' => true,
81 'show_in_rest' => true,
82 'sanitize_callback' => 'rest_sanitize_boolean',
83 ));
84
85 // fixed content slider
86 register_setting('rest-api-settings', 'gut_fixed_content_slider', array(
87 'type' => 'boolean',
88 'default' => true,
89 'show_in_rest' => true,
90 'sanitize_callback' => 'rest_sanitize_boolean',
91 ));
92
93 // any content
94 register_setting('rest-api-settings', 'gut_any_content_slider', array(
95 'type' => 'boolean',
96 'default' => true,
97 'show_in_rest' => true,
98 'sanitize_callback' => 'rest_sanitize_boolean',
99 ));
100
101 // any content
102 register_setting('rest-api-settings', 'gut_testimonial_slider', array(
103 'type' => 'boolean',
104 'default' => true,
105 'show_in_rest' => true,
106 'sanitize_callback' => 'rest_sanitize_boolean',
107 ));
108 }
109 }
110 }
111
112
113 new GutSlider_Admin(); // initialize the class