Below, you’ll find a detailed guide on how to add the Glossary Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Glossary Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Glossary Plugin and the shortcodes it provides:
"Glossary by Codeat is a powerful WordPress plugin designed to create, manage and display a glossary of terms, abbreviations, or specialized language in a user-friendly way."
- [glossary_by_codeat]
Glossary [glossary_by_codeat] Shortcode
The Glossary-by-Codeat shortcode is a versatile tool that enables the addition of custom content within a site. It takes arguments, processes them, and outputs the desired content. The shortcode_output function is the heart of this shortcode. It accepts arguments and content, processes them, and then outputs the final content. It also handles the addition of CSS classes and attributes to the output. If the shortcode is enclosed, the enclosed content is added to the ‘html’ argument. It also handles the wrapping of the output in a div with a specific class. If there’s a title provided, it’s added before the main content. If the ‘no_wrap’ option is set, the output won’t be wrapped in a div. In preview mode, if the output is empty, a placeholder text is shown. Finally, the output is returned, after being filtered through ‘wp_super_duper_widget_output’.
Shortcode: [glossary_by_codeat]
Parameters
Here is a list of all possible glossary_by_codeat shortcode parameters and attributes:
args
– array of arguments that customize the shortcode’s outputcontent
– enclosed content to be added in the shortcode’s outputhtml
– additional HTML content to be included in the outputwidget_ops
– options for widget operations, including classnameclassname
– CSS class to be added to the output’s div wrapperno_wrap
– decides whether the content should be wrapped in a div or nottitle
– title of the shortcode’s output, wrapped based on sidebar settingsbefore_title
– HTML content to be added before the titleafter_title
– HTML content to be added after the title
Examples and Usage
Basic example – Showcases a simple implementation of the shortcode. The shortcode pulls in the widget based on the given ID.
[shortcode id="123" /]
Advanced examples
1. Using the shortcode to display a widget with a specific class. The ‘classname’ attribute is used to specify the class of the widget.
[shortcode id="123" classname="my-custom-class" /]
2. Utilizing the shortcode to display a widget without a wrapper. The ‘no_wrap’ attribute is set to ‘true’ to achieve this.
[shortcode id="123" no_wrap="true" /]
3. Implementing the shortcode to display a widget with a specific title. The ‘title’ attribute is used to set the title of the widget.
[shortcode id="123" title="My Custom Widget" /]
4. Using the shortcode to display a widget with custom HTML content. The ‘html’ attribute is used to specify the HTML content.
[shortcode id="123" html="Custom HTML content
" /]
These examples demonstrate the flexibility and power of shortcodes in WordPress. By adjusting the attributes, you can customize the output to suit your specific needs.
PHP Function Code
In case you have difficulties debugging what causing issues with [glossary_by_codeat]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( $this->sd->base_id, array( $this, 'shortcode_output' ) );
Shortcode PHP function:
function shortcode_output( $args = array(), $content = '' ) {
$args = $this->sd->argument_values( $args );
// Clean booleans.
$args = $this->sd->string_to_bool( $args );
// if we have a enclosed shortcode we add it to the special `html` argument
if ( ! empty( $content ) ) {
$args['html'] = $content;
}
$class = isset( $this->sd->options['widget_ops']['classname'] ) ? esc_attr( $this->sd->options['widget_ops']['classname'] ) : '';
$class .= " sdel-" . $this->sd->get_instance_hash();
$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this->sd, $this );
$class = apply_filters( 'wp_super_duper_div_classname_' . $this->sd->base_id, $class, $args, $this->sd, $this );
$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this->sd, $this );
$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->sd->base_id, $attrs, $args, $this->sd, $this );
$shortcode_args = array();
$output = '';
$no_wrap = ! empty( $this->sd->options['no_wrap'] ) || ! empty( $args['no_wrap'] );
$main_content = $this->sd->output( $args, $shortcode_args, $content );
if ( $main_content && ! $no_wrap ) {
// wrap the shortcode in a div with the same class as the widget
$output .= '<div class="' . esc_attr( $class ) . '" ' . $attrs . '>';
if ( ! empty( $args['title'] ) ) {
// if its a shortcode and there is a title try to grab the title wrappers
$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
if ( empty( $instance ) ) {
global $wp_registered_sidebars;
if ( ! empty( $wp_registered_sidebars ) ) {
foreach ( $wp_registered_sidebars as $sidebar ) {
if ( ! empty( $sidebar['before_title'] ) ) {
$shortcode_args['before_title'] = $sidebar['before_title'];
$shortcode_args['after_title'] = $sidebar['after_title'];
break;
}
}
}
}
$output .= $this->sd->output_title( $shortcode_args, $args );
}
$output .= $main_content;
$output .= '</div>';
} elseif ( $main_content && $no_wrap ) {
$output .= $main_content;
}
// if preview, show a placeholder if empty
if ( $this->sd->is_preview() && $output == '' ) {
$output = $this->sd->preview_placeholder_text( "{{" . $this->sd->base_id . "}}" );
}
return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
}
Code file location:
glossary-by-codeat/glossary-by-codeat/vendor/ayecode/wp-super-duper/type/shortcode.php
Conclusion
Now that you’ve learned how to embed the Glossary Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply