Skip to content

Commit

Permalink
Opt to inline the descending-ordering comment logic since temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jan 30, 2018
1 parent 63d83d0 commit 310a74a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
7 changes: 2 additions & 5 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,14 @@ function amp_after_setup_theme() {
}

add_action( 'init', 'amp_init' );
add_action( 'widgets_init', 'AMP_Theme_Support::register_widgets' );
add_action( 'widgets_init', 'AMP_Theme_Support::register_widgets' ); // @todo Let this be called by AMP_Theme_Support::init().
add_action( 'init', 'AMP_Theme_Support::setup_commenting' ); // @todo Let this be called by AMP_Theme_Support::init().
add_action( 'admin_init', 'AMP_Options_Manager::register_settings' );
add_filter( 'amp_post_template_analytics', 'amp_add_custom_analytics' );
add_action( 'wp_loaded', 'amp_post_meta_box' );
add_action( 'wp_loaded', 'amp_add_options_menu' );
add_action( 'parse_query', 'amp_correct_query_when_is_front_page' );
AMP_Post_Type_Support::add_post_type_support();
add_filter( 'option_comment_order', function() {
return 'desc';
}, PHP_INT_MAX );
add_action( 'admin_print_footer_scripts-options-discussion.php', 'amp_comments_order_disable_scripts' );
}
add_action( 'after_setup_theme', 'amp_after_setup_theme', 5 );

Expand Down
16 changes: 0 additions & 16 deletions assets/js/amp-admin-comments.js

This file was deleted.

2 changes: 1 addition & 1 deletion includes/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function amp_comments_order_disable_scripts() {
true
);
?>
<div class="notice notice-info inline" id="amp-comment-notice"><p><?php echo wp_kses_post( __( 'Note: AMP does not yet <a href="https://github.com/ampproject/amphtml/issues/5396" target="_blank">support ascending</a> comments with newer entries appearing at the bottom.', 'amp' ) ); ?></p></div>

<?php
}

33 changes: 33 additions & 0 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,39 @@ public static function purge_amp_query_vars() {
}
}

/**
* Set up commenting.
*/
public static function setup_commenting() {
if ( ! current_theme_supports( AMP_QUERY_VAR ) ) {
return;
}

/*
* Temporarily force comments to be listed in descending order.
*
* The following hooks are temporary while waiting for amphtml#5396 to be resolved.
*/
add_filter( 'option_comment_order', function() {
return 'desc';
}, PHP_INT_MAX );

add_action( 'admin_print_footer_scripts-options-discussion.php', function() {
?>
<div class="notice notice-info inline" id="amp-comment-notice"><p><?php echo wp_kses_post( __( 'Note: AMP does not yet <a href="https://github.com/ampproject/amphtml/issues/5396" target="_blank">support ascending</a> comments with newer entries appearing at the bottom.', 'amp' ) ); ?></p></div>
<script>
// Move the notice below the selector and disable selector.
jQuery( function( $ ) {
var orderSelect = $( '#comment_order' ),
notice = $( '#amp-comment-notice' );
orderSelect.prop( 'disabled', true );
orderSelect.closest( 'fieldset' ).append( notice );
} );
</script>
<?php
} );
}

/**
* Register/override widgets.
*
Expand Down

0 comments on commit 310a74a

Please sign in to comment.