PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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
← All changes | src/presenters/url-list-presenter.php +20 -6 18.1 → trunk View file →
@@ -7,8 +7,15 @@
7 7 */
8 8 class Url_List_Presenter extends Abstract_Presenter {
9 9
10 10 /**
11 + * If the url should be target blank.
12 + *
13 + * @var bool
14 + */
15 + private $target_blank;
16 +
17 + /**
11 18 * A list of arrays containing titles and URLs.
12 19 *
13 20 * @var array
14 21 */
@@ -23,14 +30,16 @@
23 30
24 31 /**
25 32 * Url_List_Presenter constructor.
26 33 *
27 - * @param array $links A list of arrays containing titles and urls.
28 - * @param string $class_name Classname for the url list.
34 + * @param array $links A list of arrays containing titles and urls.
35 + * @param string $class_name Classname for the url list.
36 + * @param bool $target_blank If the url should be target blank.
29 37 */
30 - public function __construct( $links, $class_name = 'yoast-url-list' ) {
31 - $this->links = $links;
32 - $this->class_name = $class_name;
38 + public function __construct( $links, $class_name = 'yoast-url-list', $target_blank = false ) {
39 + $this->links = $links;
40 + $this->class_name = $class_name;
41 + $this->target_blank = $target_blank;
33 42 }
34 43
35 44 /**
36 45 * Presents the URL list.
@@ -39,10 +48,15 @@
39 48 */
40 49 public function present() {
41 50 $output = '<ul class="' . $this->class_name . '">';
42 51 foreach ( $this->links as $link ) {
43 - $output .= '<li><a href="' . $link['permalink'] . '">' . $link['title'] . '</a></li>';
52 + $output .= '<li><a';
53 + if ( $this->target_blank ) {
54 + $output .= ' target = "_blank"';
55 + }
56 + $output .= ' href="' . \esc_url( $link['permalink'] ) . '">' . \esc_html( $link['title'] ) . '</a></li>';
44 57 }
45 58 $output .= '</ul>';
59 +
46 60 return $output;
47 61 }
48 62 }