Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 77 lines (63 sloc) 2.236 kb
8a72bae initial addition and commit
Joel Oliveira authored
1 <?php
2 if(function_exists('register_sidebar'))
3 {
4 // register_sidebar();
5 }
cb0b0f1 queueing the google hosted version of jQuery 1.3.2
Joel Oliveira authored
6
ab9771f @jayroh added a [raw][/raw] shortcode for chunks of not wanting to be wpautop'd....
authored
7 wp_deregister_script('jquery');
8 wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"), false, '1.4.2');
9 wp_enqueue_script('jquery');
10
11 // ===========================================================================
12
13 /*
14 Plugin Name: Raw Code Injector
15 Plugin URI: http://www.thebinarypenguin.com
16 Description: Removes auto-formatting from text
17 Version: 0.1
18 Author: TheBinaryPenguin
19 Author URI: http://www.thebinarypenguin.com
20 */
21
22 /**
23 * Takes the content and splits it into pieces.
24 *
25 * The pieces can be either
26 * (1) Text wrapped in a [raw][/raw] shortcode
27 * or
28 * (2) Text not wrapped in a [raw][/raw] shortcode
29 *
30 * The pieces retain their order in the content.
31 *
32 * Think of it as a crazy version of explode() where the delimiter
33 * is a regular expression and the delimiter is also returned in the array.
34 *
35 * Then loop over the pieces
36 * If the piece contains a [raw][/raw] shortcode then append the interior text to the new_content string
37 * Else
38 * Apply the wpautop() and wptexturize() formatters to the piece and append it to the new_content string
39 */
40 function my_formatter($content) {
41
42 $new_content = '';
43
44 /* Matches the contents and the open and closing tags */
45 $pattern_full = '{(\[raw\].*?\[/raw\])}is';
46
47 /* Matches just the contents */
48 $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
49
50 /* Divide content into pieces */
51 $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
52
53 /* Loop over pieces */
54 foreach ($pieces as $piece) {
55 /* Look for presence of the shortcode */
56 if (preg_match($pattern_contents, $piece, $matches)) {
57 /* Append to content (no formatting) */
58 $new_content .= $matches[1];
59 } else {
60 /* Format and append to content */
61 $new_content .= wptexturize(wpautop($piece));
62 }
63 }
64 return $new_content;
cb0b0f1 queueing the google hosted version of jQuery 1.3.2
Joel Oliveira authored
65 }
ab9771f @jayroh added a [raw][/raw] shortcode for chunks of not wanting to be wpautop'd....
authored
66
67 /* Remove the 2 main auto-formatters */
68 remove_filter('the_content', 'wpautop');
69 remove_filter('the_content', 'wptexturize');
70
71 /* Before displaying for viewing, apply this function */
72 add_filter('the_content', 'my_formatter', 99);
73
74 // ===========================================================================
75
76
8a72bae initial addition and commit
Joel Oliveira authored
77 ?>
Something went wrong with that request. Please try again.