From d8d2d89fda0b72cfe6859008a60e4a77969ce03b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 17 Jan 2018 11:05:40 -0800 Subject: [PATCH] Prevent mere post update from cementing enabled status postmeta --- assets/js/amp-post-meta-box.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/js/amp-post-meta-box.js b/assets/js/amp-post-meta-box.js index 4816fa8116d..17b077c197d 100644 --- a/assets/js/amp-post-meta-box.js +++ b/assets/js/amp-post-meta-box.js @@ -58,6 +58,7 @@ var ampPostMetaBox = ( function( $ ) { component.boot = function boot( data ) { component.data = data; $( document ).ready( function() { + component.statusRadioInputs = $( '[name="' + component.data.statusInputName + '"]' ); if ( component.data.enabled ) { component.addPreviewButton(); } @@ -77,8 +78,10 @@ var ampPostMetaBox = ( function( $ ) { component.onAmpPreviewButtonClick(); } ); + component.statusRadioInputs.prop( 'disabled', true ); // Prevent cementing setting default status as overridden status. $( '.edit-amp-status, [href="#amp_status"]' ).click( function( e ) { e.preventDefault(); + component.statusRadioInputs.prop( 'disabled', false ); component.toggleAmpStatus( $( e.target ) ); } ); @@ -147,7 +150,7 @@ var ampPostMetaBox = ( function( $ ) { // Don't modify status on cancel button click. if ( ! $target.hasClass( 'button-cancel' ) ) { - status = $( '[name="' + component.data.statusInputName + '"]:checked' ).val(); + status = component.statusRadioInputs.filter( ':checked' ).val(); } $checked = $( '#amp-status-' + status );