Glossary index shortcode issue
-
iThoughts Tooltip Glossary is my choice for implementing a Glossary and subglossaries in my site. It is really easy to use, pretty customizable, and works quite well. I only miss the ability to associate categories and tags to each term of the glossary.
Now I got that the “Add a Glossary Index” button from the TinyMCE Editor just puts a blank character ” ” in page.
I then tried to manually insert the two shortcodes “[Glossary A-to-Z]” and “[Glossary List]” shown in the screenshorts provided, but to no avail.
Then, from the code of the plugin, I figured out that the right shortcodes are “[glossary_atoz]” and “[glossary_term_list]”. So I tried these ones instead and the two types of glossary indexes were rightly displayed in the frontend.
But I got also the following warnings:
Warning: count(): Parameter must be an array or an object that implements Countable in /…/wp-content/plugins/ithoughts-tooltip-glossary/class/shortcode/class-glossarylist.php on line 153
… on line 189
… on line 215
… on line 153
… on line 189
… on line 215
Warning: count(): Parameter must be an array or an object that implements Countable in /…/wp-content/plugins/ithoughts-tooltip-glossary/class/shortcode/class-termlist.php on line 104
… on line 104
… on line 104
… on line 104
(I suppose that the duplicity of warnings is due to the presence of the two shortcodes).
So I resorted to the next page from the author: https://www.gerkindevelopment.net/en/tips/shortcodes-post-excerpts/ were I read that: “Sometimes, depending on your theme and configuration, your shortcodes contents are stripped out with the shortcode itself.”
Following the directions there given, I inserted the following code in my child-theme’s functions.php file:
// SOLVING AN ISSUE WITH THE REPLACE SHORTCODES OF ITHOUGHTS TOOLTIP GLOSSARY function keep_shortcodes_content($content = ""){ ????$replacedShortcodes = array( '/[(glossary_atoz|glossary_term_list|glossary-(?:mediatip|tooltip|glossary))(?:.*?)(?:/]|](.*?)[/1])/' => "$2" ); $original = $content; ????if ( '' == $content ) { ????????$content = get_the_content(''); ????????foreach($replacedShortcodes as $regex => $replace){ ????????????$content = preg_replace($regex, $replace, $content); ????????} ????????$content = strip_shortcodes( $content ); ????????$content = apply_filters('the_content', $content); ????????$excerpt_length = apply_filters('excerpt_length', 55); ????????$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); ????????$content = wp_trim_words( $content, $excerpt_length, $excerpt_more ); ????} ????return apply_filters('wp_trim_excerpt', $content, $original); } remove_filter( 'get_the_excerpt', 'wp_trim_excerpt'??); add_filter( 'get_the_excerpt', "keep_shortcodes_content" );
The result was then the following error message:
Parse error: syntax error, unexpected ‘$replacedShortcodes’ (T_VARIABLE) in /…/wp-content/themes/responsivepro-child/functions.php on line 45
I would appreciate any help to fix this issue. Thank you very much.
- The topic ‘Glossary index shortcode issue’ is closed to new replies.