Skip to content

Commit

Permalink
Distinguish enabled-status from support-error
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jan 17, 2018
1 parent d8d2d89 commit 8c51443
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions assets/js/amp-post-meta-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ var ampPostMetaBox = ( function( $ ) {
*/
data: {
previewLink: '',
enabled: '',
enabled: true, // Overridden by post_supports_amp( $post ).
canSupport: true, // Overridden by count( AMP_Post_Type_Support::get_support_errors( $post ) ) === 0.
statusInputName: '',
l10n: {
ampPreviewBtnLabel: ''
Expand Down Expand Up @@ -164,7 +165,7 @@ var ampPostMetaBox = ( function( $ ) {
$container.slideToggle( component.toggleSpeed );

// Update status.
if ( component.data.enabled ) {
if ( component.data.canSupport ) {
$container.data( 'amp-status', status );
$checked.prop( 'checked', true );
$( '.amp-status-text' ).text( $checked.next().text() );
Expand Down
1 change: 1 addition & 0 deletions includes/admin/class-amp-post-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function enqueue_admin_assets() {
wp_json_encode( array(
'previewLink' => esc_url_raw( add_query_arg( AMP_QUERY_VAR, '', get_preview_post_link( $post ) ) ),
'enabled' => post_supports_amp( $post ),
'canSupport' => count( AMP_Post_Type_Support::get_support_errors( $post ) ) === 0,
'statusInputName' => self::STATUS_INPUT_NAME,
'l10n' => array(
'ampPreviewBtnLabel' => __( 'Preview changes in AMP (opens in new window)', 'amp' ),
Expand Down

0 comments on commit 8c51443

Please sign in to comment.