Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bainternet/f140dd0c79d847f7299ec0a2b7499056 to your computer and use it in GitHub Desktop.
Save bainternet/f140dd0c79d847f7299ec0a2b7499056 to your computer and use it in GitHub Desktop.
<?php
// Elementor Class
if ( ! defined( 'ABSPATH' ) ) exit;
// This file is pretty much a boilerplate WordPress plugin.
// It does very little except including wp-widget.php
class ElementorRecentProduct {
private static $instance = null;
public static function get_instance() {
if ( ! self::$instance )
self::$instance = new self;
return self::$instance;
}
public function init(){
add_action( 'elementor/init', array( $this, 'widgets_registered' ) );
}
/**
* Loads the custom Elementor elements.
*/
public function widgets_registered() {
// We check if the Elementor plugin has been installed / activated.
if (defined('ELEMENTOR_PATH') && class_exists('Elementor\Widget_Base')){
// We look for any theme overrides for this custom Elementor element.
// If no theme overrides are found we use the default one in this plugin.
$template_file = get_template_directory().'/elementor/includes/elementor/el-recent-product.php';
if ( !$template_file || !is_readable( $template_file ) ) {
$template_file = get_template_directory().'/elementor/includes/elementor/el-recent-product.php';
}
if ( $template_file && is_readable( $template_file ) ) {
require_once $template_file;
}
}
if ( defined( 'ELEMENTOR_PATH' ) && class_exists( 'Elementor\Widget_Base' ) ) {
// get our own widgets up and running:
// copied from widgets-manager.php
if ( class_exists( 'Elementor\Plugin' ) ) {
if ( is_callable( 'Elementor\Plugin', 'instance' ) ) {
$elementor = Elementor\Plugin::instance();
if ( isset( $elementor->widgets_manager ) ) {
if ( method_exists( $elementor->widgets_manager, 'register_widget_type' ) ) {
$template_file = get_template_directory().'/elementor/includes/elementor/el-recent-product.php';
if ( $template_file && is_readable( $template_file ) ) {
require_once $template_file;
Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Elementor\CepatLakoo_Recent_Products_Widget_Elementor() );
}
}
}
}
}
}
}
}
ElementorRecentProduct::get_instance()->init();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment