Raw HTML - Version 1.4.16

Version Description

  • Tested with WP 4.5.
Download this release

Release Info

Developer whiteshadow
Plugin Icon wp plugin Raw HTML
Version 1.4.16
Comparing to
See all releases

Code changes from version 1.4.15 to 1.4.16

include/screen-options/screen-options.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- if ( !class_exists('wsScreenOptions12') ):
4
 
5
  /**
6
  * Class for adding new panels to the "Screen Options" box.
@@ -8,13 +8,13 @@ if ( !class_exists('wsScreenOptions12') ):
8
  * Do not access this class directly. Instead, use the add_screen_options_panel() function.
9
  *
10
  * @author Janis Elsts
11
- * @copyright 2010
12
- * @version 1.2
13
  * @access public
14
  */
15
- class wsScreenOptions12 {
16
- var $registered_panels; //List of custom "Screen Options" panels
17
- var $page_panels; //Index of panels registered for each page ($page => array of panel ids).
18
 
19
  /**
20
  * Class constructor
@@ -24,10 +24,11 @@ class wsScreenOptions12 {
24
  function init(){
25
  $this->registered_panels = array();
26
  $this->page_panels = array();
27
-
28
- add_filter('screen_settings', array(&$this, 'append_screen_settings'), 10, 2);
29
- add_action('admin_print_scripts', array(&$this, 'add_autosave_script'));
30
- }
 
31
 
32
  /**
33
  * Add a new settings panel to the "Screen Options" box.
@@ -37,38 +38,53 @@ class wsScreenOptions12 {
37
  * @param callback $callback Function that fills the panel with the desired content. Should return its output.
38
  * @param string|array $page The page(s) on which to show the panel (similar to add_meta_box()).
39
  * @param callback $save_callback Optional. Function that saves the settings.
40
- * @param bool $autosave Optional. If se, settings will be automatically saved (via AJAX) when the value of any input element in the panel changes. Defaults to false.
41
  * @return void
42
  */
43
  function add_screen_options_panel($id, $title, $callback, $page, $save_callback = null, $autosave = false){
44
  if ( !is_array($page) ){
45
  $page = array($page);
46
  }
47
- //Convert page hooks/slugs to screen IDs
48
- $page = array_map(array(&$this, 'page_to_screen_id'), $page);
49
- $page = array_unique($page);
50
-
51
  $new_panel = array(
52
  'title' => $title,
53
  'callback' => $callback,
54
- 'page' => $page,
55
  'save_callback' => $save_callback,
56
  'autosave' => $autosave,
57
  );
58
-
 
59
  if ( $save_callback ){
60
- add_action('wp_ajax_save_settings-' . $id, array(&$this, 'ajax_save_callback'));
61
  }
62
-
63
- //Store the panel ID in each relevant page's list
64
- foreach($page as $page_id){
65
- if ( !isset($this->page_panels[$page_id]) ){
66
- $this->page_panels[$page_id] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
- $this->page_panels[$page_id][] = $id;
69
  }
70
-
71
- $this->registered_panels[$id] = $new_panel;
72
  }
73
 
74
  /**
@@ -81,7 +97,7 @@ class wsScreenOptions12 {
81
  * @return string
82
  */
83
  function page_to_screen_id($page){
84
- if ( function_exists('convert_to_screen') ){
85
  $screen = convert_to_screen($page);
86
  if ( isset($screen->id) ){
87
  return $screen->id;
@@ -243,7 +259,7 @@ global $ws_screen_options_versions;
243
  if ( !isset($ws_screen_options_versions) ){
244
  $ws_screen_options_versions = array();
245
  }
246
- $ws_screen_options_versions['1.2'] = 'wsScreenOptions12';
247
 
248
  endif;
249
 
@@ -252,7 +268,7 @@ if ( !function_exists('add_screen_options_panel') ){
252
  /**
253
  * Add a new settings panel to the "Screen Options" box.
254
  *
255
- * @see wsScreenOptions10::add_screen_options_panel()
256
  *
257
  * @param string $id String to use in the 'id' attribute of the settings panel. Should be unique.
258
  * @param string $title Title of the settings panel. Set to an empty string to omit title.
@@ -265,7 +281,7 @@ if ( !function_exists('add_screen_options_panel') ){
265
  function add_screen_options_panel($id, $title, $callback, $page, $save_callback = null, $autosave = false){
266
  global $ws_screen_options_versions;
267
 
268
- static $instance = null;
269
  if ( is_null($instance) ){
270
  //Instantiate the latest version of the wsScreenOptions class
271
  uksort($ws_screen_options_versions, 'version_compare');
@@ -274,9 +290,8 @@ if ( !function_exists('add_screen_options_panel') ){
274
  $instance->init();
275
  }
276
 
277
- return $instance->add_screen_options_panel($id, $title, $callback, $page, $save_callback, $autosave);
278
  }
279
 
280
  }
281
 
282
- ?>
1
  <?php
2
 
3
+ if ( !class_exists('wsScreenOptions14') ):
4
 
5
  /**
6
  * Class for adding new panels to the "Screen Options" box.
8
  * Do not access this class directly. Instead, use the add_screen_options_panel() function.
9
  *
10
  * @author Janis Elsts
11
+ * @copyright 2015
12
+ * @version 1.4
13
  * @access public
14
  */
15
+ class wsScreenOptions14 {
16
+ protected $registered_panels; //List of custom "Screen Options" panels
17
+ protected $page_panels; //Index of panels registered for each page ($page => array of panel ids).
18
 
19
  /**
20
  * Class constructor
24
  function init(){
25
  $this->registered_panels = array();
26
  $this->page_panels = array();
27
+
28
+ add_action('current_screen', array($this, 'populate_page_panels'));
29
+ add_filter('screen_settings', array($this, 'append_screen_settings'), 10, 2);
30
+ add_action('admin_print_scripts', array($this, 'add_autosave_script'));
31
+ }
32
 
33
  /**
34
  * Add a new settings panel to the "Screen Options" box.
38
  * @param callback $callback Function that fills the panel with the desired content. Should return its output.
39
  * @param string|array $page The page(s) on which to show the panel (similar to add_meta_box()).
40
  * @param callback $save_callback Optional. Function that saves the settings.
41
+ * @param bool $autosave Optional. If set, settings will be automatically saved (via AJAX) when the value of any input element in the panel changes. Defaults to false.
42
  * @return void
43
  */
44
  function add_screen_options_panel($id, $title, $callback, $page, $save_callback = null, $autosave = false){
45
  if ( !is_array($page) ){
46
  $page = array($page);
47
  }
48
+
 
 
 
49
  $new_panel = array(
50
  'title' => $title,
51
  'callback' => $callback,
52
+ 'page' => $page,
53
  'save_callback' => $save_callback,
54
  'autosave' => $autosave,
55
  );
56
+ $this->registered_panels[$id] = $new_panel;
57
+
58
  if ( $save_callback ){
59
+ add_action('wp_ajax_save_settings-' . $id, array($this, 'ajax_save_callback'));
60
  }
61
+ }
62
+
63
+ /**
64
+ * Populate a lookup table for screen -> panels queries.
65
+ *
66
+ * This is a callback for the "current_screen" action. We have to do it in this hook or WordPress will
67
+ * complain about "doing it wrong" and incorrectly suggest using the "add_meta_boxes" action.
68
+ *
69
+ * "add_meta_boxes" doesn't work here because it only gets called on CPT pages and we want the ability
70
+ * to add screen options to any page.
71
+ */
72
+ function populate_page_panels() {
73
+ foreach($this->registered_panels as $id => $panel) {
74
+ $page = $panel['page'];
75
+
76
+ //Convert page hooks/slugs to screen IDs
77
+ $page = array_map(array($this, 'page_to_screen_id'), $page);
78
+ $page = array_unique($page);
79
+
80
+ //Store the panel ID in each relevant page's list
81
+ foreach($page as $page_id){
82
+ if ( !isset($this->page_panels[$page_id]) ){
83
+ $this->page_panels[$page_id] = array();
84
+ }
85
+ $this->page_panels[$page_id][] = $id;
86
  }
 
87
  }
 
 
88
  }
89
 
90
  /**
97
  * @return string
98
  */
99
  function page_to_screen_id($page){
100
+ if ( function_exists('convert_to_screen') && class_exists('WP_Screen') ){
101
  $screen = convert_to_screen($page);
102
  if ( isset($screen->id) ){
103
  return $screen->id;
259
  if ( !isset($ws_screen_options_versions) ){
260
  $ws_screen_options_versions = array();
261
  }
262
+ $ws_screen_options_versions['1.4'] = 'wsScreenOptions14';
263
 
264
  endif;
265
 
268
  /**
269
  * Add a new settings panel to the "Screen Options" box.
270
  *
271
+ * @see wsScreenOptions14::add_screen_options_panel()
272
  *
273
  * @param string $id String to use in the 'id' attribute of the settings panel. Should be unique.
274
  * @param string $title Title of the settings panel. Set to an empty string to omit title.
281
  function add_screen_options_panel($id, $title, $callback, $page, $save_callback = null, $autosave = false){
282
  global $ws_screen_options_versions;
283
 
284
+ static $instance = null; /** @var wsScreenOptions14 $instance */
285
  if ( is_null($instance) ){
286
  //Instantiate the latest version of the wsScreenOptions class
287
  uksort($ws_screen_options_versions, 'version_compare');
290
  $instance->init();
291
  }
292
 
293
+ $instance->add_screen_options_panel($id, $title, $callback, $page, $save_callback, $autosave);
294
  }
295
 
296
  }
297
 
 
include/tag-handler.php CHANGED
@@ -4,7 +4,7 @@
4
  Filter inline blocks of raw HTML
5
  ***********************************************/
6
  global $wsh_raw_parts;
7
- $wsh_raw_parts=array();
8
 
9
  /**
10
  * Extract content surrounded by [raw] or other supported tags
@@ -158,7 +158,10 @@ function wsh_insert_exclusions_for_editor($text){
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);
4
  Filter inline blocks of raw HTML
5
  ***********************************************/
6
  global $wsh_raw_parts;
7
+ $wsh_raw_parts = array();
8
 
9
  /**
10
  * Extract content surrounded by [raw] or other supported tags
158
 
159
  function wsh_insertion_callback_for_editor($matches){
160
  $code = wsh_get_block_from_matches($matches);
161
+ if ( !function_exists('format_for_editor') || has_filter('the_editor_content', 'format_for_editor') ) {
162
+ $code = htmlspecialchars($code, ENT_NOQUOTES);
163
+ }
164
+ return $code;
165
  }
166
 
167
  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.15
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.16
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: 4.2
6
- Stable tag: 1.4.15
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
 
@@ -72,6 +72,9 @@ Open to the post editor and click the "Screen Options" button in the top-right p
72
 
73
  == Changelog ==
74
 
 
 
 
75
  = 1.4.15 =
76
  * Tested with WP 4.2.
77
  * Fixed a rare "trying to get property of non-object" notice.
2
  Contributors: whiteshadow
3
  Tags: posts, formatting, javascript, html, css, code, disable
4
  Requires at least: 2.8
5
+ Tested up to: 4.5
6
+ Stable tag: 1.4.16
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
 
72
 
73
  == Changelog ==
74
 
75
+ = 1.4.16 =
76
+ * Tested with WP 4.5.
77
+
78
  = 1.4.15 =
79
  * Tested with WP 4.2.
80
  * Fixed a rare "trying to get property of non-object" notice.