WP Multibyte Patch - Version 2.5

Version Description

Download this release

Release Info

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

Code changes from version 2.4 to 2.5

ext/ja/class.php CHANGED
@@ -3,7 +3,7 @@
3
  * WP Multibyte Patch Japanese Locale Extension
4
  *
5
  * @package WP_Multibyte_Patch
6
- * @version 2.4
7
  * @author Seisuke Kuraishi <210pura@gmail.com>
8
  * @copyright Copyright (c) 2015 Seisuke Kuraishi, Tinybit Inc.
9
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
@@ -150,10 +150,7 @@ if ( class_exists( 'multibyte_patch' ) ) :
150
  }
151
 
152
  function wp_trim_words( $text = '', $num_words = 110, $more = '', $original_text = '' ) {
153
- if (
154
- $this->is_wp_required_version( '4.3-RC1' ) && 0 !== strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) ||
155
- !$this->is_wp_required_version( '4.3-RC1' ) && 'characters' != _x( 'words', 'word count: words or characters?' )
156
- )
157
  return $text;
158
 
159
  // If the caller is wp_dashboard_recent_drafts()
3
  * WP Multibyte Patch Japanese Locale Extension
4
  *
5
  * @package WP_Multibyte_Patch
6
+ * @version 2.5
7
  * @author Seisuke Kuraishi <210pura@gmail.com>
8
  * @copyright Copyright (c) 2015 Seisuke Kuraishi, Tinybit Inc.
9
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
150
  }
151
 
152
  function wp_trim_words( $text = '', $num_words = 110, $more = '', $original_text = '' ) {
153
+ if ( 0 !== strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) )
 
 
 
154
  return $text;
155
 
156
  // If the caller is wp_dashboard_recent_drafts()
