PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 2.10.0
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v2.10.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 / slider-blocks.php

slider-blocks.php in GutSlider – All in One Slider and Carousel Blocks for Gutenberg 2.10.0, at slider-blocks.php

145 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: GutSlider - All in One Block Slider for Gutenberg
4 * Description: A collection of custom Gutenberg Slider Blocks to slide your content.
5 * Requires at least: 6.5
6 * Requires PHP: 7.4
7 * Version: 2.10.0
8 * Author: Gutenbergkits
9 * Author URI: https://gutenbergkits.com
10 * License: GPLv2 or later
11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 * Text Domain: slider-blocks
13 *
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
17
18
19 /**
20 * GutSlider Blocks Final Class
21 *
22 * @package GutSliderBlocks
23 * @since 1.0.0
24 */
25
26 if( ! class_exists( 'GutSliderBlocks' ) ) {
27
28 final class GutSliderBlocks {
29
30 // Plugin version
31 public $version = '2.10.0';
32
33 // Instance of the class
34 /**
35 * @var GutSliderBlocks
36 */
37 private static $instance = null;
38
39 /**
40 * The constructor function initializes constants, includes necessary files, loads a text domain, and
41 * sets up activation redirection for a PHP class.
42 */
43 private function __construct() {
44 $this->define_constants();
45 $this->includes();
46 register_activation_hook( __FILE__, [ $this, 'set_activation_redirect' ] );
47 add_action( 'admin_init', [ $this, 'redirect_to_welcome_page' ] );
48 }
49
50 /**
51 * Define the plugin constants
52 * return void
53 */
54 private function define_constants() {
55 define( 'GUTSLIDER_VERSION', $this->version );
56 define( 'GUTSLIDER_URL', plugin_dir_url( __FILE__ ) );
57 define('GUTSLIDER_DIR_PATH', plugin_dir_path(__FILE__));
58 define( 'GUTSLIDER_DIR', __DIR__ );
59 }
60
61 /**
62 * Initialize the plugin
63 * return GutSliderBlocks
64 */
65 public static function init() {
66 if( is_null( self::$instance ) ) {
67 self::$instance = new self();
68 }
69 return self::$instance;
70 }
71
72 /**
73 * Include the files
74 * return void
75 */
76 public function includes() {
77 require_once GUTSLIDER_DIR . '/includes/init.php';
78 require_once GUTSLIDER_DIR . '/admin/admin.php';
79 }
80
81 /**
82 * Set the activation redirect
83 * return void
84 */
85 public function set_activation_redirect() {
86 add_option( 'gutsliderblocks_do_activation_redirect', true );
87 }
88
89 /**
90 * Redirect to the welcome page
91 * return void
92 */
93 public function redirect_to_welcome_page() {
94 if ( is_admin() && get_option( 'gutsliderblocks_do_activation_redirect', false ) ) {
95 delete_option( 'gutsliderblocks_do_activation_redirect' );
96 wp_safe_redirect( admin_url( 'admin.php?page=gutslider-blocks' ) );
97 exit; // Added exit after redirect
98 }
99 }
100
101 /**
102 * Cleanup the plugin data
103 * return void
104 */
105 public static function cleanup() {
106 $upload_dir = wp_upload_dir();
107 $css_dir = $upload_dir['basedir'] . '/gutslider-styles';
108
109 if ( file_exists( $css_dir ) ) {
110 global $wp_filesystem;
111 if ( empty( $wp_filesystem ) ) {
112 require_once( ABSPATH . '/wp-admin/includes/file.php' );
113 WP_Filesystem();
114 }
115
116 $files = glob( $css_dir . '/*' );
117 foreach ( $files as $file ) {
118 if ( is_file( $file ) ) {
119 $wp_filesystem->delete( $file );
120 }
121 }
122 $wp_filesystem->rmdir( $css_dir );
123 }
124
125 // Remove parent directory if it's empty
126 $parent_dir = dirname( $css_dir );
127 if ( file_exists( $parent_dir ) && ( count( glob( "$parent_dir/*" ) ) === 0 ) ) {
128 $wp_filesystem->rmdir( $parent_dir );
129 }
130 }
131
132 }
133
134 }
135
136 /**
137 * Initialize the GutSliderBlocks
138 * return GutSliderBlocks
139 */
140 function gutsliderblocks() {
141 return GutSliderBlocks::init();
142 }
143
144 // kick-off the plugin
145 gutsliderblocks();