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
wordpress-seo / admin / metabox / class-metabox-section-additional.php

class-metabox-section-additional.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at admin/metabox/class-metabox-section-additional.php

110 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin\Metabox
6 */
7
8 /**
9 * Generates and displays an additional metabox section.
10 */
11 class WPSEO_Metabox_Section_Additional implements WPSEO_Metabox_Section {
12
13 /**
14 * Name of the section, used as an identifier in the HTML.
15 *
16 * @var string
17 */
18 public $name;
19
20 /**
21 * Content of the tab's section.
22 *
23 * @var string
24 */
25 public $content;
26
27 /**
28 * HTML to use in the tab header.
29 *
30 * @var string
31 */
32 private $link_content;
33
34 /**
35 * Class to add to the link.
36 *
37 * @var string
38 */
39 private $link_class;
40
41 /**
42 * Aria label to use for the link.
43 *
44 * @var string
45 */
46 private $link_aria_label;
47
48 /**
49 * Represents the content class.
50 *
51 * @var string
52 */
53 private $content_class;
54
55 /**
56 * Constructor.
57 *
58 * @param string $name The name of the section, used as an identifier in the html.
59 * Can only contain URL safe characters.
60 * @param string $link_content The text content of the section link.
61 * @param string $content Optional. Content to use above the React root element.
62 * @param array $options Optional link attributes.
63 */
64 public function __construct( $name, $link_content, $content = '', array $options = [] ) {
65 $this->name = $name;
66 $this->content = $content;
67 $default_options = [
68 'link_class' => '',
69 'link_aria_label' => '',
70 'content_class' => 'wpseo-form',
71 ];
72 $options = wp_parse_args( $options, $default_options );
73 $this->link_content = $link_content;
74 $this->link_class = $options['link_class'];
75 $this->link_aria_label = $options['link_aria_label'];
76 $this->content_class = $options['content_class'];
77 }
78
79 /**
80 * Outputs the section link.
81 *
82 * @return void
83 */
84 public function display_link() {
85 printf(
86 '<li role="presentation"><a role="tab" href="#wpseo-meta-section-%1$s" id="wpseo-meta-tab-%1$s" aria-controls="wpseo-meta-section-%1$s" class="wpseo-meta-section-link %2$s"%3$s>%4$s</a></li>',
87 esc_attr( $this->name ),
88 esc_attr( $this->link_class ),
89 ( $this->link_aria_label !== '' ) ? ' aria-label="' . esc_attr( $this->link_aria_label ) . '"' : '',
90 $this->link_content,
91 );
92 }
93
94 /**
95 * Outputs the section content.
96 *
97 * @return void
98 */
99 public function display_content() {
100 $html = sprintf(
101 '<div role="tabpanel" id="wpseo-meta-section-%1$s" aria-labelledby="wpseo-meta-tab-%1$s" tabindex="0" class="wpseo-meta-section %2$s">',
102 esc_attr( $this->name ),
103 esc_attr( $this->content_class ),
104 );
105 $html .= $this->content;
106 $html .= '</div>';
107 echo $html;
108 }
109 }
110