<?php

/* Theme setup section
-------------------------------------------------------------------- */
if (!function_exists('seohub_sc_blogger_theme_setup')) {
	add_action( 'seohub_action_before_init_theme', 'seohub_sc_blogger_theme_setup' );
	function seohub_sc_blogger_theme_setup() {
		add_action('seohub_action_shortcodes_list', 		'seohub_sc_blogger_reg_shortcodes');
		if (function_exists('seohub_exists_visual_composer') && seohub_exists_visual_composer())
			add_action('seohub_action_shortcodes_list_vc','seohub_sc_blogger_reg_shortcodes_vc');
	}
}



/* Shortcode implementation
-------------------------------------------------------------------- */

/*
[trx_blogger id="unique_id" ids="comma_separated_list" cat="id|slug" orderby="date|views|comments" order="asc|desc" count="5" descr="0" dir="horizontal|vertical" style="regular|date|image_large|image_medium|image_small|accordion|list" border="0"]
*/
global $SEOHUB_GLOBALS;
$SEOHUB_GLOBALS['sc_blogger_busy'] = false;

if (!function_exists('seohub_sc_blogger')) {	
	function seohub_sc_blogger($atts, $content=null){	
		if (seohub_in_shortcode_blogger(true)) return '';
		extract(seohub_html_decode(shortcode_atts(array(
			// Individual params
			"style" => "accordion",
			"filters" => "no",
			"post_type" => "post",
			"ids" => "",
			"cat" => "",
			"count" => "3",
			"columns" => "",
			"offset" => "",
			"orderby" => "date",
			"order" => "desc",
			"only" => "no",
			"descr" => "",
			"readmore" => "",
			"loadmore" => "no",
			"location" => "default",
			"dir" => "horizontal",
			"hover" => seohub_get_theme_option('hover_style'),
			"hover_dir" => seohub_get_theme_option('hover_dir'),
			"scroll" => "no",
			"controls" => "no",
			"rating" => "no",
			"info" => "yes",
			"links" => "yes",
			"date_format" => "",
			"title" => "",
			"subtitle" => "",
			"description" => "",
			"link" => '',
			"link_caption" => esc_html__('Learn more', 'seohub'),
			// Common params
			"id" => "",
			"class" => "",
			"css" => "",
			"animation" => "",
			"width" => "",
			"height" => "",
			"top" => "",
			"bottom" => "",
			"left" => "",
			"right" => ""
		), $atts)));
	
		$class .= ($class ? ' ' : '') . seohub_get_css_position_as_classes($top, $right, $bottom, $left);

		$css .= seohub_get_css_dimensions_from_values($width, $height);
		$width  = seohub_prepare_css_value($width);
		$height = seohub_prepare_css_value($height);
	
		global $post, $SEOHUB_GLOBALS;
	
		$SEOHUB_GLOBALS['sc_blogger_busy'] = true;
		$SEOHUB_GLOBALS['sc_blogger_counter'] = 0;
	
		if (empty($id)) $id = "sc_blogger_".str_replace('.', '', mt_rand());
		
		if ($style=='date' && empty($date_format)) $date_format = 'd.m+Y';
	
		if (!empty($ids)) {
			$posts = explode(',', str_replace(' ', '', $ids));
			$count = count($posts);
		}
		
		if ($descr == '') $descr = seohub_get_custom_option('post_excerpt_maxlength'.($columns > 1 ? '_masonry' : ''));
	
		if (!seohub_param_is_off($scroll)) {
			seohub_enqueue_slider();
			if (empty($id)) $id = 'sc_blogger_'.str_replace('.', '', mt_rand());
		}
		
		$class = apply_filters('seohub_filter_blog_class',
					'sc_blogger'
					. ' layout_'.esc_attr($style)
					. ' template_'.esc_attr(seohub_get_template_name($style))
					. (!empty($class) ? ' '.esc_attr($class) : '')
					. ' ' . esc_attr(seohub_get_template_property($style, 'container_classes'))
					. ' sc_blogger_' . ($dir=='vertical' ? 'vertical' : 'horizontal')
					. (seohub_param_is_on($scroll) && seohub_param_is_on($controls) ? ' sc_scroll_controls sc_scroll_controls_type_top sc_scroll_controls_'.esc_attr($dir) : '')
					. ($descr == 0 ? ' no_description' : ''),
					array('style'=>$style, 'dir'=>$dir, 'descr'=>$descr)
		);
	
		$container = apply_filters('seohub_filter_blog_container', seohub_get_template_property($style, 'container'), array('style'=>$style, 'dir'=>$dir));
		$container_start = $container_end = '';
		if (!empty($container)) {
			$container = explode('%s', $container);
			$container_start = !empty($container[0]) ? $container[0] : '';
			$container_end = !empty($container[1]) ? $container[1] : '';
		}
		$container2 = apply_filters('seohub_filter_blog_container2', seohub_get_template_property($style, 'container2'), array('style'=>$style, 'dir'=>$dir));
		$container2_start = $container2_end = '';
		if (!empty($container2)) {
			$container2 = explode('%s', $container2);
			$container2_start = !empty($container2[0]) ? $container2[0] : '';
			//$container2_start = str_replace(array('%css'), array('style="height:'.esc_attr($height).'"'), $container2_start);
			$container2_end = !empty($container2[1]) ? $container2[1] : '';
		}
	
		$output = '<div'
				. ($id ? ' id="'.esc_attr($id).'"' : '') 
				. ' class="'.($style=='list' ? 'sc_list sc_list_style_iconed ' : '') . esc_attr($class).'"'
				. ($css!='' ? ' style="'.esc_attr($css).'"' : '')
				. (!seohub_param_is_off($animation) ? ' data-animation="'.esc_attr(seohub_get_animation_classes($animation)).'"' : '')
			. '>'
			. ($container_start)
			. (!empty($subtitle) ? '<h6 class="sc_blogger_subtitle sc_item_subtitle">' . trim(seohub_strmacros($subtitle)) . '</h6>' : '')
			. (!empty($title) ? '<h2 class="sc_blogger_title sc_item_title">' . trim(seohub_strmacros($title)) . '</h2>' : '')
			. (!empty($description) ? '<div class="sc_blogger_descr sc_item_descr">' . trim(seohub_strmacros($description)) . '</div>' : '')
			. ($container2_start)
			. ($style=='list' ? '<ul class="sc_list sc_list_style_iconed">' : '')
			. ($dir=='horizontal' && $columns > 1 && seohub_get_template_property($style, 'need_columns') ? '<div class="columns_wrap">' : '')
			. (seohub_param_is_on($scroll) 
				? '<div id="'.esc_attr($id).'_scroll" class="sc_scroll sc_scroll_'.esc_attr($dir).' sc_slider_noresize swiper-slider-container scroll-container"'
					. ' style="'.($dir=='vertical' ? 'height:'.($height != '' ? $height : "230px").';' : 'width:'.($width != '' ? $width.';' : "100%;")).'"'
					. '>'
					. '<div class="sc_scroll_wrapper swiper-wrapper">' 
						. '<div class="sc_scroll_slide swiper-slide">' 
				: '')
			;
	
		if (seohub_get_template_property($style, 'need_isotope')) {
			if (!seohub_param_is_off($filters))
				$output .= '<div class="isotope_filters"></div>';
			if ($columns<1) $columns = seohub_substr($style, -1);
			$output .= '<div class="isotope_wrap" data-columns="'.max(1, min(12, $columns)).'">';
		}
	
		$args = array(
			'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish',
			'posts_per_page' => $count,
			'ignore_sticky_posts' => true,
			'order' => $order=='asc' ? 'asc' : 'desc',
			'orderby' => 'date',
		);
	
		if ($offset > 0 && empty($ids)) {
			$args['offset'] = $offset;
		}
	
		$args = seohub_query_add_sort_order($args, $orderby, $order);
		if (!seohub_param_is_off($only)) $args = seohub_query_add_filters($args, $only);
		$args = seohub_query_add_posts_and_cats($args, $ids, $post_type, $cat);
	
		$query = new WP_Query( $args );
	
		$flt_ids = array();
	
		while ( $query->have_posts() ) { $query->the_post();
	
			$SEOHUB_GLOBALS['sc_blogger_counter']++;
	
			$args = array(
				'layout' => $style,
				'show' => false,
				'number' => $SEOHUB_GLOBALS['sc_blogger_counter'],
				'add_view_more' => false,
				'posts_on_page' => ($count > 0 ? $count : $query->found_posts),
				// Additional options to layout generator
				"location" => $location,
				"descr" => $descr,
				"readmore" => $readmore,
				"loadmore" => $loadmore,
				"reviews" => seohub_param_is_on($rating),
				"dir" => $dir,
				"scroll" => seohub_param_is_on($scroll),
				"info" => seohub_param_is_on($info),
				"links" => seohub_param_is_on($links),
				"orderby" => $orderby,
				"columns_count" => $columns,
				"date_format" => $date_format,
				// Get post data
				'strip_teaser' => false,
				'content' => seohub_get_template_property($style, 'need_content'),
				'terms_list' => !seohub_param_is_off($filters) || seohub_get_template_property($style, 'need_terms'),
				'filters' => seohub_param_is_off($filters) ? '' : $filters,
				'hover' => $hover,
				'hover_dir' => $hover_dir
			);
			$post_data = seohub_get_post_data($args);
			$output .= seohub_show_post_layout($args, $post_data);
		
			if (!seohub_param_is_off($filters)) {
				if ($filters == 'tags') {			// Use tags as filter items
					if (!empty($post_data['post_terms'][$post_data['post_taxonomy_tags']]->terms) && is_array($post_data['post_terms'][$post_data['post_taxonomy_tags']]->terms)) {
						foreach ($post_data['post_terms'][$post_data['post_taxonomy_tags']]->terms as $tag) {
							$flt_ids[$tag->term_id] = $tag->name;
						}
					}
				}
			}
	
		}
	
		wp_reset_postdata();
	
		// Close isotope wrapper
		if (seohub_get_template_property($style, 'need_isotope'))
			$output .= '</div>';
	
		// Isotope filters list
		if (!seohub_param_is_off($filters)) {
			$filters_list = '';
			if ($filters == 'categories') {			// Use categories as filter items
				$taxonomy = seohub_get_taxonomy_categories_by_post_type($post_type);
				$portfolio_parent = $cat ? max(0, seohub_get_parent_taxonomy_by_property($cat, 'show_filters', 'yes', true, $taxonomy)) : 0;
				$args2 = array(
					'type'			=> $post_type,
					'child_of'		=> $portfolio_parent,
					'orderby'		=> 'name',
					'order'			=> 'ASC',
					'hide_empty'	=> 1,
					'hierarchical'	=> 0,
					'exclude'		=> '',
					'include'		=> '',
					'number'		=> '',
					'taxonomy'		=> $taxonomy,
					'pad_counts'	=> false
				);
				$portfolio_list = get_categories($args2);
				if (is_array($portfolio_list) && count($portfolio_list) > 0) {
					$filters_list .= '<a href="#" data-filter="*" class="theme_button active">'.esc_html__('All', 'seohub').'</a>';
					foreach ($portfolio_list as $cat) {
						$filters_list .= '<a href="#" data-filter=".flt_'.esc_attr($cat->term_id).'" class="theme_button">'.($cat->name).'</a>';
					}
				}
			} else {								// Use tags as filter items
				if (is_array($flt_ids) && count($flt_ids) > 0) {
					$filters_list .= '<a href="#" data-filter="*" class="theme_button active">'.esc_html__('All', 'seohub').'</a>';
					foreach ($flt_ids as $flt_id=>$flt_name) {
						$filters_list .= '<a href="#" data-filter=".flt_'.esc_attr($flt_id).'" class="theme_button">'.($flt_name).'</a>';
					}
				}
			}
			if ($filters_list) {
				$output .= '<script type="text/javascript">'
					. 'jQuery(document).ready(function () {'
						. 'jQuery("#'.esc_attr($id).' .isotope_filters").append("'.addslashes($filters_list).'");'
					. '});'
					. '</script>';
			}
		}
		$output	.= (seohub_param_is_on($scroll) 
				? '</div></div><div id="'.esc_attr($id).'_scroll_bar" class="sc_scroll_bar sc_scroll_bar_'.esc_attr($dir).' '.esc_attr($id).'_scroll_bar"></div></div>'
					. (!seohub_param_is_off($controls) ? '<div class="sc_scroll_controls_wrap"><a class="sc_scroll_prev" href="#"></a><a class="sc_scroll_next" href="#"></a></div>' : '')
				: '')
			. ($dir=='horizontal' && $columns > 1 && seohub_get_template_property($style, 'need_columns') ? '</div>' :  '')
			. ($style == 'list' ? '</ul>' : '')
			. ($container2_end)
			. (!empty($link) 
				? '<div class="sc_blogger_button sc_item_button">'.do_shortcode('[trx_button link="'.esc_url($link).'" icon="icon-right"]'.esc_html($link_caption).'[/trx_button]').'</div>' 				: '')
			. ($container_end)
			. '</div>';
	
		// Add template specific scripts and styles
		do_action('seohub_action_blog_scripts', $style);
		
		$SEOHUB_GLOBALS['sc_blogger_busy'] = false;
	
		return apply_filters('seohub_shortcode_output', $output, 'trx_blogger', $atts, $content);
	}
	seohub_require_shortcode('trx_blogger', 'seohub_sc_blogger');
}



