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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 13 years ago js 12 years ago capabilities.php 13 years ago classes.php 13 years ago controller.php 12 years ago deprecated.php 14 years ago formatting.php 13 years ago functions.php 13 years ago pipe.php 14 years ago shortcodes.php 13 years ago
formatting.php
150 lines
1 <?php
2
3 function wpcf7_autop( $pee, $br = 1 ) {
4
5 if ( trim( $pee ) === '' )
6 return '';
7 $pee = $pee . "\n"; // just to make things a little easier, pad the end
8 $pee = preg_replace( '|<br />\s*<br />|', "\n\n", $pee );
9 // Space things out a little
10 /* wpcf7: remove select and input */
11 $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)';
12 $pee = preg_replace( '!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee );
13 $pee = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $pee );
14 $pee = str_replace( array( "\r\n", "\r" ), "\n", $pee ); // cross-platform newlines
15 if ( strpos( $pee, '<object' ) !== false ) {
16 $pee = preg_replace( '|\s*<param([^>]*)>\s*|', "<param$1>", $pee ); // no pee inside object/embed
17 $pee = preg_replace( '|\s*</embed>\s*|', '</embed>', $pee );
18 }
19 $pee = preg_replace( "/\n\n+/", "\n\n", $pee ); // take care of duplicates
20 // make paragraphs, including one at the end
21 $pees = preg_split( '/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY );
22 $pee = '';
23 foreach ( $pees as $tinkle )
24 $pee .= '<p>' . trim( $tinkle, "\n" ) . "</p>\n";
25 $pee = preg_replace( '|<p>\s*</p>|', '', $pee ); // under certain strange conditions it could create a P of entirely whitespace
26 $pee = preg_replace( '!<p>([^<]+)</(div|address|form|fieldset)>!', "<p>$1</p></$2>", $pee );
27 $pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee ); // don't pee all over a tag
28 $pee = preg_replace( "|<p>(<li.+?)</p>|", "$1", $pee ); // problem with nested lists
29 $pee = preg_replace( '|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee );
30 $pee = str_replace( '</blockquote></p>', '</p></blockquote>', $pee );
31 $pee = preg_replace( '!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee );
32 $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee );
33 if ( $br ) {
34 /* wpcf7: add textarea */
35 $pee = preg_replace_callback( '/<(script|style|textarea).*?<\/\\1>/s', create_function( '$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);' ), $pee );
36 $pee = preg_replace( '|(?<!<br />)\s*\n|', "<br />\n", $pee ); // optionally make line breaks
37 $pee = str_replace( '<WPPreserveNewline />', "\n", $pee );
38 }
39 $pee = preg_replace( '!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee );
40 $pee = preg_replace( '!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee );
41 if ( strpos( $pee, '<pre' ) !== false )
42 $pee = preg_replace_callback( '!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee );
43 $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
44
45 return $pee;
46 }
47
48 function wpcf7_strip_quote( $text ) {
49 $text = trim( $text );
50
51 if ( preg_match( '/^"(.*)"$/', $text, $matches ) )
52 $text = $matches[1];
53 elseif ( preg_match( "/^'(.*)'$/", $text, $matches ) )
54 $text = $matches[1];
55
56 return $text;
57 }
58
59 function wpcf7_strip_quote_deep( $arr ) {
60 if ( is_string( $arr ) )
61 return wpcf7_strip_quote( $arr );
62
63 if ( is_array( $arr ) ) {
64 $result = array();
65
66 foreach ( $arr as $key => $text )
67 $result[$key] = wpcf7_strip_quote_deep( $text );
68
69 return $result;
70 }
71 }
72
73 function wpcf7_normalize_newline( $text, $to = "\n" ) {
74 if ( ! is_string( $text ) )
75 return $text;
76
77 $nls = array( "\r\n", "\r", "\n" );
78
79 if ( ! in_array( $to, $nls ) )
80 return $text;
81
82 return str_replace( $nls, $to, $text );
83 }
84
85 function wpcf7_normalize_newline_deep( $arr, $to = "\n" ) {
86 if ( is_array( $arr ) ) {
87 $result = array();
88
89 foreach ( $arr as $key => $text )
90 $result[$key] = wpcf7_normalize_newline_deep( $text, $to );
91
92 return $result;
93 }
94
95 return wpcf7_normalize_newline( $arr, $to );
96 }
97
98 function wpcf7_canonicalize( $text ) {
99 if ( function_exists( 'mb_convert_kana' ) && 'UTF-8' == get_option( 'blog_charset' ) )
100 $text = mb_convert_kana( $text, 'asKV', 'UTF-8' );
101
102 $text = strtolower( $text );
103 $text = trim( $text );
104 return $text;
105 }
106
107 function wpcf7_is_name( $string ) {
108 // See http://www.w3.org/TR/html401/types.html#h-6.2
109 // ID and NAME tokens must begin with a letter ([A-Za-z])
110 // and may be followed by any number of letters, digits ([0-9]),
111 // hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
112
113 return preg_match( '/^[A-Za-z][-A-Za-z0-9_:.]*$/', $string );
114 }
115
116 function wpcf7_sanitize_unit_tag( $tag ) {
117 $tag = preg_replace( '/[^A-Za-z0-9_-]/', '', $tag );
118 return $tag;
119 }
120
121 function wpcf7_is_email( $email ) {
122 $result = is_email( $email );
123 return apply_filters( 'wpcf7_is_email', $result, $email );
124 }
125
126 function wpcf7_is_url( $url ) {
127 $result = ( false !== filter_var( $url, FILTER_VALIDATE_URL ) );
128 return apply_filters( 'wpcf7_is_url', $result, $url );
129 }
130
131 function wpcf7_is_tel( $tel ) {
132 $result = preg_match( '/^[+]?[0-9() -]*$/', $tel );
133 return apply_filters( 'wpcf7_is_tel', $result, $tel );
134 }
135
136 function wpcf7_is_number( $number ) {
137 $result = is_numeric( $number );
138 return apply_filters( 'wpcf7_is_number', $result, $number );
139 }
140
141 function wpcf7_is_date( $date ) {
142 $result = preg_match( '/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/', $date, $matches );
143
144 if ( $result )
145 $result = checkdate( $matches[2], $matches[3], $matches[1] );
146
147 return apply_filters( 'wpcf7_is_date', $result, $date );
148 }
149
150 ?>