File: /home/kashmira/public_html/razitahir.com/wp-content/plugins/upress-widgets/elementor-widgets.php
<?php
/**
 * Widgets class.
 *
 * @category   Class
 * @package    UrduPressWidgets
 * @subpackage WordPress
 */
namespace UrduPressWidgets;
// Security Note: Blocks direct access to the plugin PHP files.
defined( 'ABSPATH' ) || die();
/**
 * Class Plugin
 *
 * Main Plugin class
 *
 * @since 1.0.0
 */
class Widgets {
	/**
	 * Instance
	 *
	 * @since 1.0.0
	 * @access private
	 * @static
	 *
	 * @var Plugin The single instance of the class.
	 */
	private static $instance = null;
	/**
	 * Activae widgets
	 */
	private $widget_grid;
	private $widget_list;
	private $widget_carousel;
	private $widget_classic;
	private $widget_slider;
	private $widget_videos;
	private $widget_heading;
	private $widget_popular;
	private $modules_video;
	/**
	 * Instance
	 *
	 * Ensures only one instance of the class is loaded or can be loaded.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return Plugin An instance of the class.
	 */
	public static function instance() {
		if ( is_null( self::$instance ) ) {
			self::$instance = new self();
		}
		return self::$instance;
	}
	/**
     * Add elementor category
     *
     * @since v1.0.0
     */
    public function register_elementor_categories($elements_manager)
    {
        $elements_manager->add_category(
            'urdupress-widgets',
            [
                'title' => __('UrduPress Widgets', 'urdupress-widgets'),
                'icon' => 'fas fa-plug',
            ], 10);
	}
	
	/**
	 * Include Widgets files
	 *
	 * Load widgets files
	 *
	 * @since 1.0.0
	 * @access private
	 */
	private function include_widgets_files() {
		require_once 'widgets/elementor/posts-grid.php';
		require_once 'widgets/elementor/posts-list.php';
		require_once 'widgets/elementor/posts-classic.php';
		require_once 'widgets/elementor/posts-carousel.php';
		require_once 'widgets/elementor/posts-slider.php';
		require_once 'widgets/elementor/videos-grid.php';
		require_once 'widgets/elementor/urdu-heading.php';
		require_once 'widgets/elementor/posts-popular.php';
	}
	/**
	 * Register Widgets
	 *
	 * Register new Elementor widgets.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function register_widgets() {
		// It's now safe to include Widgets files.
		$this->include_widgets_files();
		// Get widget status
		$this->widget_grid = get_option( 'URDUPRESS_WIDGETS_posts_grid' );
		$this->widget_list = get_option( 'URDUPRESS_WIDGETS_posts_list' );
		$this->widget_carousel = get_option( 'URDUPRESS_WIDGETS_posts_carousel' );
		$this->widget_classic = get_option( 'URDUPRESS_WIDGETS_posts_classic' );
		$this->widget_slider = get_option( 'URDUPRESS_WIDGETS_posts_slider' );
		$this->widget_videos = get_option( 'URDUPRESS_WIDGETS_videos_grid' );
		$this->widget_heading = get_option( 'URDUPRESS_WIDGETS_urdu_heading' );
		$this->widget_popular = get_option( 'URDUPRESS_WIDGETS_popular_posts' );
		$this->modules_video = get_option( 'urdupress_widgets_module_videos' );
		// Load active widgets
		if($this->widget_grid == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\STBFeaturedGrid() );
		}
		if($this->widget_list == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\coneblog_Posts_List() );
		}
		if($this->widget_classic == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\coneblog_Classic_Posts() );
		}
		if($this->widget_carousel == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\coneblog_Carousel_Posts() );
		}
		if($this->widget_slider == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\coneblog_Slider_Posts() );
		}
		if($this->widget_videos == "on" && $this->modules_video == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\urdupress_videos_grid() );
		}
		if($this->widget_heading == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\UPress_Urdu_Heading() );
		}
		if($this->widget_popular == "on") {
			\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new Widgets\UPRESS_Popular_Posts() );
		}
	}
	/**
	 *  Plugin class constructor
	 *
	 * Register plugin action hooks and filters
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function __construct() {
		// Register the widgets.
		add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) );
		add_action('elementor/elements/categories_registered', array($this, 'register_elementor_categories'));
	}
	
}
// Instantiate the Widgets class.
Widgets::instance();