class-extension.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin
  6. */
  7. /**
  8. * Represents the values for a single Yoast Premium extension plugin.
  9. */
  10. class WPSEO_Extension {
  11. /**
  12. * Holds the extension config.
  13. *
  14. * @var array
  15. */
  16. protected $config = [];
  17. /**
  18. * WPSEO_Extension constructor.
  19. *
  20. * @param array $config The config to use.
  21. */
  22. public function __construct( array $config ) {
  23. $this->config = $config;
  24. }
  25. /**
  26. * Returns the product title.
  27. *
  28. * @return string The set title.
  29. */
  30. public function get_title() {
  31. return $this->config['title'];
  32. }
  33. /**
  34. * Returns the product title to display.
  35. *
  36. * @return string The title to display on the license page.
  37. */
  38. public function get_display_title() {
  39. return empty( $this->config['display_title'] ) ? $this->get_title() : $this->config['display_title'];
  40. }
  41. /**
  42. * Returns URL to the page where the product can be bought.
  43. *
  44. * @return string The buy url.
  45. */
  46. public function get_buy_url() {
  47. return $this->config['buyUrl'];
  48. }
  49. /**
  50. * Returns URL to the page with more info.
  51. *
  52. * @return string The url to the info page.
  53. */
  54. public function get_info_url() {
  55. return $this->config['infoUrl'];
  56. }
  57. /**
  58. * Returns the image.
  59. *
  60. * @return string The image.
  61. */
  62. public function get_image() {
  63. return $this->config['image'];
  64. }
  65. /**
  66. * Returns the buy button value if set, otherwise fallback to the title.
  67. *
  68. * @return string The buy button.
  69. */
  70. public function get_buy_button() {
  71. if ( isset( $this->config['buy_button'] ) ) {
  72. return $this->config['buy_button'];
  73. }
  74. return $this->get_title();
  75. }
  76. /**
  77. * Returns the benefits.
  78. *
  79. * @return array The array with benefits.
  80. */
  81. public function get_benefits() {
  82. return $this->config['benefits'];
  83. }
  84. }