Skip to content

Commit

Permalink
804 : Merge in develop, resolve conflicts.
Browse files Browse the repository at this point in the history
In phpcs.xml, retain edits from both branches.
There were several conflicts in:
class-amp-tag-and-attribute-sanitizer.php
These were mainly conflicts with 03c12.
Some were only DocBlocks, but some were logic.
I mainly resovled them in favor of this branch:
feature/804-allowed-tags.
  • Loading branch information
Ryan Kienstra committed Dec 11, 2017
2 parents ed3c93d + b94b10b commit c3b28c0
Show file tree
Hide file tree
Showing 72 changed files with 4,752 additions and 1,147 deletions.
2 changes: 2 additions & 0 deletions .dev-lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SYNC_README_MD=0
PATH_EXCLUDES_PATTERN=includes/lib/*
116 changes: 84 additions & 32 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
* Plugin URI: https://github.com/automattic/amp-wp
* Author: Automattic
* Author URI: https://automattic.com
* Version: 0.5.1
* Version: 0.6.0-alpha
* Text Domain: amp
* Domain Path: /languages/
* License: GPLv2 or later
*
* @package AMP
*/

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '0.5.1' );
define( 'AMP__VERSION', '0.6.0-alpha' );

require_once( AMP__DIR__ . '/back-compat/back-compat.php' );
require_once( AMP__DIR__ . '/includes/amp-helper-functions.php' );
require_once( AMP__DIR__ . '/includes/admin/functions.php' );
require_once( AMP__DIR__ . '/includes/admin/class-amp-customizer.php' );
require_once( AMP__DIR__ . '/includes/settings/class-amp-customizer-settings.php' );
require_once( AMP__DIR__ . '/includes/settings/class-amp-customizer-design-settings.php' );
require_once AMP__DIR__ . '/includes/class-amp-autoloader.php';
AMP_Autoloader::register();

require_once( AMP__DIR__ . '/includes/actions/class-amp-frontend-actions.php' );
require_once( AMP__DIR__ . '/includes/actions/class-amp-paired-post-actions.php' );
require_once AMP__DIR__ . '/back-compat/back-compat.php';
require_once AMP__DIR__ . '/includes/amp-helper-functions.php';
require_once AMP__DIR__ . '/includes/admin/functions.php';

register_activation_hook( __FILE__, 'amp_activate' );
function amp_activate() {
amp_after_setup_theme();
if ( ! did_action( 'amp_init' ) ) {
amp_init();
}
Expand All @@ -47,20 +47,55 @@ function amp_deactivate() {
flush_rewrite_rules();
}

add_action( 'init', 'amp_init' );
function amp_init() {
/**
* Set up AMP.
*
* This function must be invoked through the 'after_setup_theme' action to allow
* the AMP setting to declare the post types support earlier than plugins/theme.
*
* @since 0.6
*/
function amp_after_setup_theme() {
if ( false === apply_filters( 'amp_is_enabled', true ) ) {
return;
}

define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
if ( ! defined( 'AMP_QUERY_VAR' ) ) {
/**
* Filter the AMP query variable.
*
* @since 0.3.2
* @param string $query_var The AMP query variable.
*/
define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
}

add_action( 'init', 'amp_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' );
AMP_Post_Type_Support::add_post_type_support();
}
add_action( 'after_setup_theme', 'amp_after_setup_theme', 5 );

/**
* Init AMP.
*
* @since 0.1
*/
function amp_init() {

/**
* Triggers on init when AMP plugin is active.
*
* @since 0.3
*/
do_action( 'amp_init' );

load_plugin_textdomain( 'amp', false, plugin_basename( AMP__DIR__ ) . '/languages' );

add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK );
add_post_type_support( 'post', AMP_QUERY_VAR );

add_filter( 'request', 'amp_force_query_var_value' );
add_action( 'wp', 'amp_maybe_add_actions' );
Expand Down Expand Up @@ -111,7 +146,7 @@ function amp_maybe_add_actions() {
}

function amp_load_classes() {
require_once( AMP__DIR__ . '/includes/class-amp-post-template.php' ); // this loads everything else
_deprecated_function( __FUNCTION__, '0.6.0' );
}

function amp_add_frontend_actions() {
Expand All @@ -127,24 +162,47 @@ function amp_prepare_render() {
add_action( 'template_redirect', 'amp_render' );
}

/**
* Render AMP for queried post.
*
* @since 0.1
*/
function amp_render() {
$post_id = get_queried_object_id();
amp_render_post( $post_id );
exit;
}

function amp_render_post( $post_id ) {
$post = get_post( $post_id );
if ( ! $post ) {
return;
// Note that queried object is used instead of the ID so that the_preview for the queried post can apply.
$post = get_queried_object();
if ( $post instanceof WP_Post ) {
amp_render_post( $post );
exit;
}
}

amp_load_classes();
/**
* Render AMP post template.
*
* @since 0.5
* @param WP_Post|int $post Post.
*/
function amp_render_post( $post ) {

if ( ! ( $post instanceof WP_Post ) ) {
$post = get_post( $post );
if ( ! $post ) {
return;
}
}
$post_id = $post->ID;

/**
* Fires before rendering a post in AMP.
*
* @since 0.2
*
* @param int $post_id Post ID.
*/
do_action( 'pre_amp_render_post', $post_id );

amp_add_post_template_actions();
$template = new AMP_Post_Template( $post_id );
$template = new AMP_Post_Template( $post );
$template->load();
}

Expand Down Expand Up @@ -182,9 +240,3 @@ function amp_redirect_old_slug_to_new_url( $link ) {

return $link;
}

// Unconditionally load code required when running unit tests.
if ( function_exists( 'tests_add_filter' ) ) {
amp_load_classes();
require_once dirname( __FILE__ ) . '/tests/stubs.php';
}
61 changes: 61 additions & 0 deletions assets/css/amp-post-meta-box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* 1.0 AMP preview.
*
* Submit box preview buttons.
*/

/* Core preview button */
.wp-core-ui #preview-action.has-amp-preview #post-preview {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
float: none;
}

/* AMP preview button */
.wp-core-ui #amp-post-preview.preview {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
text-indent: -9999px;
padding-right: 7px;
padding-left: 7px;
}

.wp-core-ui #amp-post-preview.preview::after {
content: "icon";
width: 14px;
float: left;
background: no-repeat center url( '../images/amp-icon.svg' );
background-size: 14px !important;
}

.wp-core-ui #amp-post-preview.preview.disabled::after {
opacity: 0.6;
}

/* AMP status */
.misc-amp-status .amp-icon {
float: left;
background: transparent url( '../images/amp-icon.svg' ) no-repeat left;
background-size: 17px;
width: 17px;
height: 17px;
margin: 0 8px 0 1px;
}

#amp-status-select fieldset {
margin: 7px 0 0 1px;
}

#amp-status-select .notice {
margin: 10px 0 -5px 3px;
}

.amp-status-actions {
margin-top: 10px;
}

@media screen and ( max-width: 782px ) {
#amp-status-select {
line-height: 280%;
}
}
7 changes: 7 additions & 0 deletions assets/images/amp-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c3b28c0

Please sign in to comment.