/admin/banner/class-admin-banner-sidebar-renderer.php

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