Skip to content

Instantly share code, notes, and snippets.

@CNDLS
Last active February 5, 2020 16:53
Show Gist options
  • Save CNDLS/8c5207f54c8b1fa4a9ae113c3db7402a to your computer and use it in GitHub Desktop.
Save CNDLS/8c5207f54c8b1fa4a9ae113c3db7402a to your computer and use it in GitHub Desktop.
Register custom widget class definition files and custom widget category.
<?php
// Load the theme's custom Widgets so that they appear in the Elementor element panel.
add_action( 'elementor/widgets/widgets_registered', 'register_elementor_widgets' );
function register_elementor_widgets() {
// We check if the Elementor plugin has been installed / activated.
if ( defined( 'ELEMENTOR_PATH' ) && class_exists('Elementor\Widget_Base') ) {
require_once( get_template_directory() . '/widgets/course-box.php' );
require_once( get_template_directory() . '/widgets/h2-content.php' );
require_once( get_template_directory() . '/widgets/h3-content.php' );
require_once( get_template_directory() . '/widgets/program-requirement.php' );
require_once( get_template_directory() . '/widgets/schedule.php' );
}
}
// Add a custom 'mld' category for to the Elementor element panel so that
// our theme's widgets have their own category.
add_action( 'elementor/init', function() {
\Elementor\Plugin::$instance->elements_manager->add_category(
'mld',
[
'title' => __( 'MLD', 'mld' ),
'icon' => 'fa fa-plug', //default icon
],
1 // position
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment