PS Disable Auto Formatting - Version 0.9.0

Version Description

Download this release

Release Info

Developer jim912
Plugin Icon wp plugin PS Disable Auto Formatting
Version 0.9.0
Comparing to
See all releases

Version 0.9.0

js/ps_editor.js ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ switchEditors = {
3
+
4
+ mode : '',
5
+
6
+ I : function(e) {
7
+ return document.getElementById(e);
8
+ },
9
+
10
+ edInit : function() {
11
+ var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview');
12
+
13
+ // Activate TinyMCE if it's the user's default editor
14
+ if ( getUserSetting( 'editor' ) == 'html' ) {
15
+ if ( h )
16
+ try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){};
17
+ } else {
18
+ try {
19
+ this.I("quicktags").style.display = "none";
20
+ } catch(e){};
21
+ tinyMCE.execCommand("mceAddControl", false, "content");
22
+ }
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
+ // We have a TON of cleanup to do. Line breaks are already stripped.
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
+ // Fix some block element newline issues
50
+ content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div');
51
+ content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n');
52
+ content = content.replace(new RegExp('\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*', 'gi'), '\n\n[caption$1[/caption]\n\n');
53
+ content = content.replace(new RegExp('caption\\]\\n\\n+\\[caption', 'g'), 'caption]\n\n[caption');
54
+
55
+ var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre';
56
+ content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
57
+ content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n');
58
+ content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>');
59
+
60
+ if ( content.indexOf('<object') != -1 ) {
61
+ content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>");
62
+ content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>');
63
+ }
64
+
65
+ // Unmark special paragraph closing tags
66
+ content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
67
+ content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
68
+
69
+ // put back the line breaks in pre|script
70
+ content = content.replace(/<wp_temp>/g, '\n');
71
+
72
+ // Hope.
73
+ return content;
74
+ },
75
+
76
+ go : function(id, mode) {
77
+ id = id || 'content';
78
+ mode = mode || this.mode || '';
79
+
80
+ var ed = tinyMCE.get(id) || false;
81
+ var qt = this.I('quicktags');
82
+ var H = this.I('edButtonHTML');
83
+ var P = this.I('edButtonPreview');
84
+ var ta = this.I(id);
85
+
86
+ if ( 'tinymce' == mode ) {
87
+
88
+ if ( ed && ! ed.isHidden() )
89
+ return false;
90
+
91
+ this.mode = 'html';
92
+ ta.style.color = '#fff';
93
+
94
+ P.className = 'active';
95
+ H.className = '';
96
+ edCloseAllTags(); // :-(
97
+
98
+ qt.style.display = 'none';
99
+
100
+ ta.value = this.wpautop(ta.value);
101
+
102
+ if ( ed ) ed.show();
103
+ else tinyMCE.execCommand("mceAddControl", false, id);
104
+
105
+ setUserSetting( 'editor', 'tinymce' );
106
+ } else {
107
+ if ( ! ed || ed.isHidden() )
108
+ return false;
109
+
110
+ this.mode = 'tinymce';
111
+ H.className = 'active';
112
+ P.className = '';
113
+
114
+ ta.style.height = ed.getContentAreaContainer().offsetHeight + 6 + 'px';
115
+
116
+ ed.hide();
117
+ qt.style.display = 'block';
118
+
119
+ ta.style.color = '';
120
+ setUserSetting( 'editor', 'html' );
121
+ }
122
+ return false;
123
+ },
124
+
125
+ wpautop : function(pee) {
126
+ 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]';
127
+
128
+ pee = pee + "\n\n";
129
+ // pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\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*?</p>', 'gi'), '');
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>\\s*<blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
139
+ pee = pee.replace(new RegExp('</blockquote>\\s*</p>', 'gi'), '</p></blockquote>');
140
+ pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1");
141
+ pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");
142
+ pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
143
+ pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
144
+ pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
145
+ pee = pee.replace(new RegExp('(?:<p>|<br ?/?>)*\\s*\\[caption([^\\[]+)\\[/caption\\]\\s*(?:</p>|<br ?/?>)*', 'gi'), '[caption$1[/caption]');
146
+ // pee = pee.replace(new RegExp('^((?:&nbsp;)*)\\s', 'mg'), '$1&nbsp;');
147
+
148
+ // Fix the pre|script tags
149
+ pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
150
+ a = a.replace(/<br ?\/?>[\r\n]*/g, '\n');
151
+ return a.replace(/<\/?p( [^>]*)?>[\r\n]*/g, '\n');
152
+ });
153
+
154
+ return pee;
155
+ }
156
+ }
language/ps_disable_auto_formatting-ja.mo ADDED
Binary file
language/ps_disable_auto_formatting-ja.po ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: PS Disable Auto Formatting\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2009-01-13 11:37+0900\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: hitoshi omagari\n"
8
+ "Language-Team: Prime Strategy Co.,Ltd. <system@prime-strategy.co.jp>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-Language: Japanese\n"
13
+ "X-Poedit-Country: JAPAN\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "X-Poedit-Basepath: T:\\wp_test\\DocumentRoot\\wp-content\\plugins\\\n"
17
+ "X-Poedit-SearchPath-0: ps_disable_auto_formatting\n"
18
+
19
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:15
20
+ msgid "content formatting"
21
+ msgstr "記事内容の自動整形"
22
+
23
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:16
24
+ msgid "comment formatting"
25
+ msgstr "コメントの自動整形"
26
+
27
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:17
28
+ msgid "excerpt formatting"
29
+ msgstr "抜粋の自動整形"
30
+
31
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:18
32
+ msgid "term description formatting"
33
+ msgstr "説明(カテゴリー、リンクなど)の自動整形"
34
+
35
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:110
36
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:184
37
+ msgid "Auto Formatting"
38
+ msgstr "自動整形"
39
+
40
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:150
41
+ msgid "Could not update post in the database"
42
+ msgstr "データベースのアップデートに失敗いたしました。"
43
+
44
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:153
45
+ msgid "Database is not found."
46
+ msgstr "データベースが見つかりません。"
47
+
48
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:163
49
+ msgid "No formatting post or page exists."
50
+ msgstr "整形する記事が存在しません。"
51
+
52
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:166
53
+ msgid "Require checked allow batch formatting."
54
+ msgstr "一括整形処理の許可が必要です。"
55
+
56
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:187
57
+ msgid "The settings has changed successfully."
58
+ msgstr "設定が変更されました。"
59
+
60
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:191
61
+ #, php-format
62
+ msgid "Batch fomatting process has completed. total %d posts formatted."
63
+ msgstr "一括整形処理が完了いたしました。整形処理が行われた記事は、全部で%dです。"
64
+
65
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:199
66
+ msgid "The settings has not been changed. There were no changes or failed to update the data base."
67
+ msgstr "設定は変更されていません。変更された項目が存在しないか、データベースのアップデート失敗です。"
68
+
69
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:210
70
+ msgid "disable"
71
+ msgstr "停止"
72
+
73
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:219
74
+ msgid "Batch formatting for past posts"
75
+ msgstr "過去記事の一括整形"
76
+
77
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:220
78
+ msgid ""
79
+ "<p>To make it display the same as the format before run this plug-in,\n"
80
+ "automatic operation process to the specified period of the posts.<br />\n"
81
+ "Even if some unexpected errors occur, the data is restorable because\n"
82
+ "rivision on the processed post is made.<br />\n"
83
+ "This process is safe even if you do two or more times, perhaps. We cannot assure though.<br />\n"
84
+ "* It is strongly recommended to take the <a href=\"http://codex.wordpress.org/Backing_Up_Your_Database\" title=\"Backing Up Your Database\">backup your database</a> before processing.</p>"
85
+ msgstr "<p>プラグインを利用する場合にも段落・改行が以前通り表示されるよう、最新の編集が指定日以前の投稿・ページ全てに対し、自動段落整形の一括処理を行います。<br />整形処理を行った投稿・ページについては、リビジョンを作成しますので、万が一不具合が発生した投稿・ページにおいても復元が可能です。<br />複数回整形処理を行ってもおそらく問題にはならないと思いますが、極力避けてください。<br />※ 処理を行う前に極力<a href=\"http://wpdocs.sourceforge.jp/%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%81%AE%E3%83%90%E3%83%83%E3%82%AF%E3%82%A2%E3%83%83%E3%83%97\" title=\"データベースのバックアップ\">データベースのバックアップ</a>を行っておいてください。</p>"
86
+
87
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:228
88
+ msgid "Formatting before"
89
+ msgstr "整形処理時限"
90
+
91
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:231
92
+ msgid "* Formatting posts and pages are modified before this time."
93
+ msgstr "※ 最新の更新時刻が指定時刻以前である記事に対して整形処理が行われます。"
94
+
95
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:236
96
+ msgid "Batch formatting"
97
+ msgstr "一括整形処理"
98
+
99
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:238
100
+ msgid "Allow batch formatting"
101
+ msgstr "一括整形処理を許可"
102
+
103
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:242
104
+ msgid "If you have any problems or find a bug in this plugin, please <a href=\"http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/#postcomment\">report to us</a>."
105
+ msgstr "本プラグインのご利用に際して問題があったり、バグを発見された場合には、<a href=\"http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/#postcomment\">ご連絡</a>いただければ幸いです。"
106
+
107
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:250
108
+ msgid "Sorry, Your WordPress (version %s) is old to use PS Disable Auto Formatting plugin. Please upgrade to version 2.5 or higher."
109
+ msgstr "ご利用中のWordPress (バージョン %s)では、PS Natural Paragraph Formatting プラグインはご利用になれません。2.5以上のバージョンにアップグレードしてください。"
110
+
language/ps_disable_auto_formatting.pot ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: PS Disable Auto Formatting\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-Language: \n"
13
+ "X-Poedit-Country: \n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "X-Poedit-Basepath: T:\n"
17
+ "X-Poedit-SearchPath-0: \n"
18
+
19
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:15
20
+ msgid "content formatting"
21
+ msgstr ""
22
+
23
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:16
24
+ msgid "comment formatting"
25
+ msgstr ""
26
+
27
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:17
28
+ msgid "excerpt formatting"
29
+ msgstr ""
30
+
31
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:18
32
+ msgid "term description formatting"
33
+ msgstr ""
34
+
35
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:110
36
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:184
37
+ msgid "Auto Formatting"
38
+ msgstr ""
39
+
40
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:150
41
+ msgid "Could not update post in the database"
42
+ msgstr ""
43
+
44
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:153
45
+ msgid "Database is not found."
46
+ msgstr ""
47
+
48
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:163
49
+ msgid "No formatting post or page exists."
50
+ msgstr ""
51
+
52
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:166
53
+ msgid "Require checked allow batch formatting."
54
+ msgstr ""
55
+
56
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:187
57
+ msgid "The settings has changed successfully."
58
+ msgstr ""
59
+
60
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:191
61
+ #, php-format
62
+ msgid "Batch fomatting process has completed. total %d posts formatted."
63
+ msgstr ""
64
+
65
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:199
66
+ msgid "The settings has not been changed. There were no changes or failed to update the data base."
67
+ msgstr ""
68
+
69
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:210
70
+ msgid "disable"
71
+ msgstr ""
72
+
73
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:219
74
+ msgid "Batch formatting for past posts"
75
+ msgstr ""
76
+
77
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:220
78
+ msgid ""
79
+ "<p>To make it display the same as the format before run this plug-in,\n"
80
+ "automatic operation process to the specified period of the posts.<br />\n"
81
+ "Even if some unexpected errors occur, the data is restorable because\n"
82
+ "rivision on the processed post is made.<br />\n"
83
+ "This process is safe even if you do two or more times, perhaps. We cannot assure though.<br />\n"
84
+ "* It is strongly recommended to take the <a href=\"http://codex.wordpress.org/Backing_Up_Your_Database\" title=\"Backing Up Your Database\">backup your database</a> before processing.</p>"
85
+ msgstr ""
86
+
87
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:228
88
+ msgid "Formatting before"
89
+ msgstr ""
90
+
91
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:231
92
+ msgid "* Formatting posts and pages are modified before this time."
93
+ msgstr ""
94
+
95
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:236
96
+ msgid "Batch formatting"
97
+ msgstr ""
98
+
99
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:238
100
+ msgid "Allow batch formatting"
101
+ msgstr ""
102
+
103
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:242
104
+ msgid "If you have any problems or find a bug in this plugin, please <a href=\"http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/#postcomment\">report to us</a>."
105
+ msgstr ""
106
+
107
+ #: ps_disable_auto_formatting/ps_disable_auto_formatting.php:250
108
+ msgid "Sorry, Your WordPress (version %s) is old to use PS Disable Auto Formatting plugin. Please upgrade to version 2.5 or higher."
109
+ msgstr ""
ps_disable_auto_formatting.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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 Disable Auto Formatting is able to disable function auto formatting (wpautop) and save &lt;p&gt; and &lt;br /&gt; formatted content.
6
+ Version: 0.9.0
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
+
14
+ var $setting_items = array(
15
+ 'content formatting' => 'the_content',
16
+ 'comment formatting' => 'comment_text',
17
+ 'excerpt formatting' => 'the_excerpt',
18
+ 'term description formatting' => 'term_description',
19
+ );
20
+
21
+ var $mce_version = '20081129';
22
+
23
+ function __construct() {
24
+ global $wp_version;
25
+
26
+ if ( version_compare( $wp_version, '2.5', '>=' ) ) {
27
+ add_action( 'init', array( &$this, 'disable_auto_formatting_init' ) );
28
+ add_action( 'admin_menu', array( &$this, 'add_disable_formatting_setting_page') );
29
+ add_filter( 'print_scripts_array', array( &$this, 'rewrite_default_script' ) );
30
+ } else {
31
+ add_action('admin_notices', array( &$this, 'version_too_old' ) );
32
+ }
33
+ }
34
+
35
+
36
+ function ps_disable_auto_formatting() {
37
+ $this->__construct();
38
+ }
39
+
40
+
41
+ function disable_auto_formatting_init() {
42
+ $locale = get_locale();
43
+ $lang_file = dirname( __file__ ) . '/language/ps_disable_auto_formatting-' . $locale . '.mo';
44
+
45
+ if ( file_exists( $lang_file ) ) {
46
+ load_textdomain( 'ps_disable_auto_formatting', $lang_file );
47
+ }
48
+
49
+ $this->option_settings = get_option( 'ps_disable_auto_formatting' );
50
+
51
+ if ( $this->option_settings === false ) {
52
+ $this->set_default_settings();
53
+ $this->option_settings = get_option( 'ps_disable_auto_formatting' );
54
+ } elseif ( ! $this->option_settings ) {
55
+ $this->option_settings = array();
56
+ }
57
+
58
+ $this->delete_default_filters();
59
+ }
60
+
61
+
62
+ function delete_default_filters() {
63
+ global $wp_filter;
64
+
65
+ foreach ( $this->option_settings as $hook ) {
66
+ if ( $hook == 'comment_text' ) {
67
+ $priority = 30;
68
+ } else {
69
+ $priority = 10;
70
+ }
71
+ remove_filter( $hook, 'wpautop', $priority );
72
+ if ( $hook == 'the_content' ) {
73
+ foreach ( array_keys( $wp_filter['the_content'][10] ) as $hook_name ) {
74
+ if ( strpos( $hook_name, 'tam_contact_form_sevenwpautop_substitute' ) !== false ) {
75
+ remove_filter( 'the_content', $hook_name );
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+
83
+ function set_default_settings() {
84
+ $default = array( 'the_content' );
85
+ update_option( 'ps_disable_auto_formatting', $default );
86
+ }
87
+
88
+
89
+ function rewrite_default_script( $todo ) {
90
+ global $wp_scripts;
91
+
92
+ if ( function_exists( 'mce_version' ) ) {
93
+ $mce_version = mce_version();
94
+ } else {
95
+ $mce_version = $this->mce_version;
96
+ }
97
+ $wp_scripts->add( 'ps_editor', get_option( 'home' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/ps_editor.js', false, $mce_version );
98
+
99
+ $key = array_search( 'editor', $todo );
100
+ if ( $key !== false ) {
101
+ $todo[$key] = 'ps_editor';
102
+ }
103
+ return $todo;
104
+ }
105
+
106
+
107
+ function add_disable_formatting_setting_page() {
108
+ if ( function_exists( 'add_options_page' ) ) {
109
+ add_options_page( 'PS Disable Auto Formatting',
110
+ __( 'Auto Formatting', 'ps_disable_auto_formatting' ),
111
+ 8,
112
+ basename( __FILE__ ),
113
+ array( &$this, 'output_disable_formatting_setting_page') );
114
+ }
115
+ }
116
+
117
+
118
+ function output_disable_formatting_setting_page() {
119
+ global $wpdb, $wp_error;
120
+ if( $_POST['_wpnonce'] ) {
121
+ check_admin_referer();
122
+
123
+ if ( $_POST['batch_formatting'] ) {
124
+ if ( $_POST['allow_batch_formatting'] ) {
125
+ $time_limit = sprintf( '%04d-%02d-%02d %02d:%02d:00', $_POST['aa'], $_POST['mm'], $_POST['jj'], $_POST['hh'], $_POST['mn'] );
126
+ $sql = "
127
+ SELECT `ID`
128
+ FROM $wpdb->posts
129
+ WHERE `post_status` IN ( 'publish', 'draft', 'pending' )
130
+ AND `post_type` IN ( 'post', 'page' )
131
+ AND `post_modified` < '$time_limit'
132
+ ";
133
+ $formatting_posts = $wpdb->get_results( $sql, ARRAY_A );
134
+ $formatted_posts = array();
135
+
136
+ if ( $formatting_posts ) {
137
+ foreach ( $formatting_posts as $row ) {
138
+ $data = array();
139
+ $post = get_post( $row['ID'] );
140
+ $data['post_content'] = wpautop( $post->post_content );
141
+ if ( $post->post_content_filtered ) {
142
+ $data['post_content_filtered'] = wpautop( $post->post_content_filtered );
143
+ }
144
+ $data['post_modified_gmt'] = current_time( 'mysql', 1 );
145
+ $data['post_modified'] = current_time( 'mysql' );
146
+
147
+ do_action( 'pre_post_update', $post->ID );
148
+ if ( false === $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post->ID ) ) ) {
149
+ if ( $wp_error ) {
150
+ $error_mes = new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
151
+ break;
152
+ } else {
153
+ $error_mes = __( 'Database is not found.', 'ps_disable_auto_formatting' );
154
+ break;
155
+ }
156
+ }
157
+ $formatted_posts[] = $row['ID'];
158
+ }
159
+ if ( ! $error_mes ) {
160
+ $batch_ret = true;
161
+ }
162
+ } else {
163
+ $error_mes = __( 'No formatting post or page exists.', 'ps_disable_auto_formatting' );
164
+ }
165
+ } else {
166
+ $error_mes = __( 'Require checked allow batch formatting.', 'ps_disable_auto_formatting' );
167
+ }
168
+ } else {
169
+ foreach ( $_POST['ps_disable_auto_formatting'] as $key => $func ) {
170
+ if ( ! in_array( $func, $this->setting_items) ) {
171
+ unset( $_POST['ps_disable_auto_formatting'][$key] );
172
+ }
173
+ }
174
+ $ret = update_option( 'ps_disable_auto_formatting', $_POST['ps_disable_auto_formatting'] );
175
+ if ( $ret ) {
176
+ $this->option_settings = get_option( 'ps_disable_auto_formatting' );
177
+ }
178
+ }
179
+ }
180
+
181
+ ?>
182
+ <div class=wrap>
183
+ <?php if ( function_exists( 'screen_icon' ) ) { screen_icon(); } ?>
184
+ <h2><?php _e( 'Auto Formatting', 'ps_disable_auto_formatting' ); ?></h2>
185
+ <?php if ( $ret ) { ?>
186
+ <div id="message" class="updated">
187
+ <p><?php _e('The settings has changed successfully.', 'ps_disable_auto_formatting' );?></p>
188
+ </div>
189
+ <?php } elseif ( $batch_ret ) { ?>
190
+ <div id="message" class="updated">
191
+ <p><?php printf( __( 'Batch fomatting process has completed. total %d posts formatted.', 'ps_disable_auto_formatting' ), count( $formatting_posts ) );?></p>
192
+ </div>
193
+ <?php } elseif ( $error_mes ) { ?>
194
+ <div id="notice" class="error">
195
+ <p><?php echo wp_specialchars( $error_mes ); ?></p>
196
+ </div>
197
+ <?php } elseif ( $_POST['ps_disable_auto_formatting'] && ! $ret ) { ?>
198
+ <div id="notice" class="error">
199
+ <p><?php _e('The settings has not been changed. There were no changes or failed to update the data base.', 'ps_disable_auto_formatting' );?></p>
200
+ </div>
201
+ <?php } ?>
202
+ <form method="post" action="">
203
+ <?php wp_nonce_field(); ?>
204
+ <table class="form-table">
205
+ <?php foreach( $this->setting_items as $id => $func ) { ?>
206
+ <tr>
207
+ <th><?php _e( $id, 'ps_disable_auto_formatting' ); ?></th>
208
+ <td>
209
+ <input type="checkbox" id="ps_disable_auto_formatting_<?php echo $func ?>" name="ps_disable_auto_formatting[]" value="<?php echo $func ?>"<?php if ( in_array( $func, $this->option_settings ) ) { echo ' checked="checked"'; } ?> />
210
+ <label for="ps_disable_auto_formatting_<?php echo $func ?>"><?php _e( 'disable', 'ps_disable_auto_formatting' ); ?></label>
211
+ </td>
212
+ </tr>
213
+ <?php } ?>
214
+ </table>
215
+ <p class="submit">
216
+ <input type="submit" name="ps_disable_auto_formatting_submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" />
217
+ </p>
218
+ <?php if ( current_user_can( 'edit_post' ) && current_user_can( 'edit_page' ) ) { ?>
219
+ <h3><?php _e( 'Batch formatting for past posts' ,'ps_disable_auto_formatting' ); ?></h3>
220
+ <?php _e( '<p>To make it display the same as the format before run this plug-in,
221
+ automatic operation process to the specified period of the posts.<br />
222
+ Even if some unexpected errors occur, the data is restorable because
223
+ rivision on the processed post is made.<br />
224
+ This process is safe even if you do two or more times, perhaps. We cannot assure though.<br />
225
+ * It is strongly recommended to take the <a href="http://codex.wordpress.org/Backing_Up_Your_Database" title="Backing Up Your Database">backup your database</a> before processing.</p>' ,'ps_disable_auto_formatting' ); ?>
226
+ <table class="form-table">
227
+ <tr>
228
+ <th><?php _e( 'Formatting before' ,'ps_disable_auto_formatting' ); ?></th>
229
+ <td>
230
+ <?php touch_time( 0, 0, 0, 1 ); ?><br />
231
+ <?php _e( '* Formatting posts and pages are modified before this time.' ,'ps_disable_auto_formatting' ); ?>
232
+ </td>
233
+ </tr>
234
+ </table>
235
+ <div>
236
+ <span class="submit"><input type="submit" name="batch_formatting" value="<?php _e( 'Batch formatting', 'ps_disable_auto_formatting' ); ?>" /></span>
237
+ &nbsp;&nbsp;&nbsp;<input type="checkbox" id="allow_batch_formatting" name="allow_batch_formatting" value="1" />
238
+ <label for="allow_batch_formatting"><?php _e( 'Allow batch formatting', 'ps_disable_auto_formatting' ); ?></label>
239
+ </div>
240
+ <?php } ?>
241
+ </form>
242
+ <p><?php _e( 'If you have any problems or find a bug in this plugin, please <a href="http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/#postcomment">report to us</a>.' , 'ps_disable_auto_formatting' ); ?></p>
243
+ </div>
244
+ <?php
245
+ }
246
+
247
+
248
+ function version_too_old() {
249
+ global $wp_version;
250
+ echo '<div class="updated fade"><p>' . sprintf( __( 'Sorry, Your WordPress (version %s) is old to use PS Disable Auto Formatting plugin. Please upgrade to version 2.5 or higher.', 'ps_disable_auto_formatting' ), $wp_version ) . '</p></div>';
251
+ $active_plugins = get_option('active_plugins');
252
+ $search_plugin = str_replace( str_replace( '\\', '/', ABSPATH . PLUGINDIR . '/' ), '', str_replace( '\\', '/', __file__ ) );
253
+ $key = array_search( $search_plugin, $active_plugins );
254
+ if ( $key !== false ) {
255
+ unset( $active_plugins[$key] );
256
+ }
257
+ update_option( 'active_plugins', $active_plugins );
258
+ }
259
+
260
+ } // class end
readme.txt ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 2.7
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.
9
+
10
+ == Description ==
11
+ If you are annoying by the habit of the WordPress automatic formatting, try this plugin.
12
+
13
+ PS Disable Auto Formatting stops automatic formatting of WordPress (wpautop), and modifies the html source generated by the visual editor.
14
+
15
+ This plugin stops automatic formatting of WordPress (wpautop), and modifies the html source generated by the visual editor.
16
+
17
+ When editing it in the HTML mode, it stops unintended removal of br tag and p tag , either addition of p tag.
18
+ And when editing in the visual mode, it achieves to generate natural changing line and paragraph that you will intend.
19
+
20
+
21
+ = Functions =
22
+ * Disable the auto formating in the each areas of post, comment, excerpt, terms description.
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.0**
28
+ * Public release
29
+
30
+ == Installation ==
31
+
32
+ 1. Unzip the downloaded package and upload into your WordPress plugins directory.
33
+ If you use WordPress 2.7 or later, you can install from admin page.
34
+ 2. Go to plugins list and activate "PS Disable Auto Formatting".
35
+ 3. After install, a managing page of automatic forming is added to config list.
36
+ The default setting stops only the automatic formating of the post.
37
+ Change and submit the settings of each areas if necessary.
38
+
39
+ = Batch formatting for past posts =
40
+
41
+ Batch formatting is a function for the past posts posted before use this plugin.
42
+ You do not have to use it if there are no post.
43
+
44
+ When you activate this plugin, there will be no changing line and paragraph in the past posts because auto formatting of WordPress has stopped.
45
+
46
+ To solve this problem, this function does the batch processing to the article within
47
+ the specified range.
48
+
49
+ (Before use this function, reserve the [backup of the data base](http://codex.wordpress.org/Backing_Up_Your_Database "backup of the data base") is recommended.)
50
+
51
+
52
+ == Frequently Asked Questions ==
53
+ = When is this plugin effective? =
54
+
55
+ For example, it will be effective in case use HTML mode every time, and when copy from existing HTML files.
56
+ It also comes to be able to post consecutive changing line.
57
+
58
+
59
+ = I do not understand whether which area to be stop batch formatting. =
60
+ Try to stop the area where the visual editor is used.
61
+
62
+ = Can the setting change and the batch formatting function be done at the same time? =
63
+ No.
64
+ When "change setting" button is pushed, the setting is changed.
65
+ When "Batch formatting" button is pushed, the batch plastic operation is done. The setting is not changed.
66
+
67
+ = It displays as "It is necessary to permit the batch formatting" and cannot do the batch formatting. =
68
+ To prevent the operational error, the batch processing is not done if there is no permission.
69
+ Please check "Permit batch formatting" check box.
70
+
71
+ == Screenshots ==
72
+ 1. Administration interface of PS Disable Auto Formatting
73
+
74
+ == Notice ==
75
+ Please back up the data base as much as possible before doing the batch formatting.
76
+
77
+ Though we have tested as much as possible, there is a possibility that processing stops on the way.
78
+
79
+ Even if some trouble occurs in the article data by some rare accident, we can not assume the responsibility.
80
+
81
+ If you have any problems or find a bug in this plugin, please [report to us](http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/#postcomment "contact form").
82
+
83
+ == Links ==
84
+ "[PS Auto Sitemap](http://wordpress.org/extend/plugins/ps-auto-sitemap/ "WordPress sitemap plugin")" is a plugin automatically generates a site map page from your WordPress site.
85
+ It is easy to install for beginners and easy to customize for experts.
86
+ It can change the settings of the display of the lists from administration page, several neat CSS skins for the site map tree are prepared.
87
+
88
+ "[CMS service with WordPress](http://www.web-strategy.jp/ "CMS service with WordPress")" provides you service that uses WordPress as a CMS.
89
+
90
+ == Special Thanks ==
91
+ Translation:[dacelo](http://www.dacelo.info/blog/ "Translation")
92
+
93
+ Naming Advise:[Samuel Bollinge](http://blog.comeuphither.com/ "Naming Advise")
screenshot-1.png ADDED
Binary file