WPSEO_Admin_Banner_Sidebar_Renderer

Represents the render object for generating the html for the banner sidebar.

Defined (1)

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

/admin/banner/class-admin-banner-sidebar-renderer.php  
  1. class WPSEO_Admin_Banner_Sidebar_Renderer { 
  2.  
  3. /** @var WPSEO_Admin_Banner_Spot_Renderer */ 
  4. protected $spot_renderer; 
  5.  
  6. /** 
  7. * Sets the spot renderer. 
  8. * @param WPSEO_Admin_Banner_Spot_Renderer $spot_renderer The spot renderer that has to be used. 
  9. */ 
  10. public function __construct( WPSEO_Admin_Banner_Spot_Renderer $spot_renderer ) { 
  11. $this->spot_renderer = $spot_renderer; 
  12.  
  13. /** 
  14. * Renders the admin banner sidebar. 
  15. * @param WPSEO_Admin_Banner_Sidebar $banner_sidebar The sidebar to render. 
  16. * @return string 
  17. */ 
  18. public function render( WPSEO_Admin_Banner_Sidebar $banner_sidebar ) { 
  19. return sprintf( ' 
  20. <div class="wpseo_content_cell" id="sidebar-container"> 
  21. <div id="sidebar"> 
  22. <div class="wpseo_content_cell_title yoast-sidebar__title "> 
  23. %1$s 
  24. </div> 
  25. %2$s 
  26. </div> 
  27. </div>',  
  28. $banner_sidebar->get_title(),  
  29. $this->render_banner_spots( $banner_sidebar->get_banner_spots() ) 
  30. ); 
  31.  
  32. /** 
  33. * Renders the admin banner spots. 
  34. * @param WPSEO_Admin_Banner_Spot[] $banner_spots The banner spots to render. 
  35. * @return string 
  36. */ 
  37. protected function render_banner_spots( array $banner_spots ) { 
  38. $return = ''; 
  39. foreach ( $banner_spots as $banner_spot ) { 
  40. $return .= $this->spot_renderer->render( $banner_spot ); 
  41.  
  42. return $return;