actions
5 years ago
admin
5 years ago
blocks
5 years ago
classes
5 years ago
compatibility
5 years ago
exceptions
5 years ago
gateways
5 years ago
generators
5 years ago
integrations
5 years ago
autoloader.php
5 years ago
file-upload.php
5 years ago
form-handler.php
5 years ago
form-manager.php
5 years ago
form-messages-builder.php
5 years ago
form-messages-manager.php
5 years ago
form-preset.php
5 years ago
live-form.php
5 years ago
plugin.php
5 years ago
post-type.php
5 years ago
request-handler.php
5 years ago
plugin.php
121 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Jet_Form_Builder; |
| 4 | |
| 5 | // If this file is called directly, abort. |
| 6 | use Jet_Form_Builder\Classes\Frontend_Helper; |
| 7 | use Jet_Form_Builder\Integrations\Forms_Captcha; |
| 8 | |
| 9 | if ( ! defined( 'WPINC' ) ) { |
| 10 | die; |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * Main file |
| 15 | */ |
| 16 | class Plugin { |
| 17 | |
| 18 | /** |
| 19 | * Instance. |
| 20 | * |
| 21 | * Holds the plugin instance. |
| 22 | * |
| 23 | * @since 1.0.0 |
| 24 | * @access public |
| 25 | * @static |
| 26 | * |
| 27 | * @var Plugin |
| 28 | */ |
| 29 | public static $instance = null; |
| 30 | |
| 31 | public $post_type; |
| 32 | public $blocks; |
| 33 | public $actions; |
| 34 | public $form; |
| 35 | public $form_handler; |
| 36 | public $editor; |
| 37 | public $captcha; |
| 38 | |
| 39 | public $is_activated_jet_sm; |
| 40 | |
| 41 | /** |
| 42 | * Instance. |
| 43 | * |
| 44 | * Ensures only one instance of the plugin class is loaded or can be loaded. |
| 45 | * |
| 46 | * @return Plugin An instance of the class. |
| 47 | * @since 1.0.0 |
| 48 | * @access public |
| 49 | * @static |
| 50 | * |
| 51 | */ |
| 52 | public static function instance() { |
| 53 | |
| 54 | if ( is_null( self::$instance ) ) { |
| 55 | self::$instance = new self(); |
| 56 | } |
| 57 | |
| 58 | return self::$instance; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Register autoloader. |
| 63 | */ |
| 64 | private function register_autoloader() { |
| 65 | require JET_FORM_BUILDER_PATH . 'includes' . DIRECTORY_SEPARATOR . 'autoloader.php'; |
| 66 | Autoloader::run(); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Initialize plugin parts |
| 71 | * |
| 72 | * @return void |
| 73 | */ |
| 74 | public function init_components() { |
| 75 | |
| 76 | $this->post_type = new Post_Type(); |
| 77 | $this->blocks = new Blocks\Manager(); |
| 78 | $this->actions = new Actions\Manager(); |
| 79 | $this->form = new Form_Manager(); |
| 80 | $this->form_handler = new Form_Handler(); |
| 81 | $this->captcha = new Forms_Captcha(); |
| 82 | |
| 83 | File_Upload::instance(); |
| 84 | |
| 85 | if ( is_admin() ) { |
| 86 | $this->editor = new Admin\Editor(); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Returns url to file or dir inside plugin folder |
| 92 | * |
| 93 | * @param string $path Path inside plugin dir. |
| 94 | * |
| 95 | * @return string |
| 96 | */ |
| 97 | public function plugin_url( $path = null ) { |
| 98 | return JET_FORM_BUILDER_URL . $path; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Returns plugin version |
| 103 | */ |
| 104 | public function get_version() { |
| 105 | return JET_FORM_BUILDER_VERSION; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Plugin constructor. |
| 110 | */ |
| 111 | private function __construct() { |
| 112 | |
| 113 | $this->register_autoloader(); |
| 114 | |
| 115 | add_action( 'after_setup_theme', array( $this, 'init_components' ), 0 ); |
| 116 | } |
| 117 | |
| 118 | } |
| 119 | |
| 120 | Plugin::instance(); |
| 121 |