ID, AMP_Post_Meta_Box::STATUS_POST_META_KEY, true ) ) { case AMP_Post_Meta_Box::ENABLED_STATUS: return true; case AMP_Post_Meta_Box::DISABLED_STATUS: return false; // Disabled by default for custom page templates, page on front and page for posts. default: $enabled = ( ! (bool) get_page_template_slug( $post ) && ! ( 'page' === $post->post_type && 'page' === get_option( 'show_on_front' ) && in_array( (int) $post->ID, array( (int) get_option( 'page_on_front' ), (int) get_option( 'page_for_posts' ), ), true ) ) ); /** * Filters whether default AMP status should be enabled or not. * * @since 0.6 * * @param string $status Status. * @param WP_Post $post Post. */ return apply_filters( 'amp_post_status_default_enabled', $enabled, $post ); } } /** * Are we currently on an AMP URL? * * Note: will always return `false` if called before the `parse_query` hook. * * @return bool Whether it is the AMP endpoint. */ function is_amp_endpoint() { 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' ); } return false !== get_query_var( AMP_QUERY_VAR, false ); } /** * Get AMP asset URL. * * @param string $file Relative path to file in assets directory. * @return string URL. */ function amp_get_asset_url( $file ) { return plugins_url( sprintf( 'assets/%s', $file ), AMP__FILE__ ); }