Making WordPress.org


Ignore:
Timestamp:
02/09/2023 09:36:57 PM (4 years ago)
Author:
ryelle
Message:

Handbooks: Add a filter to disable the Table of Contents HTML.

The redesigned sites will use the Table of Contents block, so they need a method for disabling the native handbook ToC.

Fixes https://github.com/WordPress/wporg-developer/issues/204.
See [12327] for the same change to HelpHub.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php

    r12138 r12392  
    8585
    8686        public function load_filters() {
    87                 if ( is_singular( $this->post_types ) && ! is_embed() ) {
     87                $page_supports_toc = is_singular( $this->post_types ) && ! is_embed();
     88
     89                /**
     90                 * Filter whether the table of contents should be injected into the page.
     91                 *
     92                 * @param bool $page_supports_toc True if the current page supports a table of contents.
     93                 */
     94                $should_add_toc = apply_filters( 'wporg_handbook_toc_should_add_toc', $page_supports_toc );
     95
     96                if ( $should_add_toc ) {
    8897                        add_filter( 'the_content', array( $this, 'add_toc' ) );
    8998                }
Note: See TracChangeset for help on using the changeset viewer.