/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. * Class WPSEO_Option_Tab
  9. */
  10. class WPSEO_Option_Tab {
  11. /** @var string Name of the tab */
  12. private $name;
  13. /** @var string Label of the tab */
  14. private $label;
  15. /** @var array Optional arguments */
  16. private $arguments;
  17. /**
  18. * WPSEO_Option_Tab constructor.
  19. *
  20. * @param string $name Name of the tab.
  21. * @param string $label Localized label of the tab.
  22. * @param array $arguments Optional arguments.
  23. */
  24. public function __construct( $name, $label, array $arguments = array() ) {
  25. $this->name = sanitize_title( $name );
  26. $this->label = $label;
  27. $this->arguments = $arguments;
  28. }
  29. /**
  30. * Gets the name.
  31. *
  32. * @return string The name.
  33. */
  34. public function get_name() {
  35. return $this->name;
  36. }
  37. /**
  38. * Gets the label.
  39. *
  40. * @return string The label.
  41. */
  42. public function get_label() {
  43. return $this->label;
  44. }
  45. /**
  46. * Gets the video URL.
  47. *
  48. * @return string The video url.
  49. */
  50. public function get_video_url() {
  51. return $this->get_argument( 'video_url' );
  52. }
  53. /**
  54. * Retrieves whether the tab needs a save button.
  55. *
  56. * @return bool True whether the tabs needs a save button.
  57. */
  58. public function has_save_button() {
  59. return (bool) $this->get_argument( 'save_button', true );
  60. }
  61. /**
  62. * Gets the option group.
  63. *
  64. * @return string The option group.
  65. */
  66. public function get_opt_group() {
  67. return $this->get_argument( 'opt_group' );
  68. }
  69. /**
  70. * Retrieves the variable from the supplied arguments.
  71. *
  72. * @param string $variable Variable to retrieve.
  73. * @param string|mixed $default Default to use when variable not found.
  74. *
  75. * @return mixed|string The retrieved variable.
  76. */
  77. protected function get_argument( $variable, $default = '' ) {
  78. return array_key_exists( $variable, $this->arguments ) ? $this->arguments[ $variable ] : $default;
  79. }
  80. }