<?php
/*
Plugin Name: Progression Elements
Text Domain: pro-elements
Plugin URI: http://http://progressionstudios.com
Description: This plugin registers custom elements for Progression Studios
Version: 1.0
Author: Progression Studios
Author URI: http://progressionstudios.com/
Author Email: contact@progressionstudios.com
License: GNU General Public License v3.0
*/



// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}
define( 'PROGRESSION_STUDIOS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );


/* Translation */
add_action('plugins_loaded', 'progression_studios_elements_textdomain');
function progression_studios_elements_textdomain() {
	load_plugin_textdomain( 'pro-elements', false, dirname( plugin_basename(__FILE__) ) . '/languages/' );
}


/**
 * Registering Custom Post Types
 */
/*** Registering Custom Post Type ***/
add_action('init', 'progression_studios_portfolio_init');
function progression_studios_portfolio_init() {	
	
	register_post_type(
		'portfolio',
		array(
			'labels' => array(
				'name' => __( "Portfolio", "pro-elements" ),
				'singular_name' => __( "Portfolio", "pro-elements" )
			),
			'menu_icon' => 'dashicons-portfolio',
			'public' => true,
			'has_archive' => true,
			'rewrite' => array('slug' => 'portfolio-type'),
			'supports' => array('title', 'editor', 'thumbnail','comments'),
			'can_export' => true,
		)
	);

	register_taxonomy('portfolio-category', 'portfolio', array('hierarchical' => true, 'label' => __( "Portfolio Categories", "pro-elements" ), 'query_var' => true, 'rewrite' => true));
	
}



/**
 * Enqueue or de-enqueue third party plugin scripts/styles
 */
function progression_studios_plugin_styles_scripts() {
	wp_enqueue_style( 'prettyphoto' );
	wp_deregister_style( 'flexslider' );
	wp_deregister_style( 'font-awesome' );
	wp_deregister_script( 'prettyphoto' );
}
add_action( 'wp_enqueue_scripts', 'progression_studios_plugin_styles_scripts', 100 );




// CSS Styles in Admin
function progression_studios_vc_wp_admin_style() {
    wp_register_style( 'pro-vc-styles',  plugin_dir_url( __FILE__ ) . 'assets/style.css' );
    wp_enqueue_style( 'pro-vc-styles' );
}
add_action( 'admin_enqueue_scripts', 'progression_studios_vc_wp_admin_style' );



// Element Shortcodes
if( ! function_exists( 'js_composer' ) ) {
	require_once( plugin_dir_path( __FILE__ ) . 'elements/portfolio-shortcode.php' );
	require_once( plugin_dir_path( __FILE__ ) . 'elements/blog-shortcode.php' );
	require_once( plugin_dir_path( __FILE__ ) . 'elements/shop-shortcode.php' );
	require_once( plugin_dir_path( __FILE__ ) . 'elements/category-shop-shortcode.php' );
}


// Remove WooCOmmerce Elements
function progression_studios_vc_remove_woocommerce() {
    if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        vc_remove_element( 'products' );
		  vc_remove_element( 'product_attribute' );
		  vc_remove_element( 'product_category' );
        vc_remove_element( 'product_categories' );
		  vc_remove_element( 'sale_products' );
		  vc_remove_element( 'recent_products' );
		  vc_remove_element( 'featured_products' );
		  vc_remove_element( 'best_selling_products' );
		  vc_remove_element( 'top_rated_products' );
        // Add other elements that should be removed here
    }
}
// Hook for admin editor.
add_action( 'vc_build_admin_page', 'progression_studios_vc_remove_woocommerce', 11 );
// Hook for frontend editor.
add_action( 'vc_load_shortcode', 'progression_studios_vc_remove_woocommerce', 11 );


?>