| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: GutSlider - All in One Block Slider |
| 4 |
* Description: A collection of custom Gutenberg Slider Blocks to slide your post or custom content. |
| 5 |
* Requires at least: 5.7 |
| 6 |
* Requires PHP: 7.0 |
| 7 |
* Version: 2.6.1 |
| 8 |
* Author: Zakaria Binsaifullah |
| 9 |
* Author URI: https://makegutenblock.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 |
|
| 17 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
| 18 |
|
| 19 |
/** |
| 20 |
* Blocks Final Class |
| 21 |
* return GutSliderBlocks |
| 22 |
*/ |
| 23 |
if( ! class_exists('GutSliderBlocks') ) { |
| 24 |
|
| 25 |
final class GutSliderBlocks { |
| 26 |
|
| 27 |
private static $instance = null; |
| 28 |
|
| 29 |
/** |
| 30 |
* Constructor |
| 31 |
* return void |
| 32 |
*/ |
| 33 |
public function __construct() { |
| 34 |
$this->define_constants(); |
| 35 |
$this->includes(); |
| 36 |
|
| 37 |
// redirecting |
| 38 |
register_activation_hook( __FILE__, [ $this, 'set_activation_redirect' ] ); |
| 39 |
add_action( 'admin_init', [ $this, 'redirect_to_welcome_page' ] ); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Define the plugin constants |
| 44 |
* return void |
| 45 |
*/ |
| 46 |
private function define_constants() { |
| 47 |
define( 'GUTSLIDER_VERSION', '2.6.1' ); |
| 48 |
define( 'GUTSLIDER_URL', plugin_dir_url( __FILE__ ) ); |
| 49 |
define('GUTSLIDER_DIR_PATH', plugin_dir_path(__FILE__)); |
| 50 |
define( 'GUTSLIDER_DIR', __DIR__ ); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Initialize the plugin |
| 55 |
* return GutSliderBlocks |
| 56 |
*/ |
| 57 |
public static function init() { |
| 58 |
if( is_null( self::$instance ) ) { |
| 59 |
self::$instance = new self(); |
| 60 |
} |
| 61 |
return self::$instance; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Include the files |
| 66 |
* return void |
| 67 |
*/ |
| 68 |
public function includes() { |
| 69 |
require_once trailingslashit( GUTSLIDER_DIR ) . '/includes/init.php'; |
| 70 |
require_once trailingslashit( GUTSLIDER_DIR ) . '/admin/admin.php'; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Set the activation redirect |
| 75 |
* return void |
| 76 |
*/ |
| 77 |
public function set_activation_redirect() { |
| 78 |
add_option( 'gutsliderblocks_do_activation_redirect', true ); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Redirect to the welcome page |
| 83 |
* return void |
| 84 |
*/ |
| 85 |
public function redirect_to_welcome_page() { |
| 86 |
if ( is_admin() && get_option( 'gutsliderblocks_do_activation_redirect', false ) ) { |
| 87 |
delete_option( 'gutsliderblocks_do_activation_redirect' ); |
| 88 |
wp_safe_redirect( admin_url( 'admin.php?page=gutslider-blocks' ) ); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
} |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* Initialize the GutSliderBlocks |
| 98 |
* return GutSliderBlocks |
| 99 |
*/ |
| 100 |
function gutsliderblocks() { |
| 101 |
return GutSliderBlocks::init(); |
| 102 |
} |
| 103 |
|
| 104 |
// kick-off the plugin |
| 105 |
gutsliderblocks(); |