<?php
namespace Booktics\Assets;

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

/**
 * Manage all common scripts and styles
 */
class Feedback_Modal_Assets extends Base_Assets {
    /**
     * Register single service
     *
     * @return  void
     */
    public function register() {
        add_action( 'admin_enqueue_scripts',  [$this, 'register_styles_scripts'], 9 );
        add_action( 'admin_enqueue_scripts',  [$this, 'enqueue'] );
    }

    /**
     * Enqueue scripts and styles
     *
     * @return  void
     */
    public function enqueue() {
        $screen = get_current_screen();
        if ( $screen->base !== 'plugins') {
            return;
        }
        wp_enqueue_style( 'booktics-feedback-modal' );
        wp_enqueue_script( 'booktics-feedback-modal' );

        wp_localize_script('booktics-feedback-modal','booktics_feedback',  [ 'site_url' => site_url(), 'admin_email' => get_option('admin_email') ]);
    }

    /**
     * Get all scripts
     *
     * @return  array List register scripts
     */
    public function get_scripts(): array {
        $scripts = [
            'booktics-feedback-modal' => [
                'src'       => booktics()->assets_url . '/build/js/feedback-modal.js',
                'deps'      => [
                    'wp-i18n'
                ],
                'in_footer' => false,
            ],
        ];

        return apply_filters( 'booktics_feedback_modal_assets', $scripts );
    }

    /**
     * List of register styles
     *
     * @return  array
     */
    public function get_styles(): array {
        $styles = [
            'booktics-feedback-modal' => [
                'src' => booktics()->assets_url . '/build/css/feedback-modal.css',
            ],
        ];

        return apply_filters( 'booktics_feedback_modal_styles', $styles );
    }
}

