Shortcode Widget

Many membership sites require you to wrap elements within shortcodes, for this we need a shortcode wrapper:

5 Likes

Hey Dean,
I personally think this makes sense, even though I haven’t built any membership sites yet.

Would you be so kind and submit this as an idea on the Idea Board (and share the link here)? I assume that we will get a lot of upvotes relatively quickly.

Best regards,
timmse

2 Likes

Hey,

as I am confronted to this problem at the moment, I’ve found a solution that works.
This may help @Deanphillips.

@timmse, you may be able to create an element with that code maybe, the pain point being to add complex HTML structure, so a shortcode wrapper would be a nice addition to the builder.

<?php
    // shortcode opening tag 
    $shortcode = '[shortcode]';
		
    // HTML Code
    $html = 'your HTML here';
		
    // shortcode closing tag
    $html .= '[/shortcode]';

    if (shortcode_exists('shortcode')) {
        // If the shortcode does exist, we try to execute it and check for errors
        $execution_result = do_shortcode($shortcode . $html);

        // If execution result contains 'error', we exit the script
        if (strpos($execution_result, 'error') !== false) {
            exit();
        } else {
            // If no error, we output the result
            echo $execution_result;
        }
    } else {
        // If the shortcode does not exist, we exit the script
        exit();
    }
?>