<?php
defined( 'ABSPATH' ) || exit;

class Willro_Reviews_Assets {

    public function __construct() {
        add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_assets' ], 999 );
        add_action( 'elementor/frontend/after_enqueue_scripts', [ $this, 'enqueue_assets' ], 999 );
        add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_assets' ], 999 );
        add_action( 'elementor/preview/enqueue_scripts', [ $this, 'enqueue_assets' ], 999 );
    }

    public function enqueue_assets() {
        wp_enqueue_script( 'jquery' );

        wp_enqueue_style(
            'willro-reviews-fonts',
            WILLRO_REVIEWS_URL . 'assets/css/fonts.css',
            [],
            WILLRO_REVIEWS_VERSION
        );

        wp_enqueue_style(
            'willro-reviews-style',
            WILLRO_REVIEWS_URL . 'assets/css/style.css',
            [ 'willro-reviews-fonts' ],
            WILLRO_REVIEWS_VERSION
        );

        wp_enqueue_style(
            'willro-reviews-skeleton',
            WILLRO_REVIEWS_URL . 'assets/css/skeleton.css',
            [ 'willro-reviews-style' ],
            WILLRO_REVIEWS_VERSION
        );

        wp_enqueue_script(
            'willro-reviews-script',
            WILLRO_REVIEWS_URL . 'assets/js/main.js',
            [ 'jquery' ],
            WILLRO_REVIEWS_VERSION,
            true
        );
    }
}
