Version Description
- Fixed a rare bug where all [raw]...[/raw] blocks in a post would be replaced with the content of the first block.
Download this release
Release Info
Developer | whiteshadow |
Plugin | Raw HTML |
Version | 1.4.10 |
Comparing to | |
See all releases |
Code changes from version 1.4.9 to 1.4.10
- include/tag-handler.php +26 -9
- raw_html.php +1 -1
- readme.txt +5 -2
include/tag-handler.php
CHANGED
@@ -54,7 +54,7 @@ function wsh_extract_exclusions($text, $keep_tags = false){
|
|
54 |
$text = substr_replace($text, $replacement, $start,
|
55 |
$fin+strlen($end_tag)-$start
|
56 |
);
|
57 |
-
|
58 |
//Have we reached the end of the string yet?
|
59 |
if ($start + strlen($replacement) > strlen($text)) break;
|
60 |
|
@@ -77,24 +77,41 @@ function wsh_extract_exclusions($text, $keep_tags = false){
|
|
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 |
/**
|
84 |
* Regex callback for wsh_insert_exclusions. Returns the extracted content
|
85 |
* corresponding to a matched placeholder.
|
86 |
*
|
87 |
-
* @global $wsh_raw_parts
|
88 |
-
*
|
89 |
* @param array $matches Regex matches.
|
90 |
* @return string Replacement string for this match.
|
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 =
|
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.
|
@@ -140,8 +157,8 @@ function wsh_insert_exclusions_for_editor($text){
|
|
140 |
}
|
141 |
|
142 |
function wsh_insertion_callback_for_editor($matches){
|
143 |
-
|
144 |
-
return htmlspecialchars($
|
145 |
}
|
146 |
|
147 |
add_filter('the_editor_content', 'wsh_extract_exclusions_for_editor', 2);
|
54 |
$text = substr_replace($text, $replacement, $start,
|
55 |
$fin+strlen($end_tag)-$start
|
56 |
);
|
57 |
+
|
58 |
//Have we reached the end of the string yet?
|
59 |
if ($start + strlen($replacement) > strlen($text)) break;
|
60 |
|
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 |
+
/**
|
84 |
+
* Get the original content associated with a placeholder.
|
85 |
+
*
|
86 |
+
* @param array $matches Regex matches for a specific placeholder. @see wsh_insert_exclusions()
|
87 |
+
* @return string Original content.
|
88 |
+
*/
|
89 |
+
function wsh_get_block_from_matches($matches) {
|
90 |
+
global $wsh_raw_parts;
|
91 |
+
|
92 |
+
if ( isset($matches['index']) ) {
|
93 |
+
$index = $matches['index'];
|
94 |
+
} else if ( isset($matches[2]) ) {
|
95 |
+
$index = $matches[2];
|
96 |
+
} else {
|
97 |
+
return '{Invalid RAW block}';
|
98 |
+
}
|
99 |
+
|
100 |
+
$index = intval($index);
|
101 |
+
return $wsh_raw_parts[$index];
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
* Regex callback for wsh_insert_exclusions. Returns the extracted content
|
106 |
* corresponding to a matched placeholder.
|
107 |
*
|
|
|
|
|
108 |
* @param array $matches Regex matches.
|
109 |
* @return string Replacement string for this match.
|
110 |
*/
|
111 |
function wsh_insertion_callback($matches){
|
|
|
|
|
112 |
$openingParagraph = isset($matches[1]) ? $matches[1] : '';
|
113 |
$closingParagraph = isset($matches[3]) ? $matches[3] : '';
|
114 |
+
$code = wsh_get_block_from_matches($matches);
|
115 |
|
116 |
//If the [raw] block is wrapped in its own paragraph, strip the <p>...</p> tags. If there's
|
117 |
//only one of <p>|</p> tag present, keep it - it's probably part of a larger paragraph.
|
157 |
}
|
158 |
|
159 |
function wsh_insertion_callback_for_editor($matches){
|
160 |
+
$code = wsh_get_block_from_matches($matches);
|
161 |
+
return htmlspecialchars($code, ENT_NOQUOTES);
|
162 |
}
|
163 |
|
164 |
add_filter('the_editor_content', 'wsh_extract_exclusions_for_editor', 2);
|
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.10
|
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.6-
|
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,9 @@ Open to the post editor and click the "Screen Options" button in the top-right p
|
|
70 |
|
71 |
== Changelog ==
|
72 |
|
|
|
|
|
|
|
73 |
= 1.4.9 =
|
74 |
* Fixed a new conflict with WP-Syntax 1.0.
|
75 |
* Tested with WP 3.5.1 and WP 3.6-beta1.
|
2 |
Contributors: whiteshadow
|
3 |
Tags: posts, formatting, javascript, html, css, code, disable
|
4 |
Requires at least: 2.8
|
5 |
+
Tested up to: 3.6-beta2
|
6 |
+
Stable tag: 1.4.10
|
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.10 =
|
74 |
+
* Fixed a rare bug where all [raw]...[/raw] blocks in a post would be replaced with the content of the first block.
|
75 |
+
|
76 |
= 1.4.9 =
|
77 |
* Fixed a new conflict with WP-Syntax 1.0.
|
78 |
* Tested with WP 3.5.1 and WP 3.6-beta1.
|