HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/MvAlphen/va-bo.nl/wwwroot/wp-content/plugins/hattan-plugin/hattan-plugin.php
<?php
/*
Plugin Name: Hattan Plugin
Plugin URI: http://themeforest.net/user/ef1eden/portfolio
Author: Studio Themes
Author URI: http://themeforest.net/user/ef1eden/portfolio
Version: 1.0.0
Description: Custom Posty Type, Taxonomy and Shortcodes for Visual Composer, Plugin dedicated for Hattan Theme
Text Domain: hattan-plugin
Domain Path:  /languages/
*/

// don't load directly
if ( ! defined( 'ABSPATH' ) ) die( '-1' );

if ( ! defined( 'HATTAN_PLUGIN_VERSION' ) ) define( 'HATTAN_PLUGIN_VERSION', '1.0.0' );

if(!class_exists('Studio_Themes_Shortcodes')){
	class Studio_Themes_Shortcodes 
	{
		function __construct(){
			add_action('admin_init',array($this,'check_version'));	
			add_action('init',array($this,'load_plugin_textdomain'));	
			add_action('init',array($this,'module_init'));
			add_action( 'init', array($this,'portfolio_posttype_init') );
			add_action( 'init', array($this,'portfolio_taxonomies_innit'));
			add_action( 'init', array($this,'portfolio_metabox_init') );
			add_action( 'init', array($this, 'testimonial_posttype_init'));
			add_action( 'init', array($this, 'vc_init_hattan'));
            add_action( 'init', array($this, 'testimonial_metabox_init'));
        	add_action( 'init', array($this, 'ef1_vc_shortcodes_remove'));
        	add_action( 'init', array($this, 'vc_add_params'));
        	add_action('do_meta_boxes',array($this, 'ef1eden_remove_vc_boxes'));
    		add_action( 'vc_before_init', array($this,'ef1eden_vcSetAsTheme'));

            add_action( 'after_setup_theme', array($this,'portfolio_thumb') );
		}
		
		function vc_init_hattan(){
			if(function_exists('vc_set_shortcodes_templates_dir')){
				$dir = plugin_dir_path( __FILE__ ). 'visual-composer/vc_templates/';
				vc_set_shortcodes_templates_dir($dir);	
			}
		}
		function load_plugin_textdomain () {
			load_plugin_textdomain ( 'hattan-plugin', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
		}
		function module_init(){
			$module_path = plugin_dir_path( __FILE__ ).'modules';
			require_once($module_path.'/VC_Module.php');
			require_once(plugin_dir_path( __FILE__ ).'includes/icons.php');
			foreach(glob($module_path."/*.php") as $module)
			{
				require_once($module);
			}
			
		}
                
        function portfolio_thumb(){
            add_image_size( 'portfolio-thumb', 570,570,true );
            add_image_size( 'portfolio-image', 825); 
        }
		
		function portfolio_posttype_init() {
			$img_path = plugin_dir_url( __FILE__ ).'assets/img';
			$portfolio_labels = array(
			  'name' => _x('Portfolio', 'post type general name','hattan-plugin'),
			  'singular_name' => _x('Portfolio', 'post type singular name','hattan-plugin'),
			  'add_new' => _x('Add New', 'Portfolio','hattan-plugin'),
			  'add_new_item' => __('Add New Portfolio','hattan-plugin'),
			  'edit_item' => __('Edit Portfolio','hattan-plugin'),
			  'new_item' => __('New Portfolio','hattan-plugin'),
			  'all_items' => __('All Portfolio','hattan-plugin'),
			  'view_item' => __('View Portfolio','hattan-plugin'),
			  'search_items' => __('Search Portfolio','hattan-plugin'),
			  'not_found' =>  __('No Portfolio found','hattan-plugin'),
			  'not_found_in_trash' => __('No Portfolios found in Trash','hattan-plugin'), 
			  'parent_item_colon' => '',
			  'menu_name' => __('Portfolio','hattan-plugin')
			);

			$portfolio_args = array(
			  'labels' => $portfolio_labels,
			  'public' => true,
			  'publicly_queryable' => true,
			  'show_ui' => true, 
			  'show_in_menu' => true, 
			  'query_var' => true,
			  'rewrite' => true,
			  'capability_type' => 'post',
			  'has_archive' => true, 
			  'hierarchical' => false,
			  'menu_position' => 10,
			  'menu_icon' => 'dashicons-format-gallery',
			  'supports' => array( 'title','editor','thumbnail' ) 
			); 

			register_post_type( 'portfolio', $portfolio_args );
		}
                
                function testimonial_posttype_init() {
			$img_path = plugin_dir_url( __FILE__ ).'assets/img';
			$portfolio_labels = array(
			  'name' => _x('Testimonial', 'post type general name','hattan-plugin'),
			  'singular_name' => _x('Testimonial', 'post type singular name','hattan-plugin'),
			  'add_new' => _x('Add New', 'Testimonial','hattan-plugin'),
			  'add_new_item' => __('Add New Testimonial','hattan-plugin'),
			  'edit_item' => __('Edit Testimonial','hattan-plugin'),
			  'new_item' => __('New Testimonial','hattan-plugin'),
			  'all_items' => __('All Testimonial','hattan-plugin'),
			  'view_item' => __('View Testimonial','hattan-plugin'),
			  'search_items' => __('Search Testimonial','hattan-plugin'),
			  'not_found' =>  __('No Testimonial found','hattan-plugin'),
			  'not_found_in_trash' => __('No Testimonial found in Trash','hattan-plugin'), 
			  'parent_item_colon' => '',
			  'menu_name' => __('Testimonial','hattan-plugin')
			);

			$testimonial_args = array(
			  'labels' => $portfolio_labels,
			  'public' => true,
			  'publicly_queryable' => true,
			  'show_ui' => true, 
			  'show_in_menu' => true, 
			  'query_var' => true,
			  'rewrite' => true,
			  'capability_type' => 'post',
			  'has_archive' => true, 
			  'hierarchical' => false,
			  'menu_position' => 10,
			  'menu_icon' => 'dashicons-editor-quote',
			  'supports' => array( 'title') 
			); 

			register_post_type( 'testimonial', $testimonial_args );
		}
		
		function portfolio_taxonomies_innit() {

		  // portfolio Category
		  $labels = array(
			'name' => _x( 'Categories', 'taxonomy general name' ,'hattan-plugin'),
			'singular_name' => _x( 'Category', 'taxonomy singular name','hattan-plugin' ),
			'search_items' =>  __( 'Search Categories','hattan-plugin' ),
			'all_items' => __( 'All Categories' ,'hattan-plugin'),
			'parent_item' => __( 'Parent Category' ,'hattan-plugin'),
			'parent_item_colon' => __( 'Parent Category:' ,'hattan-plugin'),
			'edit_item' => __( 'Edit Category' ,'hattan-plugin'), 
			'update_item' => __( 'Update Category' ,'hattan-plugin'),
			'add_new_item' => __( 'Add New Category' ,'hattan-plugin'),
			'new_item_name' => __( 'New Category Name' ,'hattan-plugin'),
			'menu_name' => __( 'Category','hattan-plugin' ),
		  );  

		  register_taxonomy('portfolio-category',array('portfolio'), array(
			'hierarchical' => true,
			'labels' => $labels,
			'show_ui' => true,
			'query_var' => true,
			'rewrite' => array( 'slug' => 'portfolio-category' ),
		  ));

		// END Portoflio_posttype_init

		}
		function portfolio_metabox_init(){
			
			if(is_admin()){
				if(class_exists('AT_Meta_Box'))
				{
					$prefix = 'ef_';

					$config = array(
					  'id'             => 'demo_meta_box',          // meta box id, unique per meta box
					  'title'          => 'Simple Meta Box fields',          // meta box title
					  'pages'          => array('portfolio'),      // post types, accept custom post types as well, default is array('post'); optional
					  'context'        => 'normal',            // where the meta box appear: normal (default), advanced, side; optional
					  'priority'       => 'high',            // order of meta box: high (default), low; optional
					  'fields'         => array(),            // list of meta fields (can be added by field arrays)
					  'local_images'   => false,          // Use local or hosted images (meta box images for add/remove)
					  'use_with_theme' => true          //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
					);

					$my_meta =  new AT_Meta_Box($config);
					$my_meta->addImage($prefix.'full_image',array('name'=> __('Full Header Image OR Full Lighbox Image','hattan-plugin')));
            		$my_meta->addText($prefix.'video_url',array('name'=> __('VIDEO URL','hattan-plugin')));
					$my_meta->Finish();
				}
			}
		}
                
    	function testimonial_metabox_init(){
			if(is_admin()){
				if(class_exists('AT_Meta_Box'))
				{
					$prefix = 'ef_';

					$config = array(
					  'id'             => 'testimonial',          // meta box id, unique per meta box
					  'title'          => 'Testimonial Meta Box fields',          // meta box title
					  'pages'          => array('testimonial'),      // post types, accept custom post types as well, default is array('post'); optional
					  'context'        => 'normal',            // where the meta box appear: normal (default), advanced, side; optional
					  'priority'       => 'high',            // order of meta box: high (default), low; optional
					  'fields'         => array(),            // list of meta fields (can be added by field arrays)
					  'local_images'   => false,          // Use local or hosted images (meta box images for add/remove)
					  'use_with_theme' => true          //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
					);

					$my_meta =  new AT_Meta_Box($config);
					$my_meta->addTextarea($prefix.'content',array('name'=> 'Content'));
                                        $my_meta->addText($prefix.'author',array('name'=> 'Author'));
                                        $my_meta->addText($prefix.'company',array('name'=> 'Company or Site'));
					$my_meta->Finish();
				}
			}
		}
		function check_version()
		{
			if(defined('WPB_VC_VERSION')){
				if( version_compare( '4.3', WPB_VC_VERSION, '>' )){
					add_action( 'admin_notices', array($this,'admin_notice_for_version_hattan_plugin'));
				}
			} else {
				add_action( 'admin_notices', array($this,'hattan_admin_notice_for_hattan_plugin_activation'));
			}

			if(defined('EF1_THEME_NAME') && EF1_THEME_NAME != 'hattan'){
				add_action( 'admin_notices', array($this,'hattan_plugin_message'));
			}
		}// end init_addons
		
		function admin_notice_for_version_hattan_plugin()
		{
			echo '<div class="updated"><p><strong>Hattan Plugin</strong> requires <strong>Visual Composer</strong> version 4.3 or greater.</p></div>';    
		}
		
		function hattan_admin_notice_for_hattan_plugin_activation()
		{
			echo '<div class="updated"><p><strong>Hattan Plugin</strong> requires <strong>Visual Composer</strong> Plugin installed and activated.</p></div>';
		}
		function hattan_plugin_message() {
			echo '<div class="updated"><p>This add-on works correctly only with the theme Hattan. You can buy it <a href="http://themeforest.net/user/ef1eden/portfolio"target="_blank">HERE</a>.</p></div>';
		}

	
		function ef1_vc_shortcodes_remove() {	
			if ( function_exists('vc_remove_element') ) {	
				vc_remove_element('vc_wp_recentcomments');
				vc_remove_element('vc_wp_rss');	
				vc_remove_element('vc_wp_search');
				vc_remove_element('vc_wp_tagcloud');
				vc_remove_element('vc_wp_pages');
				vc_remove_element('vc_wp_posts');
				vc_remove_element('vc_wp_meta');
				vc_remove_element('vc_wp_links');
				vc_remove_element('vc_wp_custommenu');
				vc_remove_element('vc_wp_categories');
				vc_remove_element('vc_wp_calendar');
				vc_remove_element('vc_wp_archives');
				vc_remove_element('vc_widget_sidebar');
				vc_remove_element('vc_teaser_grid');
				vc_remove_element('vc_posts_slider');
				vc_remove_element('vc_posts_grid');
				vc_remove_element('vc_message');
				vc_remove_element('vc_images_carousel');
				vc_remove_element('vc_flickr');	
		} 
		if ( function_exists('vc_remove_param') ) {
		    vc_remove_param('vc_progress_bar','bgcolor');
		    vc_remove_param('vc_progress_bar','custombgcolor');
		    vc_remove_param('vc_progress_bar','options');
		    vc_remove_param('vc_progress_bar','title');
		
		}
		/*** Remove frontend editor ***/
		if(function_exists('vc_disable_frontend')){
			vc_disable_frontend();
		}
	} 


	function vc_add_params(){
		if(function_exists('vc_add_param')){

			// New row params 
			$group_name_row = 'Background';


			vc_add_param('vc_progress_bar',array(
			        "type" => "colorpicker",
			        "holder" => "",
			        "class" => "",
			        "heading" => __("Title Color", 'yours-plugin'),
			        "param_name" => "title_color",
			        "value" => "",
			        "description" => ""
			)
			);

		    vc_add_param('vc_progress_bar',array(
		            "type" => "colorpicker",
		            "holder" => "",
		            "class" => "",
		            "heading" => __("Background Bar 1", 'yours-plugin'),
		            "param_name" => "bg_bar",
		            "value" => "",
		            "description" => ""
		        )
		    );

		    vc_add_param('vc_progress_bar',array(
		            "type" => "colorpicker",
		            "holder" => "",
		            "class" => "",
		            "heading" => __("Background Bar 2", 'yours-plugin'),
		            "param_name" => "bg_bar2",
		            "value" => "",
		            "description" => ""
		        )
		    );
		}
	}

	

	// Remove VC Teaser metabox
	function ef1eden_remove_vc_boxes(){
		if ( is_admin() ) {
			$post_types = get_post_types( '', 'names' ); 
			foreach ( $post_types as $post_type ) {
				remove_meta_box('vc_teaser',  $post_type, 'side');
			}
		} // End function
	}


	function ef1eden_vcSetAsTheme() {
		vc_set_as_theme();
	}

	}
new Studio_Themes_Shortcodes();
}