PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.2
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 / url-list-presenter.php

url-list-presenter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.2, at src/presenters/url-list-presenter.php

63 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;
4
5 /**
6 * Presenter class for the URL list.
7 */
8 class Url_List_Presenter extends Abstract_Presenter {
9
10 /**
11 * If the url should be target blank.
12 *
13 * @var bool
14 */
15 private $target_blank;
16
17 /**
18 * A list of arrays containing titles and URLs.
19 *
20 * @var array
21 */
22 private $links;
23
24 /**
25 * Classname for the URL list.
26 *
27 * @var string
28 */
29 private $class_name;
30
31 /**
32 * Url_List_Presenter constructor.
33 *
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.
37 */
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;
42 }
43
44 /**
45 * Presents the URL list.
46 *
47 * @return string The URL list.
48 */
49 public function present() {
50 $output = '<ul class="' . $this->class_name . '">';
51 foreach ( $this->links as $link ) {
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>';
57 }
58 $output .= '</ul>';
59
60 return $output;
61 }
62 }
63