PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / presenters / admin / beta-badge-presenter.php

beta-badge-presenter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.6, at src/presenters/admin/beta-badge-presenter.php

60 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Presenters\Admin;
4
5 use Yoast\WP\SEO\Presenters\Abstract_Presenter;
6
7 /**
8 * Represents the presenter class for "Beta" badges.
9 */
10 class Beta_Badge_Presenter extends Abstract_Presenter {
11
12 /**
13 * Identifier of the badge.
14 *
15 * @var string
16 */
17 private $id;
18
19 /**
20 * Optional link of the badge.
21 *
22 * @var string
23 */
24 private $link;
25
26 /**
27 * Beta_Badge_Presenter constructor.
28 *
29 * @param string $id Id of the badge.
30 * @param string $link Optional link of the badge.
31 */
32 public function __construct( $id, $link = '' ) {
33 $this->id = $id;
34 $this->link = $link;
35 }
36
37 /**
38 * Presents the Beta Badge. If a link has been passed, the badge is presented with the link.
39 * Otherwise a static badge is presented.
40 *
41 * @return string The styled Beta Badge.
42 */
43 public function present() {
44 if ( $this->link !== '' ) {
45 return \sprintf(
46 '<a class="yoast-badge yoast-badge__is-link yoast-beta-badge" id="%1$s-beta-badge" href="%2$s">%3$s</a>',
47 \esc_attr( $this->id ),
48 \esc_url( $this->link ),
49 'Beta', // We don't want this string to be translatable.
50 );
51 }
52
53 return \sprintf(
54 '<span class="yoast-badge yoast-beta-badge" id="%1$s-beta-badge">%2$s</span>',
55 \esc_attr( $this->id ),
56 'Beta', // We don't want this string to be translatable.
57 );
58 }
59 }
60