SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | - | |
2 | + | |
3 | /* | |
4 | Add this to the end of your Functions PHP | |
5 | */ | |
6 | ||
7 | /** Disable WP autop using shortcode for selected text, courtesy of Matt Valvano, http://ideasandpixels.com/disable-wordpress-auto-formatting-short-code */ | |
8 | ||
9 | function my_formatter($content) { | |
10 | $new_content = ''; | |
11 | $pattern_full = '{(\[raw\].*?\[/raw\])}is'; | |
12 | $pattern_contents = '{\[raw\](.*?)\[/raw\]}is'; | |
13 | $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE); | |
14 | ||
15 | foreach ($pieces as $piece) { | |
16 | if (preg_match($pattern_contents, $piece, $matches)) { | |
17 | $new_content .= $matches[1]; | |
18 | } else { | |
19 | $new_content .= wptexturize(wpautop($piece)); | |
20 | } | |
21 | } | |
22 | return $new_content; | |
23 | } | |
24 | ||
25 | ?> |