Plugin Filters

Basic

This code will disable the alert about localization of the plugin on translate.wordpress.org.

add_filter( 'glossary_alert_localization', '__return_false' );

This two filters enable you to add a custom theme inside the Glossary settings. The first one enable you to set a theme name and show it in the native plugin's dashboard. The second one is the URL of the CSS file to enqueue on the front-end.

add_filter(
    'glossary_themes_dropdown',
    array(
        'beautiful' => 'My beautiful theme',
    )
);
add_filter( 'glossary_themes_url', 
    array(
        'beautiful' => 'url to your css file to enqueue in the page'
    )
);

Modifying this snippet is possible to alter the excerpt added in the tooltips

add_filter( 'glossary_excerpt', function( $excerpt, $post_id ) {
    return $excerpt
}, 10, 2 );

Adding this line of code is possible to add the support to buddypress. We didn't add an option because we are not supporting this officially.

add_filter( 'glossary_buddypress_support', '__return_true' );

This filter enables to change the regex used by glossary for the first search inside the content before to move on the other part of the algorithm.

add_filter( 'glossary_regex', function( $regex, $term ) {
    return $regex;
}, 10, 2 );

Filter to interact with the tooltip HTML.

/**
 * Filter the HTML generated
 *
 * string $tooltip The tooltip.
 * string $excerpt The excerpt.
 * string $photo   Photo.
 * string $post    The post object.
 * string $noreadmore The internal html link.
 *
 * @return string $html The tooltip filtered.
 */
add_filter( 'glossary_tooltip_html', function( $tooltip, $excerpt, $photo, $post_id, $noreadmore ) {
    return $tooltip;
}, 10, 5 );

Eg. How to print in a tooltip the price of a WooCommerce product.

add_filter( 'glossary_tooltip_html', function( $tooltip, $excerpt, $photo, $post_id, $noreadmore ) {
    if ( is_product( $post_id ) ) {
        $product = wc_get_product( $post_id );
        return $tooltip . $product->get_price() . '€';
    }
    return $tooltip;
}, 10, 5 );

Eg. How to print in a tooltip the term title.

add_filter( 'glossary_tooltip_html', function( $tooltip, $excerpt, $photo, $post_id, $noreadmore ) {
    return get_the_title( $post_id ) . $tooltip;
}, 10, 5 );

Run Glossary auto-link in specific taxonomies, archives or post types

add_filter( 'glossary_is_page_to_parse', 'inject_glossary_tax' , 9999 );

function inject_glossary_tax( $bool ) {
    if ( is_tax('book_author') || is_post_type_archive('book') ) {
        return true;
    }

    return $bool;
}

Add your custom tooltip theme

Using this filter you can add your own custom tooltip theme directly in the settings dropdown.

\add_filter( 'glossary_themes_url', 'add_glossary_url' );

function add_glossary_url( array $themes ) {
    $themes[ 'newtheme' ] = "https://urlofyourtooltiptheme.css";

    return $themes;
}

Create a new tooltip theme name

\add_filter(' glossary_themes_dropdown', 'add_glossary_name' );
function add_glossary_name( $themes ) {
    $themes[ 'newtheme' ] = "New theme";

    return $themes;
}

Advanced

Add/Remove classes from the plugin loading.

add_filter( 'glossary_classes_to_execute', function( classes ) {
    return $classes;
}, 10, 1 );

Only for PRO users

Change the separator in the Alphabetical Index shortcode.

add_filter( 'glossary_list_excerpt_separator', function() {
    return ' > ';
} );

You can use this filter in order to add/remove meta keys before print them inside the content of an article.

add_filter( 'glossary_customizer_fields_list', function( $fields ) {
    return $fields;
}, 10, 1 );

WooCommerce

Support for WooCommerce short description

add_filter( 'woocommerce_short_description', function( $excerpt ) {
    $search_engine = new Core\Search_Engine;        
    return $search_engine->auto_link( $excerpt );
}, 10, 1 );