Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Stefano Lissa

    (@satollo)

    The shortcode is rendered only when you send the newsletter (even with using the test feature) but the rendering should be enabled in the Newsletter plugin main settings.

    Sometimes it happens shortcodes are not registered in every context by the plugin that manage them, so they couldn’t rendered. But before dealing with this possible issue, try to enable the rendering and check what happens.

    Thread Starter dansart

    (@dansart)

    Hi Stefano

    It was set in the Settings that Shortcodes should be rendered. I deactivated the option and activated again. No change.

    Best, Daniel

    Plugin Author Stefano Lissa

    (@satollo)

    When you send a test newsletter, do you see the shortcode in the email you receive? So, the shortcode is not registered when you’re inside the admin side, there no much we can do. Probably, when the campaign is started, since it runs in the “scheduler” context, the shortcode should be replaced.

    Thread Starter dansart

    (@dansart)

    Yes, in the Preview, the shortcode will not be displayed. In the email, everything is OK.
    I wrote my own function that gets the content of the Message and applies the “do_shortcode” function to it. This will render the Shortcode as it should.

    function get_newsletter_preview($id){
            global $wpdb;
            $id = (int) $id;
            $query = "SELECT message FROM ".NEWSLETTER_EMAILS_TABLE." WHERE id = '$id'";
            $result = $wpdb->get_results($query);
    
            if(!isset($result[0] -> message) OR empty($result[0] -> message)){
                return __('No Newsletter found','plek');
            }
    
            //Apply shortcodes and codes from the newsletter plugin
            return do_shortcode($result[0] -> message);
            
    
        }

    I’m just wondering why it is not possible to embed this in the preview while composing. A solution can be, to send it to the server via ajax and run the shortcode and return the result to the preview.

    Are there any plans to bring a feature like that to the plugin?

    Plugin Author Stefano Lissa

    (@satollo)

    Hi, thank you for sharing this code, I’m going to look at it and possibly patch the plungin. Executing shortcodes in the composer can embed javascript or like breaking the editor and, worst, the content generated will be saved as part of the newsletter instead of being executed while sending.

    Thread Starter dansart

    (@dansart)

    Yes, that’s indeed a possibility. Maybe a “real” preview mode that opens in a new tab / window would be a good solution.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Shortcode not rendered in Webview’ is closed to new replies.