コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: formatting.php プロジェクト: xeiter/timeplannr
function wpcf7_is_email_in_domain($email, $domain)
{
    $email_list = wpcf7_is_mailbox_list($email);
    foreach ($email_list as $email) {
        $email_domain = substr($email, strrpos($email, '@') + 1);
        $domain_parts = explode('.', $domain);
        do {
            $site_domain = implode('.', $domain_parts);
            if ($site_domain == $email_domain) {
                continue 2;
            }
            array_shift($domain_parts);
        } while ($domain_parts);
        return false;
    }
    return true;
}