From 1bbf7c19b0ed1a840a758320090eff247a088900 Mon Sep 17 00:00:00 2001 From: Nathaniel Taintor Date: Fri, 11 Aug 2017 14:25:31 -0700 Subject: [PATCH] Remove unused method for fetching preview of single shortcode Removes the unused "fetch()" method from Shortcode View constructor (it was confusingly making a request to the 'do_shortcode' ajax endpoint, which was removed a long time ago). Also removes the nonce which is set with each separate query in the bulk_do_shortcode request - since #743, a single nonce is being sent as a top-level field on the request and is being checked by the 'bulk_do_shortcode' endpoint. --- js-tests/build/specs.js | 35 +------------------- js/build/shortcode-ui.js | 37 ++-------------------- js/src/utils/shortcode-view-constructor.js | 35 +------------------- 3 files changed, 5 insertions(+), 102 deletions(-) diff --git a/js-tests/build/specs.js b/js-tests/build/specs.js index c6155080..0f871224 100644 --- a/js-tests/build/specs.js +++ b/js-tests/build/specs.js @@ -1118,43 +1118,10 @@ var shortcodeViewConstructor = { delayedFetch: function() { return fetcher.queueToFetch({ post_id: $( '#post_ID' ).val(), - shortcode: this.shortcodeModel.formatShortcode(), - nonce: shortcodeUIData.nonces.preview, + shortcode: this.shortcodeModel.formatShortcode() }); }, - /** - * Fetch a preview of a single shortcode. - * - * Async. Sets this.content and calls this.render. - * - * @return undefined - */ - fetch: function() { - var self = this; - - if ( ! this.fetching ) { - this.fetching = true; - - wp.ajax.post( 'do_shortcode', { - post_id: $( '#post_ID' ).val(), - shortcode: this.shortcodeModel.formatShortcode(), - nonce: shortcodeUIData.nonces.preview, - }).done( function( response ) { - if ( '' === response ) { - self.content = '' + self.shortcodeModel.formatShortcode() + ''; - } else { - self.content = response; - } - }).fail( function() { - self.content = '' + shortcodeUIData.strings.mce_view_error + ''; - } ).always( function() { - delete self.fetching; - self.render( null, true ); - } ); - } - }, - /** * Get the shortcode model and open modal UI for editing. * diff --git a/js/build/shortcode-ui.js b/js/build/shortcode-ui.js index 8bdea15b..a9132e20 100644 --- a/js/build/shortcode-ui.js +++ b/js/build/shortcode-ui.js @@ -625,43 +625,10 @@ var shortcodeViewConstructor = { delayedFetch: function() { return fetcher.queueToFetch({ post_id: $( '#post_ID' ).val(), - shortcode: this.shortcodeModel.formatShortcode(), - nonce: shortcodeUIData.nonces.preview, + shortcode: this.shortcodeModel.formatShortcode() }); }, - /** - * Fetch a preview of a single shortcode. - * - * Async. Sets this.content and calls this.render. - * - * @return undefined - */ - fetch: function() { - var self = this; - - if ( ! this.fetching ) { - this.fetching = true; - - wp.ajax.post( 'do_shortcode', { - post_id: $( '#post_ID' ).val(), - shortcode: this.shortcodeModel.formatShortcode(), - nonce: shortcodeUIData.nonces.preview, - }).done( function( response ) { - if ( '' === response ) { - self.content = '' + self.shortcodeModel.formatShortcode() + ''; - } else { - self.content = response; - } - }).fail( function() { - self.content = '' + shortcodeUIData.strings.mce_view_error + ''; - } ).always( function() { - delete self.fetching; - self.render( null, true ); - } ); - } - }, - /** * Get the shortcode model and open modal UI for editing. * @@ -890,6 +857,8 @@ var editAttributeFieldAttachment = sui.views.editAttributeField.extend( { this._renderAll(); + this.triggerCallbacks(); + }, _renderAll: function() { diff --git a/js/src/utils/shortcode-view-constructor.js b/js/src/utils/shortcode-view-constructor.js index 61b85496..a1cc756d 100644 --- a/js/src/utils/shortcode-view-constructor.js +++ b/js/src/utils/shortcode-view-constructor.js @@ -118,43 +118,10 @@ var shortcodeViewConstructor = { delayedFetch: function() { return fetcher.queueToFetch({ post_id: $( '#post_ID' ).val(), - shortcode: this.shortcodeModel.formatShortcode(), - nonce: shortcodeUIData.nonces.preview, + shortcode: this.shortcodeModel.formatShortcode() }); }, - /** - * Fetch a preview of a single shortcode. - * - * Async. Sets this.content and calls this.render. - * - * @return undefined - */ - fetch: function() { - var self = this; - - if ( ! this.fetching ) { - this.fetching = true; - - wp.ajax.post( 'do_shortcode', { - post_id: $( '#post_ID' ).val(), - shortcode: this.shortcodeModel.formatShortcode(), - nonce: shortcodeUIData.nonces.preview, - }).done( function( response ) { - if ( '' === response ) { - self.content = '' + self.shortcodeModel.formatShortcode() + ''; - } else { - self.content = response; - } - }).fail( function() { - self.content = '' + shortcodeUIData.strings.mce_view_error + ''; - } ).always( function() { - delete self.fetching; - self.render( null, true ); - } ); - } - }, - /** * Get the shortcode model and open modal UI for editing. *