class-gsc-modal.php 1.17 KB
Newer Older
imac's avatar
imac committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
<?php
/**
 * @package WPSEO\Admin|Google_Search_Console
 */

/**
 * Represents the Google Search Console modal.
 */
class WPSEO_GSC_Modal {

	/** @var string */
	protected $view;

	/** @var int  */
	protected $height;

	/** @var array */
	protected $view_vars;

	/**
	 * Sets the required attributes for this object.
	 *
	 * @param string $view      The file with the view content.
	 * @param int    $height    The height that the modal will get.
	 * @param array  $view_vars The attributes to use in the view.
	 */
	public function __construct( $view, $height, array $view_vars = array() ) {
		$this->view   = $view;
		$this->height = $height;
		$this->view_vars = $view_vars;
	}

	/**
	 * Returns the height of the modal.
	 *
	 * @return int The set height.
	 */
	public function get_height() {
		return $this->height;
	}

	/**
	 * Loads the view of the modal.
	 *
	 * @param string $unique_id An unique identifier for the modal.
	 */
	public function load_view( $unique_id ) {
		extract( $this->view_vars );

		echo '<div id="redirect-' . $unique_id . '" class="hidden">';
		echo '<div class="form-wrap wpseo_content_wrapper">';
		require( $this->view );
		echo '</div>';
		echo '</div>';
	}
}