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

95 lines
1.7 KiB
PHP
Raw Normal View History

2017-06-13 09:45:37 +02:00
<?php
/**
2018-12-04 14:01:14 +01:00
* WPSEO plugin file.
*
2017-06-13 09:45:37 +02:00
* @package WPSEO\Admin\Options\Tabs
*/
/**
2021-08-04 17:09:29 +02:00
* Class WPSEO_Option_Tab.
2017-06-13 09:45:37 +02:00
*/
class WPSEO_Option_Tab {
2021-08-04 17:09:29 +02:00
/**
* Name of the tab.
*
* @var string
*/
2017-06-13 09:45:37 +02:00
private $name;
2021-08-04 17:09:29 +02:00
/**
* Label of the tab.
*
* @var string
*/
2017-06-13 09:45:37 +02:00
private $label;
2021-08-04 17:09:29 +02:00
/**
* Optional arguments.
*
* @var array
*/
2018-12-04 14:01:14 +01:00
private $arguments;
2017-06-13 09:45:37 +02:00
/**
* WPSEO_Option_Tab constructor.
*
* @param string $name Name of the tab.
2018-12-04 14:01:14 +01:00
* @param string $label Localized label of the tab.
2017-06-13 09:45:37 +02:00
* @param array $arguments Optional arguments.
*/
2021-08-04 17:09:29 +02:00
public function __construct( $name, $label, array $arguments = [] ) {
2017-06-13 09:45:37 +02:00
$this->name = sanitize_title( $name );
$this->label = $label;
2018-12-04 14:01:14 +01:00
$this->arguments = $arguments;
2017-06-13 09:45:37 +02:00
}
/**
2018-12-04 14:01:14 +01:00
* Gets the name.
2017-06-13 09:45:37 +02:00
*
2018-12-04 14:01:14 +01:00
* @return string The name.
2017-06-13 09:45:37 +02:00
*/
public function get_name() {
return $this->name;
}
/**
2018-12-04 14:01:14 +01:00
* Gets the label.
2017-06-13 09:45:37 +02:00
*
2018-12-04 14:01:14 +01:00
* @return string The label.
2017-06-13 09:45:37 +02:00
*/
public function get_label() {
return $this->label;
}
/**
2018-12-04 14:01:14 +01:00
* Retrieves whether the tab needs a save button.
2017-06-13 09:45:37 +02:00
*
2018-12-04 14:01:14 +01:00
* @return bool True whether the tabs needs a save button.
*/
public function has_save_button() {
return (bool) $this->get_argument( 'save_button', true );
}
/**
* Gets the option group.
*
* @return string The option group.
2017-06-13 09:45:37 +02:00
*/
public function get_opt_group() {
return $this->get_argument( 'opt_group' );
}
/**
2018-12-04 14:01:14 +01:00
* Retrieves the variable from the supplied arguments.
2017-06-13 09:45:37 +02:00
*
2018-12-04 14:01:14 +01:00
* @param string $variable Variable to retrieve.
* @param string|mixed $default Default to use when variable not found.
2017-06-13 09:45:37 +02:00
*
2018-12-04 14:01:14 +01:00
* @return mixed|string The retrieved variable.
2017-06-13 09:45:37 +02:00
*/
protected function get_argument( $variable, $default = '' ) {
2018-12-04 14:01:14 +01:00
return array_key_exists( $variable, $this->arguments ) ? $this->arguments[ $variable ] : $default;
2017-06-13 09:45:37 +02:00
}
}