PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.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 / admin / metabox / class-metabox-collapsibles-section.php

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

64 lines 2.0 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 * Generates and displays a metabox tab that consists of collapsible sections.
10 */
11 class WPSEO_Metabox_Collapsibles_Sections extends WPSEO_Abstract_Metabox_Tab_With_Sections {
12
13 /**
14 * Holds the tab's collapsibles.
15 *
16 * @var WPSEO_Metabox_Collapsible[]
17 */
18 private $collapsibles = [];
19
20 /**
21 * Constructor.
22 *
23 * @param string $name The name of the section, used as an identifier in the html.
24 * Can only contain URL safe characters.
25 * @param string $link_content The text content of the section link.
26 * @param array $collapsibles The metabox collapsibles (`WPSEO_Metabox_Collapsible[]`) to be included in the section.
27 * @param array $options Optional link attributes.
28 */
29 public function __construct( $name, $link_content, array $collapsibles = [], array $options = [] ) {
30 parent::__construct( $name, $link_content, $options );
31
32 $this->collapsibles = $collapsibles;
33 }
34
35 /**
36 * Outputs the section content if any tab has been added.
37 */
38 public function display_content() {
39 if ( $this->has_sections() ) {
40 printf( '<div id="%1$s" class="wpseo-meta-section">', esc_attr( 'wpseo-meta-section-' . $this->name ) );
41 echo '<div class="wpseo_content_wrapper">';
42
43 add_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_forms' ] );
44 add_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_a11y' ] );
45 foreach ( $this->collapsibles as $collapsible ) {
46 echo wp_kses_post( $collapsible->content() );
47 }
48 remove_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_forms' ] );
49 remove_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_a11y' ] );
50
51 echo '</div></div>';
52 }
53 }
54
55 /**
56 * Checks whether the tab has any sections.
57 *
58 * @return bool Whether the tab has any sections
59 */
60 protected function has_sections() {
61 return ! empty( $this->collapsibles );
62 }
63 }
64