PluginProbe
GutSlider – All in One Slider and Carousel Blocks for Gutenberg / 3.2.0
GutSlider – All in One Slider and Carousel Blocks for Gutenberg v3.2.0
3.2.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 All 57 releases
← All changes | slider-blocks.php +54 -121 2.10.1 → 3.2.0 View file →
@@ -1,145 +1,78 @@
1 1 <?php
2 2 /**
3 - * Plugin Name: GutSlider - All in One Block Slider for Gutenberg
3 + * Plugin Name: GutSlider - All in One Slider Blocks for Gutenberg
4 4 * Description: A collection of custom Gutenberg Slider Blocks to slide your content.
5 5 * Requires at least: 6.5
6 6 * Requires PHP: 7.4
7 - * Version: 2.10.1
8 - * Author: Gutenbergkits
9 - * Author URI: https://gutenbergkits.com
7 + * Version: 3.2.0
8 + * Author: Binsaifullah
10 9 * License: GPLv2 or later
11 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 11 * Text Domain: slider-blocks
13 12 *
13 + * @package GutSlider
14 14 */
15 15
16 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit;
18 +}
17 19
20 +/**
21 + * Plugin version constant.
22 + *
23 + * @since 1.0.0
24 + * @var string
25 + */
26 +define( 'GUTSLIDER_VERSION', '3.2.0' );
18 27
19 28 /**
20 - * GutSlider Blocks Final Class
21 - *
22 - * @package GutSliderBlocks
29 + * Plugin directory URL with trailing slash.
30 + *
23 31 * @since 1.0.0
32 + * @var string
24 33 */
34 +define( 'GUTSLIDER_URL', plugin_dir_url( __FILE__ ) );
25 35
26 - if( ! class_exists( 'GutSliderBlocks' ) ) {
36 +/**
37 + * Plugin directory path with trailing slash.
38 + *
39 + * @since 1.0.0
40 + * @var string
41 + */
42 +define( 'GUTSLIDER_DIR_PATH', plugin_dir_path( __FILE__ ) );
27 43
28 - final class GutSliderBlocks {
44 +/**
45 + * Plugin directory path without trailing slash.
46 + *
47 + * @since 1.0.0
48 + * @var string
49 + */
50 +define( 'GUTSLIDER_DIR', __DIR__ );
29 51
30 - // Plugin version
31 - public $version = '2.10.1';
52 +// Load PSR-4 autoloader.
53 +require_once GUTSLIDER_DIR . '/includes/Autoloader.php';
54 +( new GutSlider_Autoloader( GUTSLIDER_DIR . '/includes/' ) )->register();
32 55
33 - // Instance of the class
34 - /**
35 - * @var GutSliderBlocks
36 - */
37 - private static $instance = null;
56 +// Load backward-compatibility global functions.
57 +require_once GUTSLIDER_DIR . '/includes/compat.php';
38 58
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 - }
59 +// Load admin (outside refactoring scope).
60 +require_once GUTSLIDER_DIR . '/admin/admin.php';
60 61
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 - }
62 +// Register activation and deactivation hooks.
63 +register_activation_hook( __FILE__, array( GutSlider\Plugin::class, 'on_activation' ) );
64 +register_deactivation_hook( __FILE__, array( GutSlider\Plugin::class, 'cleanup' ) );
71 65
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 - }
66 +/**
67 + * Return the main plugin singleton instance.
68 + *
69 + * @since 1.0.0
70 + *
71 + * @return GutSlider\Plugin The plugin instance.
72 + */
73 +function gutsliderblocks(): GutSlider\Plugin {
74 + return GutSlider\Plugin::get_instance();
75 +}
80 76
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();
77 +// Boot the plugin.
78 +gutsliderblocks();