<?php

/**
 * Floating Widget class for Easy Video Reviews
 *
 * @since 1.3.0
 * @package EasyVideoReviews
 */

// Namespace.
namespace EasyVideoReviews;

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


if ( ! class_exists( __NAMESPACE__ . '\Floatingwidget' ) ) {
    /**
     * Floatingwidget class for Easy Video Reviews
     */
    class Floatingwidget extends \EasyVideoReviews\Base\Controller {

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

        /**
         * Register hooks
         *
         * @return void
         */
        public function register_hooks() {
            // Register action hooks.
            add_action( 'wp_footer', array( $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();
}
