Version Description
Download this release
Release Info
Developer | jim912 |
Plugin | PS Disable Auto Formatting |
Version | 1.0.9 |
Comparing to | |
See all releases |
Code changes from version 1.0.8 to 1.0.9
- js/390/ps_editor.js +219 -0
- ps_disable_auto_formatting.php +5 -3
- readme.txt +5 -3
- screenshot-1.png +0 -0
js/390/ps_editor.js
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
var switchEditors = {
|
3 |
+
|
4 |
+
switchto: function(el) {
|
5 |
+
var aid = el.id, l = aid.length, id = aid.substr(0, l - 5), mode = aid.substr(l - 4);
|
6 |
+
|
7 |
+
this.go(id, mode);
|
8 |
+
},
|
9 |
+
|
10 |
+
// mode can be 'html', 'tmce', or 'toggle'; 'html' is used for the 'Text' editor tab.
|
11 |
+
go: function( id, mode ) {
|
12 |
+
var t = this, ed, wrap_id, txtarea_el, iframe, editorHeight, toolbarHeight,
|
13 |
+
DOM = tinymce.DOM; //DOMUtils outside the editor iframe
|
14 |
+
|
15 |
+
id = id || 'content';
|
16 |
+
mode = mode || 'toggle';
|
17 |
+
|
18 |
+
ed = tinymce.get( id );
|
19 |
+
wrap_id = 'wp-' + id + '-wrap';
|
20 |
+
txtarea_el = DOM.get( id );
|
21 |
+
|
22 |
+
if ( 'toggle' === mode ) {
|
23 |
+
if ( ed && ! ed.isHidden() ) {
|
24 |
+
mode = 'html';
|
25 |
+
} else {
|
26 |
+
mode = 'tmce';
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
function getToolbarHeight() {
|
31 |
+
var node = DOM.select( '.mce-toolbar-grp', ed.getContainer() )[0],
|
32 |
+
height = node && node.clientHeight;
|
33 |
+
|
34 |
+
if ( height && height > 10 && height < 200 ) {
|
35 |
+
return parseInt( height, 10 );
|
36 |
+
}
|
37 |
+
|
38 |
+
return 30;
|
39 |
+
}
|
40 |
+
|
41 |
+
if ( 'tmce' === mode || 'tinymce' === mode ) {
|
42 |
+
if ( ed && ! ed.isHidden() ) {
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
if ( typeof( QTags ) !== 'undefined' ) {
|
47 |
+
QTags.closeAllTags( id );
|
48 |
+
}
|
49 |
+
|
50 |
+
editorHeight = txtarea_el ? parseInt( txtarea_el.style.height, 10 ) : 0;
|
51 |
+
|
52 |
+
if ( tinyMCEPreInit.mceInit[ id ] && tinyMCEPreInit.mceInit[ id ].wpautop ) {
|
53 |
+
txtarea_el.value = t.wpautop( txtarea_el.value );
|
54 |
+
}
|
55 |
+
|
56 |
+
if ( ed ) {
|
57 |
+
ed.show();
|
58 |
+
|
59 |
+
if ( editorHeight ) {
|
60 |
+
toolbarHeight = getToolbarHeight();
|
61 |
+
editorHeight = editorHeight - toolbarHeight + 14;
|
62 |
+
|
63 |
+
// height cannot be under 50 or over 5000
|
64 |
+
if ( editorHeight > 50 && editorHeight < 5000 ) {
|
65 |
+
ed.theme.resizeTo( null, editorHeight );
|
66 |
+
}
|
67 |
+
}
|
68 |
+
} else {
|
69 |
+
tinymce.init( tinyMCEPreInit.mceInit[id] );
|
70 |
+
}
|
71 |
+
|
72 |
+
DOM.removeClass( wrap_id, 'html-active' );
|
73 |
+
DOM.addClass( wrap_id, 'tmce-active' );
|
74 |
+
setUserSetting( 'editor', 'tinymce' );
|
75 |
+
|
76 |
+
} else if ( 'html' === mode ) {
|
77 |
+
|
78 |
+
if ( ed && ed.isHidden() ) {
|
79 |
+
return false;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( ed ) {
|
83 |
+
iframe = DOM.get( id + '_ifr' );
|
84 |
+
editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0;
|
85 |
+
|
86 |
+
if ( editorHeight ) {
|
87 |
+
toolbarHeight = getToolbarHeight();
|
88 |
+
editorHeight = editorHeight + toolbarHeight - 14;
|
89 |
+
|
90 |
+
// height cannot be under 50 or over 5000
|
91 |
+
if ( editorHeight > 50 && editorHeight < 5000 ) {
|
92 |
+
txtarea_el.style.height = editorHeight + 'px';
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
ed.hide();
|
97 |
+
} else {
|
98 |
+
// The TinyMCE instance doesn't exist, run the content through 'pre_wpautop()' and show the textarea
|
99 |
+
if ( tinyMCEPreInit.mceInit[ id ] && tinyMCEPreInit.mceInit[ id ].wpautop ) {
|
100 |
+
txtarea_el.value = t.pre_wpautop( txtarea_el.value );
|
101 |
+
}
|
102 |
+
|
103 |
+
DOM.setStyles( txtarea_el, {'display': '', 'visibility': ''} );
|
104 |
+
}
|
105 |
+
|
106 |
+
DOM.removeClass( wrap_id, 'tmce-active' );
|
107 |
+
DOM.addClass( wrap_id, 'html-active' );
|
108 |
+
setUserSetting( 'editor', 'html' );
|
109 |
+
}
|
110 |
+
return false;
|
111 |
+
},
|
112 |
+
|
113 |
+
_wp_Nop : function(content) {
|
114 |
+
var blocklist1, blocklist2;
|
115 |
+
|
116 |
+
// Protect pre|script tags
|
117 |
+
if ( content.indexOf('<pre') != -1 || content.indexOf('<script') != -1 ) {
|
118 |
+
content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
|
119 |
+
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp_temp>');
|
120 |
+
return a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp_temp>');
|
121 |
+
});
|
122 |
+
}
|
123 |
+
|
124 |
+
// Pretty it up for the source editor
|
125 |
+
var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|p';
|
126 |
+
content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n');
|
127 |
+
content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
|
128 |
+
|
129 |
+
content = content.replace(new RegExp('<p( [^>]*)?>[\\s\\n]*<(/?script[^>]*)>', 'mg'), '\n<$2>');
|
130 |
+
content = content.replace(new RegExp('<(/?script[^>]*)>[\\s\\n]*</p>', 'mg'), '\n<$1>');
|
131 |
+
|
132 |
+
// Fix some block element newline issues
|
133 |
+
content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
|
134 |
+
content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
|
135 |
+
content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
|
136 |
+
content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
|
137 |
+
|
138 |
+
var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
|
139 |
+
content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
|
140 |
+
content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
|
141 |
+
content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
|
142 |
+
|
143 |
+
if ( content.indexOf('<object') != -1 ) {
|
144 |
+
content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
|
145 |
+
content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
|
146 |
+
}
|
147 |
+
|
148 |
+
// Unmark special paragraph closing tags
|
149 |
+
content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
|
150 |
+
content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
|
151 |
+
content = content.replace(new RegExp('<p>\\s*</p>', 'mg'), "<p> </p>\n");
|
152 |
+
|
153 |
+
// put back the line breaks in pre|script
|
154 |
+
content = content.replace(/<wp_temp>/g, '\n');
|
155 |
+
|
156 |
+
return content;
|
157 |
+
},
|
158 |
+
|
159 |
+
_wp_Autop : function(pee) {
|
160 |
+
// filtered when switching html to visual
|
161 |
+
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';
|
162 |
+
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';
|
163 |
+
pee = pee + "\n\n";
|
164 |
+
pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");
|
165 |
+
pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), "$1\n\n");
|
166 |
+
pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
|
167 |
+
pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
|
168 |
+
pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
|
169 |
+
pee = pee.replace(new RegExp('<p( [^>]*)?>[\\s\\n]*</p>', 'mg'), "<p$1> </p>\n");
|
170 |
+
pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
|
171 |
+
pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
|
172 |
+
pee = pee.replace(new RegExp("<p ?[^>]*>(<!--(.*)?-->)", 'gi'), "$1");
|
173 |
+
pee = pee.replace(new RegExp("(<!--(.*)?-->)</p>", 'gi'), "$1");
|
174 |
+
pee = pee.replace(new RegExp('<p>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
|
175 |
+
pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
|
176 |
+
pee = pee.replace(new RegExp('<p>[\\s\\n]*(<(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
|
177 |
+
pee = pee.replace(new RegExp('<p>[\\s\\n]*(</(?:'+blocklist2+')[^>]*>)', 'gi'), "$1");
|
178 |
+
pee = pee.replace(new RegExp('(<(?:'+blocklist2+')[^>]*>)[\\s\\n]*</p>', 'gi'), "$1");
|
179 |
+
pee = pee.replace(new RegExp('(</(?:'+blocklist+')[^>]*>)[\\s\\n]*</p>', 'gi'), "$1");
|
180 |
+
pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
|
181 |
+
pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
|
182 |
+
pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
|
183 |
+
|
184 |
+
// Fix the pre|script tags
|
185 |
+
pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
|
186 |
+
a = a.replace(/<br ?\/?>[\r\n]*/g, '\n');
|
187 |
+
return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n');
|
188 |
+
});
|
189 |
+
|
190 |
+
return pee;
|
191 |
+
},
|
192 |
+
|
193 |
+
pre_wpautop : function(content) {
|
194 |
+
var t = this, o = { o: t, data: content, unfiltered: content },
|
195 |
+
q = typeof(jQuery) != 'undefined';
|
196 |
+
|
197 |
+
if ( q )
|
198 |
+
jQuery('body').trigger('beforePreWpautop', [o]);
|
199 |
+
o.data = t._wp_Nop(o.data);
|
200 |
+
if ( q )
|
201 |
+
jQuery('body').trigger('afterPreWpautop', [o]);
|
202 |
+
|
203 |
+
return o.data;
|
204 |
+
},
|
205 |
+
|
206 |
+
wpautop : function(pee) {
|
207 |
+
var t = this, o = { o: t, data: pee, unfiltered: pee },
|
208 |
+
q = typeof(jQuery) != 'undefined';
|
209 |
+
|
210 |
+
if ( q )
|
211 |
+
jQuery('body').trigger('beforeWpautop', [o]);
|
212 |
+
o.data = t._wp_Autop(o.data);
|
213 |
+
if ( q )
|
214 |
+
jQuery('body').trigger('afterWpautop', [o]);
|
215 |
+
|
216 |
+
return o.data;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
ps_disable_auto_formatting.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
Plugin Name: PS Disable Auto Formatting
|
4 |
Plugin URI: http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/
|
5 |
Description: PS Disable Auto Formatting is able to disable function auto formatting (wpautop) and save <p> and <br /> formatted content.
|
6 |
-
Version: 1.0.
|
7 |
-
Author: Hitoshi Omagari
|
8 |
Author URI: http://www.web-strategy.jp/
|
9 |
License: GPLv2 or later
|
10 |
*/
|
@@ -91,7 +91,9 @@ function set_default_settings() {
|
|
91 |
function rewrite_default_script( $todo ) {
|
92 |
global $wp_version, $wp_scripts;
|
93 |
|
94 |
-
if ( version_compare( $wp_version, '3.
|
|
|
|
|
95 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/330/ps_editor.js';
|
96 |
} elseif ( version_compare( $wp_version, '2.8', '>=' ) ) {
|
97 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/280/ps_editor.js';
|
3 |
Plugin Name: PS Disable Auto Formatting
|
4 |
Plugin URI: http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/
|
5 |
Description: PS Disable Auto Formatting is able to disable function auto formatting (wpautop) and save <p> and <br /> formatted content.
|
6 |
+
Version: 1.0.9
|
7 |
+
Author: Hitoshi Omagari,
|
8 |
Author URI: http://www.web-strategy.jp/
|
9 |
License: GPLv2 or later
|
10 |
*/
|
91 |
function rewrite_default_script( $todo ) {
|
92 |
global $wp_version, $wp_scripts;
|
93 |
|
94 |
+
if ( version_compare( $wp_version, '3.9.x', '>' ) ) {
|
95 |
+
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/390/ps_editor.js';
|
96 |
+
} elseif ( version_compare( $wp_version, '3.3.x', '>' ) ) {
|
97 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/330/ps_editor.js';
|
98 |
} elseif ( version_compare( $wp_version, '2.8', '>=' ) ) {
|
99 |
$scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/280/ps_editor.js';
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== PS Disable Auto Formatting ===
|
2 |
-
Contributors: jim912
|
3 |
Tags: auto formatting, formatting, format, paragraph, linebreak, wpautop
|
4 |
Requires at least: 2.5
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 1.0.
|
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.
|
9 |
|
@@ -65,6 +65,8 @@ To prevent the operational error, the batch processing is not done if there is n
|
|
65 |
Please check "Permit batch formatting" check box.
|
66 |
|
67 |
== Changelog ==
|
|
|
|
|
68 |
* **1.0.8**
|
69 |
* fix : bug fix : load javascript file for 3.3 in 3.2.1
|
70 |
* **1.0.7**
|
1 |
=== PS Disable Auto Formatting ===
|
2 |
+
Contributors: jim912, kuck1u
|
3 |
Tags: auto formatting, formatting, format, paragraph, linebreak, wpautop
|
4 |
Requires at least: 2.5
|
5 |
+
Tested up to: 3.9
|
6 |
+
Stable tag: 1.0.9
|
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.
|
9 |
|
65 |
Please check "Permit batch formatting" check box.
|
66 |
|
67 |
== Changelog ==
|
68 |
+
* **1.0.9**
|
69 |
+
* Compatible with WordPress 3.9
|
70 |
* **1.0.8**
|
71 |
* fix : bug fix : load javascript file for 3.3 in 3.2.1
|
72 |
* **1.0.7**
|
screenshot-1.png
DELETED
Binary file
|