Skip to content

Commit

Permalink
Prevent mere post update from cementing enabled status postmeta
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jan 17, 2018
1 parent 7704076 commit d8d2d89
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion assets/js/amp-post-meta-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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 ) );
} );

Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit d8d2d89

Please sign in to comment.