<?php

/**
 * Floating Widget class for Revio
 *
 * @since 1.3.0
 * @package RVIOR
 */

// Namespace.
namespace RVIOR;

// Exit if accessed directly.
defined('ABSPATH') || exit(1);


if ( ! class_exists( __NAMESPACE__ . '\Floatingwidget' ) ) {
    /**
	 * Floatingwidget class for Revio
	 */
	class Floatingwidget extends \RVIOR\Base\Controller {

        // Use the utilities trait.
		use \RVIOR\Traits\Utilities;

        /**
		 * Register hooks
		 *
		 * @return void
		 */
		public function register_hooks() {
			// Register action hooks.
			add_action('wp_footer', [ $this, 'render_floating_widget' ]);
		}

        /**
		 * Renders the floating widget template
		 *
		 * @return void
		 */
		public function render_floating_widget() {
            $floating_widget_enable = $this->option()->get('enable_floating_widget_review');
            if ( '0' === $floating_widget_enable ) {
				return;
            }
			echo '<div id="floating-widget-app"></div>';
		}
    }

    // Instantiate the class.
	Floatingwidget::init();
}
