WPSEO_Admin_Help_Panel

Generates the HTML for an inline Help Button and Panel.

Defined (1)

The class is defined in the following location(s).

/admin/class-admin-help-panel.php  
  1. class WPSEO_Admin_Help_Panel { 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $id; 
  7.  
  8. /** 
  9. * @var string 
  10. */ 
  11. private $help_button_text; 
  12.  
  13. /** 
  14. * @var string 
  15. */ 
  16. private $help_content; 
  17.  
  18. /** 
  19. * @var string 
  20. */ 
  21. private $wrapper; 
  22.  
  23. /** 
  24. * Constructor. 
  25. * @param string $id Unique identifier of the element the inline help refers to, used as an identifier in the html. 
  26. * @param string $help_button_text The Help Button text. 
  27. * @param string $help_content The Help Panel content. 
  28. * @param string $wrapper Optional Whether to print out a container div element for the Help Panel, used for styling. 
  29. * Pass a `has-wrapper` value to print out the container. Default: no container. 
  30. */ 
  31. public function __construct( $id, $help_button_text, $help_content, $wrapper = '' ) { 
  32. $this->id = $id; 
  33. $this->help_button_text = $help_button_text; 
  34. $this->help_content = $help_content; 
  35. $this->wrapper = $wrapper; 
  36.  
  37. /** 
  38. * Returns the html for the Help Button. 
  39. * @return string 
  40. */ 
  41. public function get_button_html() { 
  42.  
  43. if ( ! $this->id || ! $this->help_button_text || ! $this->help_content ) { 
  44. return ''; 
  45.  
  46. return sprintf( 
  47. ' <button type="button" class="yoast_help yoast-help-button dashicons" id="%1$s-help-toggle" aria-expanded="false" aria-controls="%1$s-help"><span class="screen-reader-text">%2$s</span></button>',  
  48. esc_attr( $this->id ),  
  49. $this->help_button_text 
  50. ); 
  51.  
  52. /** 
  53. * Returns the html for the Help Panel. 
  54. * @return string 
  55. */ 
  56. public function get_panel_html() { 
  57.  
  58. if ( ! $this->id || ! $this->help_button_text || ! $this->help_content ) { 
  59. return ''; 
  60.  
  61. $wrapper_start = $wrapper_end = ''; 
  62.  
  63. if ( 'has-wrapper' === $this->wrapper ) { 
  64. $wrapper_start = '<div class="yoast-seo-help-container">'; 
  65. $wrapper_end = '</div>'; 
  66.  
  67. return sprintf( 
  68. '%1$s<p id="%2$s-help" class="yoast-help-panel">%3$s</p>%4$s',  
  69. $wrapper_start,  
  70. esc_attr( $this->id ),  
  71. $this->help_content,  
  72. $wrapper_end 
  73. );