| 1 |
<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 |
/** |
| 3 |
* Plugin |
| 4 |
* |
| 5 |
* @package wpstream-theme |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace elementor; |
| 9 |
|
| 10 |
use ElementorWpStreamTheme\Widgets; |
| 11 |
|
| 12 |
print 'loaded pluginelementor '; |
| 13 |
|
| 14 |
|
| 15 |
/** |
| 16 |
* Class Plugin |
| 17 |
* |
| 18 |
* Main Plugin class |
| 19 |
* |
| 20 |
* @since 1.2.0 |
| 21 |
*/ |
| 22 |
class Plugin { |
| 23 |
/** |
| 24 |
* Instance |
| 25 |
* |
| 26 |
* @since 1.2.0 |
| 27 |
* @access private |
| 28 |
* @static |
| 29 |
* |
| 30 |
* @var Plugin The single instance of the class. |
| 31 |
*/ |
| 32 |
private static $instance = null; |
| 33 |
|
| 34 |
/** |
| 35 |
* Instance |
| 36 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 37 |
* |
| 38 |
* @return Plugin An instance of the class. |
| 39 |
* @since 1.2.0 |
| 40 |
* @access public |
| 41 |
*/ |
| 42 |
public static function instance() { |
| 43 |
if ( is_null( self::$instance ) ) { |
| 44 |
self::$instance = new self(); |
| 45 |
} |
| 46 |
|
| 47 |
return self::$instance; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Widget_scripts |
| 52 |
* Load required plugin core files. |
| 53 |
* |
| 54 |
* @since 1.2.0 |
| 55 |
* @access public |
| 56 |
*/ |
| 57 |
public function widget_scripts() { |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Include Widgets files |
| 62 |
* Load widgets files |
| 63 |
* |
| 64 |
* @since 1.2.0 |
| 65 |
* @access private |
| 66 |
*/ |
| 67 |
private function include_widgets_files() { |
| 68 |
require_once __DIR__ . '/elementor/widgets/recent-items.php'; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Register Widgets |
| 73 |
* Register new Elementor widgets. |
| 74 |
* |
| 75 |
* @since 1.2.0 |
| 76 |
* @access public |
| 77 |
*/ |
| 78 |
public function register_widgets() { |
| 79 |
// Its is now safe to include Widgets files. |
| 80 |
$this->include_widgets_files(); |
| 81 |
|
| 82 |
// Register Widgets. |
| 83 |
\Elementor\Plugin::instance()->widgets_manager->register( new Widgets\WpStreamTheme_Recent_Items() ); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Plugin class constructor. |
| 88 |
* |
| 89 |
* Register plugin action hooks and filters. |
| 90 |
* |
| 91 |
* @param \Elementor\Elements_Manager $elements_manager The Elementor elements manager instance. |
| 92 |
* @since 1.2.0 |
| 93 |
* @access public |
| 94 |
*/ |
| 95 |
public function add_elementor_widget_categories( $elements_manager ) { |
| 96 |
$elements_manager->add_category( |
| 97 |
'hello-wpstream', |
| 98 |
array( |
| 99 |
'title' => __( 'Hello WpStream Widgets', 'hello-wpstream' ), |
| 100 |
'icon' => 'fa fa-home', |
| 101 |
) |
| 102 |
); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Constructor |
| 107 |
*/ |
| 108 |
public function __construct() { |
| 109 |
// Register widget scripts. |
| 110 |
add_action( 'elementor/frontend/after_register_scripts', array( $this, 'widget_scripts' ) ); |
| 111 |
|
| 112 |
// Register widgets. |
| 113 |
add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) ); |
| 114 |
|
| 115 |
add_action( 'elementor/elements/categories_registered', array( $this, 'add_elementor_widget_categories' ) ); |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
// Instantiate Plugin Class. |
| 120 |
Plugin::instance(); |
| 121 |
|