diff --git a/amp.php b/amp.php index a6b381ff819..0b6001e75ca 100644 --- a/amp.php +++ b/amp.php @@ -127,13 +127,14 @@ function amp_force_query_var_value( $query_vars ) { * @return void */ function amp_maybe_add_actions() { + $is_amp_endpoint = is_amp_endpoint(); // Add hooks for when a themes that support AMP. if ( current_theme_supports( 'amp' ) ) { - if ( amp_is_canonical() || is_amp_endpoint() ) { - AMP_Theme_Support::register_hooks(); + if ( $is_amp_endpoint ) { + AMP_Theme_Support::init(); } else { - AMP_Frontend_Actions::register_hooks(); + amp_add_frontend_actions(); } return; } @@ -143,8 +144,6 @@ function amp_maybe_add_actions() { return; } - $is_amp_endpoint = is_amp_endpoint(); - // Cannot use `get_queried_object` before canonical redirect; see . global $wp_query; $post = $wp_query->post; @@ -152,7 +151,7 @@ function amp_maybe_add_actions() { $supports = post_supports_amp( $post ); if ( ! $supports ) { - if ( $is_amp_endpoint ) { + if ( $is_amp_endpoint && isset( $post->ID ) ) { wp_safe_redirect( get_permalink( $post->ID ), 301 ); exit; } @@ -172,7 +171,7 @@ function amp_maybe_add_actions() { * Themes can register support for this with `add_theme_support( 'amp' )`. * Then, this will change the plugin from 'paired mode,' and it won't use its own templates. * Nor output frontend markup like the 'rel' link. If the theme registers support for AMP with: - * `add_theme_support( 'amp', array( 'template_path' => get_template_directory() . 'my-amp-templates/' ) )` + * `add_theme_support( 'amp', array( 'template_dir' => 'my-amp-templates' ) )` * it will retain 'paired mode. * * @return boolean Whether this is in AMP 'canonical mode'. @@ -184,7 +183,7 @@ function amp_is_canonical() { } if ( is_array( $support ) ) { $args = array_shift( $support ); - if ( empty( $args['template_path'] ) ) { + if ( empty( $args['template_dir'] ) ) { return true; } } @@ -196,12 +195,13 @@ function amp_load_classes() { } function amp_add_frontend_actions() { - AMP_Frontend_Actions::register_hooks(); + require_once AMP__DIR__ . '/includes/amp-frontend-actions.php'; } function amp_add_post_template_actions() { - AMP_Paired_Post_Actions::register_hooks(); - require_once( AMP__DIR__ . '/includes/amp-post-template-functions.php' ); + require_once AMP__DIR__ . '/includes/amp-post-template-actions.php'; + require_once AMP__DIR__ . '/includes/amp-post-template-functions.php'; + amp_post_template_init_hooks(); } function amp_prepare_render() { diff --git a/includes/actions/class-amp-actions.php b/includes/actions/class-amp-actions.php deleted file mode 100644 index 4a95034e66d..00000000000 --- a/includes/actions/class-amp-actions.php +++ /dev/null @@ -1,20 +0,0 @@ -', esc_url( $amp_url ) ); - } - } - - /** - * Get the amphtml URL for the current request. - * - * @todo Put this function in includes/amp-helper-functions.php? - * @return string|null URL or null if AMP version is not available. - */ - public static function get_current_amphtml_url() { - if ( is_singular() ) { - return amp_get_permalink( get_queried_object_id() ); - } - - // @todo Get callback from get_theme_support( 'amp' ) to determine whether AMP is allowed for current request. See . - if ( ! current_theme_supports( 'amp' ) ) { - return null; - } - - $amp_url = ''; - $home_url = wp_parse_url( home_url() ); - if ( isset( $home_url['scheme'] ) ) { - $amp_url .= $home_url['scheme'] . ':'; - } - $amp_url .= '//' . $home_url['host']; - if ( ! empty( $home_url['port'] ) ) { - $amp_url .= ':' . $home_url['port']; - } - $amp_url .= esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ); - return add_query_arg( AMP_QUERY_VAR, '', $amp_url ); - } -} diff --git a/includes/actions/class-amp-paired-post-actions.php b/includes/actions/class-amp-paired-post-actions.php deleted file mode 100644 index 816818dbb3a..00000000000 --- a/includes/actions/class-amp-paired-post-actions.php +++ /dev/null @@ -1,176 +0,0 @@ - - <?php echo esc_html( $amp_template->get( 'document_title' ) ); ?> - - - get( 'amp_component_scripts', array() ); - foreach ( $scripts as $element => $script ) : - $custom_type = ( 'amp-mustache' === $element ) ? 'template' : 'element'; - ?> - - - - get( 'font_urls', array() ); - ?> - $url ) : ?> - - - get( 'metadata' ); - if ( empty( $metadata ) ) { - return; - } - ?> - - get( 'post_amp_styles' ); - if ( ! empty( $styles ) ) { - echo '/* Inline styles */' . PHP_EOL; // WPCS: XSS OK. - foreach ( $styles as $selector => $declarations ) { - $declarations = implode( ';', $declarations ) . ';'; - printf( '%1$s{%2$s}', $selector, $declarations ); // WPCS: XSS OK. - } - } - } - - /** - * Add analytics scripts. - * - * @param array $data Data. - * @return array Data. - */ - public static function add_analytics_scripts( $data ) { - if ( ! empty( $data['amp_analytics'] ) ) { - $data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js'; - } - return $data; - } - - /** - * Print analytics data. - * - * @param AMP_Post_Template $amp_template Template. - */ - public static function add_analytics_data( $amp_template ) { - $analytics_entries = $amp_template->get( 'amp_analytics' ); - if ( empty( $analytics_entries ) ) { - return; - } - - foreach ( $analytics_entries as $id => $analytics_entry ) { - if ( ! isset( $analytics_entry['type'], $analytics_entry['attributes'], $analytics_entry['config_data'] ) ) { - /* translators: %1$s is analytics entry ID, %2$s is actual entry keys. */ - _doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'Analytics entry for %1$s is missing one of the following keys: `type`, `attributes`, or `config_data` (array keys: %2$s)', 'amp' ), esc_html( $id ), esc_html( implode( ', ', array_keys( $analytics_entry ) ) ) ), '0.3.2' ); - continue; - } - - $script_element = AMP_HTML_Utils::build_tag( 'script', array( - 'type' => 'application/json', - ), wp_json_encode( $analytics_entry['config_data'] ) ); - - $amp_analytics_attr = array_merge( array( - 'id' => $id, - 'type' => $analytics_entry['type'], - ), $analytics_entry['attributes'] ); - - echo AMP_HTML_Utils::build_tag( 'amp-analytics', $amp_analytics_attr, $script_element ); // WPCS: XSS OK. - } - } - - /** - * Print AMP generator metadata. - * - * @param AMP_Post_Template $amp_template AMP_Post_Template object. - * @since 0.6 - */ - public static function add_generator_metadata( $amp_template ) { - ?> - - ', esc_url( amp_get_permalink( get_queried_object_id() ) ) ); +} diff --git a/includes/amp-helper-functions.php b/includes/amp-helper-functions.php index 95b01f16a56..4f078702273 100644 --- a/includes/amp-helper-functions.php +++ b/includes/amp-helper-functions.php @@ -63,6 +63,10 @@ function amp_get_permalink( $post_id ) { * @return bool Whether the post supports AMP. */ function post_supports_amp( $post ) { + if ( amp_is_canonical() ) { + return true; + } + return 0 === count( AMP_Post_Type_Support::get_support_errors( $post ) ); } @@ -74,6 +78,10 @@ function post_supports_amp( $post ) { * @return bool Whether it is the AMP endpoint. */ function is_amp_endpoint() { + if ( amp_is_canonical() ) { + return true; + } + if ( 0 === did_action( 'parse_query' ) ) { _doing_it_wrong( __FUNCTION__, sprintf( esc_html__( "is_amp_endpoint() was called before the 'parse_query' hook was called. This function will always return 'false' before the 'parse_query' hook is called.", 'amp' ) ), '0.4.2' ); } diff --git a/includes/amp-post-template-actions.php b/includes/amp-post-template-actions.php new file mode 100644 index 00000000000..711e5bbe023 --- /dev/null +++ b/includes/amp-post-template-actions.php @@ -0,0 +1,170 @@ + + <?php echo esc_html( $amp_template->get( 'document_title' ) ); ?> + + + get( 'amp_component_scripts', array() ); + foreach ( $scripts as $element => $script ) { + $custom_type = ( 'amp-mustache' === $element ) ? 'template' : 'element'; + printf( + '', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + esc_attr( $custom_type ), + esc_attr( $element ), + esc_url( $script ) + ); + } + printf( + '', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + esc_url( $amp_template->get( 'amp_runtime_script' ) ) + ); +} + +/** + * Print fonts. + * + * @param AMP_Post_Template $amp_template Template. + */ +function amp_post_template_add_fonts( $amp_template ) { + $font_urls = $amp_template->get( 'font_urls', array() ); + foreach ( $font_urls as $slug => $url ) { + printf( '', esc_url( esc_url( $url ) ) ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet + } +} + +/** + * Print boilerplate CSS. + */ +function amp_post_template_add_boilerplate_css() { + ?> + + get( 'metadata' ); + if ( empty( $metadata ) ) { + return; + } + ?> + + get( 'post_amp_styles' ); + if ( ! empty( $styles ) ) { + echo '/* Inline styles */' . PHP_EOL; // WPCS: XSS OK. + foreach ( $styles as $selector => $declarations ) { + $declarations = implode( ';', $declarations ) . ';'; + printf( '%1$s{%2$s}', $selector, $declarations ); // WPCS: XSS OK. + } + } +} + +/** + * Add analytics scripts. + * + * @param array $data Data. + * @return array Data. + */ +function amp_post_template_add_analytics_script( $data ) { + if ( ! empty( $data['amp_analytics'] ) ) { + $data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js'; + } + return $data; +} + +/** + * Print analytics data. + * + * @param AMP_Post_Template $amp_template Template. + */ +function amp_post_template_add_analytics_data( $amp_template ) { + $analytics_entries = $amp_template->get( 'amp_analytics' ); + if ( empty( $analytics_entries ) ) { + return; + } + + foreach ( $analytics_entries as $id => $analytics_entry ) { + if ( ! isset( $analytics_entry['type'], $analytics_entry['attributes'], $analytics_entry['config_data'] ) ) { + /* translators: %1$s is analytics entry ID, %2$s is actual entry keys. */ + _doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'Analytics entry for %1$s is missing one of the following keys: `type`, `attributes`, or `config_data` (array keys: %2$s)', 'amp' ), esc_html( $id ), esc_html( implode( ', ', array_keys( $analytics_entry ) ) ) ), '0.3.2' ); + continue; + } + $script_element = AMP_HTML_Utils::build_tag( 'script', array( + 'type' => 'application/json', + ), wp_json_encode( $analytics_entry['config_data'] ) ); + + $amp_analytics_attr = array_merge( array( + 'id' => $id, + 'type' => $analytics_entry['type'], + ), $analytics_entry['attributes'] ); + + echo AMP_HTML_Utils::build_tag( 'amp-analytics', $amp_analytics_attr, $script_element ); // WPCS: XSS OK. + } +} + +/** + * Add generator metadata. + * + * @since 6.0 + */ +function amp_add_generator_metadata() { + printf( '', esc_attr( 'AMP Plugin v' . AMP__VERSION ) ); +} diff --git a/includes/class-amp-autoloader.php b/includes/class-amp-autoloader.php index 6ad8d1e1e77..05bbf021b9d 100644 --- a/includes/class-amp-autoloader.php +++ b/includes/class-amp-autoloader.php @@ -29,9 +29,6 @@ class AMP_Autoloader { * @var string[] */ private static $_classmap = array( - 'AMP_Actions' => 'includes/actions/class-amp-actions', - 'AMP_Frontend_Actions' => 'includes/actions/class-amp-frontend-actions', - 'AMP_Paired_Post_Actions' => 'includes/actions/class-amp-paired-post-actions', 'AMP_Theme_Support' => 'includes/class-amp-theme-support', 'AMP_Template_Customizer' => 'includes/admin/class-amp-customizer', 'AMP_Post_Meta_Box' => 'includes/admin/class-amp-post-meta-box', diff --git a/includes/class-amp-post-type-support.php b/includes/class-amp-post-type-support.php index 12b10c73f59..54c899a1098 100644 --- a/includes/class-amp-post-type-support.php +++ b/includes/class-amp-post-type-support.php @@ -72,7 +72,7 @@ public static function get_support_errors( $post ) { $errors = array(); // Because `add_rewrite_endpoint` doesn't let us target specific post_types. - if ( ! post_type_supports( $post->post_type, AMP_QUERY_VAR ) ) { + if ( isset( $post->post_type ) && ! post_type_supports( $post->post_type, AMP_QUERY_VAR ) ) { $errors[] = 'post-type-support'; } @@ -103,7 +103,7 @@ public static function get_support_errors( $post ) { * @param int $post_id Post ID. * @param WP_Post $post Post. */ - if ( true === apply_filters( 'amp_skip_post', false, $post->ID, $post ) ) { + if ( isset( $post->ID ) && true === apply_filters( 'amp_skip_post', false, $post->ID, $post ) ) { $errors[] = 'skip-post'; } diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php index 2693358cf57..889e7e91f8d 100644 --- a/includes/class-amp-theme-support.php +++ b/includes/class-amp-theme-support.php @@ -12,8 +12,89 @@ */ class AMP_Theme_Support { + /** + * Replaced with the necessary scripts depending on components used in output. + * + * @var string + */ const COMPONENT_SCRIPTS_PLACEHOLDER = ''; + /** + * Template types. + * + * @var array + */ + protected static $template_types = array( + 'paged', // Deprecated. + 'index', + '404', + 'archive', + 'author', + 'category', + 'tag', + 'taxonomy', + 'date', + 'home', + 'front_page', + 'page', + 'search', + 'single', + 'embed', + 'singular', + 'attachment', + ); + + /** + * Initialize. + */ + public static function init() { + require_once AMP__DIR__ . '/includes/amp-post-template-actions.php'; + if ( amp_is_canonical() ) { + + // Permanently redirect to canonical URL if the AMP URL was loaded, since canonical is now AMP. + if ( false !== get_query_var( AMP_QUERY_VAR, false ) ) { // Because is_amp_endpoint() now returns true if amp_is_canonical(). + wp_safe_redirect( self::get_current_canonical_url(), 301 ); + exit; + } + } else { + self::register_paired_hooks(); + } + self::register_hooks(); + } + + /** + * Determines whether paired mode is available. + * + * When 'amp' theme support has not been added or canonical mode is enabled, then this returns false. + * Returns true when there is a template_dir defined in theme support, and if a defined available_callback + * returns true. + * + * @return bool Whether available. + */ + public static function is_paired_available() { + $support = get_theme_support( 'amp' ); + if ( empty( $support ) || amp_is_canonical() ) { + return false; + } + + $args = array_shift( $support ); + + if ( isset( $args['available_callback'] ) && is_callable( $args['available_callback'] ) ) { + return call_user_func( $args['available_callback'] ); + } + return true; + } + + /** + * Register hooks for paired mode. + */ + public static function register_paired_hooks() { + foreach ( self::$template_types as $template_type ) { + add_filter( "{$template_type}_template_hierarchy", array( __CLASS__, 'filter_paired_template_hierarchy' ) ); + } + add_filter( 'template_include', array( __CLASS__, 'filter_paired_template_include' ), 100 ); + } + /** * Register hooks. */ @@ -39,7 +120,7 @@ public static function register_hooks() { add_action( 'wp_head', 'amp_print_boilerplate_code', 3 ); add_action( 'wp_head', array( __CLASS__, 'add_scripts' ), 4 ); add_action( 'wp_head', array( __CLASS__, 'add_styles' ), 5 ); - add_action( 'wp_head', array( __CLASS__, 'add_meta_generator' ), 6 ); + add_action( 'wp_head', 'amp_add_generator_metadata', 6 ); /* * Disable admin bar because admin-bar.css (28K) and Dashicons (48K) alone @@ -54,6 +135,44 @@ public static function register_hooks() { // @todo Add character conversion. } + /** + * Prepends template hierarchy with template_dir for AMP paired mode templates. + * + * @see get_query_template() + * + * @param array $templates Template hierarchy. + * @returns array Templates. + */ + public static function filter_paired_template_hierarchy( $templates ) { + $support = get_theme_support( 'amp' ); + $args = array_shift( $support ); + if ( isset( $args['template_dir'] ) ) { + $amp_templates = array(); + foreach ( $templates as $template ) { + $amp_templates[] = $args['template_dir'] . '/' . $template; + } + $templates = $amp_templates; + } + return $templates; + } + + /** + * Redirect to the non-canonical URL when the template to include is empty. + * + * This is a failsafe in case an index.php is not located in the AMP template_dir, + * and the available_callback fails to omit a given request from being available in AMP. + * + * @param string $template Template to include. + * @return string Template to include. + */ + public static function filter_paired_template_include( $template ) { + if ( empty( $template ) || ! self::is_paired_available() ) { + wp_safe_redirect( self::get_current_canonical_url() ); + exit; + } + return $template; + } + /** * Print meta charset tag. * @@ -85,19 +204,15 @@ public static function add_scripts() { } /** - * Add canonical link. - * - * Replaces `rel_canonical()` which only outputs canonical URLs for singular posts and pages. - * This can be removed once WP Core #18660 lands. - * - * @link https://www.ampproject.org/docs/reference/spec#canon. - * @link https://core.trac.wordpress.org/ticket/18660 + * Get canonical URL for current request. * * @see rel_canonical() * @global WP $wp * @global WP_Rewrite $wp_rewrite + * + * @return string Canonical non-AMP URL. */ - public static function add_canonical_link() { + public static function get_current_canonical_url() { global $wp, $wp_rewrite; $url = null; @@ -136,7 +251,23 @@ public static function add_canonical_link() { $url = remove_query_arg( AMP_QUERY_VAR, $url ); } - echo '' . "\n"; + return $url; + } + + /** + * Add canonical link. + * + * Replaces `rel_canonical()` which only outputs canonical URLs for singular posts and pages. + * This can be removed once WP Core #18660 lands. + * + * @link https://www.ampproject.org/docs/reference/spec#canon. + * @link https://core.trac.wordpress.org/ticket/18660 + */ + public static function add_canonical_link() { + $url = self::get_current_canonical_url(); + if ( ! empty( $url ) ) { + printf( '', esc_url( $url ) ); + } } /** @@ -164,13 +295,6 @@ public static function add_styles() { echo ''; } - /** - * Print AMP meta generator tag. - */ - public static function add_meta_generator() { - printf( '', esc_attr( 'AMP Plugin v' . AMP__VERSION ) ); - } - /** * Determine required AMP scripts. * diff --git a/includes/templates/class-amp-post-template.php b/includes/templates/class-amp-post-template.php index 2f88c6545f4..30624a746db 100644 --- a/includes/templates/class-amp-post-template.php +++ b/includes/templates/class-amp-post-template.php @@ -109,7 +109,6 @@ public function __construct( $post ) { 'canonical_url' => get_permalink( $this->ID ), 'home_url' => home_url(), 'blog_name' => get_bloginfo( 'name' ), - 'generator_metadata' => 'AMP Plugin v' . AMP__VERSION, 'html_tag_attributes' => array(), 'body_class' => '', diff --git a/readme.md b/readme.md index 8339193a366..9e9ac452157 100644 --- a/readme.md +++ b/readme.md @@ -59,20 +59,17 @@ Follow along with or [contribute](https://github.com/Automattic/amp-wp/blob/deve - Add support for canonical AMP. ### 0.6 (unreleased) ### -- Add: support for the "page" post type, except when used as homepage or page for posts. A new `page.php` is introduced with template parts factored out (`html-start.php`, `header.php`, `footer.php`, `html-end.php`) and re-used from `single.php`. Note that AMP URLs will end in `?amp` instead of `/amp/`. See [#825](https://github.com/Automattic/amp-wp/pull/825). Props technosailor, ThierryA, westonruter. -- Add: AMP post preview button alongside non-AMP preview button. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. -- Add: ability to disable AMP on a per-post basis via toggle in publish metabox. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. -- Add: AMP settings admin screen for managing which post types have AMP support, eliminating the requirement to add `add_post_type_support()` calls in theme or plugin. See [#811](https://github.com/Automattic/amp-wp/pull/811). Props ThierryA, westonruter. -- Add: generator meta tag for AMP. See [#810](https://github.com/Automattic/amp-wp/pull/810). Props vaporwavre. -- Add: code quality checking via phpcs, eslint, jscs, and jshint. See [#795](https://github.com/Automattic/amp-wp/pull/795). Props westonruter. -- Add: autoloader to reduce complexity. See [#828](https://github.com/Automattic/amp-wp/pull/828). Props mikeschinkel, westonruter, ThierryA. -- Add: Vanilla WordPress "embed" test page. A new `bin/create-embed-test-post.php` wp-cli script is introduced. See [#829](https://github.com/Automattic/amp-wp/pull/829). Props kienstra, westonruter, ThierryA. -- Move: AMP Customizer into main Customizer. See [#819](https://github.com/Automattic/amp-wp/pull/819). Props kaitnyl, westonruter. -- Update: AMP HTML tags and attributes. A new `bin/amphtml-update.sh` bash script is introduced. See [#823](https://github.com/Automattic/amp-wp/pull/823). Props kienstra, ThierryA, westonruter. -- Fix: SoundCloud embed -- Fix: Polldaddy embed -- Fix: Playbuzz not working -- Fix: not allowed script tag +- Add support for the "page" post type, except when used as homepage or page for posts. A new `page.php` is introduced with template parts factored out (`html-start.php`, `header.php`, `footer.php`, `html-end.php`) and re-used from `single.php`. Note that AMP URLs will end in `?amp` instead of `/amp/`. See [#825](https://github.com/Automattic/amp-wp/pull/825). Props technosailor, ThierryA, westonruter. +- Add AMP post preview button alongside non-AMP preview button. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. +- Add ability to disable AMP on a per-post basis via toggle in publish metabox. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. +- Add AMP settings admin screen for managing which post types have AMP support, eliminating the requirement to add `add_post_type_support()` calls in theme or plugin. See [#811](https://github.com/Automattic/amp-wp/pull/811). Props ThierryA, westonruter. +- Add generator meta tag for AMP. See [#810](https://github.com/Automattic/amp-wp/pull/810). Props vaporwavre. +- Add code quality checking via phpcs, eslint, jscs, and jshint. See [#795](https://github.com/Automattic/amp-wp/pull/795). Props westonruter. +- Add autoloader to reduce complexity. See [#828](https://github.com/Automattic/amp-wp/pull/828). Props mikeschinkel, westonruter, ThierryA. +- Fix Polldaddy amd SoundCloud embeds. Add vanilla WordPress "embed" test page. A new `bin/create-embed-test-post.php` wp-cli script is introduced. See [#829](https://github.com/Automattic/amp-wp/pull/829). Props kienstra, westonruter, ThierryA. +- Merge AMP Customizer into main Customizer. See [#819](https://github.com/Automattic/amp-wp/pull/819). Props kaitnyl, westonruter. +- Update AMP HTML tags and attributes. A new `bin/amphtml-update.sh` bash script is introduced. Fixes Playbuzz. See [#823](https://github.com/Automattic/amp-wp/pull/823). Props kienstra, ThierryA, westonruter. +- Remove erroneous hash from id on amp-wp-header. See [#853](https://github.com/Automattic/amp-wp/pull/853). Props eshannon3. See [0.6 milestone](https://github.com/Automattic/amp-wp/milestone/5?closed=1). diff --git a/readme.txt b/readme.txt index 06dfd8daf9f..b50d10ec031 100644 --- a/readme.txt +++ b/readme.txt @@ -44,20 +44,17 @@ Follow along with or [contribute](https://github.com/Automattic/amp-wp/blob/deve = 0.6 (unreleased) = -- Add: support for the "page" post type, except when used as homepage or page for posts. A new `page.php` is introduced with template parts factored out (`html-start.php`, `header.php`, `footer.php`, `html-end.php`) and re-used from `single.php`. Note that AMP URLs will end in `?amp` instead of `/amp/`. See [#825](https://github.com/Automattic/amp-wp/pull/825). Props technosailor, ThierryA, westonruter. -- Add: AMP post preview button alongside non-AMP preview button. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. -- Add: ability to disable AMP on a per-post basis via toggle in publish metabox. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. -- Add: AMP settings admin screen for managing which post types have AMP support, eliminating the requirement to add `add_post_type_support()` calls in theme or plugin. See [#811](https://github.com/Automattic/amp-wp/pull/811). Props ThierryA, westonruter. -- Add: generator meta tag for AMP. See [#810](https://github.com/Automattic/amp-wp/pull/810). Props vaporwavre. -- Add: code quality checking via phpcs, eslint, jscs, and jshint. See [#795](https://github.com/Automattic/amp-wp/pull/795). Props westonruter. -- Add: autoloader to reduce complexity. See [#828](https://github.com/Automattic/amp-wp/pull/828). Props mikeschinkel, westonruter, ThierryA. -- Add: Vanilla WordPress "embed" test page. A new `bin/create-embed-test-post.php` wp-cli script is introduced. See [#829](https://github.com/Automattic/amp-wp/pull/829). Props kienstra, westonruter, ThierryA. -- Move: AMP Customizer into main Customizer. See [#819](https://github.com/Automattic/amp-wp/pull/819). Props kaitnyl, westonruter. -- Update: AMP HTML tags and attributes. A new `bin/amphtml-update.sh` bash script is introduced. See [#823](https://github.com/Automattic/amp-wp/pull/823). Props kienstra, ThierryA, westonruter. -- Fix: SoundCloud embed -- Fix: Polldaddy embed -- Fix: Playbuzz not working -- Fix: not allowed script tag +- Add support for the "page" post type, except when used as homepage or page for posts. A new `page.php` is introduced with template parts factored out (`html-start.php`, `header.php`, `footer.php`, `html-end.php`) and re-used from `single.php`. Note that AMP URLs will end in `?amp` instead of `/amp/`. See [#825](https://github.com/Automattic/amp-wp/pull/825). Props technosailor, ThierryA, westonruter. +- Add AMP post preview button alongside non-AMP preview button. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. +- Add ability to disable AMP on a per-post basis via toggle in publish metabox. See [#813](https://github.com/Automattic/amp-wp/pull/813). Props ThierryA, westonruter. +- Add AMP settings admin screen for managing which post types have AMP support, eliminating the requirement to add `add_post_type_support()` calls in theme or plugin. See [#811](https://github.com/Automattic/amp-wp/pull/811). Props ThierryA, westonruter. +- Add generator meta tag for AMP. See [#810](https://github.com/Automattic/amp-wp/pull/810). Props vaporwavre. +- Add code quality checking via phpcs, eslint, jscs, and jshint. See [#795](https://github.com/Automattic/amp-wp/pull/795). Props westonruter. +- Add autoloader to reduce complexity. See [#828](https://github.com/Automattic/amp-wp/pull/828). Props mikeschinkel, westonruter, ThierryA. +- Fix Polldaddy amd SoundCloud embeds. Add vanilla WordPress "embed" test page. A new `bin/create-embed-test-post.php` wp-cli script is introduced. See [#829](https://github.com/Automattic/amp-wp/pull/829). Props kienstra, westonruter, ThierryA. +- Merge AMP Customizer into main Customizer. See [#819](https://github.com/Automattic/amp-wp/pull/819). Props kaitnyl, westonruter. +- Update AMP HTML tags and attributes. A new `bin/amphtml-update.sh` bash script is introduced. Fixes Playbuzz. See [#823](https://github.com/Automattic/amp-wp/pull/823). Props kienstra, ThierryA, westonruter. +- Remove erroneous hash from id on amp-wp-header. See [#853](https://github.com/Automattic/amp-wp/pull/853). Props eshannon3. See [0.6 milestone](https://github.com/Automattic/amp-wp/milestone/5?closed=1). diff --git a/tests/test-amp.php b/tests/test-amp.php index 61515354745..19b68d9ad26 100644 --- a/tests/test-amp.php +++ b/tests/test-amp.php @@ -32,7 +32,7 @@ public function test_amp_is_canonical() { remove_theme_support( 'amp' ); add_theme_support( 'amp', array( - 'template_path' => get_template_directory() . 'amp-templates/', + 'template_dir' => 'amp-templates', ) ); $this->assertFalse( amp_is_canonical() );