PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wordpress-seo/admin/class-option-tab.php

https://bitbucket.org/carloskikea/helpet
PHP | 91 lines | 29 code | 11 blank | 51 comment | 0 complexity | 7a8a5524c8e7aab524427c9b1676e657 MD5 | raw file
 1<?php
 2/**
 3 * WPSEO plugin file.
 4 *
 5 * @package WPSEO\Admin\Options\Tabs
 6 */
 7
 8/**
 9 * Class WPSEO_Option_Tab
10 */
11class WPSEO_Option_Tab {
12
13	/** @var string Name of the tab */
14	private $name;
15
16	/** @var string Label of the tab */
17	private $label;
18
19	/** @var array Optional arguments */
20	private $arguments;
21
22	/**
23	 * WPSEO_Option_Tab constructor.
24	 *
25	 * @param string $name      Name of the tab.
26	 * @param string $label     Localized label of the tab.
27	 * @param array  $arguments Optional arguments.
28	 */
29	public function __construct( $name, $label, array $arguments = array() ) {
30		$this->name      = sanitize_title( $name );
31		$this->label     = $label;
32		$this->arguments = $arguments;
33	}
34
35	/**
36	 * Gets the name.
37	 *
38	 * @return string The name.
39	 */
40	public function get_name() {
41		return $this->name;
42	}
43
44	/**
45	 * Gets the label.
46	 *
47	 * @return string The label.
48	 */
49	public function get_label() {
50		return $this->label;
51	}
52
53	/**
54	 * Gets the video URL.
55	 *
56	 * @return string The video url.
57	 */
58	public function get_video_url() {
59		return $this->get_argument( 'video_url' );
60	}
61
62	/**
63	 * Retrieves whether the tab needs a save button.
64	 *
65	 * @return bool True whether the tabs needs a save button.
66	 */
67	public function has_save_button() {
68		return (bool) $this->get_argument( 'save_button', true );
69	}
70
71	/**
72	 * Gets the option group.
73	 *
74	 * @return string The option group.
75	 */
76	public function get_opt_group() {
77		return $this->get_argument( 'opt_group' );
78	}
79
80	/**
81	 * Retrieves the variable from the supplied arguments.
82	 *
83	 * @param string       $variable Variable to retrieve.
84	 * @param string|mixed $default  Default to use when variable not found.
85	 *
86	 * @return mixed|string The retrieved variable.
87	 */
88	protected function get_argument( $variable, $default = '' ) {
89		return array_key_exists( $variable, $this->arguments ) ? $this->arguments[ $variable ] : $default;
90	}
91}