• Hi Mike, I’ve used your plugin to add a CAPTCHA to Jetpack’s Contact Form and it works just fine when the [contact_form] shortcode is embedded in the_content but fails when the [contact_form] shortcode is placed in a text widget.

    FYI, the solution is to filter widget_text with the following (which I placed directly after line 193 in ‘si-captcha.php’):

    add_filter( 'widget_text', array($this, 'si_captcha_jetpack_form'), 0);

    In addition, it is necessary to force shortcodes to be parsed in text widgets:

    add_filter( 'widget_text', 'shortcode_unautop' );
    add_filter( 'widget_text', 'do_shortcode' );
    

    If you think this is too complicated for most of your users, you might wish to implement a version of what Jetpack does specifically for your shortcode when users have opted to enable CAPTCHA on Jetpack Contact Forms:

    https://github.com/Automattic/jetpack/blob/master/modules/contact-form/grunion-contact-form.php#L444

    Thanks for a neat plugin!

    Cheers, Christian

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thanks for the suggestion. I can fix that in the next version

    Mike

    Thread Starter Christian Wach

    (@needle)

    That would be great. Look forward to the update.

    Cheers, Christian

    The upgrade is done. does it work?

    Thread Starter Christian Wach

    (@needle)

    Hi Mike, yes, that works. Thanks for the quick response!

    The only thing I’d suggest is that you might want to check if there is a pre-existing addition of do_shortcode() to the widget_text filter with has_filter() to prevent double-parsing. Or perhaps take Jetpack’s approach and trigger do_shortcode() only when your shortcode is present in widget_text.

    Cheers, Christian

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Compatibility with Jetpack’s Contact Form in a widget’ is closed to new replies.