Make WordPress Core

Changeset 33426


Ignore:
Timestamp:
07/26/2015 10:10:31 AM (10 years ago)
Author:
iseulde
Message:

TinyMCE: views: use media setting to get post ID

Also fix dependency declarations and confusing variable names.

Props rhurling.
Fixes #33096.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/mce-view.js

    r33338 r33426  
    11/* global tinymce */
    2 
    3 window.wp = window.wp || {};
    42
    53/*
     
    2523 * |  |- ...
    2624 */
    27 ( function( window, wp, $ ) {
     25( function( window, wp, shortcode, $ ) {
    2826    'use strict';
    2927
     
    672670         */
    673671        match: function( content ) {
    674             var match = wp.shortcode.next( this.type, content );
     672            var match = shortcode.next( this.type, content );
    675673
    676674            if ( match ) {
     
    721719        }
    722720    } );
    723 } )( window, window.wp, window.jQuery );
     721} )( window, window.wp, window.wp.shortcode, window.jQuery );
    724722
    725723/*
     
    728726 * and a view for embeddable URLs.
    729727 */
    730 ( function( window, views, $ ) {
    731     var postID = $( '#post_ID' ).val() || 0,
    732         media, gallery, av, embed;
    733 
    734     media = {
     728( function( window, views, media ) {
     729    var base, gallery, av, embed;
     730
     731    base = {
    735732        state: [],
    736733
    737734        edit: function( text, update ) {
    738735            var type = this.type,
    739                 media = wp.media[ type ],
    740                 frame = media.edit( text );
     736                frame = media[ type ].edit( text );
    741737
    742738            this.pausePlayers && this.pausePlayers();
     
    744740            _.each( this.state, function( state ) {
    745741                frame.state( state ).on( 'update', function( selection ) {
    746                     update( media.shortcode( selection ).string(), type === 'gallery' );
     742                    update( media[ type ].shortcode( selection ).string(), type === 'gallery' );
    747743                } );
    748744            } );
     
    756752    };
    757753
    758     gallery = _.extend( {}, media, {
     754    gallery = _.extend( {}, base, {
    759755        state: [ 'gallery-edit' ],
    760         template: wp.media.template( 'editor-gallery' ),
     756        template: media.template( 'editor-gallery' ),
    761757
    762758        initialize: function() {
    763             var attachments = wp.media.gallery.attachments( this.shortcode, postID ),
     759            var attachments = media.gallery.attachments( this.shortcode, media.view.settings.post.id ),
    764760                attrs = this.shortcode.attrs.named,
    765761                self = this;
     
    783779                self.render( self.template( {
    784780                    attachments: attachments,
    785                     columns: attrs.columns ? parseInt( attrs.columns, 10 ) : wp.media.galleryDefaults.columns
     781                    columns: attrs.columns ? parseInt( attrs.columns, 10 ) : media.galleryDefaults.columns
    786782                } ) );
    787783            } )
     
    792788    } );
    793789
    794     av = _.extend( {}, media, {
     790    av = _.extend( {}, base, {
    795791        action: 'parse-media-shortcode',
    796792
     
    800796            if ( this.url ) {
    801797                this.loader = false;
    802                 this.shortcode = wp.media.embed.shortcode( {
     798                this.shortcode = media.embed.shortcode( {
    803799                    url: this.text
    804800                } );
     
    806802
    807803            wp.ajax.post( this.action, {
    808                 post_ID: postID,
     804                post_ID: media.view.settings.post.id,
    809805                type: this.shortcode.tag,
    810806                shortcode: this.shortcode.string()
     
    847843
    848844        edit: function( text, update ) {
    849             var media = wp.media.embed,
    850                 frame = media.edit( text, this.url ),
     845            var frame = media.embed.edit( text, this.url ),
    851846                self = this;
    852847
     
    865860                    update( data.url );
    866861                } else {
    867                     update( media.shortcode( data ).string() );
     862                    update( media.embed.shortcode( data ).string() );
    868863                }
    869864            } );
     
    909904        }
    910905    } ) );
    911 } )( window, window.wp.mce.views, window.jQuery );
     906} )( window, window.wp.mce.views, window.wp.media );
  • trunk/src/wp-includes/script-loader.php

    r33364 r33426  
    457457    $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
    458458    $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
    459     $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models', 'media-audiovideo', 'wp-playlist' ), false, 1 );
     459    $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
    460460
    461461    if ( is_admin() ) {
Note: See TracChangeset for help on using the changeset viewer.