• File: elementor-init.php
  • Full Path: /home/slvgwrnz/public_html/wp-content/plugins/prinox-tools/elementor/elementor-init.php
  • Date Modified: 02/05/2025 11:48 AM
  • File size: 3.92 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php
/**
 * All Elementor widget init
 * @package prinox
 * @since 1.0.0
 */

if ( !defined('ABSPATH') ){
	exit(); // exit if access directly
}


if ( !class_exists('Prinox_Elementor_Widget_Init') ){

	class Prinox_Elementor_Widget_Init{
		/*
			* $instance
			* @since 1.0.0
			* */
		private static $instance;
		/*
		* construct()
		* @since 1.0.0
		* */
		public function __construct() {
			add_action( 'elementor/elements/categories_registered', array($this,'_widget_categories') );
			//elementor widget registered
			add_action('elementor/widgets/register',array($this,'prinox_custom_widgets'));
			add_action('elementor/editor/after_enqueue_styles',array($this,'editor_style'));
		}
		/*
	   * getInstance()
	   * @since 1.0.0
	   * */
		public static function getInstance(){
			if ( null == self::$instance ){
				self::$instance = new self();
			}
			return self::$instance;
		}
		/**
		 * _widget_categories()
		 * @since 1.0.0
		 * */
		public function _widget_categories($elements_manager){
			$elements_manager->add_category(
				'prinox_widgets',
				[
					'title' => __( 'Prinox Addons', 'prinox-tools' ),
					'icon' => 'fa fa-plug',
				]
			);
		}

		/**
		 * prinox_custom_widgets()
		 * @since 1.0.0
		 * */
		public function prinox_custom_widgets(){
			if( !class_exists('Elementor\Widget_Base') ){
				return;
			}
			$elementor_widgets = array(	
				
				// prinox Theme Widgets 
				'slider',
				'slider-two',
				'slider-three',
				'slider-four',
				'slider-five',
				'banner-home-3',
				'service',
				'service-two',
				'service-four',
				'service-three',
				'service-carousel',
				'about',
				'about-two',
				'about-three',
				'projects',
				'project-two',
				'project-filter',
				'project-info',
				'project-contact-info',
				'printing-section',
				'icon-box',
				'quality-section',
				'casestudy',
				'casestudy-two',
				'testimonial',
				'faq',
				'faq-two',
				'faq-three',
				'brand-name',
				'sponsors',
				'pricing-table',
				'cta',
				'cta-two',
				'cta-three',
				'team-carousel',
				'blog-post',
				'contact-info-box',
				'contact-img',
				'video-popup',
				'accordion',
				'service-navigation',
				'openign-time',
				'breadcrumb',
				'featured-product',
				'prinox-demo-page',
				'info-box-item',
				'best-seller-product',
				'shop-banner',
				'deal-product',
				'shop-banner-three',
				'testimonial-v2',
				'brand-v2',
				'cta-four',
				'product-category',
				'shop-banner-four',
				'testimonial-v3',
				'deal-banner',
				'shop-banner-five',
				'app-banner',
				'deal-banner-v2',
				'best-seller-product-list',
				'blog-post-v2',
				'newslater-widget',
				'service-five',
				'printing-image',
				'printing-list-new',
				'button',
				'printing-image-two',
				'blog-post-v3',
				'team-carousel-two',
				'testimonial-v4',
				'faq-four',
				'product-tabs',
				'hero_home_eight',
				'product-category-slider',
				'testimonial-5',
				'product-grid-item',
				'cta-five',
				'product-grid-carousel',
				'printing-image-3',
				'image-box',
				'countdown',
			);
			
			$elementor_widgets = apply_filters('prinox_elementor_widget',$elementor_widgets);

			if ( is_array($elementor_widgets) && !empty($elementor_widgets) ) {
				foreach ( $elementor_widgets as $widget ){
					$widget_file = 'plugins/elementor/widget/'.$widget.'.php';
					$template_file = locate_template($widget_file);
					if ( !$template_file || !is_readable( $template_file ) ) {
						$template_file = PRINOX_DIR_PATH.'/elementor/widgets/'.$widget.'.php';
					}
					if ( $template_file && is_readable( $template_file ) ) {
						include_once $template_file;
					}
				}
			}

		}

		public function editor_style(){
			$cs_icon = plugins_url( 'icon.png', __FILE__ );
			wp_add_inline_style( 'elementor-editor', '.elementor-element .icon .mg-custom-icon{content: url( '.$cs_icon.');width: 28px;}' );
		}



	}

	if ( class_exists('Prinox_Elementor_Widget_Init') ){
		Prinox_Elementor_Widget_Init::getInstance();
	}

}//end if