Current File : /home/pacjaorg/wpt.pacja.org/copwordpres/wp-content/plugins/tiny-portfolio/inc/class-init.php
<?php
/**
 * Tiny Portfolio Init Class
 *
 * @package Tiny Portfolio
 * @since   1.0.7.4
 */

defined( 'ABSPATH' ) || exit;

/**
 * Main Tiny_Portfolio Class.
 *
 * @class Tiny_Portfolio
 */
final class Tiny_Portfolio {

	/**
	 * Version.
	 *
	 * @var string
	 */
	public $version = '1.0.7.4';

	/**
	 * The single instance of the class.
	 *
	 * @var Tiny_Portfolio
	 * @since 1.0.0
	 */
	protected static $_instance = null;

	/**
	 * Main Tiny_Portfolio Instance.
	 *
	 * Ensures only one instance of Tiny_Portfolio is loaded or can be loaded.
	 *
	 * @since 1.0.0
	 * @static
	 * @see Tiny_Portfolio()
	 * @return Tiny_Portfolio - Main instance.
	 */
	public static function instance() {
		if ( is_null( self::$_instance ) ) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}

	/**
	 * Cloning is forbidden.
	 *
	 * @since 1.0.0
	 */
	public function __clone() {
		wc_doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'tiny-portfolio' ), $this->version );
	}

	/**
	 * Unserializing instances of this class is forbidden.
	 *
	 * @since 1.0.0
	 */
	public function __wakeup() {
		wc_doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'tiny-portfolio' ), $this->version );
	}

	/**
	 * Tiny_Portfolio Constructor.
	 */
	public function __construct() {
		$this->define_constants();
		$this->includes();
		$this->init_hooks();
	}

	/**
	 * Init Hooks
	 */
	public function init_hooks(){
		add_action( 'init', array($this,'textdomain') );
        add_action( 'elementor/frontend/after_register_styles', array( $this, 'frontend_styles' ), 10 );
        add_action( 'elementor/frontend/after_register_scripts', array( $this, 'frontend_scripts' ), 10 );
        add_action( 'elementor/widgets/widgets_registered', array( $this, 'widgets_registered' ) );
        add_action( 'elementor/init', array( $this, 'new_elementor_category' ) );
        add_action( 'wp_footer', array( $this, 'load_single_template' ) );
	}

	/**
	 * Define Constants.
	 */
	private function define_constants() {
		$this->define( 'TP_DEBUG', true );
		$this->define( 'TP_ABSPATH', dirname( TP_FILE ) . '/' );
		$this->define( 'TP_PLUGIN_BASENAME', plugin_basename( TP_FILE ) );
		$this->define( 'TP_DIR', plugin_dir_path( dirname( __FILE__ ) ) );
      	$this->define( 'TP_ROOT_DIR', plugins_url() . '/' . plugin_basename( TP_FILE ) . '/' );
		$this->define( 'TP_VERSION', $this->version );
	}

	/**
	 * Define constant if not already set.
	 *
	 * @param string      $name  Constant name.
	 * @param string|bool $value Constant value.
	 */
	private function define( $name, $value ) {
		if ( ! defined( $name ) ) {
			define( $name, $value );
		}
	}

	/**
     * Localize
     */
	public function textdomain() {
	   load_plugin_textdomain( 'tiny-portfolio', FALSE, dirname( plugin_basename( TP_FILE ) ) . '/languages/' );
	}

	/**
     * Load Scripts
     */
    public function frontend_scripts() {
    	wp_enqueue_script( 'infiniteScroll', plugins_url( 'assets/js/infiniteScroll.js', TP_FILE ), array( 'jquery' ), $this->version, true );
    	wp_enqueue_script( 'niceScroll', plugins_url( 'assets/js/niceScroll.js', TP_FILE ), array( 'jquery' ), $this->version, true );
    	wp_enqueue_script( 'tiny-portfolio', plugins_url( 'assets/js/tiny-portfolio.js', TP_FILE ), array( 'jquery', 'masonry', 'imagesloaded' ), $this->version, true );
    	wp_localize_script( 'tiny-portfolio', 'tp_data',
    		array(
    			'ajaxurl' => admin_url( 'admin-ajax.php' ),
    			'string_service' => esc_html__( 'Services', 'tiny-portfolio' ),
    			'string_client' => esc_html__( 'Client', 'tiny-portfolio' ),
    			'string_date' => esc_html__( 'Date', 'tiny-portfolio' ),
    		)
    	);
    }

    /**
     * Load Style
     */
    public function frontend_styles() {
    	wp_enqueue_style( 'tiny-portfolio', plugins_url( 'assets/css/tiny-portfolio.css', TP_FILE ), [], $this->version );
    }

    /**
     * New Elementor Category
     */
    public function new_elementor_category() {
        \Elementor\Plugin::instance()->elements_manager->add_category(
            'tiny-portfolio',
            array(
                'title' => esc_html__( 'Tiny Portfolio', 'tiny-portfolio' ),
                'icon' => 'fa fa-plug',
            ),
        2 );
   }

    /**
     * Register Widget
     */
   public function widgets_registered( $widgets_manager ) {

      include_once TP_ABSPATH . 'inc/widgets/tp-portfolio.php';
      $widgets_manager->register_widget_type( new TP_Portfolio() );

   }

    /**
	 * Include Files
	 */
	public function includes() {
		include_once TP_ABSPATH . 'inc/class-template-loader.php';
		include_once TP_ABSPATH . 'inc/functions.php';
	}

	/**
	 * Load Widget Template
	 */
    public function load_template( $slug, $name = '', $settings = array() ) {

        $templates = new TP_Template_Loader();
        $data = array();

        foreach( $settings as $key => $value ) {
            $data[$key] = $value;
        }

        $templates
           ->set_template_data( $data, 'tp_data' )
           ->get_template_part( $slug, $name );
    }

    /**
	 * Load Single Template
	 */
    public function load_single_template(){
    	tp_load_template( 'tp-portfolio', 'single', array() );
    }

}
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!