Making WordPress.org

Changeset 5720


Ignore:
Timestamp:
07/26/2017 05:27:10 PM (7 years ago)
Author:
coffee2code
Message:

Breathe: Disable showing linked mentions on any handbook page.

Only current exception is a "Credits" page.

A more involved approach (to include clearing meta-cached data) would be needed to more efficiently prevent mentions from being looked for in the first place.

Fixes #2932.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/functions.php

    r5683 r5720  
    151151}
    152152add_filter( 'nav_menu_item_args', __NAMESPACE__ . '\add_screen_reader_text_for_icon_menu_items', 10, 2 );
     153
     154/**
     155 * Disables Jetpack Mentions on any handbook page or comment.
     156 *
     157 * More precisely, this prevents the linked mentions from being shown. A more
     158 * involved approach (to include clearing meta-cached data) would be needed to
     159 * more efficiently prevent mentions from being looked for in the first place.
     160 *
     161 * @param string $linked  The linked mention.
     162 * @param string $mention The term being mentioned.
     163 * @return string
     164 */
     165function disable_mentions_for_handbook( $linked, $mention ) {
     166    if ( function_exists( 'wporg_is_handbook' ) && wporg_is_handbook() && ! is_single( 'credits' ) ) {
     167        return '@' . $mention;
     168    }
     169
     170    return $linked;
     171}
     172add_filter( 'jetpack_mentions_linked_mention', __NAMESPACE__ . '\disable_mentions_for_handbook', 10, 2 );
     173
Note: See TracChangeset for help on using the changeset viewer.