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-collapsibles-section.php

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

66 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 * @return void
39 */
40 public function display_content() {
41 if ( $this->has_sections() ) {
42 printf( '<div id="%1$s" class="wpseo-meta-section">', esc_attr( 'wpseo-meta-section-' . $this->name ) );
43 echo '<div class="wpseo_content_wrapper">';
44
45 add_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_forms' ] );
46 add_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_a11y' ] );
47 foreach ( $this->collapsibles as $collapsible ) {
48 echo wp_kses_post( $collapsible->content() );
49 }
50 remove_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_forms' ] );
51 remove_filter( 'wp_kses_allowed_html', [ 'WPSEO_Utils', 'extend_kses_post_with_a11y' ] );
52
53 echo '</div></div>';
54 }
55 }
56
57 /**
58 * Checks whether the tab has any sections.
59 *
60 * @return bool Whether the tab has any sections
61 */
62 protected function has_sections() {
63 return ! empty( $this->collapsibles );
64 }
65 }
66