Plugin_Main.php
132 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Main |
| 4 | * |
| 5 | * @package FrontBlocks |
| 6 | * @author Closemarketing |
| 7 | * @copyright 2025 Closemarketing |
| 8 | * @version 1.0.3-beta.1 |
| 9 | */ |
| 10 | |
| 11 | namespace FrontBlocks; |
| 12 | |
| 13 | defined( 'ABSPATH' ) || exit; |
| 14 | |
| 15 | /** |
| 16 | * Main FrontBlocks class. |
| 17 | * |
| 18 | * @since 1.0.0 |
| 19 | */ |
| 20 | class Plugin_Main { |
| 21 | /** |
| 22 | * Plugin instance. |
| 23 | * |
| 24 | * @var FrontBlocks |
| 25 | */ |
| 26 | private static $instance = null; |
| 27 | |
| 28 | /** |
| 29 | * Get plugin instance. |
| 30 | * |
| 31 | * @return FrontBlocks |
| 32 | */ |
| 33 | public static function get_instance() { |
| 34 | if ( null === self::$instance ) { |
| 35 | self::$instance = new self(); |
| 36 | } |
| 37 | |
| 38 | return self::$instance; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Constructor. |
| 43 | */ |
| 44 | private function __construct() { |
| 45 | $this->init(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Initialize the plugin. |
| 50 | * |
| 51 | * @return void |
| 52 | */ |
| 53 | private function init() { |
| 54 | // Load modules. |
| 55 | $this->load_modules(); |
| 56 | |
| 57 | // General enqueue scripts. |
| 58 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 99 ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Load plugin modules. |
| 63 | * |
| 64 | * @return void |
| 65 | */ |
| 66 | private function load_modules() { |
| 67 | // Admin settings page. |
| 68 | if ( is_admin() ) { |
| 69 | new Admin\Settings(); |
| 70 | } |
| 71 | |
| 72 | // Carousel module. |
| 73 | new Frontend\Carousel(); |
| 74 | |
| 75 | // Animations module. |
| 76 | new Frontend\Animations(); |
| 77 | |
| 78 | // Sticky Column module. |
| 79 | new Frontend\StickyColumn(); |
| 80 | |
| 81 | // Gallery module. |
| 82 | new Frontend\Gallery(); |
| 83 | |
| 84 | // Insert Post Block module. |
| 85 | new Frontend\InsertPost(); |
| 86 | |
| 87 | // Testimonials module (includes settings). |
| 88 | new Frontend\Testimonials(); |
| 89 | |
| 90 | // Headline module (GenerateBlocks Headline enhancements). |
| 91 | new Frontend\Headline(); |
| 92 | |
| 93 | // Product Categories module (WooCommerce). |
| 94 | new Frontend\ProductCategories(); |
| 95 | |
| 96 | // Counter module (GenerateBlocks Headline counter effect). |
| 97 | new Frontend\Counter(); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Enqueue scripts. |
| 102 | * |
| 103 | * @return void |
| 104 | */ |
| 105 | public function enqueue_scripts() { |
| 106 | $dist_dir = WP_DEBUG ? 'carousel/' : 'dist/'; |
| 107 | |
| 108 | wp_enqueue_style( |
| 109 | 'frontblocks-carousel', |
| 110 | FRBL_PLUGIN_URL . 'assets/' . $dist_dir . 'frontblocks-carousel.css', |
| 111 | array(), |
| 112 | FRBL_VERSION |
| 113 | ); |
| 114 | |
| 115 | wp_enqueue_script( |
| 116 | 'frontblocks-carousel-custom', |
| 117 | FRBL_PLUGIN_URL . 'assets/' . $dist_dir . ( WP_DEBUG ? 'frontblocks-carousel.js' : 'frontblocks-carousel-min.js' ), |
| 118 | array( 'frontblocks-carousel' ), |
| 119 | FRBL_VERSION, |
| 120 | true |
| 121 | ); |
| 122 | |
| 123 | wp_enqueue_script( |
| 124 | 'frontblocks-carousel', |
| 125 | FRBL_PLUGIN_URL . 'assets/dist/glide.min.js', |
| 126 | array(), |
| 127 | FRBL_VERSION, |
| 128 | true |
| 129 | ); |
| 130 | } |
| 131 | } |
| 132 |