<?php

/**
 * The public-facing functionality of the plugin.
 *
 * @link       https://revivedesignstudios.com
 * @since      1.0.0
 *
 * @package    Rds_Bt50_Scorecard
 * @subpackage Rds_Bt50_Scorecard/public
 */

/**
 * The public-facing functionality of the plugin.
 *
 * Defines the plugin name, version, and two examples hooks for how to
 * enqueue the public-facing stylesheet and JavaScript.
 *
 * @package    Rds_Bt50_Scorecard
 * @subpackage Rds_Bt50_Scorecard/public
 * @author     Revive Design Studios <connect@revivedesignstudios.com>
 */
class Rds_Bt50_Scorecard_Public {

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of the plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct( $plugin_name, $version ) {

		$this->plugin_name = $plugin_name;
		$this->version = $version;
	}

	/**
	 * Register the stylesheets for the public-facing side of the site.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_styles() {
	}

	/**
	 *  Render the html for the scorecard app to initialize on
	 *
	 * @since    1.0.0
	 */
	public function register_scorecard_shortcode($attr, $text = null) {
		$this->enqueue_scorecard_app();
		ob_start();
		include_once( 'partials/rds-bt50-scorecard-public-display.php' );
		$output = ob_get_clean();
		return $output;
	}

	public function enqueue_scorecard_app() {
		wp_enqueue_style( $this->plugin_name );
		wp_enqueue_script( $this->plugin_name . '-common' );
		wp_enqueue_script( $this->plugin_name . '-app' );
	}

	public function register_scorecard_app() {
		wp_register_style(
			$this->plugin_name,
			plugin_dir_url( __FILE__ ) . 'css/bt50-scorecard-app.css',
			array(),
			$this->version
		);
		wp_register_script(
			$this->plugin_name. '-common',
			plugin_dir_url( __FILE__ ) . './js/bt50-scorecard-common.js',
			array( ),
			$this->version,
			true
		);

		wp_register_script(
			$this->plugin_name. '-app',
			plugin_dir_url( __FILE__ ) . './js/bt50-scorecard-app.js',
			array( $this->plugin_name. '-common' ),
			$this->version,
			true
		);
	}

	/**
	 * Register the JavaScript for the public-facing side of the site.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_scripts() {
		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/rds-bt50-scorecard-public.js', array( 'jquery' ), $this->version, false );
	}

}
