Version Description
- Fixed a conflict with WP-Syntax.
- Fixed: Prevent WordPress from wrapping each [raw]...[/raw] block in a paragraph. Doesn't affect inline [raw] blocks.
- Tested with WP 3.5-beta2.
Download this release
Release Info
Developer | whiteshadow |
Plugin | Raw HTML |
Version | 1.4.8 |
Comparing to | |
See all releases |
Code changes from version 1.4.7 to 1.4.8
- include/tag-handler.php +34 -14
- raw_html.php +1 -1
- readme.txt +7 -2
include/tag-handler.php
CHANGED
@@ -10,7 +10,7 @@ $wsh_raw_parts=array();
|
|
10 |
* Extract content surrounded by [raw] or other supported tags
|
11 |
* and replace it with placeholder text.
|
12 |
*
|
13 |
-
* @global $wsh_raw_parts Used to store the extracted content blocks.
|
14 |
*
|
15 |
* @param string $text The input content to filter.
|
16 |
* @param bool $keep_tags Store both the tagged content and the tags themselves. Defaults to false - storing only the content.
|
@@ -49,7 +49,7 @@ function wsh_extract_exclusions($text, $keep_tags = false){
|
|
49 |
} else {
|
50 |
$wsh_raw_parts[]=$content;
|
51 |
}
|
52 |
-
$replacement = "!RAWBLOCK".(count($wsh_raw_parts)-1)."!";
|
53 |
}
|
54 |
$text = substr_replace($text, $replacement, $start,
|
55 |
$fin+strlen($end_tag)-$start
|
@@ -67,17 +67,17 @@ function wsh_extract_exclusions($text, $keep_tags = false){
|
|
67 |
|
68 |
/**
|
69 |
* Replace the placeholders created by wsh_extract_exclusions() with the original content.
|
70 |
-
*
|
71 |
-
* @global $wsh_raw_parts Used to check if there is anything to insert.
|
72 |
-
*
|
73 |
* @param string $text The input content to filter.
|
74 |
-
* @param
|
75 |
* @return string Filtered content.
|
76 |
*/
|
77 |
function wsh_insert_exclusions($text, $placeholder_callback = 'wsh_insertion_callback'){
|
78 |
global $wsh_raw_parts;
|
79 |
if(!isset($wsh_raw_parts)) return $text;
|
80 |
-
return preg_replace_callback("
|
81 |
}
|
82 |
|
83 |
/**
|
@@ -91,13 +91,35 @@ function wsh_insert_exclusions($text, $placeholder_callback = 'wsh_insertion_cal
|
|
91 |
*/
|
92 |
function wsh_insertion_callback($matches){
|
93 |
global $wsh_raw_parts;
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
add_filter('the_content', '
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
/*
|
103 |
* WordPress can also mangle code when initializing the post/page editor.
|
@@ -115,10 +137,8 @@ function wsh_insert_exclusions_for_editor($text){
|
|
115 |
|
116 |
function wsh_insertion_callback_for_editor($matches){
|
117 |
global $wsh_raw_parts;
|
118 |
-
return htmlspecialchars($wsh_raw_parts[intval($matches[
|
119 |
}
|
120 |
|
121 |
add_filter('the_editor_content', 'wsh_extract_exclusions_for_editor', 2);
|
122 |
add_filter('the_editor_content', 'wsh_insert_exclusions_for_editor', 1001);
|
123 |
-
|
124 |
-
?>
|
10 |
* Extract content surrounded by [raw] or other supported tags
|
11 |
* and replace it with placeholder text.
|
12 |
*
|
13 |
+
* @global array $wsh_raw_parts Used to store the extracted content blocks.
|
14 |
*
|
15 |
* @param string $text The input content to filter.
|
16 |
* @param bool $keep_tags Store both the tagged content and the tags themselves. Defaults to false - storing only the content.
|
49 |
} else {
|
50 |
$wsh_raw_parts[]=$content;
|
51 |
}
|
52 |
+
$replacement = "!RAWBLOCK".(count($wsh_raw_parts)-1)."!";
|
53 |
}
|
54 |
$text = substr_replace($text, $replacement, $start,
|
55 |
$fin+strlen($end_tag)-$start
|
67 |
|
68 |
/**
|
69 |
* Replace the placeholders created by wsh_extract_exclusions() with the original content.
|
70 |
+
*
|
71 |
+
* @global array $wsh_raw_parts Used to check if there is anything to insert.
|
72 |
+
*
|
73 |
* @param string $text The input content to filter.
|
74 |
+
* @param callable|string $placeholder_callback Optional. The callback that will be used to process each placeholder.
|
75 |
* @return string Filtered content.
|
76 |
*/
|
77 |
function wsh_insert_exclusions($text, $placeholder_callback = 'wsh_insertion_callback'){
|
78 |
global $wsh_raw_parts;
|
79 |
if(!isset($wsh_raw_parts)) return $text;
|
80 |
+
return preg_replace_callback("/(<p>)?!RAWBLOCK(?P<index>\d+?)!(\s*?<\/p>)?/", $placeholder_callback, $text);
|
81 |
}
|
82 |
|
83 |
/**
|
91 |
*/
|
92 |
function wsh_insertion_callback($matches){
|
93 |
global $wsh_raw_parts;
|
94 |
+
|
95 |
+
$openingParagraph = isset($matches[1]) ? $matches[1] : '';
|
96 |
+
$closingParagraph = isset($matches[3]) ? $matches[3] : '';
|
97 |
+
$code = $wsh_raw_parts[intval($matches['index'])];
|
98 |
+
|
99 |
+
//If the [raw] block is wrapped in its own paragraph, strip the <p>...</p> tags. If there's
|
100 |
+
//only one of <p>|</p> tag present, keep it - it's probably part of a larger paragraph.
|
101 |
+
if ( empty($openingParagraph) || empty($closingParagraph) ) {
|
102 |
+
$code = $openingParagraph . $code . $closingParagraph;
|
103 |
+
}
|
104 |
+
return $code;
|
105 |
}
|
106 |
|
107 |
+
function wsh_setup_content_filters() {
|
108 |
+
//Extract the tagged content before WP can get to it, then re-insert it later.
|
109 |
+
add_filter('the_content', 'wsh_extract_exclusions', 2);
|
110 |
|
111 |
+
//A workaround for WP-Syntax. If we run our insertion callback at the normal, extra-late
|
112 |
+
//priority, WP-Syntax will see the wrong content when it runs its own content substitution hook.
|
113 |
+
//We adapt to that by running our callback slightly earlier than WP-Syntax's.
|
114 |
+
$wp_syntax_priority = has_filter('the_content', 'wp_syntax_after_filter');
|
115 |
+
if ( $wp_syntax_priority !== false ) {
|
116 |
+
$rawhtml_priority = $wp_syntax_priority - 1;
|
117 |
+
} else {
|
118 |
+
$rawhtml_priority = 1001;
|
119 |
+
}
|
120 |
+
add_filter('the_content', 'wsh_insert_exclusions', $rawhtml_priority);
|
121 |
+
}
|
122 |
+
add_action('plugins_loaded', 'wsh_setup_content_filters');
|
123 |
|
124 |
/*
|
125 |
* WordPress can also mangle code when initializing the post/page editor.
|
137 |
|
138 |
function wsh_insertion_callback_for_editor($matches){
|
139 |
global $wsh_raw_parts;
|
140 |
+
return htmlspecialchars($wsh_raw_parts[intval($matches['index'])], ENT_NOQUOTES);
|
141 |
}
|
142 |
|
143 |
add_filter('the_editor_content', 'wsh_extract_exclusions_for_editor', 2);
|
144 |
add_filter('the_editor_content', 'wsh_insert_exclusions_for_editor', 1001);
|
|
|
|
raw_html.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Raw HTML
|
4 |
Plugin URI: http://w-shadow.com/blog/2007/12/13/raw-html-in-wordpress/
|
5 |
Description: Lets you enter any HTML/JS/CSS in your posts without WP changing it, as well as disable automatic formatting on a per-post basis. <strong>Usage:</strong> Wrap your code in [raw]...[/raw] tags. To avoid problems, only edit posts that contain raw code in HTML mode. <strong><a href="http://rawhtmlpro.com/?utm_source=RawHTML%20free&utm_medium=plugin_description&utm_campaign=Plugins">Upgrade to Pro</a></strong> to be able to use Visual editor on the same posts without it messing up the code.
|
6 |
-
Version: 1.4.
|
7 |
Author: Janis Elsts
|
8 |
Author URI: http://w-shadow.com/
|
9 |
*/
|
3 |
Plugin Name: Raw HTML
|
4 |
Plugin URI: http://w-shadow.com/blog/2007/12/13/raw-html-in-wordpress/
|
5 |
Description: Lets you enter any HTML/JS/CSS in your posts without WP changing it, as well as disable automatic formatting on a per-post basis. <strong>Usage:</strong> Wrap your code in [raw]...[/raw] tags. To avoid problems, only edit posts that contain raw code in HTML mode. <strong><a href="http://rawhtmlpro.com/?utm_source=RawHTML%20free&utm_medium=plugin_description&utm_campaign=Plugins">Upgrade to Pro</a></strong> to be able to use Visual editor on the same posts without it messing up the code.
|
6 |
+
Version: 1.4.8
|
7 |
Author: Janis Elsts
|
8 |
Author URI: http://w-shadow.com/
|
9 |
*/
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: whiteshadow
|
3 |
Tags: posts, formatting, javascript, html, css, code, disable
|
4 |
Requires at least: 2.8
|
5 |
-
Tested up to: 3.4.
|
6 |
-
Stable tag: 1.4.
|
7 |
|
8 |
Lets you use raw HTML or any other code in your posts. You can also disable smart quotes and other automatic formatting on a per-post basis.
|
9 |
|
@@ -70,6 +70,11 @@ Open to the post editor and click the "Screen Options" button in the top-right p
|
|
70 |
|
71 |
== Changelog ==
|
72 |
|
|
|
|
|
|
|
|
|
|
|
73 |
= 1.4.7 =
|
74 |
* Tested with WP 3.4.1
|
75 |
* Fixed the Author URI (was 404).
|
2 |
Contributors: whiteshadow
|
3 |
Tags: posts, formatting, javascript, html, css, code, disable
|
4 |
Requires at least: 2.8
|
5 |
+
Tested up to: 3.4.2
|
6 |
+
Stable tag: 1.4.8
|
7 |
|
8 |
Lets you use raw HTML or any other code in your posts. You can also disable smart quotes and other automatic formatting on a per-post basis.
|
9 |
|
70 |
|
71 |
== Changelog ==
|
72 |
|
73 |
+
= 1.4.8 =
|
74 |
+
* Fixed a conflict with WP-Syntax.
|
75 |
+
* Fixed: Prevent WordPress from wrapping each [raw]...[/raw] block in a paragraph. Doesn't affect inline [raw] blocks.
|
76 |
+
* Tested with WP 3.5-beta2.
|
77 |
+
|
78 |
= 1.4.7 =
|
79 |
* Tested with WP 3.4.1
|
80 |
* Fixed the Author URI (was 404).
|