Version Description
- Added a way to preserve
[raw]
blocks in post excerpts. - Enabled the "Raw HTML" metabox for custom post types.
- Tested up to WP 5.2 (only with the Classic Editor).
Download this release
Release Info
Developer | whiteshadow |
Plugin | Raw HTML |
Version | 1.6 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.6
- include/formatting-override.php +35 -35
- include/tag-handler.php +9 -1
- raw_html.php +1 -1
- readme.txt +17 -2
include/formatting-override.php
CHANGED
@@ -87,9 +87,13 @@ add_action('save_post', 'rawhtml_save_postdata');
|
|
87 |
|
88 |
/* Adds a custom section to the "advanced" Post and Page edit screens */
|
89 |
function rawhtml_add_custom_box() {
|
90 |
-
//WP
|
91 |
-
if( function_exists(
|
92 |
-
|
|
|
|
|
|
|
|
|
93 |
add_meta_box( 'rawhtml_meta_box', 'Raw HTML', 'rawhtml_meta_box', $type, 'side' );
|
94 |
}
|
95 |
}
|
@@ -130,39 +134,35 @@ function rawhtml_meta_box(){
|
|
130 |
}
|
131 |
|
132 |
/* Saves post metadata */
|
133 |
-
function rawhtml_save_postdata(
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
if ( !isset($_POST['rawhtml_nonce']) ){
|
138 |
-
return $post_id;
|
139 |
-
}
|
140 |
-
|
141 |
-
if ( !wp_verify_nonce( $_POST['rawhtml_nonce'], plugin_basename(RAWHTML_PLUGIN_FILE) )) {
|
142 |
-
return $post_id;
|
143 |
-
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
|
166 |
}
|
167 |
|
168 |
//Add our panel to the "Screen Options" box
|
@@ -330,7 +330,7 @@ function rawhtml_default_settings_panel(){
|
|
330 |
$esc_field = esc_attr($field);
|
331 |
$output .= sprintf(
|
332 |
'<label for="rawhtml_default-%s" style="line-height: 20px;">
|
333 |
-
<input type="checkbox" name="rawhtml_default-%s" id="rawhtml_default-%s"%s>
|
334 |
%s
|
335 |
</label><br>',
|
336 |
$esc_field,
|
87 |
|
88 |
/* Adds a custom section to the "advanced" Post and Page edit screens */
|
89 |
function rawhtml_add_custom_box() {
|
90 |
+
//WP 3.0+
|
91 |
+
if( function_exists('add_meta_box') && function_exists('post_type_supports') ) {
|
92 |
+
$types = get_post_types(array('show_ui' => true, 'show_in_menu' => true), 'names');
|
93 |
+
foreach( $types as $type ) {
|
94 |
+
if ( !post_type_supports($type, 'editor') ) {
|
95 |
+
continue;
|
96 |
+
}
|
97 |
add_meta_box( 'rawhtml_meta_box', 'Raw HTML', 'rawhtml_meta_box', $type, 'side' );
|
98 |
}
|
99 |
}
|
134 |
}
|
135 |
|
136 |
/* Saves post metadata */
|
137 |
+
function rawhtml_save_postdata($post_id) {
|
138 |
+
// Verify this came from the our screen and with proper authorization,
|
139 |
+
// because save_post can be triggered at other times
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
+
if ( !isset($_POST['rawhtml_nonce']) ) {
|
142 |
+
return $post_id;
|
143 |
+
}
|
144 |
+
|
145 |
+
if ( !wp_verify_nonce($_POST['rawhtml_nonce'], plugin_basename(RAWHTML_PLUGIN_FILE)) ) {
|
146 |
+
return $post_id;
|
147 |
+
}
|
148 |
+
|
149 |
+
if ( !current_user_can('edit_post', $post_id) ) {
|
150 |
+
return $post_id;
|
151 |
+
}
|
152 |
+
|
153 |
+
// OK, we're authenticated: we need to find and save the data
|
154 |
+
$fields = rawhtml_get_settings_fields();
|
155 |
+
$new_settings = array();
|
156 |
+
foreach ($fields as $field) {
|
157 |
+
if ( !empty($_POST['rawhtml_' . $field]) ) {
|
158 |
+
$new_settings[$field] = true;
|
159 |
+
} else {
|
160 |
+
$new_settings[$field] = false;
|
161 |
+
};
|
162 |
+
}
|
163 |
+
rawhtml_save_post_settings($post_id, $new_settings);
|
164 |
|
165 |
+
return true;
|
166 |
}
|
167 |
|
168 |
//Add our panel to the "Screen Options" box
|
330 |
$esc_field = esc_attr($field);
|
331 |
$output .= sprintf(
|
332 |
'<label for="rawhtml_default-%s" style="line-height: 20px;">
|
333 |
+
<input type="checkbox" name="rawhtml_default-%s" id="rawhtml_default-%s" %s>
|
334 |
%s
|
335 |
</label><br>',
|
336 |
$esc_field,
|
include/tag-handler.php
CHANGED
@@ -27,6 +27,9 @@ function wsh_extract_exclusions($text, $keep_tags = false){
|
|
27 |
array('@<!--raw' . $shortcode_flag . '-->@i', '<!--/raw-->')
|
28 |
);
|
29 |
|
|
|
|
|
|
|
30 |
foreach ($tags as $tag_pair){
|
31 |
list($start_regex, $end_tag) = $tag_pair;
|
32 |
|
@@ -46,7 +49,12 @@ function wsh_extract_exclusions($text, $keep_tags = false){
|
|
46 |
//extract the content between the tags
|
47 |
$content = substr($text, $content_start,$fin-$content_start);
|
48 |
|
49 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
50 |
//Strip out the raw blocks when displaying an excerpt
|
51 |
$replacement = '';
|
52 |
} else {
|
27 |
array('@<!--raw' . $shortcode_flag . '-->@i', '<!--/raw-->')
|
28 |
);
|
29 |
|
30 |
+
$is_excerpt_stripping_enabled = !defined('RAW_HTML_KEEP_RAW_IN_EXCERPTS')
|
31 |
+
|| !constant('RAW_HTML_KEEP_RAW_IN_EXCERPTS');
|
32 |
+
|
33 |
foreach ($tags as $tag_pair){
|
34 |
list($start_regex, $end_tag) = $tag_pair;
|
35 |
|
49 |
//extract the content between the tags
|
50 |
$content = substr($text, $content_start,$fin-$content_start);
|
51 |
|
52 |
+
if ( $is_excerpt_stripping_enabled
|
53 |
+
&& (
|
54 |
+
(array_search('get_the_excerpt', $wp_current_filter) !== false)
|
55 |
+
|| (array_search('the_excerpt', $wp_current_filter) !== false)
|
56 |
+
)
|
57 |
+
){
|
58 |
//Strip out the raw blocks when displaying an excerpt
|
59 |
$replacement = '';
|
60 |
} else {
|
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.
|
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.6
|
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:
|
6 |
-
Stable tag: 1.
|
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 |
|
@@ -50,8 +50,18 @@ By default, shortcodes that are inside [raw] tags will not work. They will just
|
|
50 |
|
51 |
[raw]This [shortcode] won't work.[/raw]`
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
**Notes**
|
54 |
|
|
|
|
|
55 |
Some features of Raw HTML will only work for users who have the "unfiltered_html" capability. In a normal WordPress install that includes the Editor and Administrator roles. In a Multisite install, only the Super Admin has this capability by default.
|
56 |
|
57 |
== Installation ==
|
@@ -80,6 +90,11 @@ Open to the post editor and click the "Screen Options" button in the top-right p
|
|
80 |
|
81 |
== Changelog ==
|
82 |
|
|
|
|
|
|
|
|
|
|
|
83 |
= 1.5.1 =
|
84 |
* Added limited support for the page builder included with GoodLayers themes (e.g. Mediso).
|
85 |
* Tested with WP 4.8.2 and 4.9-beta1.
|
2 |
Contributors: whiteshadow
|
3 |
Tags: posts, formatting, javascript, html, css, code, disable
|
4 |
Requires at least: 2.8
|
5 |
+
Tested up to: 5.2
|
6 |
+
Stable tag: 1.6
|
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 |
|
50 |
|
51 |
[raw]This [shortcode] won't work.[/raw]`
|
52 |
|
53 |
+
**Preserving `[raw]` code in excerpts**
|
54 |
+
|
55 |
+
By default, the plugin will automatically remove any code that's inside `[raw]...[/raw]` tags from post excerpts. You can prevent that by adding the following line to `wp-config.php`:
|
56 |
+
|
57 |
+
`define('RAW_HTML_KEEP_RAW_IN_EXCERPTS', true);`
|
58 |
+
|
59 |
+
This will ensure that the plugin doesn't strip `[raw]` blocks from automatically generated excerpts.
|
60 |
+
|
61 |
**Notes**
|
62 |
|
63 |
+
This plugin doesn't fully support the Gutenberg editor. It will only work with the classic post editor.
|
64 |
+
|
65 |
Some features of Raw HTML will only work for users who have the "unfiltered_html" capability. In a normal WordPress install that includes the Editor and Administrator roles. In a Multisite install, only the Super Admin has this capability by default.
|
66 |
|
67 |
== Installation ==
|
90 |
|
91 |
== Changelog ==
|
92 |
|
93 |
+
= 1.6 =
|
94 |
+
* Added a way to preserve `[raw]` blocks in post excerpts.
|
95 |
+
* Enabled the "Raw HTML" metabox for custom post types.
|
96 |
+
* Tested up to WP 5.2 (only with the Classic Editor).
|
97 |
+
|
98 |
= 1.5.1 =
|
99 |
* Added limited support for the page builder included with GoodLayers themes (e.g. Mediso).
|
100 |
* Tested with WP 4.8.2 and 4.9-beta1.
|