Dynamic QR Code – generator Shortcode

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

Before starting, here is an overview of the Dynamic QR Code – generator Plugin and the shortcodes it provides:

Plugin Icon
Dynamic QR Code – generator

"Dynamic QR Code – generator is a versatile WordPress plugin that effortlessly creates custom QR codes. This user-friendly tool transforms any content into a scan-able code, enhancing your site's interactivity."

★★★★★ (7) Active Installs: 2000+ Tested with: 6.1.4 PHP Version: 7.4
Included Shortcodes:
  • [sanitize]

Dynamic QR Code – generator [sanitize] Shortcode

The Dynamic-QR-Code plugin shortcode sanitizes inputs from other plugins. It prevents unauthorized calls to the callback function, ensuring data integrity.

Shortcode: [sanitize]

Examples and Usage

Basic Example – Showcases a simple usage of the shortcode where no additional parameters are passed.

[dynamic-qr-code /]

Advanced Examples

Example 1: Utilizing the shortcode to generate a dynamic QR code with specific attributes. In this case, the ‘content’ attribute is set to ‘Hello World’ and the ‘size’ attribute is set to ‘300’ (for 300px).

[dynamic-qr-code content="Hello World" size="300" /]

Example 2: Another advanced usage of the shortcode where multiple attributes are passed. Here, the ‘content’ attribute is set to a URL, the ‘size’ attribute is set to ‘500’, and the ‘color’ attribute is set to ‘blue’.

[dynamic-qr-code content="https://www.example.com" size="500" color="blue" /]

These examples demonstrate the versatility of the dynamic-qr-code shortcode. By passing different attributes, you can customize the output of the QR code to suit your specific needs.

PHP Function Code

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

Shortcode line:

add_shortcode( $this->tag, array( $this, 'sanitize' ) );

Shortcode PHP function:

function sanitize( $attributes, $content, $tag ) {

        if ( sosidee_is_rest() ) {
            // do not sanitize if it's a block editor api call (in this case is_admin() always returns false and can't be used)
            return;
        }

        if ( !$this->isTrueCall ) {
            // prevent other plugins to call the $callback function
            //@TODO: unless the call comes from Elementor (otherwise its display doesn't work...)
            return;
        }

        $args = array();
        if (is_array($attributes)) {
            foreach ( $attributes as $key => $value ) {
                $args[ sanitize_key($key) ] = sanitize_text_field($value);
            }
        }
        return call_user_func( $this->callback, $args, $content, $tag );
    }

Code file location:

dynamic-qr-code/dynamic-qr-code/sos/wp/shortcode.php

Conclusion

Now that you’ve learned how to embed the Dynamic QR Code – generator 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 *