js/20131219/word-count.js DELETED
@@ -1,50 +0,0 @@
1
- /* global wordCountL10n */
2
- var wpWordCount;
3
- (function($,undefined) {
4
- wpWordCount = {
5
-
6
- settings : {
7
- strip : /<[a-zA-Z\/][^<>]*>/g, // strip HTML tags
8
- clean : /[0-9.(),;:!?%#$¿'"_+=\\/-]+/g, // regexp to remove punctuation, etc.
9
- count : /\S\s+/g // word-counting regexp
10
- },
11
-
12
- block : 0,
13
-
14
- wc : function(tx, type) {
15
- var t = this, w = $('.word-count'), tc = 0;
16
-
17
- if ( type === undefined )
18
- type = wordCountL10n.type;
19
- if ( type !== 'w' && type !== 'c' )
20
- type = 'w';
21
-
22
- if ( t.block )
23
- return;
24
-
25
- t.block = 1;
26
-
27
- setTimeout( function() {
28
- if ( tx ) {
29
- if ( type == 'w' ) { // word-counting
30
- tx = tx.replace( t.settings.strip, ' ' ).replace( /&nbsp;|&#160;/gi, ' ' );
31
- tx = tx.replace( t.settings.clean, '' );
32
- tx.replace( t.settings.count, function(){tc++;} );
33
- }
34
- else if ( type == 'c' ) { // char-counting for asian languages
35
- tx = tx.replace( t.settings.strip, '' ).replace( /^ +| +$/gm, '' );
36
- tx = tx.replace( / +|&nbsp;|&#160;/gi, ' ' );
37
- tx.replace( /[\S \u00A0\u3000]/g, function(){tc++;} );
38
- }
39
- }
40
- w.html(tc.toString());
41
-
42
- setTimeout( function() { t.block = 0; }, 2000 );
43
- }, 1 );
44
- }
45
- };
46
-
47
- $(document).bind( 'wpcountwords', function(e, txt) {
48
- wpWordCount.wc(txt);
49
- });
50
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/20131219/word-count.min.js DELETED
@@ -1 +0,0 @@
1
- var wpWordCount;(function(a,b){wpWordCount={settings:{strip:/<[a-zA-Z\/][^<>]*>/g,clean:/[0-9.(),;:!?%#$¿'"_+=\\/-]+/g,count:/\S\s+/g},block:0,wc:function(e,g){var f=this,d=a(".word-count"),c=0;if(g===b){g=wordCountL10n.type}if(g!=="w"&&g!=="c"){g="w"}if(f.block){return}f.block=1;setTimeout(function(){if(e){if(g=="w"){e=e.replace(f.settings.strip," ").replace(/&nbsp;|&#160;/gi," ");e=e.replace(f.settings.clean,"");e.replace(f.settings.count,function(){c++})}else{if(g=="c"){e=e.replace(f.settings.strip,"").replace(/^ +| +$/gm,"");e=e.replace(/ +|&nbsp;|&#160;/gi," ");e.replace(/[\S \u00A0\u3000]/g,function(){c++})}}}d.html(c.toString());setTimeout(function(){f.block=0},2000)},1)}};a(document).bind("wpcountwords",function(d,c){wpWordCount.wc(c)})}(jQuery));
 
js/20150424/wplink.min.js DELETED
@@ -1 +0,0 @@
1
- var wpLink;!function(a){function b(){return c.dom.getParent(c.selection.getNode(),"a")}var c,d,e,f,g,h={},i={},j="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){function b(){var b=a.trim(h.url.val());b&&g!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(h.url.val("http://"+b),g=b)}h.wrap=a("#wp-link-wrap"),h.dialog=a("#wp-link"),h.backdrop=a("#wp-link-backdrop"),h.submit=a("#wp-link-submit"),h.close=a("#wp-link-close"),h.text=a("#wp-link-text"),h.url=a("#wp-link-url"),h.nonce=a("#_ajax_linking_nonce"),h.openInNewTab=a("#wp-link-target"),h.search=a("#wp-link-search"),i.search=new e(a("#search-results")),i.recent=new e(a("#most-recent-results")),i.elements=h.dialog.find(".query-results"),h.queryNotice=a("#query-notice-message"),h.queryNoticeTextDefault=h.queryNotice.find(".query-notice-default"),h.queryNoticeTextHint=h.queryNotice.find(".query-notice-hint"),h.dialog.keydown(wpLink.keydown),h.dialog.keyup(wpLink.keyup),h.submit.click(function(a){a.preventDefault(),wpLink.update()}),h.close.add(h.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),i.elements.on("river-select",wpLink.updateFields),h.search.on("focus.wplink",function(){h.queryNoticeTextDefault.hide(),h.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){h.queryNoticeTextDefault.show(),h.queryNoticeTextHint.addClass("screen-reader-text").hide()}),h.search.keyup(function(){var a=this;window.clearTimeout(d),d=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)}),h.url.on("paste",function(){setTimeout(b,0)}),h.url.on("blur",b)},open:function(b){var d;a(document.body).addClass("modal-open"),wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(d=tinymce.get(wpActiveEditor),c=d&&!d.isHidden()?d:null,c&&tinymce.isIE&&(c.windowManager.bookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),h.wrap.show(),h.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",h.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(){var a="";i.search.refresh(),i.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(h.wrap.hasClass("has-text-field")||h.wrap.addClass("has-text-field"),document.selection?a=document.selection.createRange().text||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||""),h.text.val(a),wpLink.setDefaultValues()),j?h.url.focus().blur():h.url.focus()[0].select(),i.recent.ul.children().length||i.recent.ajax(),g=h.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b=c.selection.getContent();if(/</.test(b)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(b)||-1===b.indexOf("href=")))return!1;if(a){var d,e=a.childNodes;if(0===e.length)return!1;for(d=e.length-1;d>=0;d--)if(3!=e[d].nodeType)return!1}return!0},mceRefresh:function(){var a,b=c.selection.getNode(),d=c.dom.getParent(b,"a[href]"),e=this.hasSelectedText(d);d?(a=d.innerText||d.textContent,h.url.val(c.dom.getAttrib(d,"href")),h.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(d,"target")),h.submit.val(wpLinkL10n.update)):(a=c.selection.getContent({format:"text"}),this.setDefaultValues()),e?(h.text.val(a||""),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?c.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),h.backdrop.hide(),h.wrap.hide(),g=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return{href:a.trim(h.url.val()),target:h.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=h.text.val(),a.href&&(c='<a href="'+a.href+'"',a.target&&(c+=' target="'+a.target+'"'),c+=">",document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,e=i.selectionEnd,g=b||i.value.substring(d,e),c=c+g+"</a>",f=d+c.length,d!==e||g||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return wpLink.close(),c.focus(),tinymce.isIE&&c.selection.moveToBookmark(c.windowManager.bookmark),e.href?(a=b(),d=h.text.val(),void(a?(d&&("innerText"in a?a.innerText=d:a.textContent=d),c.dom.setAttribs(a,e)):d?c.selection.setNode(c.dom.create("a",e,d)):c.execCommand("mceInsertLink",!1,e))):void c.execCommand("unlink")},updateFields:function(a,b){h.url.val(b.children(".item-permalink").val())},setDefaultValues:function(){var a,b=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?a=c.selection.getContent():document.selection&&wpLink.range?a=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),h.url.val(a&&b.test(a)?"mailto:"+a:a&&d.test(a)?a.replace(/&amp;|&#0?38;/gi,"&"):""),h.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>1){if(i.recent.hide(),i.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").addClass("is-active"),i.search.change(d),i.search.ajax(function(){b.removeClass("is-active")})}else i.search.hide(),i.recent.show()},next:function(){i.search.next(),i.recent.next()},prev:function(){i.search.prev(),i.recent.prev()},keydown:function(b){var c,d,e=a.ui.keyCode;e.ESCAPE===b.keyCode?(wpLink.close(),b.stopImmediatePropagation()):e.TAB===b.keyCode&&(d=b.target.id,"wp-link-submit"!==d||b.shiftKey?"wp-link-close"===d&&b.shiftKey&&(h.submit.focus(),b.preventDefault()):(h.close.focus(),b.preventDefault())),(b.keyCode===e.UP||b.keyCode===e.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(c=b.keyCode===e.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;(b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=h.wrap.hasClass("search-panel-visible");h.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),h[b?"url":"search"].focus(),a.preventDefault()}},e=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(e.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new f(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.addClass("is-active"),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),f=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(f.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:h.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
 
js/{20150424 → 20150818}/wplink.js RENAMED
@@ -68,7 +68,7 @@ var wpLink;
68
  inputs.queryNoticeTextHint.addClass( 'screen-reader-text' ).hide();
69
  } );
70
 
71
- inputs.search.keyup( function() {
72
  var self = this;
73
 
74
  window.clearTimeout( searchTimer );
@@ -77,26 +77,28 @@ var wpLink;
77
  }, 500 );
78
  });
79
 
80
- function correctURL() {
81
- var url = $.trim( inputs.url.val() );
82
-
83
- if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
84
- inputs.url.val( 'http://' + url );
85
- correctedURL = url;
86
- }
87
- }
88
-
89
  inputs.url.on( 'paste', function() {
90
- setTimeout( correctURL, 0 );
91
  } );
92
 
93
- inputs.url.on( 'blur', correctURL );
 
 
 
 
 
 
 
 
 
 
94
  },
95
 
96
  open: function( editorId ) {
97
- var ed;
 
98
 
99
- $( document.body ).addClass( 'modal-open' );
100
 
101
  wpLink.range = null;
102
 
@@ -111,6 +113,10 @@ var wpLink;
111
  this.textarea = $( '#' + window.wpActiveEditor ).get( 0 );
112
 
113
  if ( typeof tinymce !== 'undefined' ) {
 
 
 
 
114
  ed = tinymce.get( wpActiveEditor );
115
 
116
  if ( ed && ! ed.isHidden() ) {
@@ -260,12 +266,24 @@ var wpLink;
260
  },
261
 
262
  getAttrs: function() {
 
 
263
  return {
264
  href: $.trim( inputs.url.val() ),
265
  target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : ''
266
  };
267
  },
268
 
 
 
 
 
 
 
 
 
 
 
269
  update: function() {
270
  if ( wpLink.isMCE() ) {
271
  wpLink.mceUpdate();
@@ -290,14 +308,7 @@ var wpLink;
290
  return;
291
  }
292
 
293
- // Build HTML
294
- html = '<a href="' + attrs.href + '"';
295
-
296
- if ( attrs.target ) {
297
- html += ' target="' + attrs.target + '"';
298
- }
299
-
300
- html += '>';
301
 
302
  // Insert HTML
303
  if ( document.selection && wpLink.range ) {
@@ -354,7 +365,10 @@ var wpLink;
354
  }
355
 
356
  link = getLink();
357
- text = inputs.text.val();
 
 
 
358
 
359
  if ( link ) {
360
  if ( text ) {
@@ -373,6 +387,8 @@ var wpLink;
373
  editor.execCommand( 'mceInsertLink', false, attrs );
374
  }
375
  }
 
 
376
  },
377
 
378
  updateFields: function( e, li ) {
68
  inputs.queryNoticeTextHint.addClass( 'screen-reader-text' ).hide();
69
  } );
70
 
71
+ inputs.search.on( 'keyup input', function() {
72
  var self = this;
73
 
74
  window.clearTimeout( searchTimer );
77
  }, 500 );
78
  });
79
 
 
 
 
 
 
 
 
 
 
80
  inputs.url.on( 'paste', function() {
81
+ setTimeout( wpLink.correctURL, 0 );
82
  } );
83
 
84
+ inputs.url.on( 'blur', wpLink.correctURL );
85
+ },
86
+
87
+ // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://
88
+ correctURL: function () {
89
+ var url = $.trim( inputs.url.val() );
90
+
91
+ if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
92
+ inputs.url.val( 'http://' + url );
93
+ correctedURL = url;
94
+ }
95
  },
96
 
97
  open: function( editorId ) {
98
+ var ed,
99
+ $body = $( document.body );
100
 
101
+ $body.addClass( 'modal-open' );
102
 
103
  wpLink.range = null;
104
 
113
  this.textarea = $( '#' + window.wpActiveEditor ).get( 0 );
114
 
115
  if ( typeof tinymce !== 'undefined' ) {
116
+ // Make sure the link wrapper is the last element in the body,
117
+ // or the inline editor toolbar may show above the backdrop.
118
+ $body.append( inputs.backdrop, inputs.wrap );
119
+
120
  ed = tinymce.get( wpActiveEditor );
121
 
122
  if ( ed && ! ed.isHidden() ) {
266
  },
267
 
268
  getAttrs: function() {
269
+ wpLink.correctURL();
270
+
271
  return {
272
  href: $.trim( inputs.url.val() ),
273
  target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : ''
274
  };
275
  },
276
 
277
+ buildHtml: function(attrs) {
278
+ var html = '<a href="' + attrs.href + '"';
279
+
280
+ if ( attrs.target ) {
281
+ html += ' target="' + attrs.target + '"';
282
+ }
283
+
284
+ return html + '>';
285
+ },
286
+
287
  update: function() {
288
  if ( wpLink.isMCE() ) {
289
  wpLink.mceUpdate();
308
  return;
309
  }
310
 
311
+ html = wpLink.buildHtml(attrs);
 
 
 
 
 
 
 
312
 
313
  // Insert HTML
314
  if ( document.selection && wpLink.range ) {
365
  }
366
 
367
  link = getLink();
368
+
369
+ if ( inputs.wrap.hasClass( 'has-text-field' ) ) {
370
+ text = inputs.text.val() || attrs.href;
371
+ }
372
 
373
  if ( link ) {
374
  if ( text ) {
387
  editor.execCommand( 'mceInsertLink', false, attrs );
388
  }
389
  }
390
+
391
+ editor.nodeChanged();
392
  },
393
 
394
  updateFields: function( e, li ) {
js/20150818/wplink.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var wpLink;!function(a){function b(){return c.dom.getParent(c.selection.getNode(),"a")}var c,d,e,f,g,h={},i={},j="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){h.wrap=a("#wp-link-wrap"),h.dialog=a("#wp-link"),h.backdrop=a("#wp-link-backdrop"),h.submit=a("#wp-link-submit"),h.close=a("#wp-link-close"),h.text=a("#wp-link-text"),h.url=a("#wp-link-url"),h.nonce=a("#_ajax_linking_nonce"),h.openInNewTab=a("#wp-link-target"),h.search=a("#wp-link-search"),i.search=new e(a("#search-results")),i.recent=new e(a("#most-recent-results")),i.elements=h.dialog.find(".query-results"),h.queryNotice=a("#query-notice-message"),h.queryNoticeTextDefault=h.queryNotice.find(".query-notice-default"),h.queryNoticeTextHint=h.queryNotice.find(".query-notice-hint"),h.dialog.keydown(wpLink.keydown),h.dialog.keyup(wpLink.keyup),h.submit.click(function(a){a.preventDefault(),wpLink.update()}),h.close.add(h.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),i.elements.on("river-select",wpLink.updateFields),h.search.on("focus.wplink",function(){h.queryNoticeTextDefault.hide(),h.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){h.queryNoticeTextDefault.show(),h.queryNoticeTextHint.addClass("screen-reader-text").hide()}),h.search.on("keyup input",function(){var a=this;window.clearTimeout(d),d=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)}),h.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),h.url.on("blur",wpLink.correctURL)},correctURL:function(){var b=a.trim(h.url.val());b&&g!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(h.url.val("http://"+b),g=b)},open:function(b){var d,e=a(document.body);e.addClass("modal-open"),wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(e.append(h.backdrop,h.wrap),d=tinymce.get(wpActiveEditor),c=d&&!d.isHidden()?d:null,c&&tinymce.isIE&&(c.windowManager.bookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),h.wrap.show(),h.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",h.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(){var a="";i.search.refresh(),i.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(h.wrap.hasClass("has-text-field")||h.wrap.addClass("has-text-field"),document.selection?a=document.selection.createRange().text||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||""),h.text.val(a),wpLink.setDefaultValues()),j?h.url.focus().blur():h.url.focus()[0].select(),i.recent.ul.children().length||i.recent.ajax(),g=h.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b=c.selection.getContent();if(/</.test(b)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(b)||-1===b.indexOf("href=")))return!1;if(a){var d,e=a.childNodes;if(0===e.length)return!1;for(d=e.length-1;d>=0;d--)if(3!=e[d].nodeType)return!1}return!0},mceRefresh:function(){var a,b=c.selection.getNode(),d=c.dom.getParent(b,"a[href]"),e=this.hasSelectedText(d);d?(a=d.innerText||d.textContent,h.url.val(c.dom.getAttrib(d,"href")),h.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(d,"target")),h.submit.val(wpLinkL10n.update)):(a=c.selection.getContent({format:"text"}),this.setDefaultValues()),e?(h.text.val(a||""),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?c.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),h.backdrop.hide(),h.wrap.hide(),g=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(h.url.val()),target:h.openInNewTab.prop("checked")?"_blank":""}},buildHtml:function(a){var b='<a href="'+a.href+'"';return a.target&&(b+=' target="'+a.target+'"'),b+">"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=h.text.val(),a.href&&(c=wpLink.buildHtml(a),document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,e=i.selectionEnd,g=b||i.value.substring(d,e),c=c+g+"</a>",f=d+c.length,d!==e||g||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return wpLink.close(),c.focus(),tinymce.isIE&&c.selection.moveToBookmark(c.windowManager.bookmark),e.href?(a=b(),h.wrap.hasClass("has-text-field")&&(d=h.text.val()||e.href),a?(d&&("innerText"in a?a.innerText=d:a.textContent=d),c.dom.setAttribs(a,e)):d?c.selection.setNode(c.dom.create("a",e,d)):c.execCommand("mceInsertLink",!1,e),void c.nodeChanged()):void c.execCommand("unlink")},updateFields:function(a,b){h.url.val(b.children(".item-permalink").val())},setDefaultValues:function(){var a,b=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?a=c.selection.getContent():document.selection&&wpLink.range?a=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),a&&b.test(a)?h.url.val("mailto:"+a):a&&d.test(a)?h.url.val(a.replace(/&amp;|&#0?38;/gi,"&")):h.url.val(""),h.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>1){if(i.recent.hide(),i.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").addClass("is-active"),i.search.change(d),i.search.ajax(function(){b.removeClass("is-active")})}else i.search.hide(),i.recent.show()},next:function(){i.search.next(),i.recent.next()},prev:function(){i.search.prev(),i.recent.prev()},keydown:function(b){var c,d,e=a.ui.keyCode;e.ESCAPE===b.keyCode?(wpLink.close(),b.stopImmediatePropagation()):e.TAB===b.keyCode&&(d=b.target.id,"wp-link-submit"!==d||b.shiftKey?"wp-link-close"===d&&b.shiftKey&&(h.submit.focus(),b.preventDefault()):(h.close.focus(),b.preventDefault())),(b.keyCode===e.UP||b.keyCode===e.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(c=b.keyCode===e.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;(b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=h.wrap.hasClass("search-panel-visible");h.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),h[b?"url":"search"].focus(),a.preventDefault()}},e=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(e.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new f(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.addClass("is-active"),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),f=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(f.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:h.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
js/word-count.js DELETED
@@ -1,112 +0,0 @@
1
- ( function() {
2
- function WordCounter( settings ) {
3
- var key,
4
- shortcodes;
5
-
6
- if ( settings ) {
7
- for ( key in settings ) {
8
- if ( settings.hasOwnProperty( key ) ) {
9
- this.settings[ key ] = settings[ key ];
10
- }
11
- }
12
- }
13
-
14
- shortcodes = this.settings.l10n.shortcodes;
15
-
16
- if ( shortcodes && shortcodes.length ) {
17
- this.settings.shortcodesRegExp = new RegExp( '\\[\\/?(?:' + shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
18
- }
19
- }
20
-
21
- WordCounter.prototype.settings = {
22
- HTMLRegExp: /<\/?[a-z][^>]*?>/gi,
23
- HTMLcommentRegExp: /<!--[\s\S]*?-->/g,
24
- spaceRegExp: /&nbsp;|&#160;/gi,
25
- HTMLEntityRegExp: /&\S+?;/g,
26
- connectorRegExp: /--|\u2014/g,
27
- removeRegExp: new RegExp( [
28
- '[',
29
- // Basic Latin (extract)
30
- '\u0021-\u0040\u005B-\u0060\u007B-\u007E',
31
- // Latin-1 Supplement (extract)
32
- '\u0080-\u00BF\u00D7\u00F7',
33
- // General Punctuation
34
- // Superscripts and Subscripts
35
- // Currency Symbols
36
- // Combining Diacritical Marks for Symbols
37
- // Letterlike Symbols
38
- // Number Forms
39
- // Arrows
40
- // Mathematical Operators
41
- // Miscellaneous Technical
42
- // Control Pictures
43
- // Optical Character Recognition
44
- // Enclosed Alphanumerics
45
- // Box Drawing
46
- // Block Elements
47
- // Geometric Shapes
48
- // Miscellaneous Symbols
49
- // Dingbats
50
- // Miscellaneous Mathematical Symbols-A
51
- // Supplemental Arrows-A
52
- // Braille Patterns
53
- // Supplemental Arrows-B
54
- // Miscellaneous Mathematical Symbols-B
55
- // Supplemental Mathematical Operators
56
- // Miscellaneous Symbols and Arrows
57
- '\u2000-\u2BFF',
58
- // Supplemental Punctuation
59
- '\u2E00-\u2E7F',
60
- ']'
61
- ].join( '' ), 'g' ),
62
- astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
63
- wordsRegExp: /\S\s+/g,
64
- characters_excluding_spacesRegExp: /\S/g,
65
- characters_including_spacesRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g,
66
- l10n: window.wordCountL10n || {}
67
- };
68
-
69
- WordCounter.prototype.count = function( text, type ) {
70
- var count = 0;
71
-
72
- type = type || this.settings.l10n.type;
73
-
74
- if ( type !== 'characters_excluding_spaces' && type !== 'characters_including_spaces' ) {
75
- type = 'words';
76
- }
77
-
78
- if ( text ) {
79
- text = text + '\n';
80
-
81
- text = text.replace( this.settings.HTMLRegExp, '\n' );
82
- text = text.replace( this.settings.HTMLcommentRegExp, '' );
83
-
84
- if ( this.settings.shortcodesRegExp ) {
85
- text = text.replace( this.settings.shortcodesRegExp, '\n' );
86
- }
87
-
88
- text = text.replace( this.settings.spaceRegExp, ' ' );
89
-
90
- if ( type === 'words' ) {
91
- text = text.replace( this.settings.HTMLEntityRegExp, '' );
92
- text = text.replace( this.settings.connectorRegExp, ' ' );
93
- text = text.replace( this.settings.removeRegExp, '' );
94
- } else {
95
- text = text.replace( this.settings.HTMLEntityRegExp, 'a' );
96
- text = text.replace( this.settings.astralRegExp, 'a' );
97
- }
98
-
99
- text = text.match( this.settings[ type + 'RegExp' ] );
100
-
101
- if ( text ) {
102
- count = text.length;
103
- }
104
- }
105
-
106
- return count;
107
- };
108
-
109
- window.wp = window.wp || {};
110
- window.wp.utils = window.wp.utils || {};
111
- window.wp.utils.WordCounter = WordCounter;
112
- } )();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/word-count.min.js DELETED
@@ -1 +0,0 @@
1
- !function(){function a(a){var b,c;if(a)for(b in a)a.hasOwnProperty(b)&&(this.settings[b]=a[b]);c=this.settings.l10n.shortcodes,c&&c.length&&(this.settings.shortcodesRegExp=new RegExp("\\[\\/?(?:"+c.join("|")+")[^\\]]*?\\]","g"))}a.prototype.settings={HTMLRegExp:/<\/?[a-z][^>]*?>/gi,HTMLcommentRegExp:/<!--[\s\S]*?-->/g,spaceRegExp:/&nbsp;|&#160;/gi,HTMLEntityRegExp:/&\S+?;/g,connectorRegExp:/--|\u2014/g,removeRegExp:new RegExp(["[","!-@[-`{-~","\x80-\xbf\xd7\xf7","\u2000-\u2bff","\u2e00-\u2e7f","]"].join(""),"g"),astralRegExp:/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,wordsRegExp:/\S\s+/g,characters_excluding_spacesRegExp:/\S/g,characters_including_spacesRegExp:/[^\f\n\r\t\v\u00AD\u2028\u2029]/g,l10n:window.wordCountL10n||{}},a.prototype.count=function(a,b){var c=0;return b=b||this.settings.l10n.type,"characters_excluding_spaces"!==b&&"characters_including_spaces"!==b&&(b="words"),a&&(a+="\n",a=a.replace(this.settings.HTMLRegExp,"\n"),a=a.replace(this.settings.HTMLcommentRegExp,""),this.settings.shortcodesRegExp&&(a=a.replace(this.settings.shortcodesRegExp,"\n")),a=a.replace(this.settings.spaceRegExp," "),"words"===b?(a=a.replace(this.settings.HTMLEntityRegExp,""),a=a.replace(this.settings.connectorRegExp," "),a=a.replace(this.settings.removeRegExp,"")):(a=a.replace(this.settings.HTMLEntityRegExp,"a"),a=a.replace(this.settings.astralRegExp,"a")),a=a.match(this.settings[b+"RegExp"]),a&&(c=a.length)),c},window.wp=window.wp||{},window.wp.utils=window.wp.utils||{},window.wp.utils.WordCounter=a}();
 
js/wplink.js CHANGED
@@ -382,7 +382,7 @@ var wpLink;
382
  editor.dom.setAttribs( link, attrs );
383
  } else {
384
  if ( text ) {
385
- editor.selection.setNode( editor.dom.create( 'a', attrs, text ) );
386
  } else {
387
  editor.execCommand( 'mceInsertLink', false, attrs );
388
  }
@@ -459,13 +459,14 @@ var wpLink;
459
  },
460
 
461
  keydown: function( event ) {
462
- var fn, id,
463
- key = $.ui.keyCode;
464
 
465
- if ( key.ESCAPE === event.keyCode ) {
 
466
  wpLink.close();
467
  event.stopImmediatePropagation();
468
- } else if ( key.TAB === event.keyCode ) {
 
469
  id = event.target.id;
470
 
471
  // wp-link-submit must always be the last focusable element in the dialog.
@@ -479,7 +480,8 @@ var wpLink;
479
  }
480
  }
481
 
482
- if ( event.keyCode !== key.UP && event.keyCode !== key.DOWN ) {
 
483
  return;
484
  }
485
 
@@ -488,7 +490,8 @@ var wpLink;
488
  return;
489
  }
490
 
491
- fn = event.keyCode === key.UP ? 'prev' : 'next';
 
492
  clearInterval( wpLink.keyInterval );
493
  wpLink[ fn ]();
494
  wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
@@ -496,9 +499,8 @@ var wpLink;
496
  },
497
 
498
  keyup: function( event ) {
499
- var key = $.ui.keyCode;
500
-
501
- if ( event.which === key.UP || event.which === key.DOWN ) {
502
  clearInterval( wpLink.keyInterval );
503
  event.preventDefault();
504
  }
382
  editor.dom.setAttribs( link, attrs );
383
  } else {
384
  if ( text ) {
385
+ editor.selection.setNode( editor.dom.create( 'a', attrs, editor.dom.encode( text ) ) );
386
  } else {
387
  editor.execCommand( 'mceInsertLink', false, attrs );
388
  }
459
  },
460
 
461
  keydown: function( event ) {
462
+ var fn, id;
 
463
 
464
+ // Escape key.
465
+ if ( 27 === event.keyCode ) {
466
  wpLink.close();
467
  event.stopImmediatePropagation();
468
+ // Tab key.
469
+ } else if ( 9 === event.keyCode ) {
470
  id = event.target.id;
471
 
472
  // wp-link-submit must always be the last focusable element in the dialog.
480
  }
481
  }
482
 
483
+ // Up Arrow and Down Arrow keys.
484
+ if ( 38 !== event.keyCode && 40 !== event.keyCode ) {
485
  return;
486
  }
487
 
490
  return;
491
  }
492
 
493
+ // Up Arrow key.
494
+ fn = 38 === event.keyCode ? 'prev' : 'next';
495
  clearInterval( wpLink.keyInterval );
496
  wpLink[ fn ]();
497
  wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
499
  },
500
 
501
  keyup: function( event ) {
502
+ // Up Arrow and Down Arrow keys.
503
+ if ( 38 === event.keyCode || 40 === event.keyCode ) {
 
504
  clearInterval( wpLink.keyInterval );
505
  event.preventDefault();
506
  }
js/wplink.min.js CHANGED
@@ -1 +1 @@
1
- var wpLink;!function(a){function b(){return c.dom.getParent(c.selection.getNode(),"a")}var c,d,e,f,g,h={},i={},j="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){h.wrap=a("#wp-link-wrap"),h.dialog=a("#wp-link"),h.backdrop=a("#wp-link-backdrop"),h.submit=a("#wp-link-submit"),h.close=a("#wp-link-close"),h.text=a("#wp-link-text"),h.url=a("#wp-link-url"),h.nonce=a("#_ajax_linking_nonce"),h.openInNewTab=a("#wp-link-target"),h.search=a("#wp-link-search"),i.search=new e(a("#search-results")),i.recent=new e(a("#most-recent-results")),i.elements=h.dialog.find(".query-results"),h.queryNotice=a("#query-notice-message"),h.queryNoticeTextDefault=h.queryNotice.find(".query-notice-default"),h.queryNoticeTextHint=h.queryNotice.find(".query-notice-hint"),h.dialog.keydown(wpLink.keydown),h.dialog.keyup(wpLink.keyup),h.submit.click(function(a){a.preventDefault(),wpLink.update()}),h.close.add(h.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),i.elements.on("river-select",wpLink.updateFields),h.search.on("focus.wplink",function(){h.queryNoticeTextDefault.hide(),h.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){h.queryNoticeTextDefault.show(),h.queryNoticeTextHint.addClass("screen-reader-text").hide()}),h.search.on("keyup input",function(){var a=this;window.clearTimeout(d),d=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)}),h.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),h.url.on("blur",wpLink.correctURL)},correctURL:function(){var b=a.trim(h.url.val());b&&g!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(h.url.val("http://"+b),g=b)},open:function(b){var d,e=a(document.body);e.addClass("modal-open"),wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(e.append(h.backdrop,h.wrap),d=tinymce.get(wpActiveEditor),c=d&&!d.isHidden()?d:null,c&&tinymce.isIE&&(c.windowManager.bookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),h.wrap.show(),h.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",h.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(){var a="";i.search.refresh(),i.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(h.wrap.hasClass("has-text-field")||h.wrap.addClass("has-text-field"),document.selection?a=document.selection.createRange().text||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||""),h.text.val(a),wpLink.setDefaultValues()),j?h.url.focus().blur():h.url.focus()[0].select(),i.recent.ul.children().length||i.recent.ajax(),g=h.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b=c.selection.getContent();if(/</.test(b)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(b)||-1===b.indexOf("href=")))return!1;if(a){var d,e=a.childNodes;if(0===e.length)return!1;for(d=e.length-1;d>=0;d--)if(3!=e[d].nodeType)return!1}return!0},mceRefresh:function(){var a,b=c.selection.getNode(),d=c.dom.getParent(b,"a[href]"),e=this.hasSelectedText(d);d?(a=d.innerText||d.textContent,h.url.val(c.dom.getAttrib(d,"href")),h.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(d,"target")),h.submit.val(wpLinkL10n.update)):(a=c.selection.getContent({format:"text"}),this.setDefaultValues()),e?(h.text.val(a||""),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?c.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),h.backdrop.hide(),h.wrap.hide(),g=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(h.url.val()),target:h.openInNewTab.prop("checked")?"_blank":""}},buildHtml:function(a){var b='<a href="'+a.href+'"';return a.target&&(b+=' target="'+a.target+'"'),b+">"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=h.text.val(),a.href&&(c=wpLink.buildHtml(a),document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,e=i.selectionEnd,g=b||i.value.substring(d,e),c=c+g+"</a>",f=d+c.length,d!==e||g||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return wpLink.close(),c.focus(),tinymce.isIE&&c.selection.moveToBookmark(c.windowManager.bookmark),e.href?(a=b(),h.wrap.hasClass("has-text-field")&&(d=h.text.val()||e.href),a?(d&&("innerText"in a?a.innerText=d:a.textContent=d),c.dom.setAttribs(a,e)):d?c.selection.setNode(c.dom.create("a",e,d)):c.execCommand("mceInsertLink",!1,e),void c.nodeChanged()):void c.execCommand("unlink")},updateFields:function(a,b){h.url.val(b.children(".item-permalink").val())},setDefaultValues:function(){var a,b=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?a=c.selection.getContent():document.selection&&wpLink.range?a=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),a&&b.test(a)?h.url.val("mailto:"+a):a&&d.test(a)?h.url.val(a.replace(/&amp;|&#0?38;/gi,"&")):h.url.val(""),h.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>1){if(i.recent.hide(),i.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").addClass("is-active"),i.search.change(d),i.search.ajax(function(){b.removeClass("is-active")})}else i.search.hide(),i.recent.show()},next:function(){i.search.next(),i.recent.next()},prev:function(){i.search.prev(),i.recent.prev()},keydown:function(b){var c,d,e=a.ui.keyCode;e.ESCAPE===b.keyCode?(wpLink.close(),b.stopImmediatePropagation()):e.TAB===b.keyCode&&(d=b.target.id,"wp-link-submit"!==d||b.shiftKey?"wp-link-close"===d&&b.shiftKey&&(h.submit.focus(),b.preventDefault()):(h.close.focus(),b.preventDefault())),(b.keyCode===e.UP||b.keyCode===e.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(c=b.keyCode===e.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;(b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=h.wrap.hasClass("search-panel-visible");h.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),h[b?"url":"search"].focus(),a.preventDefault()}},e=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(e.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new f(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.addClass("is-active"),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),f=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(f.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:h.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
1
+ var wpLink;!function(a){function b(){return c.dom.getParent(c.selection.getNode(),"a")}var c,d,e,f,g,h={},i={},j="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){h.wrap=a("#wp-link-wrap"),h.dialog=a("#wp-link"),h.backdrop=a("#wp-link-backdrop"),h.submit=a("#wp-link-submit"),h.close=a("#wp-link-close"),h.text=a("#wp-link-text"),h.url=a("#wp-link-url"),h.nonce=a("#_ajax_linking_nonce"),h.openInNewTab=a("#wp-link-target"),h.search=a("#wp-link-search"),i.search=new e(a("#search-results")),i.recent=new e(a("#most-recent-results")),i.elements=h.dialog.find(".query-results"),h.queryNotice=a("#query-notice-message"),h.queryNoticeTextDefault=h.queryNotice.find(".query-notice-default"),h.queryNoticeTextHint=h.queryNotice.find(".query-notice-hint"),h.dialog.keydown(wpLink.keydown),h.dialog.keyup(wpLink.keyup),h.submit.click(function(a){a.preventDefault(),wpLink.update()}),h.close.add(h.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),i.elements.on("river-select",wpLink.updateFields),h.search.on("focus.wplink",function(){h.queryNoticeTextDefault.hide(),h.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){h.queryNoticeTextDefault.show(),h.queryNoticeTextHint.addClass("screen-reader-text").hide()}),h.search.on("keyup input",function(){var a=this;window.clearTimeout(d),d=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)}),h.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),h.url.on("blur",wpLink.correctURL)},correctURL:function(){var b=a.trim(h.url.val());b&&g!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(h.url.val("http://"+b),g=b)},open:function(b){var d,e=a(document.body);e.addClass("modal-open"),wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(e.append(h.backdrop,h.wrap),d=tinymce.get(wpActiveEditor),c=d&&!d.isHidden()?d:null,c&&tinymce.isIE&&(c.windowManager.bookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),h.wrap.show(),h.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",h.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(){var a="";i.search.refresh(),i.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(h.wrap.hasClass("has-text-field")||h.wrap.addClass("has-text-field"),document.selection?a=document.selection.createRange().text||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||""),h.text.val(a),wpLink.setDefaultValues()),j?h.url.focus().blur():h.url.focus()[0].select(),i.recent.ul.children().length||i.recent.ajax(),g=h.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b=c.selection.getContent();if(/</.test(b)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(b)||-1===b.indexOf("href=")))return!1;if(a){var d,e=a.childNodes;if(0===e.length)return!1;for(d=e.length-1;d>=0;d--)if(3!=e[d].nodeType)return!1}return!0},mceRefresh:function(){var a,b=c.selection.getNode(),d=c.dom.getParent(b,"a[href]"),e=this.hasSelectedText(d);d?(a=d.innerText||d.textContent,h.url.val(c.dom.getAttrib(d,"href")),h.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(d,"target")),h.submit.val(wpLinkL10n.update)):(a=c.selection.getContent({format:"text"}),this.setDefaultValues()),e?(h.text.val(a||""),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?c.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),h.backdrop.hide(),h.wrap.hide(),g=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(h.url.val()),target:h.openInNewTab.prop("checked")?"_blank":""}},buildHtml:function(a){var b='<a href="'+a.href+'"';return a.target&&(b+=' target="'+a.target+'"'),b+">"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=h.text.val(),a.href&&(c=wpLink.buildHtml(a),document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,e=i.selectionEnd,g=b||i.value.substring(d,e),c=c+g+"</a>",f=d+c.length,d!==e||g||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return wpLink.close(),c.focus(),tinymce.isIE&&c.selection.moveToBookmark(c.windowManager.bookmark),e.href?(a=b(),h.wrap.hasClass("has-text-field")&&(d=h.text.val()||e.href),a?(d&&("innerText"in a?a.innerText=d:a.textContent=d),c.dom.setAttribs(a,e)):d?c.selection.setNode(c.dom.create("a",e,c.dom.encode(d))):c.execCommand("mceInsertLink",!1,e),void c.nodeChanged()):void c.execCommand("unlink")},updateFields:function(a,b){h.url.val(b.children(".item-permalink").val())},setDefaultValues:function(){var a,b=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?a=c.selection.getContent():document.selection&&wpLink.range?a=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),a&&b.test(a)?h.url.val("mailto:"+a):a&&d.test(a)?h.url.val(a.replace(/&amp;|&#0?38;/gi,"&")):h.url.val(""),h.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>1){if(i.recent.hide(),i.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").addClass("is-active"),i.search.change(d),i.search.ajax(function(){b.removeClass("is-active")})}else i.search.hide(),i.recent.show()},next:function(){i.search.next(),i.recent.next()},prev:function(){i.search.prev(),i.recent.prev()},keydown:function(a){var b,c;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(c=a.target.id,"wp-link-submit"!==c||a.shiftKey?"wp-link-close"===c&&a.shiftKey&&(h.submit.focus(),a.preventDefault()):(h.close.focus(),a.preventDefault())),(38===a.keyCode||40===a.keyCode)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(b=38===a.keyCode?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[b](),wpLink.keyInterval=setInterval(wpLink[b],wpLink.keySensitivity),a.preventDefault())},keyup:function(a){(38===a.keyCode||40===a.keyCode)&&(clearInterval(wpLink.keyInterval),a.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=h.wrap.hasClass("search-panel-visible");h.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),h[b?"url":"search"].focus(),a.preventDefault()}},e=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(e.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new f(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.addClass("is-active"),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),f=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(f.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:h.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === WP Multibyte Patch ===
2
  Contributors: tenpura
3
  Tags: multibyte,i18n,wp-multibyte-patch,Japanese
4
- Requires at least: 4.2-RC1
5
- Tested up to: 4.3
6
- Stable tag: 2.4
7
 
8
  Multibyte functionality enhancement for the WordPress Japanese package.
9
 
1
  === WP Multibyte Patch ===
2
  Contributors: tenpura
3
  Tags: multibyte,i18n,wp-multibyte-patch,Japanese
4
+ Requires at least: 4.3-RC3
5
+ Tested up to: 4.4
6
+ Stable tag: 2.5
7
 
8
  Multibyte functionality enhancement for the WordPress Japanese package.
9
 
wp-multibyte-patch.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: WP Multibyte Patch
4
  Description: Multibyte functionality enhancement for the WordPress Japanese package.
5
- Version: 2.4
6
  Plugin URI: http://eastcoder.com/code/wp-multibyte-patch/
7
  Author: Seisuke Kuraishi
8
  Author URI: http://tinybit.co.jp/
@@ -15,7 +15,7 @@ Domain Path: /languages
15
  * Multibyte functionality enhancement for the WordPress Japanese package.
16
  *
17
  * @package WP_Multibyte_Patch
18
- * @version 2.4
19
  * @author Seisuke Kuraishi <210pura@gmail.com>
20
  * @copyright Copyright (c) 2015 Seisuke Kuraishi, Tinybit Inc.
21
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
@@ -43,12 +43,12 @@ class multibyte_patch {
43
  'patch_process_search_terms' => false,
44
  'patch_admin_custom_css' => false,
45
  'patch_wplink_js' => true,
46
- 'patch_word_count_js' => true,
47
  'patch_force_character_count' => false,
48
  'patch_force_twentytwelve_open_sans_off' => false,
49
  'patch_force_twentythirteen_google_fonts_off' => false,
50
  'patch_force_twentyfourteen_google_fonts_off' => false,
51
  'patch_force_twentyfifteen_google_fonts_off' => false,
 
52
  'patch_sanitize_file_name' => true,
53
  'patch_bp_create_excerpt' => false,
54
  'bp_excerpt_mblength' => 110,
@@ -62,7 +62,7 @@ class multibyte_patch {
62
  var $debug_suffix = '';
63
  var $textdomain = 'wp-multibyte-patch';
64
  var $lang_dir = 'languages';
65
- var $required_version = '4.2-RC1';
66
  var $query_based_vars = array();
67
 
68
  // For fallback purpose only. (1.6)
@@ -234,11 +234,9 @@ class multibyte_patch {
234
  return preg_replace( "/<a [^<>]+>([^<>]+)<\/a>(" . preg_quote( $this->conf['bp_excerpt_more'], '/' ) . "<\/p>)$/", "$1$2", $content );
235
  }
236
 
237
- // $excerpt param could already be truncated to 20 words or less by the original get_comment_excerpt() function.
238
- // $comment param (introduced in WP 4.1) should be used instead.
239
- function get_comment_excerpt( $excerpt = '' ) {
240
- $excerpt = preg_replace( "/\.\.\.$/", '', $excerpt );
241
  $blog_encoding = $this->blog_encoding;
 
242
 
243
  if ( $this->mb_strlen( $excerpt, $blog_encoding ) > $this->conf['comment_excerpt_mblength'] )
244
  $excerpt = mb_substr( $excerpt, 0, $this->conf['comment_excerpt_mblength'], $blog_encoding ) . '&hellip;';
@@ -272,21 +270,12 @@ class multibyte_patch {
272
  }
273
 
274
  function wplink_js( &$scripts ) {
275
- $script_required_version = '4.3-RC3';
276
 
277
  if ( !$this->is_wp_required_version( $script_required_version ) )
278
- $scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/20150424/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20150424', 1 );
279
  else
280
- $scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20150818', 1 );
281
- }
282
-
283
- function word_count_js( &$scripts ) {
284
- $script_required_version = '4.3-RC1';
285
-
286
- if ( !$this->is_wp_required_version( $script_required_version ) )
287
- $scripts->add( 'word-count', plugin_dir_url( __FILE__ ) . "js/20131219/word-count{$this->debug_suffix}.js", array( 'jquery' ), 20131219, 1 );
288
- //else
289
- // $scripts->add( 'word-count', plugin_dir_url( __FILE__ ) . "js/word-count{$this->debug_suffix}.js", array(), '20150818', 1 );
290
  }
291
 
292
  function force_character_count( $translations = '', $text = '', $context = '' ) {
@@ -312,15 +301,22 @@ class multibyte_patch {
312
  }
313
 
314
  function force_twentyfifteen_google_fonts_off() {
315
- global $wp_styles;
316
-
317
  wp_dequeue_style( 'twentyfifteen-fonts' );
 
 
 
 
 
 
 
 
318
 
319
- $styles = $wp_styles->query( 'twentyfifteen-style' );
 
320
 
321
- if ( !empty( $styles->deps ) && is_array( $styles->deps ) ) {
322
- if ( false !== $key = array_search( 'twentyfifteen-fonts', $styles->deps ) )
323
- unset( $styles->deps[$key] );
324
  }
325
  }
326
 
@@ -352,10 +348,7 @@ class multibyte_patch {
352
  function filters_after_setup_theme() {
353
  // add filter
354
  if ( false !== $this->conf['patch_force_character_count']) {
355
- if (
356
- $this->is_wp_required_version( '4.3-RC1' ) && 'characters_including_spaces' != _x( 'words', 'Word count type. Do not translate!' ) ||
357
- !$this->is_wp_required_version( '4.3-RC1' ) && 'characters' != _x( 'words', 'word count: words or characters?' )
358
- )
359
  add_filter( 'gettext_with_context', array( $this, 'force_character_count' ), 10, 3 );
360
  }
361
 
@@ -376,6 +369,16 @@ class multibyte_patch {
376
 
377
  if ( false !== $this->conf['patch_force_twentyfifteen_google_fonts_off'] && 'twentyfifteen' == get_template() ) {
378
  add_action( 'wp_enqueue_scripts', array( $this, 'force_twentyfifteen_google_fonts_off' ), 99 );
 
 
 
 
 
 
 
 
 
 
379
  }
380
  }
381
 
@@ -392,7 +395,7 @@ class multibyte_patch {
392
  }
393
 
394
  if ( false !== $this->conf['patch_get_comment_excerpt'] )
395
- add_filter( 'get_comment_excerpt', array( $this, 'get_comment_excerpt' ) );
396
 
397
  if ( false !== $this->conf['patch_sanitize_file_name'] )
398
  add_filter( 'sanitize_file_name', array( $this, 'sanitize_file_name' ) );
@@ -422,9 +425,6 @@ class multibyte_patch {
422
  if ( false !== $this->conf['patch_wplink_js'] )
423
  add_action( 'wp_default_scripts', array( $this, 'wplink_js' ), 9 );
424
 
425
- if ( false !== $this->conf['patch_word_count_js'] )
426
- add_action( 'wp_default_scripts', array( $this, 'word_count_js' ), 9 );
427
-
428
  add_action( 'after_setup_theme', array( $this, 'filters_after_setup_theme' ), 99 );
429
  }
430
 
2
  /*
3
  Plugin Name: WP Multibyte Patch
4
  Description: Multibyte functionality enhancement for the WordPress Japanese package.
5
+ Version: 2.5
6
  Plugin URI: http://eastcoder.com/code/wp-multibyte-patch/
7
  Author: Seisuke Kuraishi
8
  Author URI: http://tinybit.co.jp/
15
  * Multibyte functionality enhancement for the WordPress Japanese package.
16
  *
17
  * @package WP_Multibyte_Patch
18
+ * @version 2.5
19
  * @author Seisuke Kuraishi <210pura@gmail.com>
20
  * @copyright Copyright (c) 2015 Seisuke Kuraishi, Tinybit Inc.
21
  * @license http://opensource.org/licenses/gpl-2.0.php GPLv2
43
  'patch_process_search_terms' => false,
44
  'patch_admin_custom_css' => false,
45
  'patch_wplink_js' => true,
 
46
  'patch_force_character_count' => false,
47
  'patch_force_twentytwelve_open_sans_off' => false,
48
  'patch_force_twentythirteen_google_fonts_off' => false,
49
  'patch_force_twentyfourteen_google_fonts_off' => false,
50
  'patch_force_twentyfifteen_google_fonts_off' => false,
51
+ 'patch_force_twentysixteen_google_fonts_off' => false,
52
  'patch_sanitize_file_name' => true,
53
  'patch_bp_create_excerpt' => false,
54
  'bp_excerpt_mblength' => 110,
62
  var $debug_suffix = '';
63
  var $textdomain = 'wp-multibyte-patch';
64
  var $lang_dir = 'languages';
65
+ var $required_version = '4.3-RC3';
66
  var $query_based_vars = array();
67
 
68
  // For fallback purpose only. (1.6)
234
  return preg_replace( "/<a [^<>]+>([^<>]+)<\/a>(" . preg_quote( $this->conf['bp_excerpt_more'], '/' ) . "<\/p>)$/", "$1$2", $content );
235
  }
236
 
237
+ function get_comment_excerpt( $excerpt = '', $comment_ID = 0, $comment = '' ) {
 
 
 
238
  $blog_encoding = $this->blog_encoding;
239
+ $excerpt = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
240
 
241
  if ( $this->mb_strlen( $excerpt, $blog_encoding ) > $this->conf['comment_excerpt_mblength'] )
242
  $excerpt = mb_substr( $excerpt, 0, $this->conf['comment_excerpt_mblength'], $blog_encoding ) . '&hellip;';
270
  }
271
 
272
  function wplink_js( &$scripts ) {
273
+ $script_required_version = '4.4-RC1';
274
 
275
  if ( !$this->is_wp_required_version( $script_required_version ) )
276
+ $scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/20150818/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20150818', 1 );
277
  else
278
+ $scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "js/wplink{$this->debug_suffix}.js", array( 'jquery' ), '20151207', 1 );
 
 
 
 
 
 
 
 
 
279
  }
280
 
281
  function force_character_count( $translations = '', $text = '', $context = '' ) {
301
  }
302
 
303
  function force_twentyfifteen_google_fonts_off() {
 
 
304
  wp_dequeue_style( 'twentyfifteen-fonts' );
305
+ }
306
+
307
+ function force_twentysixteen_google_fonts_off() {
308
+ wp_dequeue_style( 'twentysixteen-fonts' );
309
+ }
310
+
311
+ function remove_editor_style( $file = '' ) {
312
+ global $editor_styles;
313
 
314
+ if ( ! is_admin() || empty( $editor_styles ) || ! is_array( $editor_styles ) )
315
+ return;
316
 
317
+ foreach ( $editor_styles as $key => $value ) {
318
+ if( $file === $value )
319
+ unset( $editor_styles[$key] );
320
  }
321
  }
322
 
348
  function filters_after_setup_theme() {
349
  // add filter
350
  if ( false !== $this->conf['patch_force_character_count']) {
351
+ if ( 'characters_including_spaces' != _x( 'words', 'Word count type. Do not translate!' ) )
 
 
 
352
  add_filter( 'gettext_with_context', array( $this, 'force_character_count' ), 10, 3 );
353
  }
354
 
369
 
370
  if ( false !== $this->conf['patch_force_twentyfifteen_google_fonts_off'] && 'twentyfifteen' == get_template() ) {
371
  add_action( 'wp_enqueue_scripts', array( $this, 'force_twentyfifteen_google_fonts_off' ), 99 );
372
+
373
+ if ( function_exists( 'twentyfifteen_fonts_url' ) )
374
+ $this->remove_editor_style( twentyfifteen_fonts_url() );
375
+ }
376
+
377
+ if ( false !== $this->conf['patch_force_twentysixteen_google_fonts_off'] && 'twentysixteen' == get_template() ) {
378
+ add_action( 'wp_enqueue_scripts', array( $this, 'force_twentysixteen_google_fonts_off' ), 99 );
379
+
380
+ if ( function_exists( 'twentysixteen_fonts_url' ) )
381
+ $this->remove_editor_style( twentysixteen_fonts_url() );
382
  }
383
  }
384
 
395
  }
396
 
397
  if ( false !== $this->conf['patch_get_comment_excerpt'] )
398
+ add_filter( 'get_comment_excerpt', array( $this, 'get_comment_excerpt' ), 10, 3 );
399
 
400
  if ( false !== $this->conf['patch_sanitize_file_name'] )
401
  add_filter( 'sanitize_file_name', array( $this, 'sanitize_file_name' ) );
425
  if ( false !== $this->conf['patch_wplink_js'] )
426
  add_action( 'wp_default_scripts', array( $this, 'wplink_js' ), 9 );
427
 
 
 
 
428
  add_action( 'after_setup_theme', array( $this, 'filters_after_setup_theme' ), 99 );
429
  }
430
 
wpmp-config-sample-ja.php CHANGED
@@ -94,11 +94,11 @@ $wpmp_conf['patch_dashboard_recent_drafts'] = true;
94
  $wpmp_conf['patch_process_search_terms'] = true;
95
  $wpmp_conf['patch_admin_custom_css'] = true;
96
  $wpmp_conf['patch_wplink_js'] = true;
97
- $wpmp_conf['patch_word_count_js'] = true;
98
  $wpmp_conf['patch_force_character_count'] = true;
99
  $wpmp_conf['patch_force_twentytwelve_open_sans_off'] = true;
100
  $wpmp_conf['patch_force_twentythirteen_google_fonts_off'] = false;
101
  $wpmp_conf['patch_force_twentyfourteen_google_fonts_off'] = false;
102
  $wpmp_conf['patch_force_twentyfifteen_google_fonts_off'] = false;
 
103
  $wpmp_conf['patch_sanitize_file_name'] = true;
104
  $wpmp_conf['patch_bp_create_excerpt'] = false;
94
  $wpmp_conf['patch_process_search_terms'] = true;
95
  $wpmp_conf['patch_admin_custom_css'] = true;
96
  $wpmp_conf['patch_wplink_js'] = true;
 
97
  $wpmp_conf['patch_force_character_count'] = true;
98
  $wpmp_conf['patch_force_twentytwelve_open_sans_off'] = true;
99
  $wpmp_conf['patch_force_twentythirteen_google_fonts_off'] = false;
100
  $wpmp_conf['patch_force_twentyfourteen_google_fonts_off'] = false;
101
  $wpmp_conf['patch_force_twentyfifteen_google_fonts_off'] = false;
102
+ $wpmp_conf['patch_force_twentysixteen_google_fonts_off'] = false;
103
  $wpmp_conf['patch_sanitize_file_name'] = true;
104
  $wpmp_conf['patch_bp_create_excerpt'] = false;