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 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / includes / formatting.php
contact-form-7 / includes Last commit date
css 12 years ago js 11 years ago capabilities.php 13 years ago contact-form-template.php 11 years ago contact-form.php 11 years ago controller.php 11 years ago formatting.php 12 years ago functions.php 11 years ago mail.php 11 years ago pipe.php 12 years ago shortcodes.php 12 years ago submission.php 11 years ago upgrade.php 11 years ago
formatting.php
198 lines
1 <?php
2
3 function wpcf7_autop( $pee, $br = 1 ) {
4 if ( trim( $pee ) === '' ) {
5 return '';
6 }
7
8 $pee = $pee . "\n"; // just to make things a little easier, pad the end
9 $pee = preg_replace( '|<br />\s*<br />|', "\n\n", $pee );
10 // Space things out a little
11 /* wpcf7: remove select and input */
12 $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
13 $pee = preg_replace( '!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee );
14 $pee = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $pee );
15
16 /* wpcf7: take care of [response] tag */
17 $pee = preg_replace( '!(\[response[^]]*\])!', "\n$1\n\n", $pee );
18
19 $pee = str_replace( array( "\r\n", "\r" ), "\n", $pee ); // cross-platform newlines
20
21 if ( strpos( $pee, '<object' ) !== false ) {
22 $pee = preg_replace( '|\s*<param([^>]*)>\s*|', "<param$1>", $pee ); // no pee inside object/embed
23 $pee = preg_replace( '|\s*</embed>\s*|', '</embed>', $pee );
24 }
25
26 $pee = preg_replace( "/\n\n+/", "\n\n", $pee ); // take care of duplicates
27 // make paragraphs, including one at the end
28 $pees = preg_split( '/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY );
29 $pee = '';
30
31 foreach ( $pees as $tinkle ) {
32 $pee .= '<p>' . trim( $tinkle, "\n" ) . "</p>\n";
33 }
34
35 $pee = preg_replace( '|<p>\s*</p>|', '', $pee ); // under certain strange conditions it could create a P of entirely whitespace
36 $pee = preg_replace( '!<p>([^<]+)</(div|address|form|fieldset)>!', "<p>$1</p></$2>", $pee );
37 $pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee ); // don't pee all over a tag
38 $pee = preg_replace( "|<p>(<li.+?)</p>|", "$1", $pee ); // problem with nested lists
39 $pee = preg_replace( '|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee );
40 $pee = str_replace( '</blockquote></p>', '</p></blockquote>', $pee );
41 $pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee );
42 $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee );
43
44 /* wpcf7: take care of [response] tag */
45 $pee = preg_replace( '!<p>\s*(\[response[^]]*\])!', "$1", $pee );
46 $pee = preg_replace( '!(\[response[^]]*\])\s*</p>!', "$1", $pee );
47
48 if ( $br ) {
49 /* wpcf7: add textarea */
50 $pee = preg_replace_callback( '/<(script|style|textarea).*?<\/\\1>/s', create_function( '$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);' ), $pee );
51 $pee = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $pee ); // optionally make line breaks
52 $pee = str_replace( '<WPPreserveNewline />', "\n", $pee );
53 }
54 $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee );
55 $pee = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee );
56 if ( strpos( $pee, '<pre' ) !== false )
57 $pee = preg_replace_callback( '!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee );
58 $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
59
60 return $pee;
61 }
62
63 function wpcf7_strip_quote( $text ) {
64 $text = trim( $text );
65
66 if ( preg_match( '/^"(.*)"$/', $text, $matches ) )
67 $text = $matches[1];
68 elseif ( preg_match( "/^'(.*)'$/", $text, $matches ) )
69 $text = $matches[1];
70
71 return $text;
72 }
73
74 function wpcf7_strip_quote_deep( $arr ) {
75 if ( is_string( $arr ) )
76 return wpcf7_strip_quote( $arr );
77
78 if ( is_array( $arr ) ) {
79 $result = array();
80
81 foreach ( $arr as $key => $text )
82 $result[$key] = wpcf7_strip_quote_deep( $text );
83
84 return $result;
85 }
86 }
87
88 function wpcf7_normalize_newline( $text, $to = "\n" ) {
89 if ( ! is_string( $text ) )
90 return $text;
91
92 $nls = array( "\r\n", "\r", "\n" );
93
94 if ( ! in_array( $to, $nls ) )
95 return $text;
96
97 return str_replace( $nls, $to, $text );
98 }
99
100 function wpcf7_normalize_newline_deep( $arr, $to = "\n" ) {
101 if ( is_array( $arr ) ) {
102 $result = array();
103
104 foreach ( $arr as $key => $text )
105 $result[$key] = wpcf7_normalize_newline_deep( $text, $to );
106
107 return $result;
108 }
109
110 return wpcf7_normalize_newline( $arr, $to );
111 }
112
113 function wpcf7_strip_newline( $str ) {
114 $str = (string) $str;
115 $str = str_replace( array( "\r", "\n" ), '', $str );
116 return trim( $str );
117 }
118
119 function wpcf7_canonicalize( $text ) {
120 if ( function_exists( 'mb_convert_kana' ) && 'UTF-8' == get_option( 'blog_charset' ) )
121 $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
122
123 $text = strtolower( $text );
124 $text = trim( $text );
125 return $text;
126 }
127
128 function wpcf7_is_name( $string ) {
129 // See http://www.w3.org/TR/html401/types.html#h-6.2
130 // ID and NAME tokens must begin with a letter ([A-Za-z])
131 // and may be followed by any number of letters, digits ([0-9]),
132 // hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
133
134 return preg_match( '/^[A-Za-z][-A-Za-z0-9_:.]*$/', $string );
135 }
136
137 function wpcf7_sanitize_unit_tag( $tag ) {
138 $tag = preg_replace( '/[^A-Za-z0-9_-]/', '', $tag );
139 return $tag;
140 }
141
142 function wpcf7_is_email( $email ) {
143 $result = is_email( $email );
144 return apply_filters( 'wpcf7_is_email', $result, $email );
145 }
146
147 function wpcf7_is_url( $url ) {
148 $result = ( false !== filter_var( $url, FILTER_VALIDATE_URL ) );
149 return apply_filters( 'wpcf7_is_url', $result, $url );
150 }
151
152 function wpcf7_is_tel( $tel ) {
153 $result = preg_match( '/^[+]?[0-9() -]*$/', $tel );
154 return apply_filters( 'wpcf7_is_tel', $result, $tel );
155 }
156
157 function wpcf7_is_number( $number ) {
158 $result = is_numeric( $number );
159 return apply_filters( 'wpcf7_is_number', $result, $number );
160 }
161
162 function wpcf7_is_date( $date ) {
163 $result = preg_match( '/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/', $date, $matches );
164
165 if ( $result )
166 $result = checkdate( $matches[2], $matches[3], $matches[1] );
167
168 return apply_filters( 'wpcf7_is_date', $result, $date );
169 }
170
171 function wpcf7_antiscript_file_name( $filename ) {
172 $filename = basename( $filename );
173 $parts = explode( '.', $filename );
174
175 if ( count( $parts ) < 2 )
176 return $filename;
177
178 $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
179
180 $filename = array_shift( $parts );
181 $extension = array_pop( $parts );
182
183 foreach ( (array) $parts as $part ) {
184 if ( preg_match( $script_pattern, $part ) )
185 $filename .= '.' . $part . '_';
186 else
187 $filename .= '.' . $part;
188 }
189
190 if ( preg_match( $script_pattern, $extension ) )
191 $filename .= '.' . $extension . '_.txt';
192 else
193 $filename .= '.' . $extension;
194
195 return $filename;
196 }
197
198 ?>