File: /home/kashmira/public_html/razitahir.com/wp-content/plugins/upress-widgets/plugin-loader.php
<?php
/**
 * Widgets Loader class.
 *
 * @category   Class
 * @package    URDUPRESS_WIDGETS
 * @subpackage WordPress
 * @author     StyloThemes <info@stylothemes.com>
 * @copyright  2015 - 2023 StyloThemes
 * @since      1.0.0
 * php version 7.4
 */
if ( ! defined( 'ABSPATH' ) ) {
	// Exit if accessed directly.
	exit;
}
/**
 * Main UrduPress Widgets Class
 *
 * The init class that runs the UrduPress Widgets plugin.
 * Intended To make sure that the plugin's minimum requirements are met.
 *
 */
final class URDUPRESS_WIDGETS {
	/**
	 * Page buildres
	 */
	private $builder_elementor;
	/**
	 * Plugin Version
	 *
	 * @since 1.0.0
	 * @var string The plugin version.
	 */
	const VERSION = '1.3.0';
	/**
	 * Minimum PHP Version
	 *
	 * @since 1.0.0
	 * @var string Minimum PHP version required to run the plugin.
	 */
	const MINIMUM_PHP_VERSION = '7.0';
	/**
	 * Constructor
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function __construct() {
		
		// Get page builders status;
		$this->builder_elementor = get_option( 'urdupress_builders_elementor' );
		// Load the translation.
		add_action( 'init', array( $this, 'i18n' ) );
		// Initialize the plugin.
		add_action( 'plugins_loaded', array( $this, 'php_version' ));
		add_action( 'plugins_loaded', array( $this, 'load_elementor_widgets' ));
		//Enqueue Scripts
		add_action('wp_enqueue_scripts', array($this, 'coneblog_widget_scripts'));
		add_action('admin_enqueue_scripts', array($this, 'coneblog_admin_scripts'));
		if($this->builder_elementor == "on"){
			add_action('elementor/editor/before_enqueue_scripts', array($this, 'coneblog_widget_scripts'));
		}
		//Register Image Sizes
		add_action( 'init', array( $this, 'coneblog_image_sizes' ) );
		//Add custom class to Body element
		add_filter( 'body_class', function( $classes ) {
			return array_merge( $classes, array( 'urdupress-widgets' ) );
		} );
	}
	/**
     * Plugin scripts & styles
     *
     * @since v1.0.0
     */
	public function coneblog_widget_scripts() {
		if($this->builder_elementor == "on"){
			wp_enqueue_script('jquery');
			wp_enqueue_script( 'coneblog-posts-carousel-script', URDUPRESS_ASSETS_PATH. 'owl/carousel.min.js', array(), '2.3.4', false );
			wp_enqueue_script( 'coneblog-plugin-main', URDUPRESS_ASSETS_PATH. 'js/coneblog-main.js', array(), '1.0.0', false );
			wp_enqueue_style( 'coneblog-font-icons', URDUPRESS_ASSETS_PATH. 'css/fontello.css', [], '1.0.0' );
			wp_enqueue_style( 'coneblog-editor-icons', URDUPRESS_ASSETS_PATH. 'css/coneblog-icons.css', [], '1.0.0' );
			wp_enqueue_style( 'coneblog-posts-carousel-owl-style', URDUPRESS_ASSETS_PATH. 'owl/assets/owl.carousel.min.css', array(), '2.3.4' );
			wp_enqueue_style( 'coneblog-posts-carousel-theme', URDUPRESS_ASSETS_PATH. 'owl/assets/owl.theme.default.min.css', array(), '2.3.4' );
			wp_enqueue_style( 'coneblog-animate-css', plugins_url( '/assets/css/animate.min.css', URDUPRESS_WIDGETS ), array(), '4.1.1' );
		}
	}
	public function coneblog_admin_scripts($hook) {
		//print_r($hook);
		wp_enqueue_style('coneblog-admin-global-css', URDUPRESS_ASSETS_PATH. 'css/global-admin.css');
		if($hook == 'toplevel_page_urdupress' || $hook == 'urdupress_page_upress-widgets' || $hook == 'urdupress_page_upress-modules') {
			//Plugin Back-end CSS
			wp_enqueue_style('coneblog-admin-css', URDUPRESS_ASSETS_PATH. 'css/admin.css');
			wp_enqueue_style('coneblog-admin-fonts', URDUPRESS_ASSETS_PATH. 'css/fontello.css');
			//Plugin Back-end JS
			wp_enqueue_script('coneblog-admin-js', URDUPRESS_ASSETS_PATH. 'js/panel.js', 'jQuery', '1.0.0', true );
		} 
		wp_register_style('coneblog-admin-icon', URDUPRESS_ASSETS_PATH. 'css/upress-icon.css');
		wp_enqueue_style('coneblog-admin-icon');
	}
	/**
     * Plugin Image sizes
     *
     * @since v1.0.0
     */
	public function coneblog_image_sizes() {
		add_image_size( 'coneblog-carousel-thumb', 280, 480, true );
		add_image_size( 'coneblog-carousel-thumb-small', 320, 220, true );
		add_image_size( 'coneblog-grid-thumb', 800, 620, true );
		add_image_size( 'coneblog-classic-thumb', 480, 320, true );
		add_image_size( 'coneblog-classic-thumb-large', 640, 420, true );
		add_image_size( 'coneblog-slider-wide', 1920, 900, true );
		add_image_size( 'cb-author-avatar-md', 200, 200, true );
	}
	/**
	 * Load Textdomain
	 *
	 * Load plugin localization files.
	 * Fired by `init` action hook.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function i18n() {
		load_plugin_textdomain( 'urdupress-widgets' );
	}
	/**
	 * Initialize the plugin
	 *
	 * Validates that Elementor is already loaded.
	 * Checks for basic plugin requirements, if one check fail don't continue,
	 * if all check have passed include the plugin class.
	 *
	 * Fired by `plugins_loaded` action hook.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function load_elementor_widgets() {
		
		if($this->builder_elementor == "on"){
			// Check if Elementor installed and activated.
			if (!did_action('elementor/loaded')) {
				add_action( 'admin_notices', array( $this, 'coneblog_notice_missing_main_plugin' ) );
				return;
			}
			if(!in_array('stylo-core/stylo-core.php', apply_filters('active_plugins', get_option('active_plugins')))){
				add_action( 'admin_notices', array( $this, 'coneblog_notice_missing_core_plugin' ) );
				return;
			}
			// Once we get here, We have passed all validation checks so we can safely include our widgets.
			require_once 'elementor-widgets.php';
		}
		
	}
	/**
	 * Check PHP version
	 * @since 1.0.0
	 * @access public
	 */
	public function php_version() {
		// Check for required PHP version.
		if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
			add_action( 'admin_notices', array( $this, 'coneblog_admin_notice_minimum_php_version' ) );
			return;
		}
	}
	/**
	 * Admin notice
	 * Warning when the site doesn't have Elementor installed or activated.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 */
	function coneblog_notice_missing_core_plugin() {
		$message = sprintf(
			__( '%1$s requires %2$s to be installed and activated to function properly.', 'urdupress-widgets' ),
			'<strong>' . __( 'UrduPres Widgets', 'urdupress-widgets' ) . '</strong>',
			'<strong>' . __( 'StyloCore', 'urdupress-widgets' ) . '</strong>'
		);
		printf( '<div class="notice notice-warning is-dismissible"><p style="padding: 5px 0">%1$s</p></div>', $message );
	}
	/**
	 * Admin notice
	 * Warning when the site doesn't have Elementor installed or activated.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 */
	function coneblog_notice_missing_main_plugin() {
		$message = sprintf(
			__( '%1$s requires %2$s to be installed and activated to function properly. %3$s', 'urdupress-widgets' ),
			'<strong>' . __( 'UrduPress Widgets - Elementor', 'urdupress-widgets' ) . '</strong>',
			'<strong>' . __( 'Elementor', 'urdupress-widgets' ) . '</strong>',
			'<a href="' . esc_url( admin_url( 'plugin-install.php?s=Elementor&tab=search&type=term' ) ) . '">' . __( 'Please click here to install/activate Elementor', 'urdupress-widgets' ) . '</a>'
		);
		printf( '<div class="notice notice-warning is-dismissible"><p style="padding: 5px 0">%1$s</p></div>', $message );
	}
	/**
	 * Admin notice
	 *
	 * Warning when the site doesn't have a minimum required Elementor version.
	 *
	 * @since 1.0.0
	 *
	 * @access public
	 */
	function coneblog_notice_minimum_elementor_version() {
		if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
		$message = sprintf(
			/* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
			esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'urdupress-widgets' ),
			'<strong>' . esc_html__( 'UrduPress Widgets - Elementor', 'urdupress-widgets' ) . '</strong>',
			'<strong>' . esc_html__( 'Elementor', 'urdupress-widgets' ) . '</strong>',
			MINIMUM_ELEMENTOR_VERSION
		);
		printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
	}
	/**
	 * Admin notice
	 *
	 * Warning when the site doesn't have a minimum required PHP version.
	 *
	 * @since 1.0.0
	 * @access public
	 */
	public function coneblog_admin_notice_minimum_php_version() {
		if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
		$message = sprintf(
			/* translators: 1: Plugin name 2: PHP 3: Required PHP version */
			esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'urdupress-widgets' ),
			'<strong>' . esc_html__( 'UrduPress Widgets', 'urdupress-widgets' ) . '</strong>',
			'<strong>' . esc_html__( 'PHP', 'urdupress-widgets' ) . '</strong>',
			MINIMUM_PHP_VERSION
		);
		printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
	}
	
}
// Instantiate URDUPRESS_WIDGETS.
new URDUPRESS_WIDGETS();