title = $title; $this->banner_renderer = ( is_null( $banner_renderer ) ? new WPSEO_Admin_Banner_Renderer() : $banner_renderer ); } /** * Returns the title. * * @return string */ public function get_title() { return $this->title; } /** * Returns the description. * * @return string */ public function get_description() { return $this->description; } /** * Sets the description * * @param string $description The description. */ public function set_description( $description ) { $this->description = $description; } /** * Adds an admin banner. * * @param WPSEO_Admin_Banner $banner The banner to add. */ public function add_banner( WPSEO_Admin_Banner $banner ) { $this->banners[] = $banner; } /** * Renders the banner. * * @return string */ public function render_banner() { if ( ! $this->has_banners() ) { return ''; } return $this->banner_renderer->render( $this->get_random_banner() ); } /** * Checks if there are any banners set. * * @return bool */ public function has_banners() { return ! empty( $this->banners ); } /** * Returns a random banner. * * @return null|WPSEO_Admin_Banner */ protected function get_random_banner() { return $this->banners[ array_rand( $this->banners, 1 ) ]; } }