Exemple #1
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;
 }
 function mail_callback($matches, $html = false)
 {
     // allow [[foo]] syntax for escaping a tag
     if ($matches[1] == '[' && $matches[3] == ']') {
         return substr($matches[0], 1, -1);
     }
     $tag = $matches[0];
     $tagname = $matches[2];
     $do_not_heat = false;
     if (preg_match('/^_raw_(.+)$/', $tagname, $matches)) {
         $tagname = trim($matches[1]);
         $do_not_heat = true;
     }
     if (isset($this->posted_data[$tagname])) {
         if ($do_not_heat) {
             $submitted = isset($_POST[$tagname]) ? $_POST[$tagname] : '';
         } else {
             $submitted = $this->posted_data[$tagname];
         }
         $replaced = wpcf7_flat_join($submitted);
         if ($html) {
             $replaced = strip_tags($replaced);
             $replaced = wptexturize($replaced);
         }
         $replaced = apply_filters('wpcf7_mail_tag_replaced', $replaced, $submitted, $html);
         return stripslashes($replaced);
     }
     $special = apply_filters('wpcf7_special_mail_tags', '', $tagname, $html);
     if (!empty($special)) {
         return $special;
     }
     return $tag;
 }