<?php
namespace AnggitaPlugin\Widgets;

use Elementor\Group_Control_Typography;
use Elementor\Scheme_Typography;
use Elementor\Group_Control_Border;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;

if (!defined('ABSPATH')) exit; // Exit if accessed directly



/**
 * @since 1.1.0
 */
class Anggita_PortfolioMasonry extends Widget_Base
{

	/**
	 * Retrieve the widget name.
	 *
	 * @since 1.1.0
	 *
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name()
	{
		return 'anggita-portfolio-masonry';
	}

	//script depend
	public function get_script_depends()
	{
		return ['jquery-isotope', 'anggita-portfolio'];
	}
	/**
	 * Retrieve the widget title.
	 *
	 * @since 1.1.0
	 *
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title()
	{
		return __('Anggita Portfolio Masonry', 'anggita_plugin');
	}

	/**
	 * Retrieve the widget icon.
	 *
	 * @since 1.1.0
	 *
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon()
	{
		return 'fa fa-file-text';
	}

	/**
	 * Retrieve the list of categories the widget belongs to.
	 *
	 * Used to determine where to display the widget in the editor.
	 *
	 * Note that currently Elementor supports only one category.
	 * When multiple categories passed, Elementor uses the first one.
	 *
	 * @since 1.1.0
	 *
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories()
	{
		return ['anggita-elements'];
	}

	/**
	 * Register the widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since 1.1.0
	 *
	 * @access protected
	 */
	protected function _register_controls()
	{

		$this->start_controls_section(
			'section_content',
			[
				'label' => __('Portfolio Settings.', 'anggita_plugin'),
			]
		);

		$this->add_control(
			'port_style',
			[
				'label' => __('Style', 'anggita_plugin'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'1' => __('Style One', 'anggita_plugin'),
					'2' => __('Style Two', 'anggita_plugin'),
					'3' => __('Style Three', 'anggita_plugin'),
				],
				'default' => '1',
			]
		);

		$this->add_control(
			'filter',
			[
				'label' => __('Filter', 'anggita_plugin'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'show' => __('Show', 'anggita_plugin'),
					'hide' => __('Hide', 'anggita_plugin'),
				],
				'default' => 'show',
			]
		);

		$this->add_responsive_control(
			'filter_align',
			[
				'label' => __('Filter Alignment', 'anggita_plugin'),
				'type' => Controls_Manager::CHOOSE,
				'options' => [
					'left' => [
						'title' => __('Left', 'anggita_plugin'),
						'icon' => 'fa fa-align-left',
					],
					'center' => [
						'title' => __('Center', 'anggita_plugin'),
						'icon' => 'fa fa-align-center',
					],
					'right' => [
						'title' => __('Right', 'anggita_plugin'),
						'icon' => 'fa fa-align-right',
					],
				],
				'default' => 'center',
				'selectors' => [
					'{{WRAPPER}} .port-filter' => 'text-align: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'filter_all',
			[
				'label' => __('Text for all category. The default text is "All".', 'anggita_plugin'),
				'type' => Controls_Manager::TEXT,
				'label_block' => true,
				'placeholder' => 'Leave it blank to use the default text.',
			]
		);

		$this->add_control(
			'portfolio_item',
			[
				'label' => __('Item to display', 'anggita_plugin'),
				'type' => Controls_Manager::NUMBER,
				'default' => '8',
			]
		);

		$this->add_control(
			'sort_cat',
			[
				'label' => __('Sort Portfolio by Portfolio Category', 'anggita_plugin'),
				'type' => Controls_Manager::SWITCHER,
				'default' => '',
				'label_on' => __('Yes', 'anggita_plugin'),
				'label_off' => __('No', 'anggita_plugin'),
				'return_value' => 'yes',
			]
		);

		$this->add_control(
			'blog_cat',
			[
				'label'   => __('Category to Show', 'anggita_plugin'),
				'type'    => Controls_Manager::SELECT2, 'options' => tax_choice(),
				'condition' => [
					'sort_cat' => 'yes',
				],
				'multiple'   => 'true',
			]
		);

		$this->add_control(
			'port_order',
			[
				'label' => __('Orders', 'anggita_plugin'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'DESC' => __('Descending', 'anggita_plugin'),
					'ASC' => __('Ascending', 'anggita_plugin'),
					'rand' => __('Random', 'anggita_plugin'),
				],
				'default' => 'DESC',
			]
		);


		$this->add_control(
			'port_column',
			[
				'label' => __('Columns', 'anggita_plugin'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'2' => __('Two Columns', 'anggita_plugin'),
					'3' => __('Three Columns', 'anggita_plugin'),
					'4' => __('Four Columns', 'anggita_plugin'),
				],
				'default' => '3',
			]
		);

		$this->add_control(
			'page_show',
			[
				'label' => __('Show Pagination', 'anggita_plugin'),
				'type' => Controls_Manager::SWITCHER,
				'default' => '',
				'label_on' => __('Show', 'anggita_plugin'),
				'label_off' => __('Hide', 'anggita_plugin'),
				'return_value' => 'yes',
				'condition' => [
					'sort_cat!' => 'yes',
				],
			]
		);

		$this->add_responsive_control(
			'page_align',
			[
				'label' => __('Pagination Alignment', 'anggita_plugin'),
				'type' => Controls_Manager::CHOOSE,
				'options' => [
					'left' => [
						'title' => __('Left', 'anggita_plugin'),
						'icon' => 'fa fa-align-left',
					],
					'center' => [
						'title' => __('Center', 'anggita_plugin'),
						'icon' => 'fa fa-align-center',
					],
					'right' => [
						'title' => __('Right', 'anggita_plugin'),
						'icon' => 'fa fa-align-right',
					],
				],
				'condition' => [
					'page_show' => 'yes',
				],
				'default' => 'center',
				'selectors' => [
					'{{WRAPPER}} .pagi-box' => 'text-align: {{VALUE}};',
				],
			]
		);

		$this->end_controls_section();


		$this->start_controls_section(
			'portfolio_styling',
			[
				'label' => __('Portfolio Item Settings.', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_responsive_control(
			'portfolio_margin',
			[
				'label' => __('Margin', 'anggita_plugin'),
				'type' => Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .port-inner' => 'margin: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .portfolio-body' => 'margin: -{{SIZE}}{{UNIT}};',
				],
			]
		);


		$this->end_controls_section();

		$this->start_controls_section(
			'section_content_style',
			[
				'label' => __('Content Settings', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);



		$this->add_responsive_control(
			'port_content',
			[
				'label' => __('Content Margin', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}}  .port-dbox' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->add_responsive_control(
			'port_padding',
			[
				'label' => __('Content Padding', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .dbox-relative' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);


		$this->add_group_control(
			Group_Control_Border::get_type(),
			[
				'name' => 'port_border',
				'placeholder' => '1px',
				'default' => '',
				'selector' => '{{WRAPPER}} .dbox-relative',
				'separator' => 'before',
			]
		);

		$this->add_control(
			'bg_content',
			[
				'label' => __('Content Background', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'condition' => [
					'port_style' => '1',
				],
				'selectors' => [
					'{{WRAPPER}} .dbox-relative' => 'background-color: {{VALUE}};',
				],
			]
		);

		$this->add_responsive_control(
			'content_align',
			[
				'label' => __('Alignment', 'anggita_plugin'),
				'type' => Controls_Manager::CHOOSE,
				'options' => [
					'left' => [
						'title' => __('Left', 'anggita_plugin'),
						'icon' => 'fa fa-align-left',
					],
					'center' => [
						'title' => __('Center', 'anggita_plugin'),
						'icon' => 'fa fa-align-center',
					],
					'right' => [
						'title' => __('Right', 'anggita_plugin'),
						'icon' => 'fa fa-align-right',
					]
				],
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .dbox-relative' => 'text-align: {{VALUE}};',
				],
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'title_typo',
			[
				'label' => __('Title Content Settings', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name'      => 'cport_typography',
				'label'     => __('Title Typography', 'anggita_plugin'),
				'selector'  => '{{WRAPPER}} .dbox-relative h3',
			]
		);

		$this->add_control(
			'title_type',
			[
				'label' => __('Title Display', 'anggita_plugin'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'block' => __('Block', 'anggita_plugin'),
					'inline-block' => __('Inline Block', 'anggita_plugin'),
				],
				'default' => 'block',
				'selectors' => [
					'{{WRAPPER}} .dbox-relative h3' => 'display: {{VALUE}};',
				],
			]
		);
		$this->add_control(
			'title_cl',
			[
				'label' => __('Title Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .dbox-relative h3' => 'color: {{VALUE}};',
				],
			]
		);
		
		$this->add_control(
			'title_bgl',
			[
				'label' => __('Title Background Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .dbox-relative h3' => 'background-color: {{VALUE}};',
				],
			]
		);

		$this->add_responsive_control(
			'titlep_padding',
			[
				'label' => __('Title Padding', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .dbox-relative h3' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->add_responsive_control(
			'titlep_margin',
			[
				'label' => __('Title Margin', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .dbox-relative h3' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'sub_typo',
			[
				'label' => __('Category/Text Content Settings', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name'      => 'ctext_typography',
				'label'     => __('Text Typography', 'anggita_plugin'),
				'selector'  => '{{WRAPPER}} .dbox-relative p',
			]
		);

		$this->add_control(
			'text_type',
			[
				'label' => __('Text Display', 'anggita_plugin'),
				'type' => Controls_Manager::SELECT,
				'options' => [
					'block' => __('Block', 'anggita_plugin'),
					'inline-block' => __('Inline Block', 'anggita_plugin'),
				],
				'default' => 'block',
				'selectors' => [
					'{{WRAPPER}} .dbox-relative p' => 'display: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'txt_cl',
			[
				'label' => __('Text Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .dbox-relative p' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'txt_bg',
			[
				'label' => __('Text Background Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .dbox-relative p' => 'background-color: {{VALUE}};',
				],
			]
		);

		$this->add_responsive_control(
			'tx_padding',
			[
				'label' => __('Text Padding', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .dbox-relative p' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->add_responsive_control(
			'tx_margin',
			[
				'label' => __('Text Margin', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .dbox-relative p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'port_imgs',
			[
				'label' => __('Image Settings', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);
		$this->add_responsive_control(
			'img_padding',
			[
				'label' => __('Image Padding', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .port-inner' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);
		$this->add_responsive_control(
			'img_margin',
			[
				'label' => __('Image Margin', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .port-inner' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_title_style',
			[
				'label' => __('Filter Settings', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name'      => 'filter_typography',
				'label'     => __('Typography', 'anggita_plugin'),
				'selector'  => '{{WRAPPER}} .port-filter a',
			]
		);

		$this->add_control(
			'filter_padding',
			[
				'label' => __('Padding', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .port-filter a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->add_control(
			'filter_margin',
			[
				'label' => __('Margin', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .port-filter a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);
		$this->add_control(
			'filter_border_radius',
			[
				'label' => __('Border Radius', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .port-filter a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);



		$this->add_control(
			'color_def',
			[
				'label' => __('Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .port-filter a' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'color_bgdef',
			[
				'label' => __('Background Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .port-filter a' => 'background: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'color_hov',
			[
				'label' => __('Color on Hover & Active', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .port-filter a.active' => 'color: {{VALUE}};',
					'{{WRAPPER}} .port-filter a:hover' => 'color: {{VALUE}};'
				],
			]
		);

		$this->add_control(
			'color_bgdefhover',
			[
				'label' => __('Background Color on Hover & Active', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .port-filter a.active' => 'background: {{VALUE}};',
					'{{WRAPPER}} .port-filter a::before' => 'background: {{VALUE}};',
					'{{WRAPPER}} .port-filter a::after' => 'background: {{VALUE}};',
					'{{WRAPPER}} .port-filter a:hover' => 'background: {{VALUE}};',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			[
				'name' => 'border',
				'placeholder' => '1px',
				'default' => '1px',
				'selector' => '{{WRAPPER}} .port-filter a',
				'separator' => 'before',
			]
		);



		$this->add_control(
			'color_borderhover',
			[
				'label' => __('Border Color on Hover & Active', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .port-filter a:hover' => 'border-color: {{VALUE}};',
					'{{WRAPPER}} .port-filter a.active' => 'border-color: {{VALUE}};',
				],
			]
		);



		$this->end_controls_section();

		$this->start_controls_section(
			'port_mask',
			[
				'label' => __('Portfolio Mask Settings', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);


		$this->add_control(
			'mask_color',
			[
				'label' => __('Mask Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
					'{{WRAPPER}} .port-inner:hover .img-mask' => 'background-color: {{VALUE}};',
				],
			]
		);


		$this->add_control(
			'mask_color_opacity',
			[
				'label' => __('Mask Color Opacity (on hover)', 'anggita_plugin'),
				'type' => Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1,
						'step' => 0.1,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .port-inner:hover .img-mask' => 'opacity: {{SIZE}};',
				],
			]
		);


		$this->end_controls_section();

		$this->start_controls_section(
			'pagination_setting',
			[
				'label' => __('Pagination Setting', 'anggita_plugin'),
				'tab' => Controls_Manager::TAB_STYLE,
			]
		);

		$this->add_control(
			'page_color',
			[
				'label' => __('Pagination Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .pagination > li > a' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'page_color_hover',
			[
				'label' => __('Pagination Color on Hover', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .pagination > li > a:hover' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'page_color_bg',
			[
				'label' => __('Pagination Background Color', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .pagination > li > a' => 'background-color: {{VALUE}};border-color:{{VALUE}};',
				],
			]
		);

		$this->add_control(
			'page_color_hover_bg',
			[
				'label' => __('Pagination Background Color on Hover', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .pagination > li > a:hover' => 'background-color: {{VALUE}};border-color:{{VALUE}};',
				],
			]
		);

		$this->add_control(
			'page_color_active',
			[
				'label' => __('Pagination Color on Active', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .pagination > .active > a' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'page_color_hover_bg_active',
			[
				'label' => __('Pagination Background Color on Active', 'anggita_plugin'),
				'type' => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .pagination > .active > a' => 'background-color: {{VALUE}};border-color:{{VALUE}};',
				],
			]
		);

		$this->add_control(
			'pagi_margin',
			[
				'label' => __('Margin', 'anggita_plugin'),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => ['px', '%'],
				'selectors' => [
					'{{WRAPPER}} .pagination' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);

		$this->end_controls_section();
	}

	/**
	 * Render the widget output on the frontend.
	 *
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since 1.1.0
	 *
	 * @access protected
	 */
	protected function render()
	{
		$settings = $this->get_settings();
		if ($settings['filter'] == 'show') { ?>
		<ul class="port-filter center-port-filter">

			<?php
			$ridianur_taxonomy = 'portfolio_category';
			$ridianur_terms = get_terms($ridianur_taxonomy); // Get all terms of a taxonomy
			if ($ridianur_terms && !is_wp_error($ridianur_terms)) : ?>
				<li>
					<a class="active" href="#" data-filter="*">
						<?php if ($settings['filter_all']) {
							echo esc_html($settings['filter_all']);
						} else {
							esc_html_e('All', 'anggita_plugin');
						} ?>
					</a>
				</li>
				<?php foreach ($ridianur_terms as $ridianur_term) { ?>
					<li><a data-filter=".<?php echo  strtolower(preg_replace('/[^a-zA-Z]+/', '-', $ridianur_term->name)); ?>" href="#">
							<?php echo esc_attr($ridianur_term->name); ?></a></li>
				<?php }
		endif; ?>
		</ul>
	<?php } ?>


	<div class="<?php if ($settings['port_style'] == '2') {
					echo "portfolio-type-two";
				} else if ($settings['port_style'] == '3') {
					echo "portfolio-type-three";
				} else {
					echo "portfolio-type-one";
				} ?> portfolio-body port-mason-style clearfix">

		<?php
		$anggita_paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
		if ($settings['port_order'] != 'rand') {
			$order = 'order';
			$ord_val = $settings['port_order'];
		} else {
			$order = 'orderby';
			$ord_val = 'rand';
		}

		if ($settings['sort_cat']  == 'yes') {
			$ridianur_work = new \WP_Query(array(
				'posts_per_page'   => $settings['portfolio_item'],
				'post_type' =>  'portfolio', 'anggita_plugin',
				$order       =>  $ord_val,
				'tax_query' => array(
					array(
						'taxonomy' => 'portfolio_category',   // taxonomy name
						'field' => 'term_id',
						'terms' => $settings['blog_cat'],           // term_id, slug or name                // term id, term slug or term name
					)
				)
			));
		} else {
			$ridianur_work = new \WP_Query(array(
				'paged' => $anggita_paged,
				'posts_per_page'   => $settings['portfolio_item'],
				'post_type' =>  'portfolio', 'anggita_plugin',
				$order       =>  $ord_val
			));
		}

		if ($ridianur_work->have_posts()) : while ($ridianur_work->have_posts()) : $ridianur_work->the_post();
				global $post;

				?>

				<div class="<?php if ($settings['port_column'] == '3') {
								echo "col-md-4";
							} else if ($settings['port_column'] == '2') {
								echo "col-md-6";
							} else {
								echo "col-md-3";
							} ?>
             									port-item <?php $ridianur_terms = get_the_terms(get_the_ID(), 'portfolio_category');
															if (is_array($ridianur_terms) && count($ridianur_terms) > 0) {
																foreach ($ridianur_terms as $ridianur_term) {
																	echo  strtolower(preg_replace('/[^a-zA-Z]+/', '-', $ridianur_term->name)) . ' ';
																}
															}
															$ridianur_allClasses = get_post_class();
															foreach ($ridianur_allClasses as $ridianur_class) {
																echo esc_attr($ridianur_class . " ");
															} ?>" id="post-<?php the_ID(); ?>">

					<div class="port-inner">
						<a class="port-link" href="<?php the_permalink(); ?>"></a>
						<img alt="<?php the_title(); ?>" src="<?php echo get_the_post_thumbnail_url(); ?>">
						<div class="port-dbox">
							<div class="dbox-relative">
								<h3><?php the_title(); ?></h3>
								<div class="cleaboth clearfix"></div>
								<?php $ridianur_taxonomy = 'portfolio_category';
								$ridianur_taxs = wp_get_post_terms($post->ID, $ridianur_taxonomy);  ?>
								<p><?php $ridianur_cats = array();
									foreach ($ridianur_taxs as $ridianur_tax) {
										$ridianur_cats[] =   $ridianur_tax->name;
									}
									echo implode(', ', $ridianur_cats); ?></p>
							</div>
							<!--/.dbox-relative-->
						</div>
						<!--/.port-dbox-->
						<div class="img-mask"></div>
					</div>
					<!--/.port-inner-->



				</div>
				<!--.port-item-->

			<?php endwhile;  ?>

			<!--pagination-->
			<?php
			if ($settings['page_show'] == 'yes' && $settings['sort_cat']  != 'yes') {  ?>
				<div class="pagi-box clearfix
                   									<?php
														$ridianur_taxonomy = 'portfolio_category';
														$ridianur_terms = get_terms($ridianur_taxonomy); // Get all terms of a taxonomy
														if ($ridianur_terms && !is_wp_error($ridianur_terms)) :
															foreach ($ridianur_terms as $ridianur_term) { ?>
																									<?php echo  strtolower(preg_replace('/[^a-zA-Z]+/', '-', $ridianur_term->name)); ?>
																					<?php }
																			endif; ?>">
					<?php anggita_pagination($ridianur_work->max_num_pages);  ?>
				</div>

			<?php };

	else : ?>
			<div class="alert alert-warning"><?php _e('There is no Portfolio Post Found. You need to  choose the portfolio category to show or create at least 1 portfolio post first.', 'anggita-plg'); ?></div>
		<?php endif;
	wp_reset_postdata();  ?>


	</div>
	<!--/.portfolio-body-->

<?php


}

/**
 * Render the widget output in the editor.
 *
 * Written as a Backbone JavaScript template and used to generate the live preview.
 *
 * @since 1.1.0
 *
 * @access protected
 */
protected function _content_template()
{ }
}
