Grunion_Contact_Form_Plugin::widget_shortcode_hack PHP Method

widget_shortcode_hack() public method

For sites where text widgets are not processed for shortcodes, we add this hack to process just our shortcode Attached to widget_text
public widget_shortcode_hack ( string $text ) : string
$text string The widget text
return string The contact-form filtered widget text
    function widget_shortcode_hack($text)
    {
        if (!preg_match('/\\[contact-form([^a-zA-Z_-])/', $text)) {
            return $text;
        }
        $old = $GLOBALS['shortcode_tags'];
        remove_all_shortcodes();
        Grunion_Contact_Form_Plugin::$using_contact_form_field = true;
        $this->add_shortcode();
        $text = do_shortcode($text);
        Grunion_Contact_Form_Plugin::$using_contact_form_field = false;
        $GLOBALS['shortcode_tags'] = $old;
        return $text;
    }