class-extension.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /** @var array */
  12. protected $config = array();
  13. /**
  14. * WPSEO_Extension constructor.
  15. *
  16. * @param array $config The config to use.
  17. */
  18. public function __construct( array $config ) {
  19. $this->config = $config;
  20. }
  21. /**
  22. * Returns the product title.
  23. *
  24. * @return string The set title.
  25. */
  26. public function get_title() {
  27. return $this->config['title'];
  28. }
  29. /**
  30. * Returns URL to the page where the product can be bought.
  31. *
  32. * @return string The buy url.
  33. */
  34. public function get_buy_url() {
  35. return $this->config['buyUrl'];
  36. }
  37. /**
  38. * Returns URL to the page with more info.
  39. *
  40. * @return string The url to the info page.
  41. */
  42. public function get_info_url() {
  43. return $this->config['infoUrl'];
  44. }
  45. /**
  46. * Returns the image.
  47. *
  48. * @return string The image.
  49. */
  50. public function get_image() {
  51. return $this->config['image'];
  52. }
  53. /**
  54. * Returns the buy button value if set, otherwise fallback to the title.
  55. *
  56. * @return string The buy button.
  57. */
  58. public function get_buy_button() {
  59. if ( isset( $this->config['buy_button'] ) ) {
  60. return $this->config['buy_button'];
  61. }
  62. return $this->get_title();
  63. }
  64. /**
  65. * Returns the benefits.
  66. *
  67. * @return array The array with benefits.
  68. */
  69. public function get_benefits() {
  70. return $this->config['benefits'];
  71. }
  72. }