/* Add shortcode in the internal SC Builder
-------------------------------------------------------------------- */
if ( !function_exists( 'seohub_sc_blogger_reg_shortcodes' ) ) {
	//add_action('seohub_action_shortcodes_list', 'seohub_sc_blogger_reg_shortcodes');
	function seohub_sc_blogger_reg_shortcodes() {
		global $SEOHUB_GLOBALS;
	
		$SEOHUB_GLOBALS['shortcodes']["trx_blogger"] = array(
			"title" => esc_html__("Blogger", "seohub"),
			"desc" => wp_kses( __("Insert posts (pages) in many styles from desired categories or directly from ids", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
			"decorate" => false,
			"container" => false,
			"params" => array(
				"title" => array(
					"title" => esc_html__("Title", "seohub"),
					"desc" => wp_kses( __("Title for the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "",
					"type" => "text"
				),
				"subtitle" => array(
					"title" => esc_html__("Subtitle", "seohub"),
					"desc" => wp_kses( __("Subtitle for the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "",
					"type" => "text"
				),
				"description" => array(
					"title" => esc_html__("Description", "seohub"),
					"desc" => wp_kses( __("Short description for the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "",
					"type" => "textarea"
				),
				"style" => array(
					"title" => esc_html__("Posts output style", "seohub"),
					"desc" => wp_kses( __("Select desired style for posts output", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "accordion",
					"type" => "select",
					"options" => $SEOHUB_GLOBALS['sc_params']['blogger_styles']
				),
				"filters" => array(
					"title" => esc_html__("Show filters", "seohub"),
					"desc" => wp_kses( __("Use post's tags or categories as filter buttons", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "no",
					"dir" => "horizontal",
					"type" => "checklist",
					"options" => $SEOHUB_GLOBALS['sc_params']['filters']
				),
				"hover" => array(
					"title" => esc_html__("Hover effect", "seohub"),
					"desc" => wp_kses( __("Select hover effect (only if style=Portfolio)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"dependency" => array(
						'style' => array('portfolio','grid','square','short','colored')
					),
					"value" => "",
					"type" => "select",
					"options" => $SEOHUB_GLOBALS['sc_params']['hovers']
				),
				"hover_dir" => array(
					"title" => esc_html__("Hover direction", "seohub"),
					"desc" => wp_kses( __("Select hover direction (only if style=Portfolio and hover=Circle|Square)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"dependency" => array(
						'style' => array('portfolio','grid','square','short','colored'),
						'hover' => array('square','circle')
					),
					"value" => "left_to_right",
					"type" => "select",
					"options" => $SEOHUB_GLOBALS['sc_params']['hovers_dir']
				),
				"dir" => array(
					"title" => esc_html__("Posts direction", "seohub"),
					"desc" => wp_kses( __("Display posts in horizontal or vertical direction", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "horizontal",
					"type" => "switch",
					"size" => "big",
					"options" => $SEOHUB_GLOBALS['sc_params']['dir']
				),
				"post_type" => array(
					"title" => esc_html__("Post type", "seohub"),
					"desc" => wp_kses( __("Select post type to show", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "post",
					"type" => "select",
					"options" => $SEOHUB_GLOBALS['sc_params']['posts_types']
				),
				"ids" => array(
					"title" => esc_html__("Post IDs list", "seohub"),
					"desc" => wp_kses( __("Comma separated list of posts ID. If set - parameters above are ignored!", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "",
					"type" => "text"
				),
				"cat" => array(
					"title" => esc_html__("Categories list", "seohub"),
					"desc" => wp_kses( __("Select the desired categories. If not selected - show posts from any category or from IDs list", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"dependency" => array(
						'ids' => array('is_empty'),
						'post_type' => array('refresh')
					),
					"divider" => true,
					"value" => "",
					"type" => "select",
					"style" => "list",
					"multiple" => true,
					"options" => seohub_array_merge(array(0 => esc_html__('- Select category -', 'seohub')), $SEOHUB_GLOBALS['sc_params']['categories'])
				),
				"count" => array(
					"title" => esc_html__("Total posts to show", "seohub"),
					"desc" => wp_kses( __("How many posts will be displayed? If used IDs - this parameter ignored.", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"dependency" => array(
						'ids' => array('is_empty')
					),
					"value" => 3,
					"min" => 1,
					"max" => 100,
					"type" => "spinner"
				),
				"columns" => array(
					"title" => esc_html__("Columns number", "seohub"),
					"desc" => wp_kses( __("How many columns used to show posts? If empty or 0 - equal to posts number", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"dependency" => array(
						'dir' => array('horizontal')
					),
					"value" => 3,
					"min" => 1,
					"max" => 100,
					"type" => "spinner"
				),
				"offset" => array(
					"title" => esc_html__("Offset before select posts", "seohub"),
					"desc" => wp_kses( __("Skip posts before select next part.", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"dependency" => array(
						'ids' => array('is_empty')
					),
					"value" => 0,
					"min" => 0,
					"max" => 100,
					"type" => "spinner"
				),
				"orderby" => array(
					"title" => esc_html__("Post order by", "seohub"),
					"desc" => wp_kses( __("Select desired posts sorting method", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "date",
					"type" => "select",
					"options" => $SEOHUB_GLOBALS['sc_params']['sorting']
				),
				"order" => array(
					"title" => esc_html__("Post order", "seohub"),
					"desc" => wp_kses( __("Select desired posts order", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "desc",
					"type" => "switch",
					"size" => "big",
					"options" => $SEOHUB_GLOBALS['sc_params']['ordering']
				),
				"only" => array(
					"title" => esc_html__("Select posts only", "seohub"),
					"desc" => wp_kses( __("Select posts only with reviews, videos, audios, thumbs or galleries", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "no",
					"type" => "select",
					"options" => $SEOHUB_GLOBALS['sc_params']['formats']
				),
				"scroll" => array(
					"title" => esc_html__("Use scroller", "seohub"),
					"desc" => wp_kses( __("Use scroller to show all posts", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"divider" => true,
					"value" => "no",
					"type" => "switch",
					"options" => $SEOHUB_GLOBALS['sc_params']['yes_no']
				),
				"controls" => array(
					"title" => esc_html__("Show slider controls", "seohub"),
					"desc" => wp_kses( __("Show arrows to control scroll slider", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"dependency" => array(
						'scroll' => array('yes')
					),
					"value" => "no",
					"type" => "switch",
					"options" => $SEOHUB_GLOBALS['sc_params']['yes_no']
				),
				"location" => array(
					"title" => esc_html__("Dedicated content location", "seohub"),
					"desc" => wp_kses( __("Select position for dedicated content (only for style=excerpt)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"divider" => true,
					"dependency" => array(
						'style' => array('excerpt')
					),
					"value" => "default",
					"type" => "select",
					"options" => $SEOHUB_GLOBALS['sc_params']['locations']
				),
				"rating" => array(
					"title" => esc_html__("Show rating stars", "seohub"),
					"desc" => wp_kses( __("Show rating stars under post's header", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "no",
					"type" => "switch",
					"options" => $SEOHUB_GLOBALS['sc_params']['yes_no']
				),
				"info" => array(
					"title" => esc_html__("Show post info block", "seohub"),
					"desc" => wp_kses( __("Show post info block (author, date, tags, etc.)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "no",
					"type" => "switch",
					"options" => $SEOHUB_GLOBALS['sc_params']['yes_no']
				),
				"links" => array(
					"title" => esc_html__("Allow links on the post", "seohub"),
					"desc" => wp_kses( __("Allow links on the post from each blogger item", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "yes",
					"type" => "switch",
					"options" => $SEOHUB_GLOBALS['sc_params']['yes_no']
				),
				"descr" => array(
					"title" => esc_html__("Description length", "seohub"),
					"desc" => wp_kses( __("How many characters are displayed from post excerpt? If 0 - don't show description", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => 0,
					"min" => 0,
					"step" => 10,
					"type" => "spinner"
				),
				"readmore" => array(
					"title" => esc_html__("More link text", "seohub"),
					"desc" => wp_kses( __("Read more link text. If empty - show 'More', else - used as link text", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "",
					"type" => "text"
				),
				"link" => array(
					"title" => esc_html__("Button URL", "seohub"),
					"desc" => wp_kses( __("Link URL for the button at the bottom of the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "",
					"type" => "text"
				),
				"link_caption" => array(
					"title" => esc_html__("Button caption", "seohub"),
					"desc" => wp_kses( __("Caption for the button at the bottom of the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"value" => "",
					"type" => "text"
				),
				"width" => seohub_shortcodes_width(),
				"height" => seohub_shortcodes_height(),
				"top" => $SEOHUB_GLOBALS['sc_params']['top'],
				"bottom" => $SEOHUB_GLOBALS['sc_params']['bottom'],
				"left" => $SEOHUB_GLOBALS['sc_params']['left'],
				"right" => $SEOHUB_GLOBALS['sc_params']['right'],
				"id" => $SEOHUB_GLOBALS['sc_params']['id'],
				"class" => $SEOHUB_GLOBALS['sc_params']['class'],
				"animation" => $SEOHUB_GLOBALS['sc_params']['animation'],
				"css" => $SEOHUB_GLOBALS['sc_params']['css']
			)
		);
	}
}


/* Add shortcode in the VC Builder
-------------------------------------------------------------------- */
if ( !function_exists( 'seohub_sc_blogger_reg_shortcodes_vc' ) ) {
	//add_action('seohub_action_shortcodes_list_vc', 'seohub_sc_blogger_reg_shortcodes_vc');
	function seohub_sc_blogger_reg_shortcodes_vc() {
		global $SEOHUB_GLOBALS;
	
		vc_map( array(
			"base" => "trx_blogger",
			"name" => esc_html__("Blogger", "seohub"),
			"description" => wp_kses( __("Insert posts (pages) in many styles from desired categories or directly from ids", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
			"category" => esc_html__('Content', 'js_composer'),
			'icon' => 'icon_trx_blogger',
			"class" => "trx_sc_single trx_sc_blogger",
			"content_element" => true,
			"is_container" => false,
			"show_settings_on_create" => true,
			"params" => array(
				array(
					"param_name" => "style",
					"heading" => esc_html__("Output style", "seohub"),
					"description" => wp_kses( __("Select desired style for posts output", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"admin_label" => true,
					"std" => "accordion",
					"class" => "",
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['blogger_styles']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "filters",
					"heading" => esc_html__("Show filters", "seohub"),
					"description" => wp_kses( __("Use post's tags or categories as filter buttons", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"admin_label" => true,
					"class" => "",
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['filters']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "hover",
					"heading" => esc_html__("Hover effect", "seohub"),
					"description" => wp_kses( __("Select hover effect (only if style=Portfolio)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"class" => "",
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['hovers']),
					'dependency' => array(
						'element' => 'style',
						'value' => array('portfolio_2','portfolio_3','portfolio_4','grid_2','grid_3','grid_4','square_2','square_3','square_4','short_2','short_3','short_4','colored_2','colored_3','colored_4')
					),
					"type" => "dropdown"
				),
				array(
					"param_name" => "hover_dir",
					"heading" => esc_html__("Hover direction", "seohub"),
					"description" => wp_kses( __("Select hover direction (only if style=Portfolio and hover=Circle|Square)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"class" => "",
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['hovers_dir']),
					'dependency' => array(
						'element' => 'style',
						'value' => array('portfolio_2','portfolio_3','portfolio_4','grid_2','grid_3','grid_4','square_2','square_3','square_4','short_2','short_3','short_4','colored_2','colored_3','colored_4')
					),
					"type" => "dropdown"
				),
				array(
					"param_name" => "location",
					"heading" => esc_html__("Dedicated content location", "seohub"),
					"description" => wp_kses( __("Select position for dedicated content (only for style=excerpt)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"class" => "",
					'dependency' => array(
						'element' => 'style',
						'value' => array('excerpt')
					),
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['locations']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "dir",
					"heading" => esc_html__("Posts direction", "seohub"),
					"description" => wp_kses( __("Display posts in horizontal or vertical direction", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"admin_label" => true,
					"class" => "",
					"std" => "horizontal",
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['dir']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "columns",
					"heading" => esc_html__("Columns number", "seohub"),
					"description" => wp_kses( __("How many columns used to display posts?", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					'dependency' => array(
						'element' => 'dir',
						'value' => 'horizontal'
					),
					"class" => "",
					"value" => "",
					"type" => "textfield"
				),
				array(
					"param_name" => "rating",
					"heading" => esc_html__("Show rating stars", "seohub"),
					"description" => wp_kses( __("Show rating stars under post's header", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Details', 'seohub'),
					"class" => "",
					"value" => array(esc_html__('Show rating', 'seohub') => 'yes'),
					"type" => "checkbox"
				),
				array(
					"param_name" => "info",
					"heading" => esc_html__("Show post info block", "seohub"),
					"description" => wp_kses( __("Show post info block (author, date, tags, etc.)", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"class" => "",
					"std" => 'yes',
					"value" => array(esc_html__('Show info', 'seohub') => 'yes'),
					"type" => "checkbox"
				),
				array(
					"param_name" => "descr",
					"heading" => esc_html__("Description length", "seohub"),
					"description" => wp_kses( __("How many characters are displayed from post excerpt? If 0 - don't show description", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Details', 'seohub'),
					"class" => "",
					"value" => 0,
					"type" => "textfield"
				),
				array(
					"param_name" => "links",
					"heading" => esc_html__("Allow links to the post", "seohub"),
					"description" => wp_kses( __("Allow links to the post from each blogger item", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Details', 'seohub'),
					"class" => "",
					"std" => 'yes',
					"value" => array(esc_html__('Allow links', 'seohub') => 'yes'),
					"type" => "checkbox"
				),
				array(
					"param_name" => "readmore",
					"heading" => esc_html__("More link text", "seohub"),
					"description" => wp_kses( __("Read more link text. If empty - show 'More', else - used as link text", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Details', 'seohub'),
					"class" => "",
					"value" => "",
					"type" => "textfield"
				),
				array(
					"param_name" => "title",
					"heading" => esc_html__("Title", "seohub"),
					"description" => wp_kses( __("Title for the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"admin_label" => true,
					"group" => esc_html__('Captions', 'seohub'),
					"class" => "",
					"value" => "",
					"type" => "textfield"
				),
				array(
					"param_name" => "subtitle",
					"heading" => esc_html__("Subtitle", "seohub"),
					"description" => wp_kses( __("Subtitle for the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Captions', 'seohub'),
					"class" => "",
					"value" => "",
					"type" => "textfield"
				),
				array(
					"param_name" => "description",
					"heading" => esc_html__("Description", "seohub"),
					"description" => wp_kses( __("Description for the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Captions', 'seohub'),
					"class" => "",
					"value" => "",
					"type" => "textarea"
				),
				array(
					"param_name" => "link",
					"heading" => esc_html__("Button URL", "seohub"),
					"description" => wp_kses( __("Link URL for the button at the bottom of the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Captions', 'seohub'),
					"class" => "",
					"value" => "",
					"type" => "textfield"
				),
				array(
					"param_name" => "link_caption",
					"heading" => esc_html__("Button caption", "seohub"),
					"description" => wp_kses( __("Caption for the button at the bottom of the block", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Captions', 'seohub'),
					"class" => "",
					"value" => "",
					"type" => "textfield"
				),
				array(
					"param_name" => "post_type",
					"heading" => esc_html__("Post type", "seohub"),
					"description" => wp_kses( __("Select post type to show", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Query', 'seohub'),
					"class" => "",
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['posts_types']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "ids",
					"heading" => esc_html__("Post IDs list", "seohub"),
					"description" => wp_kses( __("Comma separated list of posts ID. If set - parameters above are ignored!", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Query', 'seohub'),
					"class" => "",
					"value" => "",
					"type" => "textfield"
				),
				array(
					"param_name" => "cat",
					"heading" => esc_html__("Categories list", "seohub"),
					"description" => wp_kses( __("Select category. If empty - show posts from any category or from IDs list", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					'dependency' => array(
						'element' => 'ids',
						'is_empty' => true
					),
					"group" => esc_html__('Query', 'seohub'),
					"class" => "",
					"value" => array_flip(seohub_array_merge(array(0 => esc_html__('- Select category -', 'seohub')), $SEOHUB_GLOBALS['sc_params']['categories'])),
					"type" => "dropdown"
				),
				array(
					"param_name" => "count",
					"heading" => esc_html__("Total posts to show", "seohub"),
					"description" => wp_kses( __("How many posts will be displayed? If used IDs - this parameter ignored.", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					'dependency' => array(
						'element' => 'ids',
						'is_empty' => true
					),
					"admin_label" => true,
					"group" => esc_html__('Query', 'seohub'),
					"class" => "",
					"value" => 3,
					"type" => "textfield"
				),
				array(
					"param_name" => "offset",
					"heading" => esc_html__("Offset before select posts", "seohub"),
					"description" => wp_kses( __("Skip posts before select next part.", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					'dependency' => array(
						'element' => 'ids',
						'is_empty' => true
					),
					"group" => esc_html__('Query', 'seohub'),
					"class" => "",
					"value" => 0,
					"type" => "textfield"
				),
				array(
					"param_name" => "orderby",
					"heading" => esc_html__("Post order by", "seohub"),
					"description" => wp_kses( __("Select desired posts sorting method", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"class" => "",
					"group" => esc_html__('Query', 'seohub'),
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['sorting']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "order",
					"heading" => esc_html__("Post order", "seohub"),
					"description" => wp_kses( __("Select desired posts order", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"class" => "",
					"group" => esc_html__('Query', 'seohub'),
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['ordering']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "only",
					"heading" => esc_html__("Select posts only", "seohub"),
					"description" => wp_kses( __("Select posts only with reviews, videos, audios, thumbs or galleries", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"class" => "",
					"group" => esc_html__('Query', 'seohub'),
					"value" => array_flip($SEOHUB_GLOBALS['sc_params']['formats']),
					"type" => "dropdown"
				),
				array(
					"param_name" => "scroll",
					"heading" => esc_html__("Use scroller", "seohub"),
					"description" => wp_kses( __("Use scroller to show all posts", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Scroll', 'seohub'),
					"class" => "",
					"value" => array(esc_html__('Use scroller', 'seohub') => 'yes'),
					"type" => "checkbox"
				),
				array(
					"param_name" => "controls",
					"heading" => esc_html__("Show slider controls", "seohub"),
					"description" => wp_kses( __("Show arrows to control scroll slider", "seohub"), $SEOHUB_GLOBALS['allowed_tags'] ),
					"group" => esc_html__('Scroll', 'seohub'),
					"class" => "",
					"value" => array(esc_html__('Show controls', 'seohub') => 'yes'),
					"type" => "checkbox"
				),
				$SEOHUB_GLOBALS['vc_params']['id'],
				$SEOHUB_GLOBALS['vc_params']['class'],
				$SEOHUB_GLOBALS['vc_params']['animation'],
				$SEOHUB_GLOBALS['vc_params']['css'],
				seohub_vc_width(),
				seohub_vc_height(),
				$SEOHUB_GLOBALS['vc_params']['margin_top'],
				$SEOHUB_GLOBALS['vc_params']['margin_bottom'],
				$SEOHUB_GLOBALS['vc_params']['margin_left'],
				$SEOHUB_GLOBALS['vc_params']['margin_right']
			),
		) );
		
		class WPBakeryShortCode_Trx_Blogger extends SEOHUB_VC_ShortCodeSingle {}
	}
}
?>