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.1 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 11 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 11 years ago functions.php 11 years ago mail.php 11 years ago pipe.php 12 years ago shortcodes.php 11 years ago submission.php 11 years ago upgrade.php 11 years ago validation.php 11 years ago
formatting.php
222 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_sanitize_query_var( $text ) {
64 $text = wp_unslash( $text );
65 $text = wp_check_invalid_utf8( $text );
66
67 if ( false !== strpos( $text, '<' ) ) {
68 $text = wp_pre_kses_less_than( $text );
69 $text = wp_strip_all_tags( $text );
70 }
71
72 $text = preg_replace( '/%[a-f0-9]{2}/i', '', $text );
73 $text = preg_replace( '/ +/', ' ', $text );
74 $text = trim( $text, ' ' );
75
76 return $text;
77 }
78
79 function wpcf7_strip_quote( $text ) {
80 $text = trim( $text );
81
82 if ( preg_match( '/^"(.*)"$/', $text, $matches ) )
83 $text = $matches[1];
84 elseif ( preg_match( "/^'(.*)'$/", $text, $matches ) )
85 $text = $matches[1];
86
87 return $text;
88 }
89
90 function wpcf7_strip_quote_deep( $arr ) {
91 if ( is_string( $arr ) )
92 return wpcf7_strip_quote( $arr );
93
94 if ( is_array( $arr ) ) {
95 $result = array();
96
97 foreach ( $arr as $key => $text )
98 $result[$key] = wpcf7_strip_quote_deep( $text );
99
100 return $result;
101 }
102 }
103
104 function wpcf7_normalize_newline( $text, $to = "\n" ) {
105 if ( ! is_string( $text ) )
106 return $text;
107
108 $nls = array( "\r\n", "\r", "\n" );
109
110 if ( ! in_array( $to, $nls ) )
111 return $text;
112
113 return str_replace( $nls, $to, $text );
114 }
115
116 function wpcf7_normalize_newline_deep( $arr, $to = "\n" ) {
117 if ( is_array( $arr ) ) {
118 $result = array();
119
120 foreach ( $arr as $key => $text )
121 $result[$key] = wpcf7_normalize_newline_deep( $text, $to );
122
123 return $result;
124 }
125
126 return wpcf7_normalize_newline( $arr, $to );
127 }
128
129 function wpcf7_strip_newline( $str ) {
130 $str = (string) $str;
131 $str = str_replace( array( "\r", "\n" ), '', $str );
132 return trim( $str );
133 }
134
135 function wpcf7_canonicalize( $text ) {
136 if ( function_exists( 'mb_convert_kana' )
137 && 'UTF-8' == get_option( 'blog_charset' ) ) {
138 $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
139 }
140
141 $text = strtolower( $text );
142 $text = trim( $text );
143 return $text;
144 }
145
146 /**
147 * Check whether a string is a valid NAME token.
148 *
149 * ID and NAME tokens must begin with a letter ([A-Za-z])
150 * and may be followed by any number of letters, digits ([0-9]),
151 * hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
152 *
153 * @see http://www.w3.org/TR/html401/types.html#h-6.2
154 *
155 * @return bool True if it is a valid name, false if not.
156 */
157 function wpcf7_is_name( $string ) {
158 return preg_match( '/^[A-Za-z][-A-Za-z0-9_:.]*$/', $string );
159 }
160
161 function wpcf7_sanitize_unit_tag( $tag ) {
162 $tag = preg_replace( '/[^A-Za-z0-9_-]/', '', $tag );
163 return $tag;
164 }
165
166 function wpcf7_is_email( $email ) {
167 $result = is_email( $email );
168 return apply_filters( 'wpcf7_is_email', $result, $email );
169 }
170
171 function wpcf7_is_url( $url ) {
172 $result = ( false !== filter_var( $url, FILTER_VALIDATE_URL ) );
173 return apply_filters( 'wpcf7_is_url', $result, $url );
174 }
175
176 function wpcf7_is_tel( $tel ) {
177 $result = preg_match( '/^[+]?[0-9() -]*$/', $tel );
178 return apply_filters( 'wpcf7_is_tel', $result, $tel );
179 }
180
181 function wpcf7_is_number( $number ) {
182 $result = is_numeric( $number );
183 return apply_filters( 'wpcf7_is_number', $result, $number );
184 }
185
186 function wpcf7_is_date( $date ) {
187 $result = preg_match( '/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/', $date, $matches );
188
189 if ( $result )
190 $result = checkdate( $matches[2], $matches[3], $matches[1] );
191
192 return apply_filters( 'wpcf7_is_date', $result, $date );
193 }
194
195 function wpcf7_antiscript_file_name( $filename ) {
196 $filename = basename( $filename );
197 $parts = explode( '.', $filename );
198
199 if ( count( $parts ) < 2 )
200 return $filename;
201
202 $script_pattern = '/^(php|phtml|pl|py|rb|cgi|asp|aspx)\d?$/i';
203
204 $filename = array_shift( $parts );
205 $extension = array_pop( $parts );
206
207 foreach ( (array) $parts as $part ) {
208 if ( preg_match( $script_pattern, $part ) )
209 $filename .= '.' . $part . '_';
210 else
211 $filename .= '.' . $part;
212 }
213
214 if ( preg_match( $script_pattern, $extension ) )
215 $filename .= '.' . $extension . '_.txt';
216 else
217 $filename .= '.' . $extension;
218
219 return $filename;
220 }
221
222 ?>