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

143 lines 3.8 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.9.8
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 * Blocks Final Class
20 * return GutSliderBlocks
21 */
22 if( ! class_exists( 'GutSliderBlocks' ) ) {
23
24 final class GutSliderBlocks {
25
26 private static $instance = null;
27
28 /**
29 * The constructor function initializes constants, includes necessary files, loads a text domain, and
30 * sets up activation redirection for a PHP class.
31 */
32 private function __construct() {
33 $this->define_constants();
34 $this->includes();
35 add_action( 'init', [ $this, 'load_textdomain' ] );
36 register_activation_hook( __FILE__, [ $this, 'set_activation_redirect' ] );
37 add_action( 'admin_init', [ $this, 'redirect_to_welcome_page' ] );
38 }
39
40 /**
41 * Define the plugin constants
42 * return void
43 */
44 private function define_constants() {
45 define( 'GUTSLIDER_VERSION', '2.9.8' );
46 define( 'GUTSLIDER_URL', plugin_dir_url( __FILE__ ) );
47 define('GUTSLIDER_DIR_PATH', plugin_dir_path(__FILE__));
48 define( 'GUTSLIDER_DIR', __DIR__ );
49 }
50
51 /**
52 * Initialize the plugin
53 * return GutSliderBlocks
54 */
55 public static function init() {
56 if( is_null( self::$instance ) ) {
57 self::$instance = new self();
58 }
59 return self::$instance;
60 }
61
62 /**
63 * Include the files
64 * return void
65 */
66 public function includes() {
67 require_once GUTSLIDER_DIR . '/includes/init.php';
68 require_once GUTSLIDER_DIR . '/admin/admin.php';
69 }
70
71 /**
72 * Load the plugin text domain
73 * return void
74 */
75 public function load_textdomain() {
76 load_plugin_textdomain( 'slider-blocks', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
77 }
78
79 /**
80 * Set the activation redirect
81 * return void
82 */
83 public function set_activation_redirect() {
84 add_option( 'gutsliderblocks_do_activation_redirect', true );
85 }
86
87 /**
88 * Redirect to the welcome page
89 * return void
90 */
91 public function redirect_to_welcome_page() {
92 if ( is_admin() && get_option( 'gutsliderblocks_do_activation_redirect', false ) ) {
93 delete_option( 'gutsliderblocks_do_activation_redirect' );
94 wp_safe_redirect( admin_url( 'admin.php?page=gutslider-blocks' ) );
95 exit; // Added exit after redirect
96 }
97 }
98
99 /**
100 * Cleanup the plugin data
101 * return void
102 */
103 public static function cleanup() {
104 $upload_dir = wp_upload_dir();
105 $css_dir = $upload_dir['basedir'] . '/gutslider-styles';
106
107 if ( file_exists( $css_dir ) ) {
108 global $wp_filesystem;
109 if ( empty( $wp_filesystem ) ) {
110 require_once( ABSPATH . '/wp-admin/includes/file.php' );
111 WP_Filesystem();
112 }
113
114 $files = glob( $css_dir . '/*' );
115 foreach ( $files as $file ) {
116 if ( is_file( $file ) ) {
117 $wp_filesystem->delete( $file );
118 }
119 }
120 $wp_filesystem->rmdir( $css_dir );
121 }
122
123 // Remove parent directory if it's empty
124 $parent_dir = dirname( $css_dir );
125 if ( file_exists( $parent_dir ) && ( count( glob( "$parent_dir/*" ) ) === 0 ) ) {
126 $wp_filesystem->rmdir( $parent_dir );
127 }
128 }
129
130 }
131
132 }
133
134 /**
135 * Initialize the GutSliderBlocks
136 * return GutSliderBlocks
137 */
138 function gutsliderblocks() {
139 return GutSliderBlocks::init();
140 }
141
142 // kick-off the plugin
143 gutsliderblocks();