Version Description
Download this release
Release Info
Developer | jim912 |
Plugin | PS Disable Auto Formatting |
Version | 1.0.0 |
Comparing to | |
See all releases |
Code changes from version 0.9.2 to 1.0.0
- js/280/ps_editor.js +158 -0
- ps_disable_auto_formatting.php +6 -4
- readme.txt +15 -12
js/280/ps_editor.js
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
jQuery(document).ready(function($){
|
3 |
+
var h = wpCookies.getHash('TinyMCE_content_size');
|
4 |
+
|
5 |
+
if ( getUserSetting( 'editor' ) == 'html' ) {
|
6 |
+
if ( h )
|
7 |
+
$('#content').css('height', h.ch - 15 + 'px');
|
8 |
+
} else {
|
9 |
+
$('#content').css('color', 'white');
|
10 |
+
$('#quicktags').hide();
|
11 |
+
}
|
12 |
+
});
|
13 |
+
|
14 |
+
var switchEditors = {
|
15 |
+
|
16 |
+
mode : '',
|
17 |
+
|
18 |
+
I : function(e) {
|
19 |
+
return document.getElementById(e);
|
20 |
+
},
|
21 |
+
|
22 |
+
edInit : function() {
|
23 |
+
},
|
24 |
+
|
25 |
+
saveCallback : function(el, content, body) {
|
26 |
+
|
27 |
+
if ( tinyMCE.activeEditor.isHidden() )
|
28 |
+
content = this.I(el).value;
|
29 |
+
else
|
30 |
+
content = this.pre_wpautop(content);
|
31 |
+
|
32 |
+
return content;
|
33 |
+
},
|
34 |
+
|
35 |
+
pre_wpautop : function(content) {
|
36 |
+
var blocklist1, blocklist2;
|
37 |
+
|
38 |
+
// Protect pre|script tags
|
39 |
+
content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
|
40 |
+
a = a.replace(/<br ?\/?>[\r\n]*/g, '<wp_temp>');
|
41 |
+
return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '<wp_temp>');
|
42 |
+
});
|
43 |
+
|
44 |
+
// Pretty it up for the source editor
|
45 |
+
var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p';
|
46 |
+
content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
|
47 |
+
content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
|
48 |
+
|
49 |
+
content = content.replace(new RegExp('<p( [^>]*)?>[\\s\\n]*<(/?script[^>]*)>', 'mg'), '\n<$2>');
|
50 |
+
content = content.replace(new RegExp('<(/?script[^>]*)>[\\s\\n]*</p>', 'mg'), '\n<$1>');
|
51 |
+
|
52 |
+
// Fix some block element newline issues
|
53 |
+
content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
|
54 |
+
content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
|
55 |
+
content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
|
56 |
+
content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
|
57 |
+
|
58 |
+
var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
|
59 |
+
content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
|
60 |
+
content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
|
61 |
+
content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
|
62 |
+
|
63 |
+
if ( content.indexOf('<object') != -1 ) {
|
64 |
+
content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
|
65 |
+
content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
|
66 |
+
}
|
67 |
+
|
68 |
+
// Unmark special paragraph closing tags
|
69 |
+
content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
|
70 |
+
content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
|
71 |
+
content = content.replace(new RegExp('<p>\\s*</p>', 'mg'), "<p> </p>\n");
|
72 |
+
|
73 |
+
// put back the line breaks in pre|script
|
74 |
+
content = content.replace(/<wp_temp>/g, '\n');
|
75 |
+
// Hope.
|
76 |
+
return content;
|
77 |
+
},
|
78 |
+
|
79 |
+
go : function(id, mode) {
|
80 |
+
id = id || 'content';
|
81 |
+
mode = mode || this.mode || '';
|
82 |
+
|
83 |
+
var ed, qt = this.I('quicktags'), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'), ta = this.I(id);
|
84 |
+
|
85 |
+
try { ed = tinyMCE.get(id); }
|
86 |
+
catch(e) { ed = false; }
|
87 |
+
|
88 |
+
if ( 'tinymce' == mode ) {
|
89 |
+
if ( ed && ! ed.isHidden() )
|
90 |
+
return false;
|
91 |
+
|
92 |
+
setUserSetting( 'editor', 'tinymce' );
|
93 |
+
this.mode = 'html';
|
94 |
+
|
95 |
+
P.className = 'active';
|
96 |
+
H.className = '';
|
97 |
+
edCloseAllTags(); // :-(
|
98 |
+
qt.style.display = 'none';
|
99 |
+
|
100 |
+
ta.value = this.wpautop(ta.value);
|
101 |
+
|
102 |
+
if ( ed ) {
|
103 |
+
ed.show();
|
104 |
+
} else {
|
105 |
+
try{tinyMCE.execCommand("mceAddControl", false, id);}
|
106 |
+
catch(e){}
|
107 |
+
}
|
108 |
+
} else {
|
109 |
+
setUserSetting( 'editor', 'html' );
|
110 |
+
ta.style.color = '#000';
|
111 |
+
this.mode = 'tinymce';
|
112 |
+
H.className = 'active';
|
113 |
+
P.className = '';
|
114 |
+
|
115 |
+
if ( ed && !ed.isHidden() ) {
|
116 |
+
ta.style.height = ed.getContentAreaContainer().offsetHeight + 24 + 'px';
|
117 |
+
ed.hide();
|
118 |
+
}
|
119 |
+
|
120 |
+
qt.style.display = 'block';
|
121 |
+
}
|
122 |
+
return false;
|
123 |
+
},
|
124 |
+
|
125 |
+
wpautop : function(pee) {
|
126 |
+
// filtered when switching html to visual
|
127 |
+
var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|script';
|
128 |
+
var blocklist2 = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|h[1-6]|script';
|
129 |
+
pee = pee + "\n\n";
|
130 |
+
pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
|
131 |
+
pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), "$1\n\n");
|
132 |
+
pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
|
133 |
+
pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
|
134 |
+
pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
|
135 |
+
pee = pee.replace(new RegExp('<p( [^>]*)?>[\\s\\n]*</p>', 'mg'), "<p$1> </p>\n");
|
136 |
+
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
|
137 |
+
pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
|
138 |
+
pee = pee.replace(new RegExp("<p ?[^>]*>(<!--(.*)?-->)", 'gi'), "$1");
|
139 |
+
pee = pee.replace(new RegExp("(<!--(.*)?-->)</p>", 'gi'), "$1");
|
140 |
+
pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
|
141 |
+
pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
|
142 |
+
pee = pee.replace(new RegExp('<p>[\\s\\n]*(<(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
|
143 |
+
pee = pee.replace(new RegExp('<p>[\\s\\n]*(</(?:'+blocklist2+')[^>]*>)', 'gi'), "$1");
|
144 |
+
pee = pee.replace(new RegExp('(<(?:'+blocklist2+')[^>]*>)[\\s\\n]*</p>', 'gi'), "$1");
|
145 |
+
pee = pee.replace(new RegExp('(</(?:'+blocklist+')[^>]*>)[\\s\\n]*</p>', 'gi'), "$1");
|
146 |
+
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
|
147 |
+
pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
|
148 |
+
pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
|
149 |
+
|
150 |
+
// Fix the pre|script tags
|
151 |
+
pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
|
152 |
+
a = a.replace(/<br ?\/?>[\r\n]*/g, '\n');
|
153 |
+
return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n');
|
154 |
+
});
|
155 |
+
|
156 |
+
return pee;
|
157 |
+
}
|
158 |
+
};
|
ps_disable_auto_formatting.php
CHANGED
@@ -2,12 +2,10 @@
|
|
2 |
/*
|
3 |
Plugin Name: PS Disable Auto Formatting
|
4 |
Plugin URI: http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/
|
5 |
-
Description: PS
|
6 |
-
Version: 0.9.2
|
7 |
Author: Hitoshi Omagari
|
8 |
Author URI: http://www.web-strategy.jp/
|
9 |
*/
|
10 |
-
$ps_disable_auto_formatting =& new ps_disable_auto_formatting();
|
11 |
|
12 |
class ps_disable_auto_formatting {
|
13 |
|
@@ -91,7 +89,9 @@ function set_default_settings() {
|
|
91 |
function rewrite_default_script( $todo ) {
|
92 |
global $wp_version, $wp_scripts;
|
93 |
|
94 |
-
if ( version_compare( $wp_version, '2.
|
|
|
|
|
95 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/270/ps_editor.js';
|
96 |
} else {
|
97 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/250/ps_editor.js';
|
@@ -303,3 +303,5 @@ function version_too_old() {
|
|
303 |
}
|
304 |
|
305 |
} // class end
|
|
|
|
2 |
/*
|
3 |
Plugin Name: PS Disable Auto Formatting
|
4 |
Plugin URI: http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/
|
5 |
+
Description: PS 1.0.0
|
|
|
6 |
Author: Hitoshi Omagari
|
7 |
Author URI: http://www.web-strategy.jp/
|
8 |
*/
|
|
|
9 |
|
10 |
class ps_disable_auto_formatting {
|
11 |
|
89 |
function rewrite_default_script( $todo ) {
|
90 |
global $wp_version, $wp_scripts;
|
91 |
|
92 |
+
if ( version_compare( $wp_version, '2.8', '>=' ) ) {
|
93 |
+
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/280/ps_editor.js';
|
94 |
+
} elseif ( version_compare( $wp_version, '2.7', '>=' ) ) {
|
95 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/270/ps_editor.js';
|
96 |
} else {
|
97 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/250/ps_editor.js';
|
303 |
}
|
304 |
|
305 |
} // class end
|
306 |
+
|
307 |
+
$ps_disable_auto_formatting =& new ps_disable_auto_formatting();
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: jim912
|
3 |
Tags: auto formatting, formatting, format, paragraph, linebreak, wpautop
|
4 |
Requires at least: 2.5
|
5 |
-
Tested up to: 2.
|
6 |
Stable tag: trunk
|
7 |
|
8 |
Stops the automatic forming and the HTML tag removal in the html mode of WordPress, and generates a natural paragraph and changing line.
|
@@ -23,17 +23,6 @@ And when editing in the visual mode, it achieves to generate natural changing li
|
|
23 |
* Stops the auto removal of p and br tag when editing html mode.
|
24 |
* Batch formatting to all articles that you have already posted.
|
25 |
|
26 |
-
= Version History =
|
27 |
-
* **0.9.2**
|
28 |
-
* bugfix : disappearing nothing included paragraph and linebreak element when load a post to edit
|
29 |
-
* bugfix : wrong javascript path in case of WordPress is set as sub directory.
|
30 |
-
* bugfix : in version 2.6 or 2.5, javascript isn't replaced.
|
31 |
-
* **0.9.1**
|
32 |
-
* bugfix : disappearing paragraph element with swithing mode in some browsers
|
33 |
-
* compatible with quickpress
|
34 |
-
* **0.9.0**
|
35 |
-
* Public release
|
36 |
-
|
37 |
== Installation ==
|
38 |
|
39 |
1. Unzip the downloaded package and upload into your WordPress plugins directory.
|
@@ -75,6 +64,20 @@ When "Batch formatting" button is pushed, the batch plastic operation is done. T
|
|
75 |
To prevent the operational error, the batch processing is not done if there is no permission.
|
76 |
Please check "Permit batch formatting" check box.
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
== Screenshots ==
|
79 |
1. Administration interface of PS Disable Auto Formatting
|
80 |
|
2 |
Contributors: jim912
|
3 |
Tags: auto formatting, formatting, format, paragraph, linebreak, wpautop
|
4 |
Requires at least: 2.5
|
5 |
+
Tested up to: 2.8.3
|
6 |
Stable tag: trunk
|
7 |
|
8 |
Stops the automatic forming and the HTML tag removal in the html mode of WordPress, and generates a natural paragraph and changing line.
|
23 |
* Stops the auto removal of p and br tag when editing html mode.
|
24 |
* Batch formatting to all articles that you have already posted.
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
== Installation ==
|
27 |
|
28 |
1. Unzip the downloaded package and upload into your WordPress plugins directory.
|
64 |
To prevent the operational error, the batch processing is not done if there is no permission.
|
65 |
Please check "Permit batch formatting" check box.
|
66 |
|
67 |
+
== Changelog ==
|
68 |
+
* **1.0.0**
|
69 |
+
* compatible with WordPress version 2.8
|
70 |
+
(bugfix : post area is whiteouted when switching visual to html mode in version 2.8)
|
71 |
+
* **0.9.2**
|
72 |
+
* bugfix : disappearing nothing included paragraph and linebreak element when load a post to edit
|
73 |
+
* bugfix : wrong javascript path in case of WordPress is set as sub directory.
|
74 |
+
* bugfix : in version 2.6 or 2.5, javascript isn't replaced.
|
75 |
+
* **0.9.1**
|
76 |
+
* bugfix : disappearing paragraph element with swithing mode in some browsers
|
77 |
+
* compatible with quickpress
|
78 |
+
* **0.9.0**
|
79 |
+
* Public release
|
80 |
+
|
81 |
== Screenshots ==
|
82 |
1. Administration interface of PS Disable Auto Formatting
|
83 |
|