Making WordPress.org

Changeset 11287


Ignore:
Timestamp:
10/20/2021 11:29:48 PM (3 years ago)
Author:
dd32
Message:

Support Forums: Make the forum search work for plugins that use pipe characters in their plugin name.

This may cause plugins to match other plugins with a similar plugin title prefix, but this is better than returning zero items.

This causes a plugin title such as 'Super Magical | Great Thing!' to simply search for all plugin threads for plugin titles starting with 'Super Magical'.

Props paapst.
Fixes #5932.

File:
1 edited

Legend:

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

    r11135 r11287  
    497497
    498498        /* translators: %s: link to plugin support or review forum */
    499         $object->prefixed_title = sprintf( __( 'Plugin: %s', 'wporg-forums' ), $object->post_title );
    500         $object->type           = 'plugin';
     499        $object->search_prefix = sprintf( __( 'Plugin: %s', 'wporg-forums' ), $object->post_title );
     500        $object->type          = 'plugin';
    501501    } elseif ( ! empty( $plugin_instance->themes->theme ) ) {
    502502        $object = $plugin_instance->themes->theme;
    503503
    504504        /* translators: %s: link to theme support or review forum */
    505         $object->prefixed_title = sprintf( __( 'Theme: %s', 'wporg-forums' ), $object->post_title );
    506         $object->type           = 'theme';
     505        $object->search_prefix = sprintf( __( 'Theme: %s', 'wporg-forums' ), $object->post_title );
     506        $object->type          = 'theme';
     507    }
     508
     509    // The search prefix must be sans any special characters.
     510    // This may cause some plugins to match other plugins of similar prefixed names.
     511    if ( ! empty( $object->search_prefix ) ) {
     512        $search_special_chars  = '|';
     513        $object->search_prefix = rtrim( strtok( $object->search_prefix, $search_special_chars ) );
    507514    }
    508515
Note: See TracChangeset for help on using the changeset viewer.