<?php

namespace FiboFilters\Integrations\Themes\Avada;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Shortcode class.
 */
class FiboFiltersShortcodes extends \Fusion_Element {

	/**
	 * Constructor.
	 *
	 * @access public
	 */
	public function __construct() {
		parent::__construct();
		add_shortcode( 'fusion_fibofilters_shortcodes', [ $this, 'render' ] );

		add_filter( 'fusion_fibofilters_shortcodes_content', 'shortcode_unautop' );
		add_filter( 'fusion_fibofilters_shortcodes_content', 'do_shortcode' );
	}

	/**
	 * Render the shortcode
	 *
	 * @access public
	 *
	 * @param array  $args Shortcode parameters.
	 * @param string $content Content between shortcode.
	 *
	 * @return string          HTML output.
	 */
	public function render( $args, $content = '' ) {

		if ( fusion_is_preview_frame() ) {
			$html = '<div style="border: 1px solid #000; margin: 10px 0; padding: 0 10px;">';
			$html .= _x( 'FiboFilters will be displayed here.', '[admin]', 'fibofilters' );
			$html .= '</div>';
		} else {
			$html = apply_filters( 'fusion_fibofilters_shortcodes_content', fusion_builder_fix_shortcodes( $content ) );
		}

		$this->on_render();

		return apply_filters( 'fusion_element_fibofilters_shortcodes_content', $html, $args );
	}
}
