<?php
	// Setup theme
	add_action('after_setup_theme', 'muziq_jellythemes_setup');
	function muziq_jellythemes_setup(){
		// Load text domain
	    load_theme_textdomain('muziq-jellythemes', get_template_directory() . '/languages');

	    // Theme supports
	    add_theme_support( 'html5', array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );
	    add_theme_support( 'automatic-feed-links' );
	    add_theme_support( "post-thumbnails" );
	    add_theme_support( 'title-tag' );
	}

	// menu's definition
	if ( function_exists( 'register_nav_menus' ) ) {
		register_nav_menus(
			array(
			  'main' =>  esc_html__('Main menu', 'muziq-jellythemes')
			)
		);
	}
	// Add custom image sizes
	if ( function_exists( 'add_image_size' ) ) {
	    add_image_size( 'muziq_jellythemes_event_image', 900, 2000, false );
	    add_image_size( 'muziq_jellythemes_artist_image', 680, 920, false );
	    add_image_size( 'muziq_jellythemes_album_cover', 740, 740, true );
	    add_image_size( 'muziq_jellythemes_gallery_big', 740, 900, true );
	    add_image_size( 'muziq_jellythemes_gallery_medium', 740, 450, true );
	    add_image_size( 'muziq_jellythemes_gallery_small', 370, 450, true );
	}

	// Filter to show custom tax clasess in post_class() function output
	add_filter( 'post_class', 'muziq_jellythemes_custom_taxonomy_post_class', 10, 3 );
	if( !function_exists( 'muziq_jellythemes_custom_taxonomy_post_class' ) ) {
	    function muziq_jellythemes_custom_taxonomy_post_class( $classes, $class, $ID ) {
	        $terms = get_the_terms( (int) $ID, 'muziq-type' );
	        if(is_object($terms) && !empty($terms)) {
	            foreach( (array) $terms as $order => $term ) {
	                if(isset($term->slug) && !in_array( $term->slug, $classes ) ) {
	                    $classes[] = $term->slug;
	                }
	            }
	        }
	    return $classes;
	    }
	}

	//Registering plugin to require activation
	add_action( 'tgmpa_register', 'muziq_jellythemes_register_plugins' );
	function muziq_jellythemes_register_plugins() {
	    $plugins = array(
	        array(
	            'name'			=> esc_html__('WPBakery Visual Composer', 'muziq-jellythemes'), // The plugin name
	            'slug'			=> 'js_composer',
	            'source'			=> get_stylesheet_directory() . '/plugins/js_composer.zip',
	            'required'			=> true,
	            'version'			=> '5.5.2',
	            'force_activation'		=> false,
	            'force_deactivation'	=> false,
	            'external_url'		=> '',
	        ),
	        array(
				'name' => esc_html__('Slider Revolution', 'muziq-jellythemes'),
				'slug' => 'revslider',
				'source' => get_stylesheet_directory() . '/plugins/revslider.zip',
				'required' => false,
				'version' => '5.4.8',
				'force_activation' => false,
				'force_deactivation' => true,
				'external_url' => '',
			),
	        array(
	            'name'			=>  esc_html__('MUZIQ Theme Functionality', 'muziq-jellythemes') ,
	            'slug'			=> 'muziq-jellythemes-plugin',
	            'source'			=> get_stylesheet_directory() . '/plugins/muziq-jellythemes-plugin.zip',
	            'required'			=> true,
	            'version'			=> '1.0.5',
	            'force_activation'		=> false,
	            'force_deactivation'	=> false,
	            'external_url'		=> '',
	        ),
	        array(
				'name' 	   => esc_html__('Redux Framework', 'muziq-jellythemes'),
				'slug' 	   => 'redux-framework',
				'required' => true,
			),
	    );

	    $config = array(
	        'domain'		=> 'muziq-jellythemes',
	        'default_path'		=> '',
	        'menu'			=> 'install-required-plugins',
	        'has_notices'		=> true,
	        'is_automatic'		=> true,
	        'message'		=> '',
	        'strings'		=> array(
	            'page_title'			=> esc_html__( 'Install Required Plugins', 'muziq-jellythemes' ),
	            'menu_title'			=> esc_html__( 'Install Plugins', 'muziq-jellythemes' ),
	            'installing'			=> esc_html__( 'Installing Plugin: %s', 'muziq-jellythemes' ),
	            'oops'				=> esc_html__( 'Something went wrong with the plugin API.', 'muziq-jellythemes' ),
	            'notice_can_install_required'	=> _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'muziq-jellythemes' ),
	            'notice_can_install_recommended'	=> _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'muziq-jellythemes' ),
	            'notice_cannot_install'		=> _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'muziq-jellythemes' ),
	            'notice_can_activate_required'	=> _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'muziq-jellythemes' ),
	            'notice_can_activate_recommended'	=> _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'muziq-jellythemes' ),
	            'notice_cannot_activate'		=> _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'muziq-jellythemes' ),
	            'notice_ask_to_update'		=> _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'muziq-jellythemes' ), // %1$s = plugin name(s)
	            'notice_cannot_update'		=> _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'muziq-jellythemes' ), // %1$s = plugin name(s)
	            'install_link'			=> _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'muziq-jellythemes' ),
	            'activate_link'			=> _n_noop( 'Activate installed plugin', 'Activate installed plugins', 'muziq-jellythemes' ),
	            'return'				=> esc_html__( 'Return to Required Plugins Installer', 'muziq-jellythemes' ),
	            'plugin_activated'			=> esc_html__( 'Plugin activated successfully.', 'muziq-jellythemes' ),
	            'complete'				=> esc_html__( 'All plugins installed and activated successfully. %s', 'muziq-jellythemes' ), // %1$s = dashboard link
	            'nag_type'				=> 'updated' // Determines admin notice type - can only be 'updated' or 'error'
	        )
	    );
	    tgmpa( $plugins, $config );
	}

	/**
	 * Force Visual Composer to initialize as "built into the theme". This will hide certain tabs under the Settings->Visual Composer page
	 */
	if(function_exists('vc_set_as_theme')) vc_set_as_theme();


	/**
	* Return jellythemes options variable
	*/
	function muziq_jellythemes_theme_options() {
		global $jellythemes;
		if (empty($jellythemes)) {
			$jellythemes['logo'] = array('url'=> get_stylesheet_directory_uri() . '/images/logo.png');
			$jellythemes['blogname'] = 'MUZIQ';
			$jellythemes['color'] = '';
			$jellythemes['style'] = '';
			$jellythemes['blog_title'] = '';
			$jellythemes['copyright'] = '';
			$jellythemes['blog_subtitle'] = '';
			$jellythemes['blog_header'] = array('url'=> '');
			$jellythemes['contact_email'] = get_option('admin_email');

			$jellythemes['footer_logo'] = array('url'=> get_stylesheet_directory_uri() . '/images/logo-footer.png');
		}
		$color_classes = array(
            "color-red.css" => 'palettered',
            'color-gold.css'=> 'palettegold',
            "color-lightblue.css" => 'palettelightblue',
            "color-purple.css" => 'palettepurple',
            "color-green.css" => 'palettegreen',
            "color-militar.css" => 'palettemilitar',
            "color-caqui.css" => 'palettecaqui',
            "color-yellow.css" => 'paletteyellow',
            "color-darkturquoise.css" => 'palettedarkturquoise',
            "color-electricred.css" => 'paletteelectricred',
            "color-lightgreen.css" => 'palettelightgreen',
            "color-lightred.css" => 'palettelightred',
            "color-lightyellow.css" => 'palettelightyellow',
            "color-malva.css" => 'palettemalva',
            "color-pink.css" => 'palettepink',
            "color-silver.css" => 'palettesilver',
            "color-water.css" => 'palettewater',
        );
        if (!empty($jellythemes['color'])) {
        	$jellythemes['color_class'] = $color_classes[$jellythemes['color']];
        } else {
        	$jellythemes['color_class'] = '';
        }


		return $jellythemes;
	}

	/**
	* REMOVE FRAMEBORDER FOR HTML VALIDATOR
	*/
	function muziq_jellythemes_oembed( $return, $data, $url ) {
	 	$return = str_replace('frameborder="0" allowfullscreen', 'style="border: none"', $return);
		return $return;
	}
	add_filter('oembed_dataparse', 'muziq_jellythemes_oembed', 90, 3 );

	function muziq_jellythemes_remove_redux_notices() {
    if ( class_exists('ReduxFrameworkPlugin') ) {
        remove_filter( 'plugin_row_meta', array( ReduxFrameworkPlugin::get_instance(), 'plugin_metalinks'), null, 2 );
    }
    if ( class_exists('ReduxFrameworkPlugin') ) {
        remove_action('admin_notices', array( ReduxFrameworkPlugin::get_instance(), 'admin_notices' ) );
    }
}
add_action('init', 'muziq_jellythemes_remove_redux_notices');

?>
