WP Multibyte Patch - Version 1.4.2

Version Description

Download this release

Release Info

Developer tenpura
Plugin Icon wp plugin WP Multibyte Patch
Version 1.4.2
Comparing to
See all releases

Version 1.4.2

ext/ja/admin.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ body *:not(textarea) {
2
+ font-style: normal !important;
3
+ font-family: Arial, "Bitstream Vera Sans", Helvetica, Verdana, sans-serif !important;
4
+ }
ext/ja/class.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* WP Multibyte Patch Extension File */
3
+
4
+ /*
5
+ WPLANG: ja
6
+ Plugin Version: 1.4.2
7
+ Description: Japanese Locale Extension.
8
+ Author: Kuraishi (tenpura)
9
+ Extension URI: http://eastcoder.com/code/wp-multibyte-patch/
10
+ */
11
+
12
+ /*
13
+ Copyright (C) 2011 Kuraishi (Email: 210pura at gmail dot com), Tinybit Inc.
14
+ This program is licensed under the GNU GPL Version 2.
15
+ */
16
+
17
+ if(class_exists('multibyte_patch')) :
18
+ class multibyte_patch_ext extends multibyte_patch {
19
+
20
+ function get_jis_name() {
21
+ if(function_exists('mb_list_encodings')) {
22
+ $list = "\t" . implode("\t", mb_list_encodings()) . "\t";
23
+ return (preg_match("/\tISO-2022-JP-MS\t/i", $list)) ? 'ISO-2022-JP-MS' : 'ISO-2022-JP';
24
+ }
25
+ else
26
+ return 'ISO-2022-JP';
27
+ }
28
+
29
+ function UTF8toJIS($string) {
30
+ return $this->convenc($string, $this->get_jis_name(), 'UTF-8');
31
+ }
32
+
33
+ function JIStoUTF8($string) {
34
+ return $this->convenc($string, 'UTF-8', $this->get_jis_name());
35
+ }
36
+
37
+ function encode_mimeheader_b_uncut($string = '', $charset = 'UTF-8') {
38
+ if(0 == strlen($string) || strlen($string) == mb_strlen($string, $charset))
39
+ return $string;
40
+
41
+ return "=?$charset?B?" . base64_encode($string) . '?=';
42
+ }
43
+
44
+ function get_phpmailer_properties($phpmailer) {
45
+ $array = (array) $phpmailer;
46
+ $new = array();
47
+ foreach($array as $key => $value) {
48
+ $key = preg_replace("/^\\0[^\\0]+\\0/", "", $key);
49
+ $new[$key] = $value;
50
+ }
51
+ return $new;
52
+ }
53
+
54
+ function wp_mail($phpmailer) {
55
+ $blog_encoding = $this->blog_encoding;
56
+
57
+ $phpmailer->FromName = preg_replace("/[\r\n]/", "", trim($phpmailer->FromName));
58
+ $phpmailer->FromName = $this->convenc($phpmailer->FromName, 'UTF-8', $blog_encoding);
59
+ $phpmailer->Subject = preg_replace("/[\r\n]/", "", trim($phpmailer->Subject));
60
+ $phpmailer->Subject = $this->convenc($phpmailer->Subject, 'UTF-8', $blog_encoding);
61
+ $phpmailer->Body = $this->convenc($phpmailer->Body, 'UTF-8', $blog_encoding);
62
+
63
+ if('UTF-8' == strtoupper(trim($this->conf['mail_mode'])))
64
+ $mode = 'UTF-8';
65
+ elseif('JIS' == strtoupper(trim($this->conf['mail_mode'])))
66
+ $mode = 'JIS';
67
+ else { // Check unmappable characters and decide what to do.
68
+ $test_str_before = $phpmailer->FromName . $phpmailer->Subject . $phpmailer->Body;
69
+ $test_str_after = $this->UTF8toJIS($test_str_before);
70
+ $test_str_after = $this->JIStoUTF8($test_str_after);
71
+ $mode = ($test_str_after != $test_str_before) ? 'UTF-8' : 'JIS';
72
+ }
73
+
74
+ $phpmailer_props = $this->get_phpmailer_properties(&$phpmailer);
75
+ $recipient_methods = array('to' => array('add' => 'AddAddress', 'clear' => 'ClearAddresses'), 'cc' => array('add' => 'AddCC', 'clear' => 'ClearCCs'), 'bcc' => array('add' => 'AddBCC', 'clear' => 'ClearBCCs'));
76
+
77
+ if('UTF-8' == $mode) {
78
+ $phpmailer->CharSet = 'UTF-8';
79
+ $phpmailer->Encoding = 'base64';
80
+ $phpmailer->AddCustomHeader('Content-Disposition: inline');
81
+ $phpmailer->FromName = $this->encode_mimeheader_b_uncut($phpmailer->FromName, 'UTF-8');
82
+ $phpmailer->Subject = $this->encode_mimeheader_b_uncut($phpmailer->Subject, 'UTF-8');
83
+
84
+ foreach($recipient_methods as $name => $method) {
85
+ if(isset($phpmailer_props[$name][0])) {
86
+ $phpmailer->{$method['clear']}();
87
+ foreach($phpmailer_props[$name] as $recipient) {
88
+ $recipient[1] = $this->encode_mimeheader_b_uncut($recipient[1], 'UTF-8');
89
+ $phpmailer->{$method['add']}($recipient[0], $recipient[1]);
90
+ }
91
+ }
92
+ }
93
+ }
94
+ elseif('JIS' == $mode) {
95
+ $phpmailer->CharSet = 'ISO-2022-JP';
96
+ $phpmailer->Encoding = '7bit';
97
+ $phpmailer->FromName = $this->UTF8toJIS($phpmailer->FromName);
98
+ $phpmailer->FromName = $this->encode_mimeheader_b_uncut($phpmailer->FromName, 'ISO-2022-JP');
99
+ $phpmailer->Subject = $this->UTF8toJIS($phpmailer->Subject);
100
+ $phpmailer->Subject = $this->encode_mimeheader_b_uncut($phpmailer->Subject, 'ISO-2022-JP');
101
+ $phpmailer->Body = $this->UTF8toJIS($phpmailer->Body);
102
+
103
+ foreach($recipient_methods as $name => $method) {
104
+ if(isset($phpmailer_props[$name][0])) {
105
+ $phpmailer->{$method['clear']}();
106
+ foreach($phpmailer_props[$name] as $recipient) {
107
+ $recipient[1] = $this->UTF8toJIS($recipient[1]);
108
+ $recipient[1] = $this->encode_mimeheader_b_uncut($recipient[1], 'ISO-2022-JP');
109
+ $phpmailer->{$method['add']}($recipient[0], $recipient[1]);
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ function process_search_terms() {
117
+ global $wpdb;
118
+ $blog_encoding = $this->blog_encoding;
119
+
120
+ if(isset($_GET['s'])) {
121
+ $_GET['s'] = stripslashes($_GET['s']);
122
+ $_GET['s'] = mb_convert_kana($_GET['s'], 's', $blog_encoding);
123
+ $_GET['s'] = preg_replace("/ +/", " ", $_GET['s']);
124
+ $_GET['s'] = $wpdb->escape($_GET['s']);
125
+ }
126
+ }
127
+
128
+ function guess_encoding($string, $encoding = '') {
129
+ $guess_list = 'UTF-8, eucJP-win, SJIS-win';
130
+
131
+ if(preg_match("/^utf-8$/i", $encoding))
132
+ return 'UTF-8';
133
+ elseif(preg_match("/^euc-jp$/i", $encoding))
134
+ return 'eucJP-win';
135
+ elseif(preg_match("/^(sjis|shift_jis)$/i", $encoding))
136
+ return 'SJIS-win';
137
+ elseif(!$encoding)
138
+ return mb_detect_encoding($string, $guess_list);
139
+ else
140
+ return $encoding;
141
+ }
142
+
143
+ function admin_custom_css() {
144
+ echo "\n" . '<link rel="stylesheet" type="text/css" href="' . plugin_dir_url(__FILE__) . 'admin.css' . '" />' . "\n";
145
+ }
146
+
147
+ function wplink_js(&$scripts) {
148
+ $scripts->add('wplink', plugin_dir_url(__FILE__) . "wplink{$this->debug_suffix}.js", array('jquery', 'wpdialogs'), '20110528');
149
+ }
150
+
151
+ function word_count_js(&$scripts) {
152
+ $scripts->add('word-count', plugin_dir_url(__FILE__) . "word-count{$this->debug_suffix}.js", array('jquery'), '20110515');
153
+ $this->import_l10n_entry('Word count: %s', 'wp-multibyte-patch');
154
+ }
155
+
156
+ function __construct() {
157
+ // auto, jis, UTF-8
158
+ $this->conf['mail_mode'] = 'jis';
159
+ // Treats any post as a multibyte text.
160
+ $this->conf['ascii_threshold'] = 100;
161
+ $this->debug_suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
162
+ parent::__construct();
163
+ }
164
+ }
165
+ endif;
166
+
167
+ ?>
ext/ja/config-sample.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* WP Multibyte Patch extension config file */
3
+
4
+ // Sets the encoding for wp_mail().
5
+ // Available options are "JIS", "UTF-8" or "auto".
6
+ // "auto" picks "JIS" or "UTF-8" automatically.
7
+ $wpmp_conf['mail_mode'] = 'JIS';
8
+
9
+ ?>
ext/ja/word-count.dev.js ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ (function($) {
3
+ wpWordCount = {
4
+
5
+ settings : {
6
+ strip : /<[a-zA-Z\/][^<>]*>/g, // strip HTML tags
7
+ clean : /[0-9.(),;:!?%#$¿'"_+=\\/-]+/g, // regexp to remove punctuation, etc.
8
+ count : /\S\s+/g // counting regexp
9
+ },
10
+
11
+ block : 0,
12
+
13
+ wc : function(tx) {
14
+ var t = this, w = $('.word-count'), tc = 0;
15
+
16
+ if ( t.block )
17
+ return;
18
+
19
+ t.block = 1;
20
+
21
+ setTimeout( function() {
22
+ if ( tx ) {
23
+ tx = tx.replace(/ +/g, ' ').replace(/<br[ \/]*> /gi, '');
24
+ tx = tx.replace(/<[a-zA-Z\/][^<>]*>/g, '').replace(/&nbsp;|&#160;/gi, ' ');
25
+ tx.replace(/./g, function(){tc++;});
26
+ }
27
+ w.html(tc.toString());
28
+
29
+ setTimeout( function() { t.block = 0; }, 2000 );
30
+ }, 1 );
31
+ }
32
+ }
33
+
34
+ $(document).bind( 'wpcountwords', function(e, txt) {
35
+ wpWordCount.wc(txt);
36
+ });
37
+ }(jQuery));
ext/ja/word-count.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(a){wpWordCount={settings:{strip:/<[a-zA-Z\/][^<>]*>/g,clean:/[0-9.(),;:!?%#$¿'"_+=\\/-]+/g,count:/\S\s+/g},block:0,wc:function(d){var e=this,c=a(".word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/ +/g," ").replace(/<br[ \/]*> /gi,"");d=d.replace(/<[a-zA-Z\/][^<>]*>/g,"").replace(/&nbsp;|&#160;/gi," ");d.replace(/./g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).bind("wpcountwords",function(c,b){wpWordCount.wc(b)})}(jQuery));
ext/ja/wplink.dev.js ADDED
@@ -0,0 +1,585 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var wpLink;
2
+
3
+ (function($){
4
+ var inputs = {}, rivers = {}, ed, River, Query;
5
+
6
+ wpLink = {
7
+ timeToTriggerRiver: 150,
8
+ minRiverAJAXDuration: 200,
9
+ riverBottomThreshold: 5,
10
+ keySensitivity: 100,
11
+ lastSearch: '',
12
+ textarea: function() { return edCanvas; },
13
+
14
+ init : function() {
15
+ inputs.dialog = $('#wp-link');
16
+ inputs.submit = $('#wp-link-submit');
17
+ // URL
18
+ inputs.url = $('#url-field');
19
+ // Secondary options
20
+ inputs.title = $('#link-title-field');
21
+ // Advanced Options
22
+ inputs.openInNewTab = $('#link-target-checkbox');
23
+ inputs.search = $('#search-field');
24
+ // Build Rivers
25
+ rivers.search = new River( $('#search-results') );
26
+ rivers.recent = new River( $('#most-recent-results') );
27
+ rivers.elements = $('.query-results', inputs.dialog);
28
+
29
+ // Bind event handlers
30
+ inputs.dialog.keydown( wpLink.keydown );
31
+ inputs.dialog.keyup( wpLink.keyup );
32
+ inputs.submit.click( function(e){
33
+ wpLink.update();
34
+ e.preventDefault();
35
+ });
36
+ $('#wp-link-cancel').click( wpLink.close );
37
+ $('#internal-toggle').click( wpLink.toggleInternalLinking );
38
+
39
+ rivers.elements.bind('river-select', wpLink.updateFields );
40
+
41
+ inputs.search.keyup( wpLink.searchInternalLinks );
42
+
43
+ inputs.dialog.bind('wpdialogrefresh', wpLink.refresh);
44
+ inputs.dialog.bind('wpdialogbeforeopen', wpLink.beforeOpen);
45
+ inputs.dialog.bind('wpdialogclose', wpLink.onClose);
46
+ },
47
+
48
+ beforeOpen : function() {
49
+ wpLink.range = null;
50
+
51
+ if ( ! wpLink.isMCE() && document.selection ) {
52
+ wpLink.textarea().focus();
53
+ wpLink.range = document.selection.createRange();
54
+ }
55
+ },
56
+
57
+ open : function() {
58
+ // Initialize the dialog if necessary (html mode).
59
+ if ( ! inputs.dialog.data('wpdialog') ) {
60
+ inputs.dialog.wpdialog({
61
+ title: wpLinkL10n.title,
62
+ width: 480,
63
+ height: 'auto',
64
+ modal: true,
65
+ dialogClass: 'wp-dialog',
66
+ zIndex: 300000
67
+ });
68
+ }
69
+
70
+ inputs.dialog.wpdialog('open');
71
+ },
72
+
73
+ isMCE : function() {
74
+ return tinyMCEPopup && ( ed = tinyMCEPopup.editor ) && ! ed.isHidden();
75
+ },
76
+
77
+ refresh : function() {
78
+ // Refresh rivers (clear links, check visibility)
79
+ rivers.search.refresh();
80
+ rivers.recent.refresh();
81
+
82
+ if ( wpLink.isMCE() )
83
+ wpLink.mceRefresh();
84
+ else
85
+ wpLink.setDefaultValues();
86
+
87
+ // Focus the URL field and highlight its contents.
88
+ // If this is moved above the selection changes,
89
+ // IE will show a flashing cursor over the dialog.
90
+ inputs.url.focus()[0].select();
91
+ // Load the most recent results if this is the first time opening the panel.
92
+ if ( ! rivers.recent.ul.children().length )
93
+ rivers.recent.ajax();
94
+ },
95
+
96
+ mceRefresh : function() {
97
+ var e;
98
+ ed = tinyMCEPopup.editor;
99
+
100
+ tinyMCEPopup.restoreSelection();
101
+
102
+ // If link exists, select proper values.
103
+ if ( e = ed.dom.getParent(ed.selection.getNode(), 'A') ) {
104
+ // Set URL and description.
105
+ inputs.url.val( e.href );
106
+ inputs.title.val( ed.dom.getAttrib(e, 'title') );
107
+ // Set open in new tab.
108
+ if ( "_blank" == ed.dom.getAttrib(e, 'target') )
109
+ inputs.openInNewTab.prop('checked', true);
110
+ // Update save prompt.
111
+ inputs.submit.val( wpLinkL10n.update );
112
+
113
+ // If there's no link, set the default values.
114
+ } else {
115
+ wpLink.setDefaultValues();
116
+ }
117
+
118
+ tinyMCEPopup.storeSelection();
119
+ },
120
+
121
+ close : function() {
122
+ if ( wpLink.isMCE() )
123
+ tinyMCEPopup.close();
124
+ else
125
+ inputs.dialog.wpdialog('close');
126
+ },
127
+
128
+ onClose: function() {
129
+ if ( ! wpLink.isMCE() ) {
130
+ wpLink.textarea().focus();
131
+ if ( wpLink.range ) {
132
+ wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
133
+ wpLink.range.select();
134
+ }
135
+ }
136
+ },
137
+
138
+ getAttrs : function() {
139
+ return {
140
+ href : inputs.url.val(),
141
+ title : inputs.title.val(),
142
+ target : inputs.openInNewTab.prop('checked') ? '_blank' : ''
143
+ };
144
+ },
145
+
146
+ update : function() {
147
+ if ( wpLink.isMCE() )
148
+ wpLink.mceUpdate();
149
+ else
150
+ wpLink.htmlUpdate();
151
+ },
152
+
153
+ htmlUpdate : function() {
154
+ var attrs, html, start, end, cursor,
155
+ textarea = wpLink.textarea();
156
+
157
+ if ( ! textarea )
158
+ return;
159
+
160
+ attrs = wpLink.getAttrs();
161
+
162
+ // If there's no href, return.
163
+ if ( ! attrs.href || attrs.href == 'http://' )
164
+ return;
165
+
166
+ // Build HTML
167
+ html = '<a href="' + attrs.href + '"';
168
+
169
+ if ( attrs.title )
170
+ html += ' title="' + attrs.title + '"';
171
+ if ( attrs.target )
172
+ html += ' target="' + attrs.target + '"';
173
+
174
+ html += '>';
175
+
176
+ // Insert HTML
177
+ // W3C
178
+ if ( typeof textarea.selectionStart !== 'undefined' ) {
179
+ start = textarea.selectionStart;
180
+ end = textarea.selectionEnd;
181
+ selection = textarea.value.substring( start, end );
182
+ html = html + selection + '</a>';
183
+ cursor = start + html.length;
184
+
185
+ // If no next is selected, place the cursor inside the closing tag.
186
+ if ( start == end )
187
+ cursor -= '</a>'.length;
188
+
189
+ textarea.value = textarea.value.substring( 0, start )
190
+ + html
191
+ + textarea.value.substring( end, textarea.value.length );
192
+
193
+ // Update cursor position
194
+ textarea.selectionStart = textarea.selectionEnd = cursor;
195
+
196
+ // IE
197
+ // Note: If no text is selected, IE will not place the cursor
198
+ // inside the closing tag.
199
+ } else if ( document.selection && wpLink.range ) {
200
+ textarea.focus();
201
+ wpLink.range.text = html + wpLink.range.text + '</a>';
202
+ wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
203
+ wpLink.range.select();
204
+
205
+ wpLink.range = null;
206
+ }
207
+
208
+ wpLink.close();
209
+ textarea.focus();
210
+ },
211
+
212
+ mceUpdate : function() {
213
+ var ed = tinyMCEPopup.editor,
214
+ attrs = wpLink.getAttrs(),
215
+ e, b;
216
+
217
+ tinyMCEPopup.restoreSelection();
218
+ e = ed.dom.getParent(ed.selection.getNode(), 'A');
219
+
220
+ // If the values are empty, unlink and return
221
+ if ( ! attrs.href || attrs.href == 'http://' ) {
222
+ if ( e ) {
223
+ tinyMCEPopup.execCommand("mceBeginUndoLevel");
224
+ b = ed.selection.getBookmark();
225
+ ed.dom.remove(e, 1);
226
+ ed.selection.moveToBookmark(b);
227
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
228
+ wpLink.close();
229
+ }
230
+ return;
231
+ }
232
+
233
+ tinyMCEPopup.execCommand("mceBeginUndoLevel");
234
+
235
+ if (e == null) {
236
+ ed.getDoc().execCommand("unlink", false, null);
237
+ tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
238
+
239
+ tinymce.each(ed.dom.select("a"), function(n) {
240
+ if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
241
+ e = n;
242
+ ed.dom.setAttribs(e, attrs);
243
+ }
244
+ });
245
+
246
+ // Sometimes WebKit lets a user create a link where
247
+ // they shouldn't be able to. In this case, CreateLink
248
+ // injects "#mce_temp_url#" into their content. Fix it.
249
+ if ( $(e).text() == '#mce_temp_url#' ) {
250
+ ed.dom.remove(e);
251
+ e = null;
252
+ }
253
+ } else {
254
+ ed.dom.setAttribs(e, attrs);
255
+ }
256
+
257
+ // Don't move caret if selection was image
258
+ if ( e && (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') ) {
259
+ ed.focus();
260
+ ed.selection.select(e);
261
+ ed.selection.collapse(0);
262
+ tinyMCEPopup.storeSelection();
263
+ }
264
+
265
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
266
+ wpLink.close();
267
+ },
268
+
269
+ updateFields : function( e, li, originalEvent ) {
270
+ inputs.url.val( li.children('.item-permalink').val() );
271
+ inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() );
272
+ if ( originalEvent && originalEvent.type == "click" )
273
+ inputs.url.focus();
274
+ },
275
+ setDefaultValues : function() {
276
+ // Set URL and description to defaults.
277
+ // Leave the new tab setting as-is.
278
+ inputs.url.val('http://');
279
+ inputs.title.val('');
280
+
281
+ // Update save prompt.
282
+ inputs.submit.val( wpLinkL10n.save );
283
+ },
284
+
285
+ searchInternalLinks : function() {
286
+ var t = $(this), waiting,
287
+ search = t.val();
288
+
289
+ if ( search.length > 1 ) {
290
+ rivers.recent.hide();
291
+ rivers.search.show();
292
+
293
+ // Don't search if the keypress didn't change the title.
294
+ if ( wpLink.lastSearch == search )
295
+ return;
296
+
297
+ wpLink.lastSearch = search;
298
+ waiting = t.siblings('img.waiting').show();
299
+
300
+ rivers.search.change( search );
301
+ rivers.search.ajax( function(){ waiting.hide(); });
302
+ } else {
303
+ rivers.search.hide();
304
+ rivers.recent.show();
305
+ }
306
+ },
307
+
308
+ next : function() {
309
+ rivers.search.next();
310
+ rivers.recent.next();
311
+ },
312
+ prev : function() {
313
+ rivers.search.prev();
314
+ rivers.recent.prev();
315
+ },
316
+
317
+ keydown : function( event ) {
318
+ var fn, key = $.ui.keyCode;
319
+
320
+ switch( event.which ) {
321
+ case key.UP:
322
+ fn = 'prev';
323
+ case key.DOWN:
324
+ fn = fn || 'next';
325
+ clearInterval( wpLink.keyInterval );
326
+ wpLink[ fn ]();
327
+ wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
328
+ break;
329
+ default:
330
+ return;
331
+ }
332
+ event.preventDefault();
333
+ },
334
+ keyup: function( event ) {
335
+ var key = $.ui.keyCode;
336
+
337
+ switch( event.which ) {
338
+ case key.ESCAPE:
339
+ event.stopImmediatePropagation();
340
+ if ( ! $(document).triggerHandler( 'wp_CloseOnEscape', [{ event: event, what: 'wplink', cb: wpLink.close }] ) )
341
+ wpLink.close();
342
+
343
+ return false;
344
+ break;
345
+ case key.UP:
346
+ case key.DOWN:
347
+ clearInterval( wpLink.keyInterval );
348
+ break;
349
+ default:
350
+ return;
351
+ }
352
+ event.preventDefault();
353
+ },
354
+
355
+ delayedCallback : function( func, delay ) {
356
+ var timeoutTriggered, funcTriggered, funcArgs, funcContext;
357
+
358
+ if ( ! delay )
359
+ return func;
360
+
361
+ setTimeout( function() {
362
+ if ( funcTriggered )
363
+ return func.apply( funcContext, funcArgs );
364
+ // Otherwise, wait.
365
+ timeoutTriggered = true;
366
+ }, delay);
367
+
368
+ return function() {
369
+ if ( timeoutTriggered )
370
+ return func.apply( this, arguments );
371
+ // Otherwise, wait.
372
+ funcArgs = arguments;
373
+ funcContext = this;
374
+ funcTriggered = true;
375
+ };
376
+ },
377
+
378
+ toggleInternalLinking : function( event ) {
379
+ var panel = $('#search-panel'),
380
+ widget = inputs.dialog.wpdialog('widget'),
381
+ // We're about to toggle visibility; it's currently the opposite
382
+ visible = !panel.is(':visible'),
383
+ win = $(window);
384
+
385
+ $(this).toggleClass('toggle-arrow-active', visible);
386
+
387
+ inputs.dialog.height('auto');
388
+ panel.slideToggle( 300, function() {
389
+ setUserSetting('wplink', visible ? '1' : '0');
390
+ inputs[ visible ? 'search' : 'url' ].focus();
391
+
392
+ // Move the box if the box is now expanded, was opened in a collapsed state,
393
+ // and if it needs to be moved. (Judged by bottom not being positive or
394
+ // bottom being smaller than top.)
395
+ var scroll = win.scrollTop(),
396
+ top = widget.offset().top,
397
+ bottom = top + widget.outerHeight(),
398
+ diff = bottom - win.height();
399
+
400
+ if ( diff > scroll ) {
401
+ widget.animate({'top': diff < top ? top - diff : scroll }, 200);
402
+ }
403
+ });
404
+ event.preventDefault();
405
+ }
406
+ }
407
+
408
+ River = function( element, search ) {
409
+ var self = this;
410
+ this.element = element;
411
+ this.ul = element.children('ul');
412
+ this.waiting = element.find('.river-waiting');
413
+
414
+ this.change( search );
415
+ this.refresh();
416
+
417
+ element.scroll( function(){ self.maybeLoad(); });
418
+ element.delegate('li', 'click', function(e){ self.select( $(this), e ); });
419
+ };
420
+
421
+ $.extend( River.prototype, {
422
+ refresh: function() {
423
+ this.deselect();
424
+ this.visible = this.element.is(':visible');
425
+ },
426
+ show: function() {
427
+ if ( ! this.visible ) {
428
+ this.deselect();
429
+ this.element.show();
430
+ this.visible = true;
431
+ }
432
+ },
433
+ hide: function() {
434
+ this.element.hide();
435
+ this.visible = false;
436
+ },
437
+ // Selects a list item and triggers the river-select event.
438
+ select: function( li, event ) {
439
+ var liHeight, elHeight, liTop, elTop;
440
+
441
+ if ( li.hasClass('unselectable') || li == this.selected )
442
+ return;
443
+
444
+ this.deselect();
445
+ this.selected = li.addClass('selected');
446
+ // Make sure the element is visible
447
+ liHeight = li.outerHeight();
448
+ elHeight = this.element.height();
449
+ liTop = li.position().top;
450
+ elTop = this.element.scrollTop();
451
+
452
+ if ( liTop < 0 ) // Make first visible element
453
+ this.element.scrollTop( elTop + liTop );
454
+ else if ( liTop + liHeight > elHeight ) // Make last visible element
455
+ this.element.scrollTop( elTop + liTop - elHeight + liHeight );
456
+
457
+ // Trigger the river-select event
458
+ this.element.trigger('river-select', [ li, event, this ]);
459
+ },
460
+ deselect: function() {
461
+ if ( this.selected )
462
+ this.selected.removeClass('selected');
463
+ this.selected = false;
464
+ },
465
+ prev: function() {
466
+ if ( ! this.visible )
467
+ return;
468
+
469
+ var to;
470
+ if ( this.selected ) {
471
+ to = this.selected.prev('li');
472
+ if ( to.length )
473
+ this.select( to );
474
+ }
475
+ },
476
+ next: function() {
477
+ if ( ! this.visible )
478
+ return;
479
+
480
+ var to = this.selected ? this.selected.next('li') : $('li:not(.unselectable):first', this.element);
481
+ if ( to.length )
482
+ this.select( to );
483
+ },
484
+ ajax: function( callback ) {
485
+ var self = this,
486
+ delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
487
+ response = wpLink.delayedCallback( function( results, params ) {
488
+ self.process( results, params );
489
+ if ( callback )
490
+ callback( results, params );
491
+ }, delay );
492
+
493
+ this.query.ajax( response );
494
+ },
495
+ change: function( search ) {
496
+ if ( this.query && this._search == search )
497
+ return;
498
+
499
+ this._search = search;
500
+ this.query = new Query( search );
501
+ this.element.scrollTop(0);
502
+ },
503
+ process: function( results, params ) {
504
+ var list = '', alt = true, classes = '',
505
+ firstPage = params.page == 1;
506
+
507
+ if ( !results ) {
508
+ if ( firstPage ) {
509
+ list += '<li class="unselectable"><span class="item-title"><em>'
510
+ + wpLinkL10n.noMatchesFound
511
+ + '</em></span></li>';
512
+ }
513
+ } else {
514
+ $.each( results, function() {
515
+ classes = alt ? 'alternate' : '';
516
+ classes += this['title'] ? '' : ' no-title';
517
+ list += classes ? '<li class="' + classes + '">' : '<li>';
518
+ list += '<input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />';
519
+ list += '<span class="item-title">';
520
+ list += this['title'] ? this['title'] : wpLinkL10n.noTitle;
521
+ list += '</span><span class="item-info">' + this['info'] + '</span></li>';
522
+ alt = ! alt;
523
+ });
524
+ }
525
+
526
+ this.ul[ firstPage ? 'html' : 'append' ]( list );
527
+ },
528
+ maybeLoad: function() {
529
+ var self = this,
530
+ el = this.element,
531
+ bottom = el.scrollTop() + el.height();
532
+
533
+ if ( ! this.query.ready() || bottom < this.ul.height() - wpLink.riverBottomThreshold )
534
+ return;
535
+
536
+ setTimeout(function() {
537
+ var newTop = el.scrollTop(),
538
+ newBottom = newTop + el.height();
539
+
540
+ if ( ! self.query.ready() || newBottom < self.ul.height() - wpLink.riverBottomThreshold )
541
+ return;
542
+
543
+ self.waiting.show();
544
+ el.scrollTop( newTop + self.waiting.outerHeight() );
545
+
546
+ self.ajax( function() { self.waiting.hide(); });
547
+ }, wpLink.timeToTriggerRiver );
548
+ }
549
+ });
550
+
551
+ Query = function( search ) {
552
+ this.page = 1;
553
+ this.allLoaded = false;
554
+ this.querying = false;
555
+ this.search = search;
556
+ };
557
+
558
+ $.extend( Query.prototype, {
559
+ ready: function() {
560
+ return !( this.querying || this.allLoaded );
561
+ },
562
+ ajax: function( callback ) {
563
+ var self = this,
564
+ query = {
565
+ action : 'wp-link-ajax',
566
+ page : this.page,
567
+ '_ajax_linking_nonce' : $('#_ajax_linking_nonce').val()
568
+ };
569
+
570
+ if ( this.search )
571
+ query.search = this.search;
572
+
573
+ this.querying = true;
574
+
575
+ $.post( ajaxurl, query, function(r) {
576
+ self.page++;
577
+ self.querying = false;
578
+ self.allLoaded = !r;
579
+ callback( r, query );
580
+ }, "json" );
581
+ }
582
+ });
583
+
584
+ $(document).ready( wpLink.init );
585
+ })(jQuery);
ext/ja/wplink.js ADDED
@@ -0,0 +1 @@
 
1
+ var wpLink;(function(f){var b={},e={},d,a,c;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:function(){return edCanvas},init:function(){b.dialog=f("#wp-link");b.submit=f("#wp-link-submit");b.url=f("#url-field");b.title=f("#link-title-field");b.openInNewTab=f("#link-target-checkbox");b.search=f("#search-field");e.search=new a(f("#search-results"));e.recent=new a(f("#most-recent-results"));e.elements=f(".query-results",b.dialog);b.dialog.keydown(wpLink.keydown);b.dialog.keyup(wpLink.keyup);b.submit.click(function(g){wpLink.update();g.preventDefault()});f("#wp-link-cancel").click(wpLink.close);f("#internal-toggle").click(wpLink.toggleInternalLinking);e.elements.bind("river-select",wpLink.updateFields);b.search.keyup(wpLink.searchInternalLinks);b.dialog.bind("wpdialogrefresh",wpLink.refresh);b.dialog.bind("wpdialogbeforeopen",wpLink.beforeOpen);b.dialog.bind("wpdialogclose",wpLink.onClose)},beforeOpen:function(){wpLink.range=null;if(!wpLink.isMCE()&&document.selection){wpLink.textarea().focus();wpLink.range=document.selection.createRange()}},open:function(){if(!b.dialog.data("wpdialog")){b.dialog.wpdialog({title:wpLinkL10n.title,width:480,height:"auto",modal:true,dialogClass:"wp-dialog",zIndex:300000})}b.dialog.wpdialog("open")},isMCE:function(){return tinyMCEPopup&&(d=tinyMCEPopup.editor)&&!d.isHidden()},refresh:function(){e.search.refresh();e.recent.refresh();if(wpLink.isMCE()){wpLink.mceRefresh()}else{wpLink.setDefaultValues()}b.url.focus()[0].select();if(!e.recent.ul.children().length){e.recent.ajax()}},mceRefresh:function(){var g;d=tinyMCEPopup.editor;tinyMCEPopup.restoreSelection();if(g=d.dom.getParent(d.selection.getNode(),"A")){b.url.val(g.href);b.title.val(d.dom.getAttrib(g,"title"));if("_blank"==d.dom.getAttrib(g,"target")){b.openInNewTab.prop("checked",true)}b.submit.val(wpLinkL10n.update)}else{wpLink.setDefaultValues()}tinyMCEPopup.storeSelection()},close:function(){if(wpLink.isMCE()){tinyMCEPopup.close()}else{b.dialog.wpdialog("close")}},onClose:function(){if(!wpLink.isMCE()){wpLink.textarea().focus();if(wpLink.range){wpLink.range.moveToBookmark(wpLink.range.getBookmark());wpLink.range.select()}}},getAttrs:function(){return{href:b.url.val(),title:b.title.val(),target:b.openInNewTab.prop("checked")?"_blank":""}},update:function(){if(wpLink.isMCE()){wpLink.mceUpdate()}else{wpLink.htmlUpdate()}},htmlUpdate:function(){var i,j,l,h,k,g=wpLink.textarea();if(!g){return}i=wpLink.getAttrs();if(!i.href||i.href=="http://"){return}j='<a href="'+i.href+'"';if(i.title){j+=' title="'+i.title+'"'}if(i.target){j+=' target="'+i.target+'"'}j+=">";if(typeof g.selectionStart!=="undefined"){l=g.selectionStart;h=g.selectionEnd;selection=g.value.substring(l,h);j=j+selection+"</a>";k=l+j.length;if(l==h){k-="</a>".length}g.value=g.value.substring(0,l)+j+g.value.substring(h,g.value.length);g.selectionStart=g.selectionEnd=k}else{if(document.selection&&wpLink.range){g.focus();wpLink.range.text=j+wpLink.range.text+"</a>";wpLink.range.moveToBookmark(wpLink.range.getBookmark());wpLink.range.select();wpLink.range=null}}wpLink.close();g.focus()},mceUpdate:function(){var h=tinyMCEPopup.editor,i=wpLink.getAttrs(),j,g;tinyMCEPopup.restoreSelection();j=h.dom.getParent(h.selection.getNode(),"A");if(!i.href||i.href=="http://"){if(j){tinyMCEPopup.execCommand("mceBeginUndoLevel");g=h.selection.getBookmark();h.dom.remove(j,1);h.selection.moveToBookmark(g);tinyMCEPopup.execCommand("mceEndUndoLevel");wpLink.close()}return}tinyMCEPopup.execCommand("mceBeginUndoLevel");if(j==null){h.getDoc().execCommand("unlink",false,null);tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1});tinymce.each(h.dom.select("a"),function(k){if(h.dom.getAttrib(k,"href")=="#mce_temp_url#"){j=k;h.dom.setAttribs(j,i)}});if(f(j).text()=="#mce_temp_url#"){h.dom.remove(j);j=null}}else{h.dom.setAttribs(j,i)}if(j&&(j.childNodes.length!=1||j.firstChild.nodeName!="IMG")){h.focus();h.selection.select(j);h.selection.collapse(0);tinyMCEPopup.storeSelection()}tinyMCEPopup.execCommand("mceEndUndoLevel");wpLink.close()},updateFields:function(i,h,g){b.url.val(h.children(".item-permalink").val());b.title.val(h.hasClass("no-title")?"":h.children(".item-title").text());if(g&&g.type=="click"){b.url.focus()}},setDefaultValues:function(){b.url.val("http://");b.title.val("");b.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var h=f(this),i,g=h.val();if(g.length>1){e.recent.hide();e.search.show();if(wpLink.lastSearch==g){return}wpLink.lastSearch=g;i=h.siblings("img.waiting").show();e.search.change(g);e.search.ajax(function(){i.hide()})}else{e.search.hide();e.recent.show()}},next:function(){e.search.next();e.recent.next()},prev:function(){e.search.prev();e.recent.prev()},keydown:function(i){var h,g=f.ui.keyCode;switch(i.which){case g.UP:h="prev";case g.DOWN:h=h||"next";clearInterval(wpLink.keyInterval);wpLink[h]();wpLink.keyInterval=setInterval(wpLink[h],wpLink.keySensitivity);break;default:return}i.preventDefault()},keyup:function(h){var g=f.ui.keyCode;switch(h.which){case g.ESCAPE:h.stopImmediatePropagation();if(!f(document).triggerHandler("wp_CloseOnEscape",[{event:h,what:"wplink",cb:wpLink.close}])){wpLink.close()}return false;break;case g.UP:case g.DOWN:clearInterval(wpLink.keyInterval);break;default:return}h.preventDefault()},delayedCallback:function(i,g){var l,k,j,h;if(!g){return i}setTimeout(function(){if(k){return i.apply(h,j)}l=true},g);return function(){if(l){return i.apply(this,arguments)}j=arguments;h=this;k=true}},toggleInternalLinking:function(h){var g=f("#search-panel"),i=b.dialog.wpdialog("widget"),k=!g.is(":visible"),j=f(window);f(this).toggleClass("toggle-arrow-active",k);b.dialog.height("auto");g.slideToggle(300,function(){setUserSetting("wplink",k?"1":"0");b[k?"search":"url"].focus();var l=j.scrollTop(),o=i.offset().top,m=o+i.outerHeight(),n=m-j.height();if(n>l){i.animate({top:n<o?o-n:l},200)}});h.preventDefault()}};a=function(i,h){var g=this;this.element=i;this.ul=i.children("ul");this.waiting=i.find(".river-waiting");this.change(h);this.refresh();i.scroll(function(){g.maybeLoad()});i.delegate("li","click",function(j){g.select(f(this),j)})};f.extend(a.prototype,{refresh:function(){this.deselect();this.visible=this.element.is(":visible")},show:function(){if(!this.visible){this.deselect();this.element.show();this.visible=true}},hide:function(){this.element.hide();this.visible=false},select:function(h,k){var j,i,l,g;if(h.hasClass("unselectable")||h==this.selected){return}this.deselect();this.selected=h.addClass("selected");j=h.outerHeight();i=this.element.height();l=h.position().top;g=this.element.scrollTop();if(l<0){this.element.scrollTop(g+l)}else{if(l+j>i){this.element.scrollTop(g+l-i+j)}}this.element.trigger("river-select",[h,k,this])},deselect:function(){if(this.selected){this.selected.removeClass("selected")}this.selected=false},prev:function(){if(!this.visible){return}var g;if(this.selected){g=this.selected.prev("li");if(g.length){this.select(g)}}},next:function(){if(!this.visible){return}var g=this.selected?this.selected.next("li"):f("li:not(.unselectable):first",this.element);if(g.length){this.select(g)}},ajax:function(j){var h=this,i=this.query.page==1?0:wpLink.minRiverAJAXDuration,g=wpLink.delayedCallback(function(k,l){h.process(k,l);if(j){j(k,l)}},i);this.query.ajax(g)},change:function(g){if(this.query&&this._search==g){return}this._search=g;this.query=new c(g);this.element.scrollTop(0)},process:function(h,l){var i="",j=true,g="",k=l.page==1;if(!h){if(k){i+='<li class="unselectable"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"}}else{f.each(h,function(){g=j?"alternate":"";g+=this["title"]?"":" no-title";i+=g?'<li class="'+g+'">':"<li>";i+='<input type="hidden" class="item-permalink" value="'+this["permalink"]+'" />';i+='<span class="item-title">';i+=this["title"]?this["title"]:wpLinkL10n.noTitle;i+='</span><span class="item-info">'+this["info"]+"</span></li>";j=!j})}this.ul[k?"html":"append"](i)},maybeLoad:function(){var h=this,i=this.element,g=i.scrollTop()+i.height();if(!this.query.ready()||g<this.ul.height()-wpLink.riverBottomThreshold){return}setTimeout(function(){var j=i.scrollTop(),k=j+i.height();if(!h.query.ready()||k<h.ul.height()-wpLink.riverBottomThreshold){return}h.waiting.show();i.scrollTop(j+h.waiting.outerHeight());h.ajax(function(){h.waiting.hide()})},wpLink.timeToTriggerRiver)}});c=function(g){this.page=1;this.allLoaded=false;this.querying=false;this.search=g};f.extend(c.prototype,{ready:function(){return !(this.querying||this.allLoaded)},ajax:function(i){var g=this,h={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:f("#_ajax_linking_nonce").val()};if(this.search){h.search=this.search}this.querying=true;f.post(ajaxurl,h,function(j){g.page++;g.querying=false;g.allLoaded=!j;i(j,h)},"json")}});f(document).ready(wpLink.init)})(jQuery);
languages/wp-multibyte-patch-ja.mo ADDED
Binary file
languages/wp-multibyte-patch-ja.po ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Multibyte Patch 1.2\n"
4
+ "PO-Revision-Date: 2011-06-04 15:07+0900\n"
5
+ "MIME-Version: 1.0\n"
6
+ "Content-Type: text/plain; charset=UTF-8\n"
7
+ "Content-Transfer-Encoding: 8bit\n"
8
+ "Plural-Forms: nplurals=1; plural=0;\n"
9
+ "POT-Creation-Date: \n"
10
+ "Last-Translator: tenpura <210pura@gmail.com>\n"
11
+ "Language-Team: \n"
12
+
13
+ msgid "Enhances multibyte string I/O functionality of WordPress."
14
+ msgstr "WP Multibyte Patch は本家版、日本語版 WordPress のマルチバイト文字の取り扱いに関する不具合の累積的修正と強化を行うプラグインです。 <a href=\"http://eastcoder.com/code/wp-multibyte-patch/\">&raquo; 詳しい説明を読む</a>"
15
+
16
+ msgid "Sorry, WP Multibyte Patch requires WordPress %s or later."
17
+ msgstr "お使いの WP Multibyte Patch を有効にするには、WordPress %s 以上が必要です。"
18
+
19
+ msgid "Sorry, WP Multibyte Patch requires mbstring functions."
20
+ msgstr "お使いの WP Multibyte Patch を有効にするには、PHP の mbstring 関数が必要です。"
21
+
22
+ msgid "Word count: %s"
23
+ msgstr "文字数: %s"
24
+
readme.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Multibyte Patch ===
2
+ Contributors: tenpura
3
+ Tags: multibyte,i18n,wp-multibyte-patch,Japanese
4
+ Requires at least: 3.2
5
+ Tested up to: 3.2.1
6
+ Stable tag: 1.4.2
7
+
8
+ Multibyte functionality enhancement for the WordPress Japanese package.
9
+
10
+ == Description ==
11
+
12
+ Multibyte functionality enhancement for the WordPress Japanese package.
13
+ [日本語の説明を読む](http://eastcoder.com/code/wp-multibyte-patch/ "Documentation in Japanese")
14
+
15
+ == Installation ==
16
+
17
+ 1. Upload the `wp-multibyte-patch` folder to the `/wp-content/plugins/` directory.
18
+ 2. Activate the plugin through the Plugins menu in WordPress.
wp-multibyte-patch.php ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Multibyte Patch
4
+ Plugin URI: http://eastcoder.com/code/wp-multibyte-patch/
5
+ Description: Enhances multibyte string I/O functionality of WordPress.
6
+ Author: Kuraishi (tenpura)
7
+ Version: 1.4.2
8
+ Author URI: http://eastcoder.com/
9
+ Text Domain: wp-multibyte-patch
10
+ Domain Path: /languages
11
+ */
12
+
13
+ /*
14
+ Copyright (C) 2011 Kuraishi (Email: 210pura at gmail dot com), Tinybit Inc.
15
+ This program is licensed under the GNU GPL Version 2.
16
+ */
17
+
18
+ class multibyte_patch {
19
+
20
+ var $conf = array(
21
+ 'excerpt_length' => 55,
22
+ 'excerpt_mblength' => 110,
23
+ 'excerpt_more' => ' [...]',
24
+ 'comment_excerpt_length' => 20,
25
+ 'comment_excerpt_mblength' => 40,
26
+ 'ascii_threshold' => 90,
27
+ 'patch_wp_mail' => true,
28
+ 'patch_incoming_trackback' => true,
29
+ 'patch_incoming_pingback' => true,
30
+ 'patch_wp_trim_excerpt' => true,
31
+ 'patch_get_comment_excerpt' => true,
32
+ 'patch_process_search_terms' => true,
33
+ 'patch_admin_custom_css' => true,
34
+ 'patch_wplink_js' => true,
35
+ 'patch_word_count_js' => true,
36
+ 'patch_sanitize_file_name' => true,
37
+ 'patch_bp_create_excerpt' => false,
38
+ 'bp_excerpt_mblength' => 110,
39
+ 'bp_excerpt_more' => ' [...]'
40
+ );
41
+
42
+ var $blog_encoding;
43
+ var $has_mbfunctions;
44
+ var $textdomain = 'wp-multibyte-patch';
45
+ var $lang_dir = 'languages';
46
+ var $required_version = '3.2-RC2';
47
+ var $query_based_vars = array();
48
+
49
+ function guess_encoding($string, $encoding = '') {
50
+ $blog_encoding = $this->blog_encoding;
51
+
52
+ if(!$encoding && seems_utf8($string))
53
+ return 'UTF-8';
54
+ elseif(!$encoding)
55
+ return $blog_encoding;
56
+ else
57
+ return $encoding;
58
+ }
59
+
60
+ function convenc($string, $to_encoding, $from_encoding = '') {
61
+ $blog_encoding = $this->blog_encoding;
62
+
63
+ if('' == $from_encoding)
64
+ $from_encoding = $blog_encoding;
65
+
66
+ if(strtoupper($to_encoding) == strtoupper($from_encoding))
67
+ return $string;
68
+ else
69
+ return mb_convert_encoding($string, $to_encoding, $from_encoding);
70
+ }
71
+
72
+ function incoming_trackback($commentdata) {
73
+ global $wpdb;
74
+
75
+ if('trackback' != $commentdata['comment_type'])
76
+ return $commentdata;
77
+
78
+ if(false === $this->conf['patch_incoming_trackback'])
79
+ return $commentdata;
80
+
81
+ $title = isset($_POST['title']) ? stripslashes($_POST['title']) : '';
82
+ $excerpt = isset($_POST['excerpt']) ? stripslashes($_POST['excerpt']) : '';
83
+ $blog_name = isset($_POST['blog_name']) ? stripslashes($_POST['blog_name']) : '';
84
+ $blog_encoding = $this->blog_encoding;
85
+
86
+ $from_encoding = isset($_POST['charset']) ? $_POST['charset'] : '';
87
+
88
+ if(!$from_encoding)
89
+ $from_encoding = (preg_match("/^.*charset=([a-zA-Z0-9\-_]+).*$/i", $_SERVER['CONTENT_TYPE'], $matched)) ? $matched[1] : '';
90
+
91
+ $from_encoding = str_replace(array(',', ' '), '', strtoupper(trim($from_encoding)));
92
+ $from_encoding = $this->guess_encoding($excerpt . $title . $blog_name, $from_encoding);
93
+
94
+ $title = $this->convenc($title, $blog_encoding, $from_encoding);
95
+ $blog_name = $this->convenc($blog_name, $blog_encoding, $from_encoding);
96
+ $excerpt = $this->convenc($excerpt, $blog_encoding, $from_encoding);
97
+
98
+ $title = strip_tags($title);
99
+ $excerpt = strip_tags($excerpt);
100
+
101
+ $title = (strlen($title) > 250) ? mb_strcut($title, 0, 250, $blog_encoding) . '...' : $title;
102
+ $excerpt = (strlen($excerpt) > 255) ? mb_strcut($excerpt, 0, 252, $blog_encoding) . '...' : $excerpt;
103
+
104
+ $commentdata['comment_author'] = $wpdb->escape($blog_name);
105
+ $commentdata['comment_content'] = $wpdb->escape("<strong>$title</strong>\n\n$excerpt");
106
+
107
+ return $commentdata;
108
+ }
109
+
110
+ function pre_remote_source($linea, $pagelinkedto) {
111
+ $this->pingback_ping_linea = $linea;
112
+ $this->pingback_ping_pagelinkedto = $pagelinkedto;
113
+ return $linea;
114
+ }
115
+
116
+ function incoming_pingback($commentdata) {
117
+ if('pingback' != $commentdata['comment_type'])
118
+ return $commentdata;
119
+
120
+ if(false === $this->conf['patch_incoming_pingback'])
121
+ return $commentdata;
122
+
123
+ $pagelinkedto = $this->pingback_ping_pagelinkedto;
124
+ $linea = $this->pingback_ping_linea;
125
+
126
+ $linea = preg_replace("/" . preg_quote('<!DOC', '/') . "/i", '<DOC', $linea);
127
+ $linea = preg_replace("/[\r\n\t ]+/", ' ', $linea);
128
+ $linea = preg_replace("/ <(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/i", "\n\n", $linea);
129
+
130
+ preg_match("/<meta[^<>]+charset=\"*([a-zA-Z0-9\-_]+)\"*[^<>]*>/i", $linea, $matches);
131
+ $charset = isset($matches[1]) ? $matches[1] : '';
132
+ $from_encoding = $this->guess_encoding(strip_tags($linea), $charset);
133
+ $blog_encoding = $this->blog_encoding;
134
+
135
+ $linea = strip_tags($linea, '<a>');
136
+ $linea = $this->convenc($linea, $blog_encoding, $from_encoding);
137
+ $p = explode("\n\n", $linea);
138
+
139
+ foreach ($p as $para) {
140
+ if(strpos($para, $pagelinkedto) !== false && preg_match("/^([^<>]*)(\<a[^<>]+[\"']" . preg_quote($pagelinkedto, '/') . "[\"'][^<>]*\>)([^<>]+)(\<\/a\>)(.*)$/i", $para, $context))
141
+ break;
142
+ }
143
+
144
+ if(!$context)
145
+ return $commentdata;
146
+
147
+ $context[1] = strip_tags($context[1]);
148
+ $context[5] = strip_tags($context[5]);
149
+ $len_max = 250;
150
+ $len_c3 = strlen($context[3]);
151
+
152
+ if($len_c3 > $len_max) {
153
+ $excerpt = mb_strcut($context[3], 0, 250, $blog_encoding);
154
+ } else {
155
+ $len_c1 = strlen($context[1]);
156
+ $len_c5 = strlen($context[5]);
157
+ $len_left = $len_max - $len_c3;
158
+ $len_left_even = ceil($len_left / 2);
159
+
160
+ if($len_left_even > $len_c1) {
161
+ $context[5] = mb_strcut($context[5], 0, $len_left - $len_c1, $blog_encoding);
162
+ }
163
+ elseif($len_left_even > $len_c5) {
164
+ $context[1] .= "\t\t\t\t\t\t";
165
+ $context[1] = mb_strcut($context[1], $len_c1 - ($len_left - $len_c5), $len_c1 + 6, $blog_encoding);
166
+ $context[1] = preg_replace("/\t*$/", '', $context[1]);
167
+ }
168
+ else {
169
+ $context[1] .= "\t\t\t\t\t\t";
170
+ $context[1] = mb_strcut($context[1], $len_c1 - $len_left_even, $len_c1 + 6, $blog_encoding);
171
+ $context[1] = preg_replace("/\t*$/", '', $context[1]);
172
+ $context[5] = mb_strcut($context[5], 0, $len_left_even, $blog_encoding);
173
+ }
174
+
175
+ $excerpt = $context[1] . $context[3] . $context[5];
176
+ }
177
+
178
+ $commentdata['comment_content'] = '[...] ' . esc_html($excerpt) . ' [...]';
179
+ $commentdata['comment_content'] = addslashes($commentdata['comment_content']);
180
+ $commentdata['comment_author'] = stripslashes($commentdata['comment_author']);
181
+ $commentdata['comment_author'] = $this->convenc($commentdata['comment_author'], $blog_encoding, $from_encoding);
182
+ $commentdata['comment_author'] = addslashes($commentdata['comment_author']);
183
+
184
+ return $commentdata;
185
+ }
186
+
187
+ function preprocess_comment($commentdata) {
188
+ if($commentdata['comment_type'] == 'trackback')
189
+ return $this->incoming_trackback($commentdata);
190
+ elseif($commentdata['comment_type'] == 'pingback')
191
+ return $this->incoming_pingback($commentdata);
192
+ else
193
+ return $commentdata;
194
+ }
195
+
196
+ function is_almost_ascii($string, $encoding) {
197
+ if(100 === $this->conf['ascii_threshold'])
198
+ return false;
199
+
200
+ return ($this->conf['ascii_threshold'] < round(@(mb_strlen($string, $encoding) / strlen($string)) * 100)) ? true : false;
201
+ }
202
+
203
+ function wp_trim_excerpt($text) {
204
+ $raw_excerpt = $text;
205
+
206
+ $blog_encoding = $this->blog_encoding;
207
+
208
+ if('' == $text) {
209
+ $text = get_the_content('');
210
+
211
+ $text = strip_shortcodes( $text );
212
+
213
+ $text = apply_filters('the_content', $text);
214
+ $text = str_replace(']]>', ']]&gt;', $text);
215
+ $text = strip_tags($text);
216
+ $excerpt_length = apply_filters('excerpt_length', $this->conf['excerpt_length']);
217
+ $excerpt_mblength = apply_filters('excerpt_mblength', $this->conf['excerpt_mblength']);
218
+ $excerpt_more = apply_filters('excerpt_more', $this->conf['excerpt_more']);
219
+
220
+ if($this->is_almost_ascii($text, $blog_encoding)) {
221
+ $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
222
+
223
+ if ( count($words) > $excerpt_length ) {
224
+ array_pop($words);
225
+ $text = implode(' ', $words);
226
+ $text = $text . $excerpt_more;
227
+ } else {
228
+ $text = implode(' ', $words);
229
+ }
230
+ }
231
+ else {
232
+ $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' ');
233
+
234
+ if(mb_strlen($text, $blog_encoding) > $excerpt_mblength)
235
+ $text = mb_substr($text, 0, $excerpt_mblength, $blog_encoding) . $excerpt_more;
236
+ }
237
+ }
238
+
239
+ return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
240
+ }
241
+
242
+ function trim_multibyte_excerpt($text = '', $length = 110, $more = ' [...]', $encoding = 'UTF-8') {
243
+ $text = strip_shortcodes($text);
244
+ $text = str_replace(']]>', ']]&gt;', $text);
245
+ $text = strip_tags($text);
246
+ $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' ');
247
+
248
+ if(mb_strlen($text, $encoding) > $length)
249
+ $text = mb_substr($text, 0, $length, $encoding) . $more;
250
+
251
+ return $text;
252
+ }
253
+
254
+ function bp_create_excerpt($text = '') {
255
+ if($this->is_almost_ascii($text, $this->blog_encoding))
256
+ return $text;
257
+ else
258
+ return $this->trim_multibyte_excerpt($text, $this->conf['bp_excerpt_mblength'], $this->conf['bp_excerpt_more'], $this->blog_encoding);
259
+ }
260
+
261
+ function bp_get_activity_content_body($content = '') {
262
+ return preg_replace("/<a [^<>]+>([^<>]+)<\/a>(" . preg_quote($this->conf['bp_excerpt_more'], '/') . "<\/p>)$/", "$1$2", $content);
263
+ }
264
+
265
+ // param $excerpt could already be truncated to 20 words or less by the original get_comment_excerpt() function.
266
+ function get_comment_excerpt($excerpt = '') {
267
+ $excerpt = preg_replace("/\.\.\.$/", '', $excerpt);
268
+ $blog_encoding = $this->blog_encoding;
269
+
270
+ if($this->is_almost_ascii($excerpt, $blog_encoding)) {
271
+ $words = explode(' ', $excerpt, $this->conf['comment_excerpt_length'] + 1);
272
+
273
+ if(count($words) > $this->conf['comment_excerpt_length']) {
274
+ array_pop($words);
275
+ $excerpt = implode(' ', $words) . '...';
276
+ }
277
+ }
278
+ elseif(mb_strlen($excerpt, $blog_encoding) > $this->conf['comment_excerpt_mblength']) {
279
+ $excerpt = mb_substr($excerpt, 0, $this->conf['comment_excerpt_mblength'], $blog_encoding) . '...';
280
+ }
281
+
282
+ return $excerpt;
283
+ }
284
+
285
+ function sanitize_file_name($name) {
286
+ $info = pathinfo($name);
287
+ $ext = !empty($info['extension']) ? '.' . $info['extension'] : '';
288
+ $name = str_replace($ext, '', $name);
289
+ $name_enc = rawurlencode($name);
290
+ $name = ($name == $name_enc) ? $name . $ext : md5($name) . $ext;
291
+ return $name;
292
+ }
293
+
294
+ function excerpt_mblength($length) {
295
+ if(isset($this->query_based_vars['excerpt_mblength']) && (int) $this->query_based_vars['excerpt_mblength'])
296
+ return $this->query_based_vars['excerpt_mblength'];
297
+ else
298
+ return (int) $length;
299
+ }
300
+
301
+ function excerpt_more($more) {
302
+ if(isset($this->query_based_vars['excerpt_more']))
303
+ return $this->query_based_vars['excerpt_more'];
304
+ else
305
+ return $more;
306
+ }
307
+
308
+ function query_based_settings() {
309
+ $is_query_funcs = array('is_feed', 'is_404', 'is_search', 'is_tax', 'is_front_page', 'is_home', 'is_attachment', 'is_single', 'is_page', 'is_category', 'is_tag', 'is_author', 'is_date', 'is_archive', 'is_paged');
310
+
311
+ foreach($is_query_funcs as $func) {
312
+ if(isset($this->conf['excerpt_mblength.' . $func]) && !isset($this->query_based_vars['excerpt_mblength']) && $func())
313
+ $this->query_based_vars['excerpt_mblength'] = $this->conf['excerpt_mblength.' . $func];
314
+
315
+ if(isset($this->conf['excerpt_more.' . $func]) && !isset($this->query_based_vars['excerpt_more']) && $func())
316
+ $this->query_based_vars['excerpt_more'] = $this->conf['excerpt_more.' . $func];
317
+ }
318
+ }
319
+
320
+ function import_l10n_entry($text, $from_domain, $to_domain = 'default') {
321
+ global $l10n;
322
+
323
+ if(isset($l10n[$to_domain]->entries) && isset($l10n[$from_domain]->entries[$text]))
324
+ $l10n[$to_domain]->entries[$text] = $l10n[$from_domain]->entries[$text];
325
+ }
326
+
327
+ function filters() {
328
+ // remove filter
329
+ if(false !== $this->conf['patch_wp_trim_excerpt'])
330
+ remove_filter('get_the_excerpt', 'wp_trim_excerpt');
331
+
332
+ // add filter
333
+ add_filter('preprocess_comment', array(&$this, 'preprocess_comment'), 99);
334
+ add_filter('excerpt_mblength', array(&$this, 'excerpt_mblength'), 9);
335
+ add_filter('excerpt_more', array(&$this, 'excerpt_more'), 9);
336
+
337
+ if(false !== $this->conf['patch_incoming_pingback'])
338
+ add_filter('pre_remote_source', array(&$this, 'pre_remote_source'), 10, 2);
339
+
340
+ if(false !== $this->conf['patch_wp_trim_excerpt'])
341
+ add_filter('get_the_excerpt', array(&$this, 'wp_trim_excerpt'));
342
+
343
+ if(false !== $this->conf['patch_get_comment_excerpt'])
344
+ add_filter('get_comment_excerpt', array(&$this, 'get_comment_excerpt'));
345
+
346
+ if(false !== $this->conf['patch_sanitize_file_name'])
347
+ add_filter('sanitize_file_name', array(&$this, 'sanitize_file_name'));
348
+
349
+ if(false !== $this->conf['patch_bp_create_excerpt']) {
350
+ add_filter('bp_create_excerpt', array(&$this, 'bp_create_excerpt'), 99);
351
+ add_filter('bp_get_activity_content_body', array(&$this, 'bp_get_activity_content_body'), 99);
352
+ }
353
+
354
+ // add action
355
+ add_action('wp', array(&$this, 'query_based_settings'));
356
+
357
+ if(method_exists($this, 'process_search_terms') && false !== $this->conf['patch_process_search_terms'])
358
+ add_action('sanitize_comment_cookies', array(&$this, 'process_search_terms'));
359
+
360
+ if(method_exists($this, 'wp_mail') && false !== $this->conf['patch_wp_mail'])
361
+ add_action('phpmailer_init', array(&$this, 'wp_mail'));
362
+
363
+ if(method_exists($this, 'admin_custom_css') && false !== $this->conf['patch_admin_custom_css'])
364
+ add_action('admin_head' , array(&$this, 'admin_custom_css'), 99);
365
+
366
+ if(method_exists($this, 'wplink_js') && false !== $this->conf['patch_wplink_js'])
367
+ add_action('wp_default_scripts' , array(&$this, 'wplink_js'), 9);
368
+
369
+ if(method_exists($this, 'word_count_js') && false !== $this->conf['patch_word_count_js'])
370
+ add_action('wp_default_scripts' , array(&$this, 'word_count_js'), 9);
371
+ }
372
+
373
+ function mbfunctions_exist() {
374
+ return (
375
+ function_exists('mb_convert_encoding') &&
376
+ function_exists('mb_convert_kana') &&
377
+ function_exists('mb_detect_encoding') &&
378
+ function_exists('mb_strcut') &&
379
+ function_exists('mb_strlen') &&
380
+ function_exists('mb_substr')
381
+ ) ? true : false;
382
+ }
383
+
384
+ function activation_check() {
385
+ global $wp_version;
386
+ $required_version = $this->required_version;
387
+
388
+ if(version_compare(substr($wp_version, 0, strlen($required_version)), $required_version, '<')) {
389
+ deactivate_plugins(__FILE__);
390
+ wp_die(sprintf(__('Sorry, WP Multibyte Patch requires WordPress %s or later.', 'wp-multibyte-patch'), $required_version));
391
+ }
392
+ elseif(!$this->has_mbfunctions) {
393
+ deactivate_plugins(__FILE__);
394
+ wp_die(__('Sorry, WP Multibyte Patch requires mbstring functions.', 'wp-multibyte-patch'));
395
+ }
396
+ }
397
+
398
+ function __construct() {
399
+ global $wpmp_conf;
400
+ $this->conf = array_merge($this->conf, $wpmp_conf);
401
+
402
+ $this->blog_encoding = get_option('blog_charset');
403
+ $this->has_mbfunctions = $this->mbfunctions_exist();
404
+
405
+ load_textdomain($this->textdomain, plugin_dir_path(__FILE__) . $this->lang_dir . '/' . $this->textdomain . '-' . get_locale() . '.mo');
406
+ register_activation_hook(__FILE__, array(&$this, 'activation_check'));
407
+
408
+ $this->filters();
409
+ }
410
+ }
411
+
412
+ if(defined('WP_PLUGIN_URL')) {
413
+ global $wpmp_conf, $wpmp;
414
+ $wpmp_conf = array();
415
+ $wpmp_conf['base_dir'] = dirname(__FILE__);
416
+
417
+ if(file_exists($wpmp_conf['base_dir'] . '/wpmp-config.php'))
418
+ require_once($wpmp_conf['base_dir'] . '/wpmp-config.php');
419
+
420
+ if(file_exists($wpmp_conf['base_dir'] . '/ext/' . get_locale() . '/class.php')) {
421
+ if(file_exists($wpmp_conf['base_dir'] . '/ext/' . get_locale() . '/config.php'))
422
+ require_once($wpmp_conf['base_dir'] . '/ext/' . get_locale() . '/config.php');
423
+
424
+ require_once($wpmp_conf['base_dir'] . '/ext/' . get_locale() . '/class.php');
425
+ $wpmp = new multibyte_patch_ext();
426
+ }
427
+ elseif(file_exists($wpmp_conf['base_dir'] . '/ext/default/class.php')) {
428
+ if(file_exists($wpmp_conf['base_dir'] . '/ext/default/config.php'))
429
+ require_once($wpmp_conf['base_dir'] . '/ext/default/config.php');
430
+
431
+ require_once($wpmp_conf['base_dir'] . '/ext/default/class.php');
432
+ $wpmp = new multibyte_patch_ext();
433
+ }
434
+ else
435
+ $wpmp = new multibyte_patch();
436
+ }
437
+
438
+ ?>
wpmp-config-sample.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* WP Multibyte Patch global config file */
3
+
4
+ // WordPress Settings
5
+ $wpmp_conf['excerpt_length'] = 55; // Maximum word count for ascii posts.
6
+ $wpmp_conf['excerpt_mblength'] = 110; // Maximum character count for multibyte posts.
7
+ $wpmp_conf['excerpt_more'] = ' [...]'; // More string at the end of the excerpt.
8
+ $wpmp_conf['comment_excerpt_length'] = 20; // Maximum word count for ascii comments.
9
+ $wpmp_conf['comment_excerpt_mblength'] = 40; // Maximum character count for multibyte comments.
10
+
11
+ // BuddyPress Settings
12
+ $wpmp_conf['bp_excerpt_mblength'] = 110; // Maximum character count for the multibyte text filtered by bp_create_excerpt hook.
13
+ $wpmp_conf['bp_excerpt_more'] = ' [...]'; // More string for the multibyte excerpt filtered by bp_create_excerpt hook.
14
+
15
+ // Each function can be turned off by using the value false.
16
+ $wpmp_conf['patch_wp_mail'] = true;
17
+ $wpmp_conf['patch_incoming_trackback'] = true;
18
+ $wpmp_conf['patch_incoming_pingback'] = true;
19
+ $wpmp_conf['patch_wp_trim_excerpt'] = true;
20
+ $wpmp_conf['patch_get_comment_excerpt'] = true;
21
+ $wpmp_conf['patch_process_search_terms'] = true;
22
+ $wpmp_conf['patch_admin_custom_css'] = true;
23
+ $wpmp_conf['patch_wplink_js'] = true;
24
+ $wpmp_conf['patch_word_count_js'] = true;
25
+ $wpmp_conf['patch_sanitize_file_name'] = true;
26
+ $wpmp_conf['patch_bp_create_excerpt'] = false;
27
+ ?>
wpmp-load.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ // To load WP Multibyte Patch as a must-use plugin, this file must be directly under the mu-plugins directory.
3
+ if(!defined('WP_INSTALLING') && defined('WPMU_PLUGIN_DIR') && defined('WPMU_PLUGIN_URL'))
4
+ require_once(WPMU_PLUGIN_DIR . '/wp-multibyte-patch/wp-multibyte-patch.php');
5
+ ?>