@@ -24,6 +24,10 @@ function _s_setup() {
2424 */
2525 load_theme_textdomain ( '_s ' , get_template_directory () . '/languages ' );
2626
27+ add_theme_support ( 'amp ' , array (
28+ 'comments_live_list ' => true ,
29+ ) );
30+
2731 // Add default posts and comments RSS feed links to head.
2832 add_theme_support ( 'automatic-feed-links ' );
2933
@@ -117,10 +121,56 @@ function _s_widgets_init() {
117121add_action ( 'widgets_init ' , '_s_widgets_init ' );
118122
119123/**
120- * Enqueue scripts and styles.
124+ * Determine whether this is an AMP response.
125+ *
126+ * Note that this must only be called after the parse_query action.
127+ *
128+ * @link https://github.com/Automattic/amp-wp
121129 */
122- function _s_scripts () {
130+ function _s_is_amp () {
131+ return function_exists ( 'is_amp_endpoint ' ) && is_amp_endpoint ();
132+ }
133+
134+ /**
135+ * Detemrine whether amp-live-list should be used for the comment list.
136+ *
137+ * @return bool Whether to use amp-live-list.
138+ */
139+ function _s_using_amp_live_list_comments () {
140+ if ( ! _s_is_amp () ) {
141+ return false ;
142+ }
143+ $ amp_theme_support = get_theme_support ( 'amp ' );
144+ return ! empty ( $ amp_theme_support [0 ]['comments_live_list ' ] );
145+ }
146+
147+ /**
148+ * Enqueue styles.
149+ */
150+ function _s_styles () {
123151 wp_enqueue_style ( '_s-style ' , get_stylesheet_uri () );
152+ }
153+ add_action ( 'wp_enqueue_scripts ' , '_s_styles ' );
154+
155+ /**
156+ * Enqueue scripts.
157+ *
158+ * This short-circuits in AMP because custom scripts are not allowed. There is are AMP equivalents provided elsewhere.
159+ *
160+ * navigation:
161+ * In AMP the :focus-within selector is used to keep submenus displayed while tabbing,
162+ * and amp-bind is used to managed the toggled state of the nav menu on small screens.
163+ *
164+ * skip-link-focus-fix:
165+ * This is not implemented in AMP because it only relates to IE11, a browser which now has a very small market share.
166+ *
167+ * comment-reply:
168+ * Support for comment replies is provided by the AMP plugin.
169+ */
170+ function _s_scripts () {
171+ if ( _s_is_amp () ) {
172+ return ;
173+ }
124174
125175 wp_enqueue_script ( '_s-navigation ' , get_template_directory_uri () . '/js/navigation.js ' , array (), '20151215 ' , true );
126176
0 commit comments