Betterdocs Shortcode

Below, you’ll find a detailed guide on how to add the Betterdocs 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 Betterdocs Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Betterdocs Plugin and the shortcodes it provides:

Plugin Icon
BetterDocs – Best Documentation & Knowledge Base Plugin

"BetterDocs is a leading documentation & knowledge base plugin for WordPress. It simplifies the process of creating, organizing, and managing online documents, providing a seamless user experience."

★★★★☆ (256) Active Installs: 30000+ Tested with: 6.3.2 PHP Version: 7.0
Included Shortcodes:
  • [betterdocs_shortcode]

Betterdocs [betterdocs_shortcode] Shortcode

The BetterDocs shortcode is a powerful tool that dynamically renders content on your WordPress site. It uses hooks to ensure smooth operation. This shortcode initiates scripts, removes deprecated attributes, and transforms attribute types. It sets and resets attributes, ensuring optimal performance. It uses action hooks before loading the shortcode and rendering the content. The content is then stored and returned after rendering.

Shortcode: [betterdocs_shortcode]

Examples and Usage

Basic example – A simple usage of the BetterDocs shortcode to render a document using its ID.

[betterdocs id=123 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [betterdocs_shortcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( $shortcode->get_name(), [$shortcode, 'render_with_hooks'] );

Shortcode PHP function:

function render_with_hooks( $atts, $content = null ) {
        $this->enqueue_scripts();

        $atts = $this->remove_deprecated_attributes( $atts );
        $this->transform_attribute_types( $atts );

        $this->client_attributes = empty( $atts ) ? [] : $atts;
        do_action( 'betterdocs_before_shortcode_load', $this );
        $this->set_attributes( $atts );

        // reset attributes;
        $this->reset_attributes();

        do_action_ref_array( 'betterdocs_before_render', [ &$this, 'shortcode' ] );

        ob_start();
        $this->render( $atts, $content = null );
        $content = ob_get_clean();

        do_action_ref_array( 'betterdocs_after_render', [ &$this, 'shortcode' ] );

        return $content;
    }

Code file location:

betterdocs/betterdocs/includes/Core/ShortcodeFactory.php

Conclusion

Now that you’ve learned how to embed the Betterdocs 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *