| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Presenters; |
| 4 |
|
| 5 |
/** |
| 6 |
* Presenter class for a score icon. |
| 7 |
*/ |
| 8 |
class Score_Icon_Presenter extends Abstract_Presenter { |
| 9 |
|
| 10 |
/** |
| 11 |
* Holds the title. |
| 12 |
* |
| 13 |
* @var string |
| 14 |
*/ |
| 15 |
protected $title; |
| 16 |
|
| 17 |
/** |
| 18 |
* Holds the CSS class. |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
protected $css_class; |
| 23 |
|
| 24 |
/** |
| 25 |
* Constructs a Score_Icon_Presenter. |
| 26 |
* |
| 27 |
* @param string $title The title and screen reader text. |
| 28 |
* @param string $css_class The CSS class. |
| 29 |
*/ |
| 30 |
public function __construct( $title, $css_class ) { |
| 31 |
$this->title = $title; |
| 32 |
$this->css_class = $css_class; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Presents the score icon. |
| 37 |
* |
| 38 |
* @return string The score icon. |
| 39 |
*/ |
| 40 |
public function present() { |
| 41 |
return \sprintf( |
| 42 |
'<div aria-hidden="true" title="%1$s" class="wpseo-score-icon %3$s"><span class="wpseo-score-text screen-reader-text">%2$s</span></div>', |
| 43 |
\esc_attr( $this->title ), |
| 44 |
\esc_html( $this->title ), |
| 45 |
\esc_attr( $this->css_class ), |
| 46 |
); |
| 47 |
} |
| 48 |
} |
| 49 |
|