function wpcf7_strip_quote_deep($arr)
{
    if (is_string($arr)) {
        return wpcf7_strip_quote($arr);
    }
    if (is_array($arr)) {
        $result = array();
        foreach ($arr as $key => $text) {
            $result[$key] = wpcf7_strip_quote_deep($text);
        }
        return $result;
    }
}
Beispiel #2
0
 private function replace_tags_callback($matches, $html = false)
 {
     // allow [[foo]] syntax for escaping a tag
     if ($matches[1] == '[' && $matches[4] == ']') {
         return substr($matches[0], 1, -1);
     }
     $tag = $matches[0];
     $tagname = $matches[2];
     $values = $matches[3];
     if (!empty($values)) {
         preg_match_all('/"[^"]*"|\'[^\']*\'/', $values, $matches);
         $values = wpcf7_strip_quote_deep($matches[0]);
     }
     $do_not_heat = false;
     if (preg_match('/^_raw_(.+)$/', $tagname, $matches)) {
         $tagname = trim($matches[1]);
         $do_not_heat = true;
     }
     $format = '';
     if (preg_match('/^_format_(.+)$/', $tagname, $matches)) {
         $tagname = trim($matches[1]);
         $format = $values[0];
     }
     $submission = WPCF7_Submission::get_instance();
     $submitted = $submission ? $submission->get_posted_data($tagname) : null;
     if (null !== $submitted) {
         if ($do_not_heat) {
             $submitted = isset($_POST[$tagname]) ? $_POST[$tagname] : '';
         }
         $replaced = $submitted;
         if (!empty($format)) {
             $replaced = $this->format($replaced, $format);
         }
         $replaced = wpcf7_flat_join($replaced);
         if ($html) {
             $replaced = esc_html($replaced);
             $replaced = wptexturize($replaced);
         }
         $replaced = apply_filters('wpcf7_mail_tag_replaced', $replaced, $submitted, $html);
         $replaced = wp_unslash(trim($replaced));
         $this->replaced_tags[$tag] = $replaced;
         return $replaced;
     }
     $special = apply_filters('wpcf7_special_mail_tags', '', $tagname, $html);
     if (!empty($special)) {
         $this->replaced_tags[$tag] = $special;
         return $special;
     }
     return $tag;
 }
Beispiel #3
0
 function shortcode_parse_atts($text)
 {
     $atts = array('options' => array(), 'values' => array());
     $text = preg_replace("/[\\x{00a0}\\x{200b}]+/u", " ", $text);
     $text = stripcslashes(trim($text));
     $pattern = '%^([-+*=0-9a-zA-Z:.!?#$&@_/|\\%\\s]*?)((?:\\s*"[^"]*"|\\s*\'[^\']*\')*)$%';
     if (preg_match($pattern, $text, $match)) {
         if (!empty($match[1])) {
             $atts['options'] = preg_split('/[\\s]+/', trim($match[1]));
         }
         if (!empty($match[2])) {
             preg_match_all('/"[^"]*"|\'[^\']*\'/', $match[2], $matched_values);
             $atts['values'] = wpcf7_strip_quote_deep($matched_values[0]);
         }
     } else {
         $atts = $text;
     }
     return $atts;
 }
 public function replace_mail_tags_with_minimum_input($matches)
 {
     // allow [[foo]] syntax for escaping a tag
     if ($matches[1] == '[' && $matches[4] == ']') {
         return substr($matches[0], 1, -1);
     }
     $tag = $matches[0];
     $tagname = $matches[2];
     $values = $matches[3];
     if (!empty($values)) {
         preg_match_all('/"[^"]*"|\'[^\']*\'/', $values, $matches);
         $values = wpcf7_strip_quote_deep($matches[0]);
     }
     $do_not_heat = false;
     if (preg_match('/^_raw_(.+)$/', $tagname, $matches)) {
         $tagname = trim($matches[1]);
         $do_not_heat = true;
     }
     $format = '';
     if (preg_match('/^_format_(.+)$/', $tagname, $matches)) {
         $tagname = trim($matches[1]);
         $format = $values[0];
     }
     $example_email = '*****@*****.**';
     $example_text = 'example';
     $example_blank = '';
     $form_tags = $this->contact_form->form_scan_shortcode(array('name' => $tagname));
     if ($form_tags) {
         $form_tag = new WPCF7_Shortcode($form_tags[0]);
         $is_required = $form_tag->is_required() || 'radio' == $form_tag->type;
         if (!$is_required) {
             return $example_blank;
         }
         $is_selectable = in_array($form_tag->basetype, array('radio', 'checkbox', 'select'));
         if ($is_selectable) {
             if ($form_tag->pipes instanceof WPCF7_Pipes) {
                 if ($do_not_heat) {
                     $before_pipes = $form_tag->pipes->collect_befores();
                     $last_item = array_pop($before_pipes);
                 } else {
                     $after_pipes = $form_tag->pipes->collect_afters();
                     $last_item = array_pop($after_pipes);
                 }
             } else {
                 $last_item = array_pop($form_tag->values);
             }
             if ($last_item && wpcf7_is_mailbox_list($last_item)) {
                 return $example_email;
             } else {
                 return $example_text;
             }
         }
         if ('email' == $form_tag->basetype) {
             return $example_email;
         } else {
             return $example_text;
         }
     } else {
         $tagname = preg_replace('/^wpcf7\\./', '_', $tagname);
         // for back-compat
         if ('_post_author_email' == $tagname) {
             return $example_email;
         } elseif ('_' == substr($tagname, 0, 1)) {
             // maybe special mail tag
             return $example_text;
         }
     }
     return $tag;
 }