Created
May 30, 2022 15:21
-
-
Save gicolek/a7c0aad8353b509510da1acbea4f9e30 to your computer and use it in GitHub Desktop.
Custom Elementor Widget functions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Elementor Widgets | |
*/ | |
class Custom_Elementor_Widgets { | |
protected static $instance = null; | |
public static function get_instance(){ | |
if ( !isset( static::$instance ) ) { | |
static::$instance = new static; | |
} | |
return static::$instance; | |
} | |
protected function __construct(){ | |
require_once( __DIR__ . DIRECTORY_SEPARATOR . 'elementor-widgets' . DIRECTORY_SEPARATOR . 'widget-custom-blog-loop.php' ); | |
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] ); | |
} | |
public function register_widgets(){ | |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\My_Widget_Custom_Blog_Loop() ); | |
} | |
} | |
add_action( 'init', 'custom_elementor_init' ); | |
/** | |
* @hook init | |
* instantiate custom elementor widgets | |
*/ | |
function custom_elementor_init(){ | |
Custom_Elementor_Widgets::get_instance(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment