PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.4
28.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 All 130 releases
wordpress-seo / admin / metabox / class-abstract-sectioned-metabox-tab.php

class-abstract-sectioned-metabox-tab.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.4, at admin/metabox/class-abstract-sectioned-metabox-tab.php

98 lines 2.3 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
6 */
7
8 /**
9 * Base class for metabox that consist of multiple sections.
10 */
11 abstract class WPSEO_Abstract_Metabox_Tab_With_Sections implements WPSEO_Metabox_Section {
12
13 /**
14 * Holds the name of the tab.
15 *
16 * @var string
17 */
18 public $name;
19
20 /**
21 * Holds the HTML of the tab header.
22 *
23 * @var string
24 */
25 protected $link_content;
26
27 /**
28 * Holds the name of the tab header.
29 *
30 * @var string
31 */
32 protected $link_title;
33
34 /**
35 * Holds the classname of the tab header.
36 *
37 * @var string
38 */
39 protected $link_class;
40
41 /**
42 * Holds the aria label of the tab header.
43 *
44 * @var string
45 */
46 protected $link_aria_label;
47
48 /**
49 * Constructor.
50 *
51 * @param string $name The name of the section, used as an identifier in the html.
52 * Can only contain URL safe characters.
53 * @param string $link_content The text content of the section link.
54 * @param array $options Optional link attributes.
55 */
56 public function __construct( $name, $link_content, array $options = [] ) {
57 $default_options = [
58 'link_title' => '',
59 'link_class' => '',
60 'link_aria_label' => '',
61 ];
62
63 $options = array_merge( $default_options, $options );
64
65 $this->name = $name;
66
67 $this->link_content = $link_content;
68 $this->link_title = $options['link_title'];
69 $this->link_class = $options['link_class'];
70 $this->link_aria_label = $options['link_aria_label'];
71 }
72
73 /**
74 * Outputs the section link if any section has been added.
75 *
76 * @return void
77 */
78 public function display_link() {
79 if ( $this->has_sections() ) {
80 printf(
81 '<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>%5$s</a></li>',
82 esc_attr( $this->name ),
83 esc_attr( $this->link_class ),
84 ( $this->link_title !== '' ) ? ' title="' . esc_attr( $this->link_title ) . '"' : '',
85 ( $this->link_aria_label !== '' ) ? ' aria-label="' . esc_attr( $this->link_aria_label ) . '"' : '',
86 $this->link_content,
87 );
88 }
89 }
90
91 /**
92 * Checks whether the tab has any sections.
93 *
94 * @return bool Whether the tab has any sections
95 */
96 abstract protected function has_sections();
97 }
98