class-option-tab.php 1.5 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
<?php
/**
 * @package WPSEO\Admin\Options\Tabs
 */

/**
 * Class WPSEO_Option_Tab
 */
class WPSEO_Option_Tab {

	/** @var string Name of the tab */
	private $name;

	/** @var string Label of the tab */
	private $label;

	/** @var array Optional arguments */
	private $arguments = array();

	/**
	 * WPSEO_Option_Tab constructor.
	 *
	 * @param string $name      Name of the tab.
	 * @param string $label     Label of the tab.
	 * @param array  $arguments Optional arguments.
	 */
	public function __construct( $name, $label, $arguments = array() ) {
		$this->name      = sanitize_title( $name );
		$this->label     = $label;
		$this->arguments = (array) $arguments;
	}

	/**
	 * Get the name
	 *
	 * @return string
	 */
	public function get_name() {
		return $this->name;
	}

	/**
	 * Get the label
	 *
	 * @return string
	 */
	public function get_label() {
		return $this->label;
	}

	/**
	 * Get the video URL
	 *
	 * @return string
	 */
	public function get_video_url() {
		return $this->get_argument( 'video_url' );
	}

	/**
	 * Get the option group
	 *
	 * @return string
	 */
	public function get_opt_group() {
		return $this->get_argument( 'opt_group' );
	}

	/**
	 * Get the variable from the supplied arguments
	 *
	 * @param string $variable Variable to retrieve.
	 * @param string $default  Default to use when variable not found.
	 *
	 * @return mixed|string
	 */
	protected function get_argument( $variable, $default = '' ) {
		return ! empty( $this->arguments[ $variable ] ) ? $this->arguments[ $variable ] : $default;
	}
}