Version Description
Download this release
Release Info
Developer | tenpura |
Plugin | WP Multibyte Patch |
Version | 2.7 |
Comparing to | |
See all releases |
Code changes from version 2.6 to 2.7
- ext/ja/class.php +43 -18
- js/20151207/wplink.js +0 -725
- js/20151207/wplink.min.js +0 -1
- js/wplink.js +0 -767
- js/wplink.min.js +0 -1
- readme.txt +3 -3
- wp-multibyte-patch.php +51 -47
- wplink.php +50 -0
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.
|
7 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
8 |
* @copyright Copyright (c) 2016 Seisuke Kuraishi, Tinybit Inc.
|
9 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
@@ -18,7 +18,7 @@
|
|
18 |
if ( class_exists( 'multibyte_patch' ) ) :
|
19 |
class multibyte_patch_ext extends multibyte_patch {
|
20 |
|
21 |
-
function get_jis_name() {
|
22 |
if ( function_exists( 'mb_list_encodings' ) ) {
|
23 |
$list = "\t" . implode( "\t", mb_list_encodings() ) . "\t";
|
24 |
return ( preg_match( "/\tISO-2022-JP-MS\t/i", $list ) ) ? 'ISO-2022-JP-MS' : 'ISO-2022-JP';
|
@@ -27,22 +27,22 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
27 |
return 'ISO-2022-JP';
|
28 |
}
|
29 |
|
30 |
-
function UTF8toJIS( $string ) {
|
31 |
return $this->convenc( $string, $this->get_jis_name(), 'UTF-8' );
|
32 |
}
|
33 |
|
34 |
-
function JIStoUTF8( $string ) {
|
35 |
return $this->convenc( $string, 'UTF-8', $this->get_jis_name() );
|
36 |
}
|
37 |
|
38 |
-
function encode_mimeheader_b_uncut( $string = '', $charset = 'UTF-8' ) {
|
39 |
if ( 0 == strlen( $string ) || strlen( $string ) == mb_strlen( $string, $charset ) )
|
40 |
return $string;
|
41 |
|
42 |
return "=?$charset?B?" . base64_encode( $string ) . '?=';
|
43 |
}
|
44 |
|
45 |
-
function get_phpmailer_properties( $phpmailer ) {
|
46 |
$array = (array) $phpmailer;
|
47 |
$new = array();
|
48 |
foreach ( $array as $key => $value ) {
|
@@ -52,7 +52,7 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
52 |
return $new;
|
53 |
}
|
54 |
|
55 |
-
function wp_mail( $phpmailer ) {
|
56 |
$blog_encoding = $this->blog_encoding;
|
57 |
|
58 |
$phpmailer->FromName = preg_replace( "/[\r\n]/", "", trim( $phpmailer->FromName ) );
|
@@ -73,7 +73,24 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
73 |
}
|
74 |
|
75 |
$phpmailer_props = $this->get_phpmailer_properties( $phpmailer );
|
76 |
-
$recipient_methods = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
if ( 'UTF-8' == $mode ) {
|
79 |
$phpmailer->CharSet = 'UTF-8';
|
@@ -83,10 +100,14 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
83 |
$phpmailer->Subject = $this->encode_mimeheader_b_uncut( $phpmailer->Subject, 'UTF-8' );
|
84 |
|
85 |
foreach ( $recipient_methods as $name => $method ) {
|
86 |
-
if ( isset( $phpmailer_props[$name][
|
87 |
$phpmailer->{$method['clear']}();
|
|
|
88 |
foreach ( $phpmailer_props[$name] as $recipient ) {
|
89 |
-
|
|
|
|
|
|
|
90 |
$phpmailer->{$method['add']}( $recipient[0], $recipient[1] );
|
91 |
}
|
92 |
}
|
@@ -102,11 +123,15 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
102 |
$phpmailer->Body = $this->UTF8toJIS( $phpmailer->Body );
|
103 |
|
104 |
foreach ( $recipient_methods as $name => $method ) {
|
105 |
-
if ( isset( $phpmailer_props[$name][
|
106 |
$phpmailer->{$method['clear']}();
|
|
|
107 |
foreach ( $phpmailer_props[$name] as $recipient ) {
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
110 |
$phpmailer->{$method['add']}( $recipient[0], $recipient[1] );
|
111 |
}
|
112 |
}
|
@@ -114,7 +139,7 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
114 |
}
|
115 |
}
|
116 |
|
117 |
-
function process_search_terms() {
|
118 |
$blog_encoding = $this->blog_encoding;
|
119 |
|
120 |
if ( isset( $_GET['s'] ) ) {
|
@@ -125,7 +150,7 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
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 ) )
|
@@ -140,7 +165,7 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
140 |
return $encoding;
|
141 |
}
|
142 |
|
143 |
-
function admin_custom_css() {
|
144 |
if ( empty( $this->conf['admin_custom_css_url'] ) )
|
145 |
$url = plugin_dir_url( __FILE__ ) . 'admin.css';
|
146 |
else
|
@@ -149,7 +174,7 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
149 |
wp_enqueue_style( 'wpmp-admin-custom', $url, array(), '20131223' );
|
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 |
|
@@ -167,7 +192,7 @@ if ( class_exists( 'multibyte_patch' ) ) :
|
|
167 |
return $text;
|
168 |
}
|
169 |
|
170 |
-
function __construct() {
|
171 |
// mbstring functions are always required for ja.
|
172 |
$this->mbfunctions_required = true;
|
173 |
|
3 |
* WP Multibyte Patch Japanese Locale Extension
|
4 |
*
|
5 |
* @package WP_Multibyte_Patch
|
6 |
+
* @version 2.7
|
7 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
8 |
* @copyright Copyright (c) 2016 Seisuke Kuraishi, Tinybit Inc.
|
9 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
18 |
if ( class_exists( 'multibyte_patch' ) ) :
|
19 |
class multibyte_patch_ext extends multibyte_patch {
|
20 |
|
21 |
+
public function get_jis_name() {
|
22 |
if ( function_exists( 'mb_list_encodings' ) ) {
|
23 |
$list = "\t" . implode( "\t", mb_list_encodings() ) . "\t";
|
24 |
return ( preg_match( "/\tISO-2022-JP-MS\t/i", $list ) ) ? 'ISO-2022-JP-MS' : 'ISO-2022-JP';
|
27 |
return 'ISO-2022-JP';
|
28 |
}
|
29 |
|
30 |
+
public function UTF8toJIS( $string ) {
|
31 |
return $this->convenc( $string, $this->get_jis_name(), 'UTF-8' );
|
32 |
}
|
33 |
|
34 |
+
public function JIStoUTF8( $string ) {
|
35 |
return $this->convenc( $string, 'UTF-8', $this->get_jis_name() );
|
36 |
}
|
37 |
|
38 |
+
public function encode_mimeheader_b_uncut( $string = '', $charset = 'UTF-8' ) {
|
39 |
if ( 0 == strlen( $string ) || strlen( $string ) == mb_strlen( $string, $charset ) )
|
40 |
return $string;
|
41 |
|
42 |
return "=?$charset?B?" . base64_encode( $string ) . '?=';
|
43 |
}
|
44 |
|
45 |
+
public function get_phpmailer_properties( $phpmailer ) {
|
46 |
$array = (array) $phpmailer;
|
47 |
$new = array();
|
48 |
foreach ( $array as $key => $value ) {
|
52 |
return $new;
|
53 |
}
|
54 |
|
55 |
+
public function wp_mail( $phpmailer ) {
|
56 |
$blog_encoding = $this->blog_encoding;
|
57 |
|
58 |
$phpmailer->FromName = preg_replace( "/[\r\n]/", "", trim( $phpmailer->FromName ) );
|
73 |
}
|
74 |
|
75 |
$phpmailer_props = $this->get_phpmailer_properties( $phpmailer );
|
76 |
+
$recipient_methods = array(
|
77 |
+
'to' => array(
|
78 |
+
'add' => 'addAddress',
|
79 |
+
'clear' => 'clearAddresses',
|
80 |
+
),
|
81 |
+
'cc' => array(
|
82 |
+
'add' => 'addCC',
|
83 |
+
'clear' => 'clearCCs',
|
84 |
+
),
|
85 |
+
'bcc' => array(
|
86 |
+
'add' => 'addBCC',
|
87 |
+
'clear' => 'clearBCCs',
|
88 |
+
),
|
89 |
+
'ReplyTo' => array(
|
90 |
+
'add' => 'addReplyTo',
|
91 |
+
'clear' => 'clearReplyTos',
|
92 |
+
),
|
93 |
+
);
|
94 |
|
95 |
if ( 'UTF-8' == $mode ) {
|
96 |
$phpmailer->CharSet = 'UTF-8';
|
100 |
$phpmailer->Subject = $this->encode_mimeheader_b_uncut( $phpmailer->Subject, 'UTF-8' );
|
101 |
|
102 |
foreach ( $recipient_methods as $name => $method ) {
|
103 |
+
if ( isset( $phpmailer_props[$name] ) && is_array( $phpmailer_props[$name] ) ) {
|
104 |
$phpmailer->{$method['clear']}();
|
105 |
+
|
106 |
foreach ( $phpmailer_props[$name] as $recipient ) {
|
107 |
+
if ( ! empty( $recipient[1] ) ) {
|
108 |
+
$recipient[1] = $this->encode_mimeheader_b_uncut( $recipient[1], 'UTF-8' );
|
109 |
+
}
|
110 |
+
|
111 |
$phpmailer->{$method['add']}( $recipient[0], $recipient[1] );
|
112 |
}
|
113 |
}
|
123 |
$phpmailer->Body = $this->UTF8toJIS( $phpmailer->Body );
|
124 |
|
125 |
foreach ( $recipient_methods as $name => $method ) {
|
126 |
+
if ( isset( $phpmailer_props[$name] ) && is_array( $phpmailer_props[$name] ) ) {
|
127 |
$phpmailer->{$method['clear']}();
|
128 |
+
|
129 |
foreach ( $phpmailer_props[$name] as $recipient ) {
|
130 |
+
if ( ! empty( $recipient[1] ) ) {
|
131 |
+
$recipient[1] = $this->UTF8toJIS( $recipient[1] );
|
132 |
+
$recipient[1] = $this->encode_mimeheader_b_uncut( $recipient[1], 'ISO-2022-JP' );
|
133 |
+
}
|
134 |
+
|
135 |
$phpmailer->{$method['add']}( $recipient[0], $recipient[1] );
|
136 |
}
|
137 |
}
|
139 |
}
|
140 |
}
|
141 |
|
142 |
+
public function process_search_terms() {
|
143 |
$blog_encoding = $this->blog_encoding;
|
144 |
|
145 |
if ( isset( $_GET['s'] ) ) {
|
150 |
}
|
151 |
}
|
152 |
|
153 |
+
public function guess_encoding( $string, $encoding = '' ) {
|
154 |
$guess_list = 'UTF-8, eucJP-win, SJIS-win';
|
155 |
|
156 |
if ( preg_match( "/^utf-8$/i", $encoding ) )
|
165 |
return $encoding;
|
166 |
}
|
167 |
|
168 |
+
public function admin_custom_css() {
|
169 |
if ( empty( $this->conf['admin_custom_css_url'] ) )
|
170 |
$url = plugin_dir_url( __FILE__ ) . 'admin.css';
|
171 |
else
|
174 |
wp_enqueue_style( 'wpmp-admin-custom', $url, array(), '20131223' );
|
175 |
}
|
176 |
|
177 |
+
public function wp_trim_words( $text = '', $num_words = 110, $more = '', $original_text = '' ) {
|
178 |
if ( 0 !== strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) )
|
179 |
return $text;
|
180 |
|
192 |
return $text;
|
193 |
}
|
194 |
|
195 |
+
public function __construct() {
|
196 |
// mbstring functions are always required for ja.
|
197 |
$this->mbfunctions_required = true;
|
198 |
|
js/20151207/wplink.js
DELETED
@@ -1,725 +0,0 @@
|
|
1 |
-
/* global ajaxurl, tinymce, wpLinkL10n, setUserSetting, wpActiveEditor */
|
2 |
-
var wpLink;
|
3 |
-
|
4 |
-
( function( $ ) {
|
5 |
-
var editor, searchTimer, River, Query, correctedURL,
|
6 |
-
inputs = {},
|
7 |
-
rivers = {},
|
8 |
-
isTouch = ( 'ontouchend' in document );
|
9 |
-
|
10 |
-
function getLink() {
|
11 |
-
return editor.dom.getParent( editor.selection.getNode(), 'a' );
|
12 |
-
}
|
13 |
-
|
14 |
-
wpLink = {
|
15 |
-
timeToTriggerRiver: 150,
|
16 |
-
minRiverAJAXDuration: 200,
|
17 |
-
riverBottomThreshold: 5,
|
18 |
-
keySensitivity: 100,
|
19 |
-
lastSearch: '',
|
20 |
-
textarea: '',
|
21 |
-
|
22 |
-
init: function() {
|
23 |
-
inputs.wrap = $('#wp-link-wrap');
|
24 |
-
inputs.dialog = $( '#wp-link' );
|
25 |
-
inputs.backdrop = $( '#wp-link-backdrop' );
|
26 |
-
inputs.submit = $( '#wp-link-submit' );
|
27 |
-
inputs.close = $( '#wp-link-close' );
|
28 |
-
|
29 |
-
// Input
|
30 |
-
inputs.text = $( '#wp-link-text' );
|
31 |
-
inputs.url = $( '#wp-link-url' );
|
32 |
-
inputs.nonce = $( '#_ajax_linking_nonce' );
|
33 |
-
inputs.openInNewTab = $( '#wp-link-target' );
|
34 |
-
inputs.search = $( '#wp-link-search' );
|
35 |
-
|
36 |
-
// Build Rivers
|
37 |
-
rivers.search = new River( $( '#search-results' ) );
|
38 |
-
rivers.recent = new River( $( '#most-recent-results' ) );
|
39 |
-
rivers.elements = inputs.dialog.find( '.query-results' );
|
40 |
-
|
41 |
-
// Get search notice text
|
42 |
-
inputs.queryNotice = $( '#query-notice-message' );
|
43 |
-
inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' );
|
44 |
-
inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' );
|
45 |
-
|
46 |
-
// Bind event handlers
|
47 |
-
inputs.dialog.keydown( wpLink.keydown );
|
48 |
-
inputs.dialog.keyup( wpLink.keyup );
|
49 |
-
inputs.submit.click( function( event ) {
|
50 |
-
event.preventDefault();
|
51 |
-
wpLink.update();
|
52 |
-
});
|
53 |
-
inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel a' ).click( function( event ) {
|
54 |
-
event.preventDefault();
|
55 |
-
wpLink.close();
|
56 |
-
});
|
57 |
-
|
58 |
-
$( '#wp-link-search-toggle' ).on( 'click', wpLink.toggleInternalLinking );
|
59 |
-
|
60 |
-
rivers.elements.on( 'river-select', wpLink.updateFields );
|
61 |
-
|
62 |
-
// Display 'hint' message when search field or 'query-results' box are focused
|
63 |
-
inputs.search.on( 'focus.wplink', function() {
|
64 |
-
inputs.queryNoticeTextDefault.hide();
|
65 |
-
inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
|
66 |
-
} ).on( 'blur.wplink', function() {
|
67 |
-
inputs.queryNoticeTextDefault.show();
|
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 );
|
75 |
-
searchTimer = window.setTimeout( function() {
|
76 |
-
wpLink.searchInternalLinks.call( self );
|
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 |
-
|
105 |
-
if ( editorId ) {
|
106 |
-
window.wpActiveEditor = editorId;
|
107 |
-
}
|
108 |
-
|
109 |
-
if ( ! window.wpActiveEditor ) {
|
110 |
-
return;
|
111 |
-
}
|
112 |
-
|
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() ) {
|
123 |
-
editor = ed;
|
124 |
-
} else {
|
125 |
-
editor = null;
|
126 |
-
}
|
127 |
-
|
128 |
-
if ( editor && tinymce.isIE ) {
|
129 |
-
editor.windowManager.bookmark = editor.selection.getBookmark();
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
if ( ! wpLink.isMCE() && document.selection ) {
|
134 |
-
this.textarea.focus();
|
135 |
-
this.range = document.selection.createRange();
|
136 |
-
}
|
137 |
-
|
138 |
-
inputs.wrap.show();
|
139 |
-
inputs.backdrop.show();
|
140 |
-
|
141 |
-
wpLink.refresh();
|
142 |
-
|
143 |
-
$( document ).trigger( 'wplink-open', inputs.wrap );
|
144 |
-
},
|
145 |
-
|
146 |
-
isMCE: function() {
|
147 |
-
return editor && ! editor.isHidden();
|
148 |
-
},
|
149 |
-
|
150 |
-
refresh: function() {
|
151 |
-
var text = '';
|
152 |
-
|
153 |
-
// Refresh rivers (clear links, check visibility)
|
154 |
-
rivers.search.refresh();
|
155 |
-
rivers.recent.refresh();
|
156 |
-
|
157 |
-
if ( wpLink.isMCE() ) {
|
158 |
-
wpLink.mceRefresh();
|
159 |
-
} else {
|
160 |
-
// For the Text editor the "Link text" field is always shown
|
161 |
-
if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) {
|
162 |
-
inputs.wrap.addClass( 'has-text-field' );
|
163 |
-
}
|
164 |
-
|
165 |
-
if ( document.selection ) {
|
166 |
-
// Old IE
|
167 |
-
text = document.selection.createRange().text || '';
|
168 |
-
} else if ( typeof this.textarea.selectionStart !== 'undefined' &&
|
169 |
-
( this.textarea.selectionStart !== this.textarea.selectionEnd ) ) {
|
170 |
-
// W3C
|
171 |
-
text = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ) || '';
|
172 |
-
}
|
173 |
-
|
174 |
-
inputs.text.val( text );
|
175 |
-
wpLink.setDefaultValues();
|
176 |
-
}
|
177 |
-
|
178 |
-
if ( isTouch ) {
|
179 |
-
// Close the onscreen keyboard
|
180 |
-
inputs.url.focus().blur();
|
181 |
-
} else {
|
182 |
-
// Focus the URL field and highlight its contents.
|
183 |
-
// If this is moved above the selection changes,
|
184 |
-
// IE will show a flashing cursor over the dialog.
|
185 |
-
inputs.url.focus()[0].select();
|
186 |
-
}
|
187 |
-
|
188 |
-
// Load the most recent results if this is the first time opening the panel.
|
189 |
-
if ( ! rivers.recent.ul.children().length ) {
|
190 |
-
rivers.recent.ajax();
|
191 |
-
}
|
192 |
-
|
193 |
-
correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
|
194 |
-
},
|
195 |
-
|
196 |
-
hasSelectedText: function( linkNode ) {
|
197 |
-
var html = editor.selection.getContent();
|
198 |
-
|
199 |
-
// Partial html and not a fully selected anchor element
|
200 |
-
if ( /</.test( html ) && ( ! /^<a [^>]+>[^<]+<\/a>$/.test( html ) || html.indexOf('href=') === -1 ) ) {
|
201 |
-
return false;
|
202 |
-
}
|
203 |
-
|
204 |
-
if ( linkNode ) {
|
205 |
-
var nodes = linkNode.childNodes, i;
|
206 |
-
|
207 |
-
if ( nodes.length === 0 ) {
|
208 |
-
return false;
|
209 |
-
}
|
210 |
-
|
211 |
-
for ( i = nodes.length - 1; i >= 0; i-- ) {
|
212 |
-
if ( nodes[i].nodeType != 3 ) {
|
213 |
-
return false;
|
214 |
-
}
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
return true;
|
219 |
-
},
|
220 |
-
|
221 |
-
mceRefresh: function() {
|
222 |
-
var text,
|
223 |
-
selectedNode = editor.selection.getNode(),
|
224 |
-
linkNode = editor.dom.getParent( selectedNode, 'a[href]' ),
|
225 |
-
onlyText = this.hasSelectedText( linkNode );
|
226 |
-
|
227 |
-
if ( linkNode ) {
|
228 |
-
text = linkNode.innerText || linkNode.textContent;
|
229 |
-
inputs.url.val( editor.dom.getAttrib( linkNode, 'href' ) );
|
230 |
-
inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) );
|
231 |
-
inputs.submit.val( wpLinkL10n.update );
|
232 |
-
} else {
|
233 |
-
text = editor.selection.getContent({ format: 'text' });
|
234 |
-
this.setDefaultValues();
|
235 |
-
}
|
236 |
-
|
237 |
-
if ( onlyText ) {
|
238 |
-
inputs.text.val( text || '' );
|
239 |
-
inputs.wrap.addClass( 'has-text-field' );
|
240 |
-
} else {
|
241 |
-
inputs.text.val( '' );
|
242 |
-
inputs.wrap.removeClass( 'has-text-field' );
|
243 |
-
}
|
244 |
-
},
|
245 |
-
|
246 |
-
close: function() {
|
247 |
-
$( document.body ).removeClass( 'modal-open' );
|
248 |
-
|
249 |
-
if ( ! wpLink.isMCE() ) {
|
250 |
-
wpLink.textarea.focus();
|
251 |
-
|
252 |
-
if ( wpLink.range ) {
|
253 |
-
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
|
254 |
-
wpLink.range.select();
|
255 |
-
}
|
256 |
-
} else {
|
257 |
-
editor.focus();
|
258 |
-
}
|
259 |
-
|
260 |
-
inputs.backdrop.hide();
|
261 |
-
inputs.wrap.hide();
|
262 |
-
|
263 |
-
correctedURL = false;
|
264 |
-
|
265 |
-
$( document ).trigger( 'wplink-close', inputs.wrap );
|
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();
|
290 |
-
} else {
|
291 |
-
wpLink.htmlUpdate();
|
292 |
-
}
|
293 |
-
},
|
294 |
-
|
295 |
-
htmlUpdate: function() {
|
296 |
-
var attrs, text, html, begin, end, cursor, selection,
|
297 |
-
textarea = wpLink.textarea;
|
298 |
-
|
299 |
-
if ( ! textarea ) {
|
300 |
-
return;
|
301 |
-
}
|
302 |
-
|
303 |
-
attrs = wpLink.getAttrs();
|
304 |
-
text = inputs.text.val();
|
305 |
-
|
306 |
-
// If there's no href, return.
|
307 |
-
if ( ! attrs.href ) {
|
308 |
-
return;
|
309 |
-
}
|
310 |
-
|
311 |
-
html = wpLink.buildHtml(attrs);
|
312 |
-
|
313 |
-
// Insert HTML
|
314 |
-
if ( document.selection && wpLink.range ) {
|
315 |
-
// IE
|
316 |
-
// Note: If no text is selected, IE will not place the cursor
|
317 |
-
// inside the closing tag.
|
318 |
-
textarea.focus();
|
319 |
-
wpLink.range.text = html + ( text || wpLink.range.text ) + '</a>';
|
320 |
-
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
|
321 |
-
wpLink.range.select();
|
322 |
-
|
323 |
-
wpLink.range = null;
|
324 |
-
} else if ( typeof textarea.selectionStart !== 'undefined' ) {
|
325 |
-
// W3C
|
326 |
-
begin = textarea.selectionStart;
|
327 |
-
end = textarea.selectionEnd;
|
328 |
-
selection = text || textarea.value.substring( begin, end );
|
329 |
-
html = html + selection + '</a>';
|
330 |
-
cursor = begin + html.length;
|
331 |
-
|
332 |
-
// If no text is selected, place the cursor inside the closing tag.
|
333 |
-
if ( begin === end && ! selection ) {
|
334 |
-
cursor -= 4;
|
335 |
-
}
|
336 |
-
|
337 |
-
textarea.value = (
|
338 |
-
textarea.value.substring( 0, begin ) +
|
339 |
-
html +
|
340 |
-
textarea.value.substring( end, textarea.value.length )
|
341 |
-
);
|
342 |
-
|
343 |
-
// Update cursor position
|
344 |
-
textarea.selectionStart = textarea.selectionEnd = cursor;
|
345 |
-
}
|
346 |
-
|
347 |
-
wpLink.close();
|
348 |
-
textarea.focus();
|
349 |
-
},
|
350 |
-
|
351 |
-
mceUpdate: function() {
|
352 |
-
var attrs = wpLink.getAttrs(),
|
353 |
-
link, text;
|
354 |
-
|
355 |
-
wpLink.close();
|
356 |
-
editor.focus();
|
357 |
-
|
358 |
-
if ( tinymce.isIE ) {
|
359 |
-
editor.selection.moveToBookmark( editor.windowManager.bookmark );
|
360 |
-
}
|
361 |
-
|
362 |
-
if ( ! attrs.href ) {
|
363 |
-
editor.execCommand( 'unlink' );
|
364 |
-
return;
|
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 ) {
|
375 |
-
if ( 'innerText' in link ) {
|
376 |
-
link.innerText = text;
|
377 |
-
} else {
|
378 |
-
link.textContent = text;
|
379 |
-
}
|
380 |
-
}
|
381 |
-
|
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 |
-
}
|
389 |
-
}
|
390 |
-
|
391 |
-
editor.nodeChanged();
|
392 |
-
},
|
393 |
-
|
394 |
-
updateFields: function( e, li ) {
|
395 |
-
inputs.url.val( li.children( '.item-permalink' ).val() );
|
396 |
-
},
|
397 |
-
|
398 |
-
setDefaultValues: function() {
|
399 |
-
var selection,
|
400 |
-
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
401 |
-
urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;
|
402 |
-
|
403 |
-
if ( this.isMCE() ) {
|
404 |
-
selection = editor.selection.getContent();
|
405 |
-
} else if ( document.selection && wpLink.range ) {
|
406 |
-
selection = wpLink.range.text;
|
407 |
-
} else if ( typeof this.textarea.selectionStart !== 'undefined' ) {
|
408 |
-
selection = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd );
|
409 |
-
}
|
410 |
-
|
411 |
-
if ( selection && emailRegexp.test( selection ) ) {
|
412 |
-
// Selection is email address
|
413 |
-
inputs.url.val( 'mailto:' + selection );
|
414 |
-
} else if ( selection && urlRegexp.test( selection ) ) {
|
415 |
-
// Selection is URL
|
416 |
-
inputs.url.val( selection.replace( /&|�?38;/gi, '&' ) );
|
417 |
-
} else {
|
418 |
-
// Set URL to default.
|
419 |
-
inputs.url.val( '' );
|
420 |
-
}
|
421 |
-
|
422 |
-
// Update save prompt.
|
423 |
-
inputs.submit.val( wpLinkL10n.save );
|
424 |
-
},
|
425 |
-
|
426 |
-
searchInternalLinks: function() {
|
427 |
-
var t = $( this ), waiting,
|
428 |
-
search = t.val();
|
429 |
-
|
430 |
-
if ( search.length > 1 ) {
|
431 |
-
rivers.recent.hide();
|
432 |
-
rivers.search.show();
|
433 |
-
|
434 |
-
// Don't search if the keypress didn't change the title.
|
435 |
-
if ( wpLink.lastSearch == search )
|
436 |
-
return;
|
437 |
-
|
438 |
-
wpLink.lastSearch = search;
|
439 |
-
waiting = t.parent().find( '.spinner' ).addClass( 'is-active' );
|
440 |
-
|
441 |
-
rivers.search.change( search );
|
442 |
-
rivers.search.ajax( function() {
|
443 |
-
waiting.removeClass( 'is-active' );
|
444 |
-
});
|
445 |
-
} else {
|
446 |
-
rivers.search.hide();
|
447 |
-
rivers.recent.show();
|
448 |
-
}
|
449 |
-
},
|
450 |
-
|
451 |
-
next: function() {
|
452 |
-
rivers.search.next();
|
453 |
-
rivers.recent.next();
|
454 |
-
},
|
455 |
-
|
456 |
-
prev: function() {
|
457 |
-
rivers.search.prev();
|
458 |
-
rivers.recent.prev();
|
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.
|
473 |
-
// following focusable elements will be skipped on keyboard navigation.
|
474 |
-
if ( id === 'wp-link-submit' && ! event.shiftKey ) {
|
475 |
-
inputs.close.focus();
|
476 |
-
event.preventDefault();
|
477 |
-
} else if ( id === 'wp-link-close' && event.shiftKey ) {
|
478 |
-
inputs.submit.focus();
|
479 |
-
event.preventDefault();
|
480 |
-
}
|
481 |
-
}
|
482 |
-
|
483 |
-
// Up Arrow and Down Arrow keys.
|
484 |
-
if ( 38 !== event.keyCode && 40 !== event.keyCode ) {
|
485 |
-
return;
|
486 |
-
}
|
487 |
-
|
488 |
-
if ( document.activeElement &&
|
489 |
-
( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
|
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 );
|
498 |
-
event.preventDefault();
|
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 |
-
}
|
507 |
-
},
|
508 |
-
|
509 |
-
delayedCallback: function( func, delay ) {
|
510 |
-
var timeoutTriggered, funcTriggered, funcArgs, funcContext;
|
511 |
-
|
512 |
-
if ( ! delay )
|
513 |
-
return func;
|
514 |
-
|
515 |
-
setTimeout( function() {
|
516 |
-
if ( funcTriggered )
|
517 |
-
return func.apply( funcContext, funcArgs );
|
518 |
-
// Otherwise, wait.
|
519 |
-
timeoutTriggered = true;
|
520 |
-
}, delay );
|
521 |
-
|
522 |
-
return function() {
|
523 |
-
if ( timeoutTriggered )
|
524 |
-
return func.apply( this, arguments );
|
525 |
-
// Otherwise, wait.
|
526 |
-
funcArgs = arguments;
|
527 |
-
funcContext = this;
|
528 |
-
funcTriggered = true;
|
529 |
-
};
|
530 |
-
},
|
531 |
-
|
532 |
-
toggleInternalLinking: function( event ) {
|
533 |
-
var visible = inputs.wrap.hasClass( 'search-panel-visible' );
|
534 |
-
|
535 |
-
inputs.wrap.toggleClass( 'search-panel-visible', ! visible );
|
536 |
-
setUserSetting( 'wplink', visible ? '0' : '1' );
|
537 |
-
inputs[ ! visible ? 'search' : 'url' ].focus();
|
538 |
-
event.preventDefault();
|
539 |
-
}
|
540 |
-
};
|
541 |
-
|
542 |
-
River = function( element, search ) {
|
543 |
-
var self = this;
|
544 |
-
this.element = element;
|
545 |
-
this.ul = element.children( 'ul' );
|
546 |
-
this.contentHeight = element.children( '#link-selector-height' );
|
547 |
-
this.waiting = element.find('.river-waiting');
|
548 |
-
|
549 |
-
this.change( search );
|
550 |
-
this.refresh();
|
551 |
-
|
552 |
-
$( '#wp-link .query-results, #wp-link #link-selector' ).scroll( function() {
|
553 |
-
self.maybeLoad();
|
554 |
-
});
|
555 |
-
element.on( 'click', 'li', function( event ) {
|
556 |
-
self.select( $( this ), event );
|
557 |
-
});
|
558 |
-
};
|
559 |
-
|
560 |
-
$.extend( River.prototype, {
|
561 |
-
refresh: function() {
|
562 |
-
this.deselect();
|
563 |
-
this.visible = this.element.is( ':visible' );
|
564 |
-
},
|
565 |
-
show: function() {
|
566 |
-
if ( ! this.visible ) {
|
567 |
-
this.deselect();
|
568 |
-
this.element.show();
|
569 |
-
this.visible = true;
|
570 |
-
}
|
571 |
-
},
|
572 |
-
hide: function() {
|
573 |
-
this.element.hide();
|
574 |
-
this.visible = false;
|
575 |
-
},
|
576 |
-
// Selects a list item and triggers the river-select event.
|
577 |
-
select: function( li, event ) {
|
578 |
-
var liHeight, elHeight, liTop, elTop;
|
579 |
-
|
580 |
-
if ( li.hasClass( 'unselectable' ) || li == this.selected )
|
581 |
-
return;
|
582 |
-
|
583 |
-
this.deselect();
|
584 |
-
this.selected = li.addClass( 'selected' );
|
585 |
-
// Make sure the element is visible
|
586 |
-
liHeight = li.outerHeight();
|
587 |
-
elHeight = this.element.height();
|
588 |
-
liTop = li.position().top;
|
589 |
-
elTop = this.element.scrollTop();
|
590 |
-
|
591 |
-
if ( liTop < 0 ) // Make first visible element
|
592 |
-
this.element.scrollTop( elTop + liTop );
|
593 |
-
else if ( liTop + liHeight > elHeight ) // Make last visible element
|
594 |
-
this.element.scrollTop( elTop + liTop - elHeight + liHeight );
|
595 |
-
|
596 |
-
// Trigger the river-select event
|
597 |
-
this.element.trigger( 'river-select', [ li, event, this ] );
|
598 |
-
},
|
599 |
-
deselect: function() {
|
600 |
-
if ( this.selected )
|
601 |
-
this.selected.removeClass( 'selected' );
|
602 |
-
this.selected = false;
|
603 |
-
},
|
604 |
-
prev: function() {
|
605 |
-
if ( ! this.visible )
|
606 |
-
return;
|
607 |
-
|
608 |
-
var to;
|
609 |
-
if ( this.selected ) {
|
610 |
-
to = this.selected.prev( 'li' );
|
611 |
-
if ( to.length )
|
612 |
-
this.select( to );
|
613 |
-
}
|
614 |
-
},
|
615 |
-
next: function() {
|
616 |
-
if ( ! this.visible )
|
617 |
-
return;
|
618 |
-
|
619 |
-
var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element );
|
620 |
-
if ( to.length )
|
621 |
-
this.select( to );
|
622 |
-
},
|
623 |
-
ajax: function( callback ) {
|
624 |
-
var self = this,
|
625 |
-
delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
|
626 |
-
response = wpLink.delayedCallback( function( results, params ) {
|
627 |
-
self.process( results, params );
|
628 |
-
if ( callback )
|
629 |
-
callback( results, params );
|
630 |
-
}, delay );
|
631 |
-
|
632 |
-
this.query.ajax( response );
|
633 |
-
},
|
634 |
-
change: function( search ) {
|
635 |
-
if ( this.query && this._search == search )
|
636 |
-
return;
|
637 |
-
|
638 |
-
this._search = search;
|
639 |
-
this.query = new Query( search );
|
640 |
-
this.element.scrollTop( 0 );
|
641 |
-
},
|
642 |
-
process: function( results, params ) {
|
643 |
-
var list = '', alt = true, classes = '',
|
644 |
-
firstPage = params.page == 1;
|
645 |
-
|
646 |
-
if ( ! results ) {
|
647 |
-
if ( firstPage ) {
|
648 |
-
list += '<li class="unselectable no-matches-found"><span class="item-title"><em>' +
|
649 |
-
wpLinkL10n.noMatchesFound + '</em></span></li>';
|
650 |
-
}
|
651 |
-
} else {
|
652 |
-
$.each( results, function() {
|
653 |
-
classes = alt ? 'alternate' : '';
|
654 |
-
classes += this.title ? '' : ' no-title';
|
655 |
-
list += classes ? '<li class="' + classes + '">' : '<li>';
|
656 |
-
list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
|
657 |
-
list += '<span class="item-title">';
|
658 |
-
list += this.title ? this.title : wpLinkL10n.noTitle;
|
659 |
-
list += '</span><span class="item-info">' + this.info + '</span></li>';
|
660 |
-
alt = ! alt;
|
661 |
-
});
|
662 |
-
}
|
663 |
-
|
664 |
-
this.ul[ firstPage ? 'html' : 'append' ]( list );
|
665 |
-
},
|
666 |
-
maybeLoad: function() {
|
667 |
-
var self = this,
|
668 |
-
el = this.element,
|
669 |
-
bottom = el.scrollTop() + el.height();
|
670 |
-
|
671 |
-
if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold )
|
672 |
-
return;
|
673 |
-
|
674 |
-
setTimeout(function() {
|
675 |
-
var newTop = el.scrollTop(),
|
676 |
-
newBottom = newTop + el.height();
|
677 |
-
|
678 |
-
if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
|
679 |
-
return;
|
680 |
-
|
681 |
-
self.waiting.addClass( 'is-active' );
|
682 |
-
el.scrollTop( newTop + self.waiting.outerHeight() );
|
683 |
-
|
684 |
-
self.ajax( function() {
|
685 |
-
self.waiting.removeClass( 'is-active' );
|
686 |
-
});
|
687 |
-
}, wpLink.timeToTriggerRiver );
|
688 |
-
}
|
689 |
-
});
|
690 |
-
|
691 |
-
Query = function( search ) {
|
692 |
-
this.page = 1;
|
693 |
-
this.allLoaded = false;
|
694 |
-
this.querying = false;
|
695 |
-
this.search = search;
|
696 |
-
};
|
697 |
-
|
698 |
-
$.extend( Query.prototype, {
|
699 |
-
ready: function() {
|
700 |
-
return ! ( this.querying || this.allLoaded );
|
701 |
-
},
|
702 |
-
ajax: function( callback ) {
|
703 |
-
var self = this,
|
704 |
-
query = {
|
705 |
-
action : 'wp-link-ajax',
|
706 |
-
page : this.page,
|
707 |
-
'_ajax_linking_nonce' : inputs.nonce.val()
|
708 |
-
};
|
709 |
-
|
710 |
-
if ( this.search )
|
711 |
-
query.search = this.search;
|
712 |
-
|
713 |
-
this.querying = true;
|
714 |
-
|
715 |
-
$.post( ajaxurl, query, function( r ) {
|
716 |
-
self.page++;
|
717 |
-
self.querying = false;
|
718 |
-
self.allLoaded = ! r;
|
719 |
-
callback( r, query );
|
720 |
-
}, 'json' );
|
721 |
-
}
|
722 |
-
});
|
723 |
-
|
724 |
-
$( document ).ready( wpLink.init );
|
725 |
-
})( jQuery );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/20151207/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(){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(/&|�?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);
|
|
js/wplink.js
DELETED
@@ -1,767 +0,0 @@
|
|
1 |
-
var wpLink;
|
2 |
-
|
3 |
-
( function( $, wpLinkL10n, wp ) {
|
4 |
-
var editor, searchTimer, River, Query, correctedURL, linkNode,
|
5 |
-
emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,
|
6 |
-
urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i,
|
7 |
-
inputs = {},
|
8 |
-
rivers = {},
|
9 |
-
isTouch = ( 'ontouchend' in document );
|
10 |
-
|
11 |
-
function getLink() {
|
12 |
-
return linkNode || editor.dom.getParent( editor.selection.getNode(), 'a[href]' );
|
13 |
-
}
|
14 |
-
|
15 |
-
wpLink = {
|
16 |
-
timeToTriggerRiver: 150,
|
17 |
-
minRiverAJAXDuration: 200,
|
18 |
-
riverBottomThreshold: 5,
|
19 |
-
keySensitivity: 100,
|
20 |
-
lastSearch: '',
|
21 |
-
textarea: '',
|
22 |
-
|
23 |
-
init: function() {
|
24 |
-
inputs.wrap = $('#wp-link-wrap');
|
25 |
-
inputs.dialog = $( '#wp-link' );
|
26 |
-
inputs.backdrop = $( '#wp-link-backdrop' );
|
27 |
-
inputs.submit = $( '#wp-link-submit' );
|
28 |
-
inputs.close = $( '#wp-link-close' );
|
29 |
-
|
30 |
-
// Input
|
31 |
-
inputs.text = $( '#wp-link-text' );
|
32 |
-
inputs.url = $( '#wp-link-url' );
|
33 |
-
inputs.nonce = $( '#_ajax_linking_nonce' );
|
34 |
-
inputs.openInNewTab = $( '#wp-link-target' );
|
35 |
-
inputs.search = $( '#wp-link-search' );
|
36 |
-
|
37 |
-
// Build Rivers
|
38 |
-
rivers.search = new River( $( '#search-results' ) );
|
39 |
-
rivers.recent = new River( $( '#most-recent-results' ) );
|
40 |
-
rivers.elements = inputs.dialog.find( '.query-results' );
|
41 |
-
|
42 |
-
// Get search notice text
|
43 |
-
inputs.queryNotice = $( '#query-notice-message' );
|
44 |
-
inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' );
|
45 |
-
inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' );
|
46 |
-
|
47 |
-
// Bind event handlers
|
48 |
-
inputs.dialog.keydown( wpLink.keydown );
|
49 |
-
inputs.dialog.keyup( wpLink.keyup );
|
50 |
-
inputs.submit.click( function( event ) {
|
51 |
-
event.preventDefault();
|
52 |
-
wpLink.update();
|
53 |
-
});
|
54 |
-
|
55 |
-
inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel button' ).click( function( event ) {
|
56 |
-
event.preventDefault();
|
57 |
-
wpLink.close();
|
58 |
-
});
|
59 |
-
|
60 |
-
rivers.elements.on( 'river-select', wpLink.updateFields );
|
61 |
-
|
62 |
-
// Display 'hint' message when search field or 'query-results' box are focused
|
63 |
-
inputs.search.on( 'focus.wplink', function() {
|
64 |
-
inputs.queryNoticeTextDefault.hide();
|
65 |
-
inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
|
66 |
-
} ).on( 'blur.wplink', function() {
|
67 |
-
inputs.queryNoticeTextDefault.show();
|
68 |
-
inputs.queryNoticeTextHint.addClass( 'screen-reader-text' ).hide();
|
69 |
-
} );
|
70 |
-
|
71 |
-
inputs.search.on( 'keyup input', function() {
|
72 |
-
window.clearTimeout( searchTimer );
|
73 |
-
searchTimer = window.setTimeout( function() {
|
74 |
-
wpLink.searchInternalLinks();
|
75 |
-
}, 500 );
|
76 |
-
});
|
77 |
-
|
78 |
-
inputs.url.on( 'paste', function() {
|
79 |
-
setTimeout( wpLink.correctURL, 0 );
|
80 |
-
} );
|
81 |
-
|
82 |
-
inputs.url.on( 'blur', wpLink.correctURL );
|
83 |
-
},
|
84 |
-
|
85 |
-
// If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://
|
86 |
-
correctURL: function () {
|
87 |
-
var url = $.trim( inputs.url.val() );
|
88 |
-
|
89 |
-
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
|
90 |
-
inputs.url.val( 'http://' + url );
|
91 |
-
correctedURL = url;
|
92 |
-
}
|
93 |
-
},
|
94 |
-
|
95 |
-
open: function( editorId, url, text, node ) {
|
96 |
-
var ed,
|
97 |
-
$body = $( document.body );
|
98 |
-
|
99 |
-
$body.addClass( 'modal-open' );
|
100 |
-
linkNode = node;
|
101 |
-
|
102 |
-
wpLink.range = null;
|
103 |
-
|
104 |
-
if ( editorId ) {
|
105 |
-
window.wpActiveEditor = editorId;
|
106 |
-
}
|
107 |
-
|
108 |
-
if ( ! window.wpActiveEditor ) {
|
109 |
-
return;
|
110 |
-
}
|
111 |
-
|
112 |
-
this.textarea = $( '#' + window.wpActiveEditor ).get( 0 );
|
113 |
-
|
114 |
-
if ( typeof window.tinymce !== 'undefined' ) {
|
115 |
-
// Make sure the link wrapper is the last element in the body,
|
116 |
-
// or the inline editor toolbar may show above the backdrop.
|
117 |
-
$body.append( inputs.backdrop, inputs.wrap );
|
118 |
-
|
119 |
-
ed = window.tinymce.get( window.wpActiveEditor );
|
120 |
-
|
121 |
-
if ( ed && ! ed.isHidden() ) {
|
122 |
-
editor = ed;
|
123 |
-
} else {
|
124 |
-
editor = null;
|
125 |
-
}
|
126 |
-
|
127 |
-
if ( editor && window.tinymce.isIE ) {
|
128 |
-
editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
if ( ! wpLink.isMCE() && document.selection ) {
|
133 |
-
this.textarea.focus();
|
134 |
-
this.range = document.selection.createRange();
|
135 |
-
}
|
136 |
-
|
137 |
-
inputs.wrap.show();
|
138 |
-
inputs.backdrop.show();
|
139 |
-
|
140 |
-
wpLink.refresh( url, text );
|
141 |
-
|
142 |
-
$( document ).trigger( 'wplink-open', inputs.wrap );
|
143 |
-
},
|
144 |
-
|
145 |
-
isMCE: function() {
|
146 |
-
return editor && ! editor.isHidden();
|
147 |
-
},
|
148 |
-
|
149 |
-
refresh: function( url, text ) {
|
150 |
-
var linkText = '';
|
151 |
-
|
152 |
-
// Refresh rivers (clear links, check visibility)
|
153 |
-
rivers.search.refresh();
|
154 |
-
rivers.recent.refresh();
|
155 |
-
|
156 |
-
if ( wpLink.isMCE() ) {
|
157 |
-
wpLink.mceRefresh( url, text );
|
158 |
-
} else {
|
159 |
-
// For the Text editor the "Link text" field is always shown
|
160 |
-
if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) {
|
161 |
-
inputs.wrap.addClass( 'has-text-field' );
|
162 |
-
}
|
163 |
-
|
164 |
-
if ( document.selection ) {
|
165 |
-
// Old IE
|
166 |
-
linkText = document.selection.createRange().text || text || '';
|
167 |
-
} else if ( typeof this.textarea.selectionStart !== 'undefined' &&
|
168 |
-
( this.textarea.selectionStart !== this.textarea.selectionEnd ) ) {
|
169 |
-
// W3C
|
170 |
-
text = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ) || text || '';
|
171 |
-
}
|
172 |
-
|
173 |
-
inputs.text.val( text );
|
174 |
-
wpLink.setDefaultValues();
|
175 |
-
}
|
176 |
-
|
177 |
-
if ( isTouch ) {
|
178 |
-
// Close the onscreen keyboard
|
179 |
-
inputs.url.focus().blur();
|
180 |
-
} else {
|
181 |
-
// Focus the URL field and highlight its contents.
|
182 |
-
// If this is moved above the selection changes,
|
183 |
-
// IE will show a flashing cursor over the dialog.
|
184 |
-
window.setTimeout( function() {
|
185 |
-
inputs.url[0].select();
|
186 |
-
inputs.url.focus();
|
187 |
-
} );
|
188 |
-
}
|
189 |
-
|
190 |
-
// Load the most recent results if this is the first time opening the panel.
|
191 |
-
if ( ! rivers.recent.ul.children().length ) {
|
192 |
-
rivers.recent.ajax();
|
193 |
-
}
|
194 |
-
|
195 |
-
correctedURL = inputs.url.val().replace( /^http:\/\//, '' );
|
196 |
-
},
|
197 |
-
|
198 |
-
hasSelectedText: function( linkNode ) {
|
199 |
-
var node, nodes, i, html = editor.selection.getContent();
|
200 |
-
|
201 |
-
// Partial html and not a fully selected anchor element
|
202 |
-
if ( /</.test( html ) && ( ! /^<a [^>]+>[^<]+<\/a>$/.test( html ) || html.indexOf('href=') === -1 ) ) {
|
203 |
-
return false;
|
204 |
-
}
|
205 |
-
|
206 |
-
if ( linkNode ) {
|
207 |
-
nodes = linkNode.childNodes;
|
208 |
-
|
209 |
-
if ( nodes.length === 0 ) {
|
210 |
-
return false;
|
211 |
-
}
|
212 |
-
|
213 |
-
for ( i = nodes.length - 1; i >= 0; i-- ) {
|
214 |
-
node = nodes[i];
|
215 |
-
|
216 |
-
if ( node.nodeType != 3 && ! window.tinymce.dom.BookmarkManager.isBookmarkNode( node ) ) {
|
217 |
-
return false;
|
218 |
-
}
|
219 |
-
}
|
220 |
-
}
|
221 |
-
|
222 |
-
return true;
|
223 |
-
},
|
224 |
-
|
225 |
-
mceRefresh: function( searchStr, text ) {
|
226 |
-
var linkText, href,
|
227 |
-
linkNode = getLink(),
|
228 |
-
onlyText = this.hasSelectedText( linkNode );
|
229 |
-
|
230 |
-
if ( linkNode ) {
|
231 |
-
linkText = linkNode.innerText || linkNode.textContent;
|
232 |
-
href = editor.dom.getAttrib( linkNode, 'href' );
|
233 |
-
|
234 |
-
if ( ! $.trim( linkText ) ) {
|
235 |
-
linkText = text || '';
|
236 |
-
}
|
237 |
-
|
238 |
-
if ( searchStr && ( urlRegexp.test( searchStr ) || emailRegexp.test( searchStr ) ) ) {
|
239 |
-
href = searchStr;
|
240 |
-
}
|
241 |
-
|
242 |
-
if ( href !== '_wp_link_placeholder' ) {
|
243 |
-
inputs.url.val( href );
|
244 |
-
inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) );
|
245 |
-
inputs.submit.val( wpLinkL10n.update );
|
246 |
-
} else {
|
247 |
-
this.setDefaultValues( linkText );
|
248 |
-
}
|
249 |
-
|
250 |
-
if ( searchStr && searchStr !== href ) {
|
251 |
-
// The user has typed something in the inline dialog. Trigger a search with it.
|
252 |
-
inputs.search.val( searchStr );
|
253 |
-
} else {
|
254 |
-
inputs.search.val( '' );
|
255 |
-
}
|
256 |
-
|
257 |
-
// Always reset the search
|
258 |
-
window.setTimeout( function() {
|
259 |
-
wpLink.searchInternalLinks();
|
260 |
-
} );
|
261 |
-
} else {
|
262 |
-
linkText = editor.selection.getContent({ format: 'text' }) || text || '';
|
263 |
-
this.setDefaultValues( linkText );
|
264 |
-
}
|
265 |
-
|
266 |
-
if ( onlyText ) {
|
267 |
-
inputs.text.val( linkText );
|
268 |
-
inputs.wrap.addClass( 'has-text-field' );
|
269 |
-
} else {
|
270 |
-
inputs.text.val( '' );
|
271 |
-
inputs.wrap.removeClass( 'has-text-field' );
|
272 |
-
}
|
273 |
-
},
|
274 |
-
|
275 |
-
close: function( reset ) {
|
276 |
-
$( document.body ).removeClass( 'modal-open' );
|
277 |
-
|
278 |
-
if ( reset !== 'noReset' ) {
|
279 |
-
if ( ! wpLink.isMCE() ) {
|
280 |
-
wpLink.textarea.focus();
|
281 |
-
|
282 |
-
if ( wpLink.range ) {
|
283 |
-
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
|
284 |
-
wpLink.range.select();
|
285 |
-
}
|
286 |
-
} else {
|
287 |
-
if ( editor.plugins.wplink ) {
|
288 |
-
editor.plugins.wplink.close();
|
289 |
-
}
|
290 |
-
|
291 |
-
editor.focus();
|
292 |
-
}
|
293 |
-
}
|
294 |
-
|
295 |
-
inputs.backdrop.hide();
|
296 |
-
inputs.wrap.hide();
|
297 |
-
|
298 |
-
correctedURL = false;
|
299 |
-
|
300 |
-
$( document ).trigger( 'wplink-close', inputs.wrap );
|
301 |
-
},
|
302 |
-
|
303 |
-
getAttrs: function() {
|
304 |
-
wpLink.correctURL();
|
305 |
-
|
306 |
-
return {
|
307 |
-
href: $.trim( inputs.url.val() ),
|
308 |
-
target: inputs.openInNewTab.prop( 'checked' ) ? '_blank' : ''
|
309 |
-
};
|
310 |
-
},
|
311 |
-
|
312 |
-
buildHtml: function(attrs) {
|
313 |
-
var html = '<a href="' + attrs.href + '"';
|
314 |
-
|
315 |
-
if ( attrs.target ) {
|
316 |
-
html += ' target="' + attrs.target + '"';
|
317 |
-
}
|
318 |
-
|
319 |
-
return html + '>';
|
320 |
-
},
|
321 |
-
|
322 |
-
update: function() {
|
323 |
-
if ( wpLink.isMCE() ) {
|
324 |
-
wpLink.mceUpdate();
|
325 |
-
} else {
|
326 |
-
wpLink.htmlUpdate();
|
327 |
-
}
|
328 |
-
},
|
329 |
-
|
330 |
-
htmlUpdate: function() {
|
331 |
-
var attrs, text, html, begin, end, cursor, selection,
|
332 |
-
textarea = wpLink.textarea;
|
333 |
-
|
334 |
-
if ( ! textarea ) {
|
335 |
-
return;
|
336 |
-
}
|
337 |
-
|
338 |
-
attrs = wpLink.getAttrs();
|
339 |
-
text = inputs.text.val();
|
340 |
-
|
341 |
-
// If there's no href, return.
|
342 |
-
if ( ! attrs.href ) {
|
343 |
-
return;
|
344 |
-
}
|
345 |
-
|
346 |
-
html = wpLink.buildHtml(attrs);
|
347 |
-
|
348 |
-
// Insert HTML
|
349 |
-
if ( document.selection && wpLink.range ) {
|
350 |
-
// IE
|
351 |
-
// Note: If no text is selected, IE will not place the cursor
|
352 |
-
// inside the closing tag.
|
353 |
-
textarea.focus();
|
354 |
-
wpLink.range.text = html + ( text || wpLink.range.text ) + '</a>';
|
355 |
-
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
|
356 |
-
wpLink.range.select();
|
357 |
-
|
358 |
-
wpLink.range = null;
|
359 |
-
} else if ( typeof textarea.selectionStart !== 'undefined' ) {
|
360 |
-
// W3C
|
361 |
-
begin = textarea.selectionStart;
|
362 |
-
end = textarea.selectionEnd;
|
363 |
-
selection = text || textarea.value.substring( begin, end );
|
364 |
-
html = html + selection + '</a>';
|
365 |
-
cursor = begin + html.length;
|
366 |
-
|
367 |
-
// If no text is selected, place the cursor inside the closing tag.
|
368 |
-
if ( begin === end && ! selection ) {
|
369 |
-
cursor -= 4;
|
370 |
-
}
|
371 |
-
|
372 |
-
textarea.value = (
|
373 |
-
textarea.value.substring( 0, begin ) +
|
374 |
-
html +
|
375 |
-
textarea.value.substring( end, textarea.value.length )
|
376 |
-
);
|
377 |
-
|
378 |
-
// Update cursor position
|
379 |
-
textarea.selectionStart = textarea.selectionEnd = cursor;
|
380 |
-
}
|
381 |
-
|
382 |
-
wpLink.close();
|
383 |
-
textarea.focus();
|
384 |
-
|
385 |
-
// Audible confirmation message when a link has been inserted in the Editor.
|
386 |
-
wp.a11y.speak( wpLinkL10n.linkInserted );
|
387 |
-
},
|
388 |
-
|
389 |
-
mceUpdate: function() {
|
390 |
-
var attrs = wpLink.getAttrs(),
|
391 |
-
link, text;
|
392 |
-
|
393 |
-
if ( window.tinymce.isIE && editor.windowManager.wplinkBookmark ) {
|
394 |
-
editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
|
395 |
-
editor.windowManager.wplinkBookmark = null;
|
396 |
-
}
|
397 |
-
|
398 |
-
if ( ! attrs.href ) {
|
399 |
-
editor.execCommand( 'unlink' );
|
400 |
-
wpLink.close();
|
401 |
-
return;
|
402 |
-
}
|
403 |
-
|
404 |
-
link = getLink();
|
405 |
-
|
406 |
-
if ( inputs.wrap.hasClass( 'has-text-field' ) ) {
|
407 |
-
text = inputs.text.val() || attrs.href;
|
408 |
-
}
|
409 |
-
|
410 |
-
if ( link ) {
|
411 |
-
if ( text ) {
|
412 |
-
if ( 'innerText' in link ) {
|
413 |
-
link.innerText = text;
|
414 |
-
} else {
|
415 |
-
link.textContent = text;
|
416 |
-
}
|
417 |
-
}
|
418 |
-
|
419 |
-
// Not editing any more
|
420 |
-
attrs['data-wplink-edit'] = null;
|
421 |
-
editor.dom.setAttribs( link, attrs );
|
422 |
-
} else {
|
423 |
-
if ( text ) {
|
424 |
-
editor.selection.setNode( editor.dom.create( 'a', attrs, editor.dom.encode( text ) ) );
|
425 |
-
} else {
|
426 |
-
editor.execCommand( 'mceInsertLink', false, attrs );
|
427 |
-
}
|
428 |
-
}
|
429 |
-
|
430 |
-
wpLink.close( 'noReset' );
|
431 |
-
editor.focus();
|
432 |
-
editor.nodeChanged();
|
433 |
-
|
434 |
-
// Audible confirmation message when a link has been inserted in the Editor.
|
435 |
-
wp.a11y.speak( wpLinkL10n.linkInserted );
|
436 |
-
},
|
437 |
-
|
438 |
-
updateFields: function( e, li ) {
|
439 |
-
inputs.url.val( li.children( '.item-permalink' ).val() );
|
440 |
-
},
|
441 |
-
|
442 |
-
getUrlFromSelection: function( selection ) {
|
443 |
-
if ( ! selection ) {
|
444 |
-
if ( this.isMCE() ) {
|
445 |
-
selection = editor.selection.getContent({ format: 'text' });
|
446 |
-
} else if ( document.selection && wpLink.range ) {
|
447 |
-
selection = wpLink.range.text;
|
448 |
-
} else if ( typeof this.textarea.selectionStart !== 'undefined' ) {
|
449 |
-
selection = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd );
|
450 |
-
}
|
451 |
-
}
|
452 |
-
|
453 |
-
selection = $.trim( selection );
|
454 |
-
|
455 |
-
if ( selection && emailRegexp.test( selection ) ) {
|
456 |
-
// Selection is email address
|
457 |
-
return 'mailto:' + selection;
|
458 |
-
} else if ( selection && urlRegexp.test( selection ) ) {
|
459 |
-
// Selection is URL
|
460 |
-
return selection.replace( /&|�?38;/gi, '&' );
|
461 |
-
}
|
462 |
-
|
463 |
-
return '';
|
464 |
-
},
|
465 |
-
|
466 |
-
setDefaultValues: function( selection ) {
|
467 |
-
inputs.url.val( this.getUrlFromSelection( selection ) );
|
468 |
-
|
469 |
-
// Empty the search field and swap the "rivers".
|
470 |
-
inputs.search.val('');
|
471 |
-
wpLink.searchInternalLinks();
|
472 |
-
|
473 |
-
// Update save prompt.
|
474 |
-
inputs.submit.val( wpLinkL10n.save );
|
475 |
-
},
|
476 |
-
|
477 |
-
searchInternalLinks: function() {
|
478 |
-
var waiting,
|
479 |
-
search = inputs.search.val() || '';
|
480 |
-
|
481 |
-
if ( search.length > 1 ) {
|
482 |
-
rivers.recent.hide();
|
483 |
-
rivers.search.show();
|
484 |
-
|
485 |
-
// Don't search if the keypress didn't change the title.
|
486 |
-
if ( wpLink.lastSearch == search )
|
487 |
-
return;
|
488 |
-
|
489 |
-
wpLink.lastSearch = search;
|
490 |
-
waiting = inputs.search.parent().find( '.spinner' ).addClass( 'is-active' );
|
491 |
-
|
492 |
-
rivers.search.change( search );
|
493 |
-
rivers.search.ajax( function() {
|
494 |
-
waiting.removeClass( 'is-active' );
|
495 |
-
});
|
496 |
-
} else {
|
497 |
-
rivers.search.hide();
|
498 |
-
rivers.recent.show();
|
499 |
-
}
|
500 |
-
},
|
501 |
-
|
502 |
-
next: function() {
|
503 |
-
rivers.search.next();
|
504 |
-
rivers.recent.next();
|
505 |
-
},
|
506 |
-
|
507 |
-
prev: function() {
|
508 |
-
rivers.search.prev();
|
509 |
-
rivers.recent.prev();
|
510 |
-
},
|
511 |
-
|
512 |
-
keydown: function( event ) {
|
513 |
-
var fn, id;
|
514 |
-
|
515 |
-
// Escape key.
|
516 |
-
if ( 27 === event.keyCode ) {
|
517 |
-
wpLink.close();
|
518 |
-
event.stopImmediatePropagation();
|
519 |
-
// Tab key.
|
520 |
-
} else if ( 9 === event.keyCode ) {
|
521 |
-
id = event.target.id;
|
522 |
-
|
523 |
-
// wp-link-submit must always be the last focusable element in the dialog.
|
524 |
-
// following focusable elements will be skipped on keyboard navigation.
|
525 |
-
if ( id === 'wp-link-submit' && ! event.shiftKey ) {
|
526 |
-
inputs.close.focus();
|
527 |
-
event.preventDefault();
|
528 |
-
} else if ( id === 'wp-link-close' && event.shiftKey ) {
|
529 |
-
inputs.submit.focus();
|
530 |
-
event.preventDefault();
|
531 |
-
}
|
532 |
-
}
|
533 |
-
|
534 |
-
// Up Arrow and Down Arrow keys.
|
535 |
-
if ( 38 !== event.keyCode && 40 !== event.keyCode ) {
|
536 |
-
return;
|
537 |
-
}
|
538 |
-
|
539 |
-
if ( document.activeElement &&
|
540 |
-
( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) {
|
541 |
-
return;
|
542 |
-
}
|
543 |
-
|
544 |
-
// Up Arrow key.
|
545 |
-
fn = 38 === event.keyCode ? 'prev' : 'next';
|
546 |
-
clearInterval( wpLink.keyInterval );
|
547 |
-
wpLink[ fn ]();
|
548 |
-
wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
|
549 |
-
event.preventDefault();
|
550 |
-
},
|
551 |
-
|
552 |
-
keyup: function( event ) {
|
553 |
-
// Up Arrow and Down Arrow keys.
|
554 |
-
if ( 38 === event.keyCode || 40 === event.keyCode ) {
|
555 |
-
clearInterval( wpLink.keyInterval );
|
556 |
-
event.preventDefault();
|
557 |
-
}
|
558 |
-
},
|
559 |
-
|
560 |
-
delayedCallback: function( func, delay ) {
|
561 |
-
var timeoutTriggered, funcTriggered, funcArgs, funcContext;
|
562 |
-
|
563 |
-
if ( ! delay )
|
564 |
-
return func;
|
565 |
-
|
566 |
-
setTimeout( function() {
|
567 |
-
if ( funcTriggered )
|
568 |
-
return func.apply( funcContext, funcArgs );
|
569 |
-
// Otherwise, wait.
|
570 |
-
timeoutTriggered = true;
|
571 |
-
}, delay );
|
572 |
-
|
573 |
-
return function() {
|
574 |
-
if ( timeoutTriggered )
|
575 |
-
return func.apply( this, arguments );
|
576 |
-
// Otherwise, wait.
|
577 |
-
funcArgs = arguments;
|
578 |
-
funcContext = this;
|
579 |
-
funcTriggered = true;
|
580 |
-
};
|
581 |
-
}
|
582 |
-
};
|
583 |
-
|
584 |
-
River = function( element, search ) {
|
585 |
-
var self = this;
|
586 |
-
this.element = element;
|
587 |
-
this.ul = element.children( 'ul' );
|
588 |
-
this.contentHeight = element.children( '#link-selector-height' );
|
589 |
-
this.waiting = element.find('.river-waiting');
|
590 |
-
|
591 |
-
this.change( search );
|
592 |
-
this.refresh();
|
593 |
-
|
594 |
-
$( '#wp-link .query-results, #wp-link #link-selector' ).scroll( function() {
|
595 |
-
self.maybeLoad();
|
596 |
-
});
|
597 |
-
element.on( 'click', 'li', function( event ) {
|
598 |
-
self.select( $( this ), event );
|
599 |
-
});
|
600 |
-
};
|
601 |
-
|
602 |
-
$.extend( River.prototype, {
|
603 |
-
refresh: function() {
|
604 |
-
this.deselect();
|
605 |
-
this.visible = this.element.is( ':visible' );
|
606 |
-
},
|
607 |
-
show: function() {
|
608 |
-
if ( ! this.visible ) {
|
609 |
-
this.deselect();
|
610 |
-
this.element.show();
|
611 |
-
this.visible = true;
|
612 |
-
}
|
613 |
-
},
|
614 |
-
hide: function() {
|
615 |
-
this.element.hide();
|
616 |
-
this.visible = false;
|
617 |
-
},
|
618 |
-
// Selects a list item and triggers the river-select event.
|
619 |
-
select: function( li, event ) {
|
620 |
-
var liHeight, elHeight, liTop, elTop;
|
621 |
-
|
622 |
-
if ( li.hasClass( 'unselectable' ) || li == this.selected )
|
623 |
-
return;
|
624 |
-
|
625 |
-
this.deselect();
|
626 |
-
this.selected = li.addClass( 'selected' );
|
627 |
-
// Make sure the element is visible
|
628 |
-
liHeight = li.outerHeight();
|
629 |
-
elHeight = this.element.height();
|
630 |
-
liTop = li.position().top;
|
631 |
-
elTop = this.element.scrollTop();
|
632 |
-
|
633 |
-
if ( liTop < 0 ) // Make first visible element
|
634 |
-
this.element.scrollTop( elTop + liTop );
|
635 |
-
else if ( liTop + liHeight > elHeight ) // Make last visible element
|
636 |
-
this.element.scrollTop( elTop + liTop - elHeight + liHeight );
|
637 |
-
|
638 |
-
// Trigger the river-select event
|
639 |
-
this.element.trigger( 'river-select', [ li, event, this ] );
|
640 |
-
},
|
641 |
-
deselect: function() {
|
642 |
-
if ( this.selected )
|
643 |
-
this.selected.removeClass( 'selected' );
|
644 |
-
this.selected = false;
|
645 |
-
},
|
646 |
-
prev: function() {
|
647 |
-
if ( ! this.visible )
|
648 |
-
return;
|
649 |
-
|
650 |
-
var to;
|
651 |
-
if ( this.selected ) {
|
652 |
-
to = this.selected.prev( 'li' );
|
653 |
-
if ( to.length )
|
654 |
-
this.select( to );
|
655 |
-
}
|
656 |
-
},
|
657 |
-
next: function() {
|
658 |
-
if ( ! this.visible )
|
659 |
-
return;
|
660 |
-
|
661 |
-
var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element );
|
662 |
-
if ( to.length )
|
663 |
-
this.select( to );
|
664 |
-
},
|
665 |
-
ajax: function( callback ) {
|
666 |
-
var self = this,
|
667 |
-
delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
|
668 |
-
response = wpLink.delayedCallback( function( results, params ) {
|
669 |
-
self.process( results, params );
|
670 |
-
if ( callback )
|
671 |
-
callback( results, params );
|
672 |
-
}, delay );
|
673 |
-
|
674 |
-
this.query.ajax( response );
|
675 |
-
},
|
676 |
-
change: function( search ) {
|
677 |
-
if ( this.query && this._search == search )
|
678 |
-
return;
|
679 |
-
|
680 |
-
this._search = search;
|
681 |
-
this.query = new Query( search );
|
682 |
-
this.element.scrollTop( 0 );
|
683 |
-
},
|
684 |
-
process: function( results, params ) {
|
685 |
-
var list = '', alt = true, classes = '',
|
686 |
-
firstPage = params.page == 1;
|
687 |
-
|
688 |
-
if ( ! results ) {
|
689 |
-
if ( firstPage ) {
|
690 |
-
list += '<li class="unselectable no-matches-found"><span class="item-title"><em>' +
|
691 |
-
wpLinkL10n.noMatchesFound + '</em></span></li>';
|
692 |
-
}
|
693 |
-
} else {
|
694 |
-
$.each( results, function() {
|
695 |
-
classes = alt ? 'alternate' : '';
|
696 |
-
classes += this.title ? '' : ' no-title';
|
697 |
-
list += classes ? '<li class="' + classes + '">' : '<li>';
|
698 |
-
list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />';
|
699 |
-
list += '<span class="item-title">';
|
700 |
-
list += this.title ? this.title : wpLinkL10n.noTitle;
|
701 |
-
list += '</span><span class="item-info">' + this.info + '</span></li>';
|
702 |
-
alt = ! alt;
|
703 |
-
});
|
704 |
-
}
|
705 |
-
|
706 |
-
this.ul[ firstPage ? 'html' : 'append' ]( list );
|
707 |
-
},
|
708 |
-
maybeLoad: function() {
|
709 |
-
var self = this,
|
710 |
-
el = this.element,
|
711 |
-
bottom = el.scrollTop() + el.height();
|
712 |
-
|
713 |
-
if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold )
|
714 |
-
return;
|
715 |
-
|
716 |
-
setTimeout(function() {
|
717 |
-
var newTop = el.scrollTop(),
|
718 |
-
newBottom = newTop + el.height();
|
719 |
-
|
720 |
-
if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold )
|
721 |
-
return;
|
722 |
-
|
723 |
-
self.waiting.addClass( 'is-active' );
|
724 |
-
el.scrollTop( newTop + self.waiting.outerHeight() );
|
725 |
-
|
726 |
-
self.ajax( function() {
|
727 |
-
self.waiting.removeClass( 'is-active' );
|
728 |
-
});
|
729 |
-
}, wpLink.timeToTriggerRiver );
|
730 |
-
}
|
731 |
-
});
|
732 |
-
|
733 |
-
Query = function( search ) {
|
734 |
-
this.page = 1;
|
735 |
-
this.allLoaded = false;
|
736 |
-
this.querying = false;
|
737 |
-
this.search = search;
|
738 |
-
};
|
739 |
-
|
740 |
-
$.extend( Query.prototype, {
|
741 |
-
ready: function() {
|
742 |
-
return ! ( this.querying || this.allLoaded );
|
743 |
-
},
|
744 |
-
ajax: function( callback ) {
|
745 |
-
var self = this,
|
746 |
-
query = {
|
747 |
-
action : 'wp-link-ajax',
|
748 |
-
page : this.page,
|
749 |
-
'_ajax_linking_nonce' : inputs.nonce.val()
|
750 |
-
};
|
751 |
-
|
752 |
-
if ( this.search )
|
753 |
-
query.search = this.search;
|
754 |
-
|
755 |
-
this.querying = true;
|
756 |
-
|
757 |
-
$.post( window.ajaxurl, query, function( r ) {
|
758 |
-
self.page++;
|
759 |
-
self.querying = false;
|
760 |
-
self.allLoaded = ! r;
|
761 |
-
callback( r, query );
|
762 |
-
}, 'json' );
|
763 |
-
}
|
764 |
-
});
|
765 |
-
|
766 |
-
$( document ).ready( wpLink.init );
|
767 |
-
})( jQuery, window.wpLinkL10n, window.wp );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/wplink.min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
var wpLink;!function(a,b,c){function d(){return j||e.dom.getParent(e.selection.getNode(),"a[href]")}var e,f,g,h,i,j,k=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,l=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i,m={},n={},o="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){m.wrap=a("#wp-link-wrap"),m.dialog=a("#wp-link"),m.backdrop=a("#wp-link-backdrop"),m.submit=a("#wp-link-submit"),m.close=a("#wp-link-close"),m.text=a("#wp-link-text"),m.url=a("#wp-link-url"),m.nonce=a("#_ajax_linking_nonce"),m.openInNewTab=a("#wp-link-target"),m.search=a("#wp-link-search"),n.search=new g(a("#search-results")),n.recent=new g(a("#most-recent-results")),n.elements=m.dialog.find(".query-results"),m.queryNotice=a("#query-notice-message"),m.queryNoticeTextDefault=m.queryNotice.find(".query-notice-default"),m.queryNoticeTextHint=m.queryNotice.find(".query-notice-hint"),m.dialog.keydown(wpLink.keydown),m.dialog.keyup(wpLink.keyup),m.submit.click(function(a){a.preventDefault(),wpLink.update()}),m.close.add(m.backdrop).add("#wp-link-cancel button").click(function(a){a.preventDefault(),wpLink.close()}),n.elements.on("river-select",wpLink.updateFields),m.search.on("focus.wplink",function(){m.queryNoticeTextDefault.hide(),m.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){m.queryNoticeTextDefault.show(),m.queryNoticeTextHint.addClass("screen-reader-text").hide()}),m.search.on("keyup input",function(){window.clearTimeout(f),f=window.setTimeout(function(){wpLink.searchInternalLinks()},500)}),m.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),m.url.on("blur",wpLink.correctURL)},correctURL:function(){var b=a.trim(m.url.val());b&&i!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(m.url.val("http://"+b),i=b)},open:function(b,c,d,f){var g,h=a(document.body);h.addClass("modal-open"),j=f,wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof window.tinymce&&(h.append(m.backdrop,m.wrap),g=window.tinymce.get(window.wpActiveEditor),e=g&&!g.isHidden()?g:null,e&&window.tinymce.isIE&&(e.windowManager.wplinkBookmark=e.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),m.wrap.show(),m.backdrop.show(),wpLink.refresh(c,d),a(document).trigger("wplink-open",m.wrap))},isMCE:function(){return e&&!e.isHidden()},refresh:function(a,b){var c="";n.search.refresh(),n.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh(a,b):(m.wrap.hasClass("has-text-field")||m.wrap.addClass("has-text-field"),document.selection?c=document.selection.createRange().text||b||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||b||""),m.text.val(b),wpLink.setDefaultValues()),o?m.url.focus().blur():window.setTimeout(function(){m.url[0].select(),m.url.focus()}),n.recent.ul.children().length||n.recent.ajax(),i=m.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b,c,d,f=e.selection.getContent();if(/</.test(f)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(f)||-1===f.indexOf("href=")))return!1;if(a){if(c=a.childNodes,0===c.length)return!1;for(d=c.length-1;d>=0;d--)if(b=c[d],3!=b.nodeType&&!window.tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(c,f){var g,h,i=d(),j=this.hasSelectedText(i);i?(g=i.innerText||i.textContent,h=e.dom.getAttrib(i,"href"),a.trim(g)||(g=f||""),c&&(l.test(c)||k.test(c))&&(h=c),"_wp_link_placeholder"!==h?(m.url.val(h),m.openInNewTab.prop("checked","_blank"===e.dom.getAttrib(i,"target")),m.submit.val(b.update)):this.setDefaultValues(g),c&&c!==h?m.search.val(c):m.search.val(""),window.setTimeout(function(){wpLink.searchInternalLinks()})):(g=e.selection.getContent({format:"text"})||f||"",this.setDefaultValues(g)),j?(m.text.val(g),m.wrap.addClass("has-text-field")):(m.text.val(""),m.wrap.removeClass("has-text-field"))},close:function(b){a(document.body).removeClass("modal-open"),"noReset"!==b&&(wpLink.isMCE()?(e.plugins.wplink&&e.plugins.wplink.close(),e.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),m.backdrop.hide(),m.wrap.hide(),i=!1,a(document).trigger("wplink-close",m.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(m.url.val()),target:m.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,d,e,f,g,h,i,j=wpLink.textarea;j&&(a=wpLink.getAttrs(),d=m.text.val(),a.href&&(e=wpLink.buildHtml(a),document.selection&&wpLink.range?(j.focus(),wpLink.range.text=e+(d||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof j.selectionStart&&(f=j.selectionStart,g=j.selectionEnd,i=d||j.value.substring(f,g),e=e+i+"</a>",h=f+e.length,f!==g||i||(h-=4),j.value=j.value.substring(0,f)+e+j.value.substring(g,j.value.length),j.selectionStart=j.selectionEnd=h),wpLink.close(),j.focus(),c.a11y.speak(b.linkInserted)))},mceUpdate:function(){var a,f,g=wpLink.getAttrs();return window.tinymce.isIE&&e.windowManager.wplinkBookmark&&(e.selection.moveToBookmark(e.windowManager.wplinkBookmark),e.windowManager.wplinkBookmark=null),g.href?(a=d(),m.wrap.hasClass("has-text-field")&&(f=m.text.val()||g.href),a?(f&&("innerText"in a?a.innerText=f:a.textContent=f),g["data-wplink-edit"]=null,e.dom.setAttribs(a,g)):f?e.selection.setNode(e.dom.create("a",g,e.dom.encode(f))):e.execCommand("mceInsertLink",!1,g),wpLink.close("noReset"),e.focus(),e.nodeChanged(),void c.a11y.speak(b.linkInserted)):(e.execCommand("unlink"),void wpLink.close())},updateFields:function(a,b){m.url.val(b.children(".item-permalink").val())},getUrlFromSelection:function(b){return b||(this.isMCE()?b=e.selection.getContent({format:"text"}):document.selection&&wpLink.range?b=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd))),b=a.trim(b),b&&k.test(b)?"mailto:"+b:b&&l.test(b)?b.replace(/&|�?38;/gi,"&"):""},setDefaultValues:function(a){m.url.val(this.getUrlFromSelection(a)),m.search.val(""),wpLink.searchInternalLinks(),m.submit.val(b.save)},searchInternalLinks:function(){var a,b=m.search.val()||"";if(b.length>1){if(n.recent.hide(),n.search.show(),wpLink.lastSearch==b)return;wpLink.lastSearch=b,a=m.search.parent().find(".spinner").addClass("is-active"),n.search.change(b),n.search.ajax(function(){a.removeClass("is-active")})}else n.search.hide(),n.recent.show()},next:function(){n.search.next(),n.recent.next()},prev:function(){n.search.prev(),n.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&&(m.submit.focus(),a.preventDefault()):(m.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}},g=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(g.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 h(a),this.element.scrollTop(0))},process:function(c,d){var e="",f=!0,g="",h=1==d.page;c?a.each(c,function(){g=f?"alternate":"",g+=this.title?"":" no-title",e+=g?'<li class="'+g+'">':"<li>",e+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',e+='<span class="item-title">',e+=this.title?this.title:b.noTitle,e+='</span><span class="item-info">'+this.info+"</span></li>",f=!f}):h&&(e+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+b.noMatchesFound+"</em></span></li>"),this.ul[h?"html":"append"](e)},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)}}),h=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(h.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:m.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(window.ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery,window.wpLinkL10n,window.wp);
|
|
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.
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 2.
|
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.5
|
5 |
+
Tested up to: 4.6
|
6 |
+
Stable tag: 2.7
|
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.
|
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.
|
19 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
20 |
* @copyright Copyright (c) 2016 Seisuke Kuraishi, Tinybit Inc.
|
21 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
@@ -28,7 +28,7 @@ Domain Path: /languages
|
|
28 |
class multibyte_patch {
|
29 |
|
30 |
// Do not edit this section. Use wpmp-config.php instead.
|
31 |
-
|
32 |
'excerpt_mblength' => 110,
|
33 |
'excerpt_more' => ' […]',
|
34 |
'comment_excerpt_mblength' => 40,
|
@@ -55,18 +55,18 @@ class multibyte_patch {
|
|
55 |
'bp_excerpt_more' => ' […]'
|
56 |
);
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
// For fallback purpose only. (1.6)
|
69 |
-
function guess_encoding( $string, $encoding = '' ) {
|
70 |
$blog_encoding = $this->blog_encoding;
|
71 |
|
72 |
if ( !$encoding && seems_utf8( $string ) )
|
@@ -78,7 +78,7 @@ class multibyte_patch {
|
|
78 |
}
|
79 |
|
80 |
// For fallback purpose only. (1.6)
|
81 |
-
function convenc( $string, $to_encoding, $from_encoding = '' ) {
|
82 |
$blog_encoding = $this->blog_encoding;
|
83 |
|
84 |
if ( '' == $from_encoding )
|
@@ -90,7 +90,7 @@ class multibyte_patch {
|
|
90 |
return mb_convert_encoding( $string, $to_encoding, $from_encoding );
|
91 |
}
|
92 |
|
93 |
-
function incoming_trackback( $commentdata ) {
|
94 |
if ( 'trackback' != $commentdata['comment_type'] )
|
95 |
return $commentdata;
|
96 |
|
@@ -126,13 +126,13 @@ class multibyte_patch {
|
|
126 |
return $commentdata;
|
127 |
}
|
128 |
|
129 |
-
function pre_remote_source( $remote_source, $pagelinkedto ) {
|
130 |
$this->pingback_ping_remote_source = $remote_source;
|
131 |
$this->pingback_ping_pagelinkedto = $pagelinkedto;
|
132 |
return $remote_source;
|
133 |
}
|
134 |
|
135 |
-
function incoming_pingback( $commentdata ) {
|
136 |
if ( 'pingback' != $commentdata['comment_type'] )
|
137 |
return $commentdata;
|
138 |
|
@@ -205,7 +205,7 @@ class multibyte_patch {
|
|
205 |
return $commentdata;
|
206 |
}
|
207 |
|
208 |
-
function preprocess_comment( $commentdata ) {
|
209 |
if ( $commentdata['comment_type'] == 'trackback' )
|
210 |
return $this->incoming_trackback( $commentdata );
|
211 |
elseif ( $commentdata['comment_type'] == 'pingback' )
|
@@ -214,7 +214,7 @@ class multibyte_patch {
|
|
214 |
return $commentdata;
|
215 |
}
|
216 |
|
217 |
-
function trim_multibyte_excerpt( $text = '', $length = 110, $more = ' […]', $encoding = 'UTF-8' ) {
|
218 |
$text = strip_shortcodes( $text );
|
219 |
$text = str_replace( ']]>', ']]>', $text );
|
220 |
$text = strip_tags( $text );
|
@@ -226,15 +226,15 @@ class multibyte_patch {
|
|
226 |
return $text;
|
227 |
}
|
228 |
|
229 |
-
function bp_create_excerpt( $text = '' ) {
|
230 |
return $this->trim_multibyte_excerpt( $text, $this->conf['bp_excerpt_mblength'], $this->conf['bp_excerpt_more'], $this->blog_encoding );
|
231 |
}
|
232 |
|
233 |
-
function bp_get_activity_content_body( $content = '' ) {
|
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 |
|
@@ -244,7 +244,7 @@ class multibyte_patch {
|
|
244 |
return $excerpt;
|
245 |
}
|
246 |
|
247 |
-
function excerpt_mblength() {
|
248 |
if ( isset( $this->query_based_vars['excerpt_mblength'] ) && (int) $this->query_based_vars['excerpt_mblength'] )
|
249 |
$length = (int) $this->query_based_vars['excerpt_mblength'];
|
250 |
else
|
@@ -253,14 +253,14 @@ class multibyte_patch {
|
|
253 |
return apply_filters( 'excerpt_mblength', $length );
|
254 |
}
|
255 |
|
256 |
-
function excerpt_more() {
|
257 |
if ( isset( $this->query_based_vars['excerpt_more'] ) )
|
258 |
return $this->query_based_vars['excerpt_more'];
|
259 |
else
|
260 |
return $this->conf['excerpt_more'];
|
261 |
}
|
262 |
|
263 |
-
function sanitize_file_name( $name ) {
|
264 |
$info = pathinfo( $name );
|
265 |
$ext = !empty( $info['extension'] ) ? '.' . $info['extension'] : '';
|
266 |
$name = str_replace( $ext, '', $name );
|
@@ -269,16 +269,20 @@ class multibyte_patch {
|
|
269 |
return $name;
|
270 |
}
|
271 |
|
272 |
-
function wplink_js( &$scripts ) {
|
273 |
-
$
|
274 |
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
|
|
279 |
}
|
280 |
|
281 |
-
function force_character_count( $translations = '', $text = '', $context = '' ) {
|
282 |
if ( 'word count: words or characters?' == $context && 'words' == $text )
|
283 |
return 'characters';
|
284 |
|
@@ -288,27 +292,27 @@ class multibyte_patch {
|
|
288 |
return $translations;
|
289 |
}
|
290 |
|
291 |
-
function force_twentytwelve_open_sans_off() {
|
292 |
wp_dequeue_style( 'twentytwelve-fonts' );
|
293 |
}
|
294 |
|
295 |
-
function force_twentythirteen_google_fonts_off() {
|
296 |
wp_dequeue_style( 'twentythirteen-fonts' );
|
297 |
}
|
298 |
|
299 |
-
function force_twentyfourteen_google_fonts_off() {
|
300 |
wp_dequeue_style( 'twentyfourteen-lato' );
|
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 ) )
|
@@ -320,7 +324,7 @@ class multibyte_patch {
|
|
320 |
}
|
321 |
}
|
322 |
|
323 |
-
function query_based_settings() {
|
324 |
$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' );
|
325 |
|
326 |
foreach ( $is_query_funcs as $func ) {
|
@@ -333,19 +337,19 @@ class multibyte_patch {
|
|
333 |
}
|
334 |
|
335 |
// The fallback only works with UTF-8 blog.
|
336 |
-
function mb_strlen( $str = '', $encoding = 'UTF-8' ) {
|
337 |
if ( $this->has_mb_strlen )
|
338 |
return mb_strlen( $str, $encoding );
|
339 |
else
|
340 |
return preg_match_all( "/./us", $str, $match );
|
341 |
}
|
342 |
|
343 |
-
function is_wp_required_version( $required_version ) {
|
344 |
global $wp_version;
|
345 |
return version_compare( $wp_version, $required_version, '<' ) ? false : true;
|
346 |
}
|
347 |
|
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!' ) )
|
@@ -382,7 +386,7 @@ class multibyte_patch {
|
|
382 |
}
|
383 |
}
|
384 |
|
385 |
-
function filters() {
|
386 |
// add filter
|
387 |
add_filter( 'preprocess_comment', array( $this, 'preprocess_comment' ), 99 );
|
388 |
|
@@ -428,7 +432,7 @@ class multibyte_patch {
|
|
428 |
add_action( 'after_setup_theme', array( $this, 'filters_after_setup_theme' ), 99 );
|
429 |
}
|
430 |
|
431 |
-
function mbfunctions_exist() {
|
432 |
return (
|
433 |
function_exists( 'mb_convert_encoding' ) &&
|
434 |
function_exists( 'mb_convert_kana' ) &&
|
@@ -438,7 +442,7 @@ class multibyte_patch {
|
|
438 |
) ? true : false;
|
439 |
}
|
440 |
|
441 |
-
function activation_check() {
|
442 |
$required_version = $this->required_version;
|
443 |
|
444 |
if ( !$this->is_wp_required_version( $required_version ) ) {
|
@@ -451,7 +455,7 @@ class multibyte_patch {
|
|
451 |
}
|
452 |
}
|
453 |
|
454 |
-
function load_conf() {
|
455 |
$wpmp_conf = array();
|
456 |
|
457 |
if ( file_exists( WP_CONTENT_DIR . '/wpmp-config.php' ) )
|
@@ -466,7 +470,7 @@ class multibyte_patch {
|
|
466 |
$this->conf = array_merge( $this->conf, $wpmp_conf );
|
467 |
}
|
468 |
|
469 |
-
function __construct() {
|
470 |
$this->load_conf();
|
471 |
$this->blog_encoding = get_option( 'blog_charset' );
|
472 |
if ( empty( $this->blog_encoding ) )
|
2 |
/*
|
3 |
Plugin Name: WP Multibyte Patch
|
4 |
Description: Multibyte functionality enhancement for the WordPress Japanese package.
|
5 |
+
Version: 2.7
|
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.7
|
19 |
* @author Seisuke Kuraishi <210pura@gmail.com>
|
20 |
* @copyright Copyright (c) 2016 Seisuke Kuraishi, Tinybit Inc.
|
21 |
* @license http://opensource.org/licenses/gpl-2.0.php GPLv2
|
28 |
class multibyte_patch {
|
29 |
|
30 |
// Do not edit this section. Use wpmp-config.php instead.
|
31 |
+
public $conf = array(
|
32 |
'excerpt_mblength' => 110,
|
33 |
'excerpt_more' => ' […]',
|
34 |
'comment_excerpt_mblength' => 40,
|
55 |
'bp_excerpt_more' => ' […]'
|
56 |
);
|
57 |
|
58 |
+
protected $blog_encoding = 'UTF-8';
|
59 |
+
protected $has_mbfunctions = false;
|
60 |
+
protected $mbfunctions_required = false;
|
61 |
+
protected $has_mb_strlen = false;
|
62 |
+
protected $debug_suffix = '';
|
63 |
+
protected $textdomain = 'wp-multibyte-patch';
|
64 |
+
protected $lang_dir = 'languages';
|
65 |
+
protected $required_version = '4.5';
|
66 |
+
protected $query_based_vars = array();
|
67 |
|
68 |
// For fallback purpose only. (1.6)
|
69 |
+
public function guess_encoding( $string, $encoding = '' ) {
|
70 |
$blog_encoding = $this->blog_encoding;
|
71 |
|
72 |
if ( !$encoding && seems_utf8( $string ) )
|
78 |
}
|
79 |
|
80 |
// For fallback purpose only. (1.6)
|
81 |
+
public function convenc( $string, $to_encoding, $from_encoding = '' ) {
|
82 |
$blog_encoding = $this->blog_encoding;
|
83 |
|
84 |
if ( '' == $from_encoding )
|
90 |
return mb_convert_encoding( $string, $to_encoding, $from_encoding );
|
91 |
}
|
92 |
|
93 |
+
public function incoming_trackback( $commentdata ) {
|
94 |
if ( 'trackback' != $commentdata['comment_type'] )
|
95 |
return $commentdata;
|
96 |
|
126 |
return $commentdata;
|
127 |
}
|
128 |
|
129 |
+
public function pre_remote_source( $remote_source, $pagelinkedto ) {
|
130 |
$this->pingback_ping_remote_source = $remote_source;
|
131 |
$this->pingback_ping_pagelinkedto = $pagelinkedto;
|
132 |
return $remote_source;
|
133 |
}
|
134 |
|
135 |
+
public function incoming_pingback( $commentdata ) {
|
136 |
if ( 'pingback' != $commentdata['comment_type'] )
|
137 |
return $commentdata;
|
138 |
|
205 |
return $commentdata;
|
206 |
}
|
207 |
|
208 |
+
public function preprocess_comment( $commentdata ) {
|
209 |
if ( $commentdata['comment_type'] == 'trackback' )
|
210 |
return $this->incoming_trackback( $commentdata );
|
211 |
elseif ( $commentdata['comment_type'] == 'pingback' )
|
214 |
return $commentdata;
|
215 |
}
|
216 |
|
217 |
+
public function trim_multibyte_excerpt( $text = '', $length = 110, $more = ' […]', $encoding = 'UTF-8' ) {
|
218 |
$text = strip_shortcodes( $text );
|
219 |
$text = str_replace( ']]>', ']]>', $text );
|
220 |
$text = strip_tags( $text );
|
226 |
return $text;
|
227 |
}
|
228 |
|
229 |
+
public function bp_create_excerpt( $text = '' ) {
|
230 |
return $this->trim_multibyte_excerpt( $text, $this->conf['bp_excerpt_mblength'], $this->conf['bp_excerpt_more'], $this->blog_encoding );
|
231 |
}
|
232 |
|
233 |
+
public function bp_get_activity_content_body( $content = '' ) {
|
234 |
return preg_replace( "/<a [^<>]+>([^<>]+)<\/a>(" . preg_quote( $this->conf['bp_excerpt_more'], '/' ) . "<\/p>)$/", "$1$2", $content );
|
235 |
}
|
236 |
|
237 |
+
public 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 |
|
244 |
return $excerpt;
|
245 |
}
|
246 |
|
247 |
+
public function excerpt_mblength() {
|
248 |
if ( isset( $this->query_based_vars['excerpt_mblength'] ) && (int) $this->query_based_vars['excerpt_mblength'] )
|
249 |
$length = (int) $this->query_based_vars['excerpt_mblength'];
|
250 |
else
|
253 |
return apply_filters( 'excerpt_mblength', $length );
|
254 |
}
|
255 |
|
256 |
+
public function excerpt_more() {
|
257 |
if ( isset( $this->query_based_vars['excerpt_more'] ) )
|
258 |
return $this->query_based_vars['excerpt_more'];
|
259 |
else
|
260 |
return $this->conf['excerpt_more'];
|
261 |
}
|
262 |
|
263 |
+
public function sanitize_file_name( $name ) {
|
264 |
$info = pathinfo( $name );
|
265 |
$ext = !empty( $info['extension'] ) ? '.' . $info['extension'] : '';
|
266 |
$name = str_replace( $ext, '', $name );
|
269 |
return $name;
|
270 |
}
|
271 |
|
272 |
+
public function wplink_js( &$scripts ) {
|
273 |
+
global $pagenow;
|
274 |
|
275 |
+
$file = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . "/wp-includes/js/wplink{$this->debug_suffix}.js";
|
276 |
+
|
277 |
+
if( ! is_admin() || ! isset( $pagenow ) || ! in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) || ! is_file( $file ) )
|
278 |
+
return;
|
279 |
+
|
280 |
+
$debug_qs = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '?sd=1' : '';
|
281 |
+
|
282 |
+
$scripts->add( 'wplink', plugin_dir_url( __FILE__ ) . "wplink.php{$debug_qs}", array( 'jquery', 'wp-a11y' ), false, 1 );
|
283 |
}
|
284 |
|
285 |
+
public function force_character_count( $translations = '', $text = '', $context = '' ) {
|
286 |
if ( 'word count: words or characters?' == $context && 'words' == $text )
|
287 |
return 'characters';
|
288 |
|
292 |
return $translations;
|
293 |
}
|
294 |
|
295 |
+
public function force_twentytwelve_open_sans_off() {
|
296 |
wp_dequeue_style( 'twentytwelve-fonts' );
|
297 |
}
|
298 |
|
299 |
+
public function force_twentythirteen_google_fonts_off() {
|
300 |
wp_dequeue_style( 'twentythirteen-fonts' );
|
301 |
}
|
302 |
|
303 |
+
public function force_twentyfourteen_google_fonts_off() {
|
304 |
wp_dequeue_style( 'twentyfourteen-lato' );
|
305 |
}
|
306 |
|
307 |
+
public function force_twentyfifteen_google_fonts_off() {
|
308 |
wp_dequeue_style( 'twentyfifteen-fonts' );
|
309 |
}
|
310 |
|
311 |
+
public function force_twentysixteen_google_fonts_off() {
|
312 |
wp_dequeue_style( 'twentysixteen-fonts' );
|
313 |
}
|
314 |
|
315 |
+
public function remove_editor_style( $file = '' ) {
|
316 |
global $editor_styles;
|
317 |
|
318 |
if ( ! is_admin() || empty( $editor_styles ) || ! is_array( $editor_styles ) )
|
324 |
}
|
325 |
}
|
326 |
|
327 |
+
public function query_based_settings() {
|
328 |
$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' );
|
329 |
|
330 |
foreach ( $is_query_funcs as $func ) {
|
337 |
}
|
338 |
|
339 |
// The fallback only works with UTF-8 blog.
|
340 |
+
public function mb_strlen( $str = '', $encoding = 'UTF-8' ) {
|
341 |
if ( $this->has_mb_strlen )
|
342 |
return mb_strlen( $str, $encoding );
|
343 |
else
|
344 |
return preg_match_all( "/./us", $str, $match );
|
345 |
}
|
346 |
|
347 |
+
public function is_wp_required_version( $required_version ) {
|
348 |
global $wp_version;
|
349 |
return version_compare( $wp_version, $required_version, '<' ) ? false : true;
|
350 |
}
|
351 |
|
352 |
+
public function filters_after_setup_theme() {
|
353 |
// add filter
|
354 |
if ( false !== $this->conf['patch_force_character_count']) {
|
355 |
if ( 'characters_including_spaces' != _x( 'words', 'Word count type. Do not translate!' ) )
|
386 |
}
|
387 |
}
|
388 |
|
389 |
+
public function filters() {
|
390 |
// add filter
|
391 |
add_filter( 'preprocess_comment', array( $this, 'preprocess_comment' ), 99 );
|
392 |
|
432 |
add_action( 'after_setup_theme', array( $this, 'filters_after_setup_theme' ), 99 );
|
433 |
}
|
434 |
|
435 |
+
public function mbfunctions_exist() {
|
436 |
return (
|
437 |
function_exists( 'mb_convert_encoding' ) &&
|
438 |
function_exists( 'mb_convert_kana' ) &&
|
442 |
) ? true : false;
|
443 |
}
|
444 |
|
445 |
+
public function activation_check() {
|
446 |
$required_version = $this->required_version;
|
447 |
|
448 |
if ( !$this->is_wp_required_version( $required_version ) ) {
|
455 |
}
|
456 |
}
|
457 |
|
458 |
+
public function load_conf() {
|
459 |
$wpmp_conf = array();
|
460 |
|
461 |
if ( file_exists( WP_CONTENT_DIR . '/wpmp-config.php' ) )
|
470 |
$this->conf = array_merge( $this->conf, $wpmp_conf );
|
471 |
}
|
472 |
|
473 |
+
public function __construct() {
|
474 |
$this->load_conf();
|
475 |
$this->blog_encoding = get_option( 'blog_charset' );
|
476 |
if ( empty( $this->blog_encoding ) )
|
wplink.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
error_reporting( 0 );
|
4 |
+
|
5 |
+
function get_file( $path = null ) {
|
6 |
+
if ( function_exists( 'realpath' ) )
|
7 |
+
$path = realpath( $path );
|
8 |
+
|
9 |
+
if ( ! $path || ! is_file( $path ) )
|
10 |
+
return false;
|
11 |
+
|
12 |
+
return @file_get_contents( $path );
|
13 |
+
}
|
14 |
+
|
15 |
+
$etag = isset( $_GET['ver'] ) ? md5( $_GET['ver'] ) : false;
|
16 |
+
|
17 |
+
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag ) {
|
18 |
+
$protocol = $_SERVER['SERVER_PROTOCOL'];
|
19 |
+
|
20 |
+
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) )
|
21 |
+
$protocol = 'HTTP/1.0';
|
22 |
+
|
23 |
+
header( "$protocol 304 Not Modified" );
|
24 |
+
|
25 |
+
exit;
|
26 |
+
}
|
27 |
+
|
28 |
+
$expires_offset = 31536000; // 1 year
|
29 |
+
|
30 |
+
if( $etag )
|
31 |
+
header( "Etag: $etag" );
|
32 |
+
|
33 |
+
header( 'Content-Type: application/javascript; charset=UTF-8' );
|
34 |
+
header( 'Vary: Accept-Encoding' );
|
35 |
+
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
|
36 |
+
header( "Cache-Control: public, max-age=$expires_offset" );
|
37 |
+
|
38 |
+
$debug_suffix = isset( $_GET['sd'] ) ? '' : '.min';
|
39 |
+
$file = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . "/wp-includes/js/wplink{$debug_suffix}.js";
|
40 |
+
$out = get_file( $file );
|
41 |
+
|
42 |
+
if( ! $out )
|
43 |
+
exit;
|
44 |
+
|
45 |
+
if( isset( $_GET['sd'] ) )
|
46 |
+
echo str_replace( 'search.length > 2', 'search.length > 1', $out );
|
47 |
+
else
|
48 |
+
echo str_replace( '.length>2){if', '.length>1){if', $out );
|
49 |
+
|
50 |
+
exit;
|