class-field-suggestions.php 1007 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\ConfigurationUI
  6. */
  7. /**
  8. * Holds the suggestions for the 'You might also like' page in the wizard.
  9. */
  10. class WPSEO_Config_Field_Suggestions extends WPSEO_Config_Field {
  11. /**
  12. * WPSEO_Config_Field_Suggestions constructor.
  13. */
  14. public function __construct() {
  15. parent::__construct( 'suggestions', 'Suggestions' );
  16. $this->properties['suggestions'] = [];
  17. }
  18. /**
  19. * Adds a suggestion to the properties.
  20. *
  21. * @param string $title The title of the choice.
  22. * @param string $copy The text explaining the choice.
  23. * @param array $button The button details.
  24. * @param array $video URL and title of the video accompanying the choice.
  25. */
  26. public function add_suggestion( $title, $copy, $button, array $video = [] ) {
  27. $suggestion = [
  28. 'title' => $title,
  29. 'copy' => $copy,
  30. 'button' => $button,
  31. ];
  32. if ( ! empty( $video ) ) {
  33. $suggestion['video'] = $video;
  34. }
  35. $this->properties['suggestions'][] = $suggestion;
  36. }
  37. }