Plugin_Main.php
176 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Main |
| 4 | * |
| 5 | * @package FrontBlocks |
| 6 | * @author Closemarketing |
| 7 | * @copyright 2025 Closemarketing |
| 8 | * @version 1.0.3 |
| 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 | // Register scripts for conditional enqueueing. |
| 58 | add_action( 'init', array( $this, 'register_scripts' ) ); |
| 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 | // Load Admin classes if autoloader is not available. |
| 70 | if ( ! class_exists( 'FrontBlocks\Admin\UI' ) ) { |
| 71 | require_once FRBL_PLUGIN_PATH . 'includes/Admin/UI.php'; |
| 72 | } |
| 73 | if ( ! class_exists( 'FrontBlocks\Admin\Settings' ) ) { |
| 74 | require_once FRBL_PLUGIN_PATH . 'includes/Admin/Settings.php'; |
| 75 | } |
| 76 | new Admin\Settings(); |
| 77 | } |
| 78 | |
| 79 | // Container Edge Alignment for GenerateBlocks. |
| 80 | new Frontend\ContainerEdgeAlignment(); |
| 81 | |
| 82 | // Carousel module. |
| 83 | new Frontend\Carousel(); |
| 84 | |
| 85 | // Animations module. |
| 86 | new Frontend\Animations(); |
| 87 | |
| 88 | // Sticky Column module. |
| 89 | new Frontend\StickyColumn(); |
| 90 | |
| 91 | // Gallery module. |
| 92 | new Frontend\Gallery(); |
| 93 | |
| 94 | // Insert Post Block module. |
| 95 | new Frontend\InsertPost(); |
| 96 | |
| 97 | // Testimonials module (includes settings). |
| 98 | new Frontend\Testimonials(); |
| 99 | |
| 100 | // Headline module (GenerateBlocks Headline enhancements). |
| 101 | new Frontend\Headline(); |
| 102 | |
| 103 | // Product Categories module (WooCommerce). |
| 104 | new Frontend\ProductCategories(); |
| 105 | |
| 106 | // Counter module (GenerateBlocks Headline counter effect). |
| 107 | new Frontend\Counter(); |
| 108 | |
| 109 | // Reading Time module. |
| 110 | new Frontend\ReadingTime(); |
| 111 | |
| 112 | // Reading Progress Bar module. |
| 113 | new Frontend\ReadingProgress(); |
| 114 | |
| 115 | // Back Button module. |
| 116 | new Frontend\BackButton(); |
| 117 | |
| 118 | // Events module. |
| 119 | new Frontend\Events(); |
| 120 | |
| 121 | // Shape Animations module (for GenerateBlocks Shape block). |
| 122 | new Frontend\ShapeAnimations(); |
| 123 | |
| 124 | // Gravity Forms Inline Layout module. |
| 125 | new Frontend\GravityFormsInline(); |
| 126 | |
| 127 | // Fluid Typography module (GeneratePress Pro integration). |
| 128 | new Frontend\FluidTypography(); |
| 129 | |
| 130 | // Stacked Images module. |
| 131 | new Frontend\StackedImages(); |
| 132 | |
| 133 | // Block Patterns module (WordPress block patterns registration). |
| 134 | new Frontend\BlockPatterns(); |
| 135 | |
| 136 | // FAQ Schema module (FAQPage JSON-LD for core/details and GB accordion). |
| 137 | new Frontend\FaqSchema(); |
| 138 | |
| 139 | // Text Animation block. |
| 140 | new Frontend\TextAnimation(); |
| 141 | |
| 142 | // Before After comparison block. |
| 143 | new Frontend\BeforeAfter(); |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Register scripts for conditional enqueueing. |
| 148 | * |
| 149 | * @return void |
| 150 | */ |
| 151 | public function register_scripts() { |
| 152 | wp_register_style( |
| 153 | 'frontblocks-carousel', |
| 154 | FRBL_PLUGIN_URL . 'assets/carousel/frontblocks-carousel.css', |
| 155 | array(), |
| 156 | FRBL_VERSION |
| 157 | ); |
| 158 | |
| 159 | wp_register_script( |
| 160 | 'frontblocks-carousel', |
| 161 | FRBL_PLUGIN_URL . 'assets/carousel/glide.min.js', |
| 162 | array(), |
| 163 | FRBL_VERSION, |
| 164 | true |
| 165 | ); |
| 166 | |
| 167 | wp_register_script( |
| 168 | 'frontblocks-carousel-custom', |
| 169 | FRBL_PLUGIN_URL . 'assets/carousel/frontblocks-carousel.js', |
| 170 | array( 'frontblocks-carousel' ), |
| 171 | FRBL_VERSION, |
| 172 | true |
| 173 | ); |
| 174 | } |
| 175 | } |
| 176 |