module.php
148 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Plugin Name: Ele Custom Skin Loop Item |
| 4 | * Version: 1.0.1 |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Main Elementor Test Extension Class |
| 14 | * |
| 15 | * The main class that initiates and runs the plugin. |
| 16 | * |
| 17 | * @since 1.0.0 |
| 18 | */ |
| 19 | final class Ele_Custom_Loop_Item{ |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * Instance |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | * |
| 27 | * @access private |
| 28 | * @static |
| 29 | * |
| 30 | * @var Elementor_Test_Extension The single instance of the class. |
| 31 | */ |
| 32 | private static $_instance = null; |
| 33 | |
| 34 | /** |
| 35 | * Instance |
| 36 | * |
| 37 | * Ensures only one instance of the class is loaded or can be loaded. |
| 38 | * |
| 39 | * @since 1.0.0 |
| 40 | * |
| 41 | * @access public |
| 42 | * @static |
| 43 | * |
| 44 | * @return Elementor_Test_Extension An instance of the class. |
| 45 | */ |
| 46 | public static function instance() { |
| 47 | |
| 48 | if ( is_null( self::$_instance ) ) { |
| 49 | self::$_instance = new self(); |
| 50 | } |
| 51 | return self::$_instance; |
| 52 | |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Constructor |
| 57 | * |
| 58 | * @since 1.0.0 |
| 59 | * |
| 60 | * @access public |
| 61 | */ |
| 62 | public function __construct() { |
| 63 | |
| 64 | $this->init(); |
| 65 | |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Initialize the plugin |
| 70 | * |
| 71 | * Load the plugin only after Elementor (and other plugins) are loaded. |
| 72 | * Checks for basic plugin requirements, if one check fail don't continue, |
| 73 | * if all check have passed load the files required to run the plugin. |
| 74 | * |
| 75 | * Fired by `plugins_loaded` action hook. |
| 76 | * |
| 77 | * @since 1.0.0 |
| 78 | * |
| 79 | * @access public |
| 80 | */ |
| 81 | public function init() { |
| 82 | |
| 83 | // Add Plugin actions |
| 84 | add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] ); |
| 85 | add_action( 'elementor/controls/register', [ $this, 'init_controls' ] ); |
| 86 | $this->init_includes(); |
| 87 | |
| 88 | } |
| 89 | |
| 90 | |
| 91 | /** |
| 92 | * Init Widgets |
| 93 | * |
| 94 | * Include widgets files and register them |
| 95 | * |
| 96 | * @since 1.0.0 |
| 97 | * |
| 98 | * @access public |
| 99 | */ |
| 100 | public function init_widgets() { |
| 101 | |
| 102 | // Include Widget files |
| 103 | require_once( __DIR__ . '/widgets/loop-item.php' ); |
| 104 | |
| 105 | // Register widget |
| 106 | \Elementor\Plugin::instance()->widgets_manager->register( new \Ele_Custom_Loop_Item_Widget() ); |
| 107 | |
| 108 | } |
| 109 | /** |
| 110 | * Init Includes |
| 111 | * |
| 112 | * Include the necessary files and register them |
| 113 | * |
| 114 | * @since 1.0.0 |
| 115 | * |
| 116 | * @access public |
| 117 | */ |
| 118 | public function init_includes() { |
| 119 | |
| 120 | /* foreach (glob( __DIR__ . "/includes/*.php") as $filename) |
| 121 | { |
| 122 | require_once( $filename ); |
| 123 | }*/ |
| 124 | |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Init Controls |
| 129 | * |
| 130 | * Include controls files and register them |
| 131 | * |
| 132 | * @since 1.0.0 |
| 133 | * |
| 134 | * @access public |
| 135 | */ |
| 136 | public function init_controls() { |
| 137 | |
| 138 | // Include Control files |
| 139 | // require_once( __DIR__ . '/controls/test-control.php' ); |
| 140 | |
| 141 | // Register control |
| 142 | // \Elementor\Plugin::$instance->controls_manager->register_control( 'control-type-', new \Test_Control() ); |
| 143 | |
| 144 | } |
| 145 | |
| 146 | } |
| 147 | |
| 148 | \Ele_Custom_Loop_Item::instance(); |