Created
March 8, 2023 15:30
-
-
Save ibrahim-kardi/7d2d6b15b8c091838814e028e94efaaa to your computer and use it in GitHub Desktop.
for theme elementor widgets loader
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
//elementor includes | |
include get_template_directory() . '/includes/elements/elementor-extensions.php'; | |
<?php | |
namespace WPC; | |
class Widget_Loader | |
{ | |
private static $_instance = null; | |
public static function instance() | |
{ | |
if (is_null(self::$_instance)) { | |
self::$_instance = new self(); | |
} | |
return self::$_instance; | |
} | |
private function include_widgets_files() | |
{ | |
require_once(__DIR__ . '/multi-image/multi-image.php'); | |
require_once(__DIR__ . '/team-member/team-member.php'); | |
require_once(__DIR__ . '/testimonial/testimonial.php'); | |
require_once(__DIR__ . '/faqs/faq.php'); | |
} | |
public function register_widgets() | |
{ | |
$this->include_widgets_files(); | |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type(new Widgets\Multi_Image_Widget()); | |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type(new Widgets\Team_Image_Widget()); | |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type(new Widgets\Testimonial_Widget()); | |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type(new Widgets\Faq_Widget()); | |
} | |
public function __construct() | |
{ | |
add_action('elementor/widgets/widgets_registered', [$this, 'register_widgets'], 99); | |
add_action('elementor/elements/categories_registered', [$this, 'elementor_common_category']); | |
// Register Widget Styles | |
} | |
// Custom JS | |
// Custom Category | |
public function elementor_common_category() | |
{ | |
\Elementor\Plugin::$instance->elements_manager->add_category( | |
'elemeta-category', | |
[ | |
'title' => __('Elemeta Category', 'elemeta-elements'), | |
'icon' => 'fa fa-plug', //default icon | |
] | |
); | |
} | |
} | |
// Instantiate Plugin Class | |
Widget_Loader::instance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment