Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ampproject/amp-wp into fix/3137-…
Browse files Browse the repository at this point in the history
…keep-attributes-with-mustache-placeholders-intact

* 'develop' of github.com:ampproject/amp-wp: (113 commits)
  This converts the keyboard cut handler to equal a copy handler to avoid bugs
  Fix aria-label adding helper function
  Remove extra line I added in resolving merge conflict
  Fix alignment of arrow
  Fix custom CTA text for page attachment
  Fix cut handler by shortcut
  Cleanup of duplicated comment
  Add unit testing to `addVideoAriaLabel`
  Remove unused piece of code
  Remove Cloudflare AMP cache since deprecated
  Handle cut keyboard requests. (#3231)
  Page Attachment block (#3035)
  Keyboard & Right-Click Menu Copy + Paste (#3083)
  Animation Previews (#3104)
  Make internal methods inaccessible
  Omit the ecosystem link also when using a core theme
  Add skipped e2e test for the video block
  Add array_colum() pollyfill for PHP < 5.5
  Add asserts to make sure we are not enqueueing both versions of dashicons
  Remove useless variable
  ...
  • Loading branch information
westonruter committed Sep 14, 2019
2 parents 3819ef1 + da5c94a commit 9b52059
Show file tree
Hide file tree
Showing 155 changed files with 8,569 additions and 2,989 deletions.
1 change: 0 additions & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/assets/css/*.css
/assets/css/src/admin-bar.css
/bin
/build
/tests
Expand Down
59 changes: 53 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,42 @@
module.exports = function( grunt ) {
'use strict';
require( 'dotenv' ).config();

// Root paths to include in the plugin build ZIP when running `npm run build`.
const productionIncludedRootFiles = [
'LICENSE',
'amp.php',
'assets',
'back-compat',
'includes',
'readme.txt',
'templates',
'vendor',
];

// These patterns paths will be excluded from among the above directory.
const productionExcludedPathPatterns = [
/.*\/src\/.*/,
/.*images\/stories-editor\/.*\.svg/,
];

// These will be removed from the vendor directory after installing but prior to creating a ZIP.
// ⚠️ Warning: These paths are passed straight to rm command in the shell, without any escaping.
const productionVendorExcludedFilePatterns = [
'composer.*',
'vendor/*/*/.editorconfig',
'vendor/*/*/.gitignore',
'vendor/*/*/composer.*',
'vendor/*/*/Doxyfile',
'vendor/*/*/LICENSE',
'vendor/*/*/phpunit.*',
'vendor/*/*/*.md',
'vendor/*/*/*.txt',
'vendor/*/*/*.yml',
'vendor/*/*/.*.yml',
'vendor/*/*/tests',
];

grunt.initConfig( {

pkg: grunt.file.readJSON( 'package.json' ),
Expand Down Expand Up @@ -32,6 +68,9 @@ module.exports = function( grunt ) {
verify_matching_versions: {
command: 'php bin/verify-version-consistency.php',
},
composer_install: {
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; cd build; composer install --no-dev -o && composer remove cweagans/composer-patches --update-no-dev -o && rm -r ' + productionVendorExcludedFilePatterns.join( ' ' ),
},
create_build_zip: {
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e amp.zip ]; then rm amp.zip; fi; cd build; zip -r ../amp.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/amp.zip"',
},
Expand Down Expand Up @@ -95,17 +134,24 @@ module.exports = function( grunt ) {
const versionAppend = new Date().toISOString().replace( /\.\d+/, '' ).replace( /-|:/g, '' ) + '-' + commitHash;

const paths = lsOutput.trim().split( /\n/ ).filter( function( file ) {
return ! /^(blocks|\.|bin|([^/]+)+\.(md|json|xml)|Gruntfile\.js|tests|wp-assets|readme\.md|composer\..*|patches|webpack.*|assets\/images\/stories-editor\/.*\.svg|assets\/src|assets\/css\/src|docker-compose\.yml|.*\.config\.js|codecov\.yml|example\.env)/.test( file );
const topSegment = file.replace( /\/.*/, '' );
if ( ! productionIncludedRootFiles.includes( topSegment ) ) {
return false;
}

for ( const productionExcludedPathPattern of productionExcludedPathPatterns ) {
if ( productionExcludedPathPattern.test( file ) ) {
return false;
}
}

return true;
} );

paths.push( 'vendor/autoload.php' );
paths.push( 'composer.*' ); // Copy in order to be able to do run composer_install.
paths.push( 'assets/js/*.js' );
paths.push( 'assets/js/*.deps.json' );
paths.push( 'assets/css/*.css' );
paths.push( 'vendor/composer/**' );
paths.push( 'vendor/sabberworm/php-css-parser/lib/**' );
paths.push( 'vendor/fasterimage/fasterimage/src/**' );
paths.push( 'vendor/willwashburn/stream/src/**' );

grunt.config.set( 'copy', {
build: {
Expand Down Expand Up @@ -138,6 +184,7 @@ module.exports = function( grunt ) {
} );
grunt.task.run( 'readme' );
grunt.task.run( 'copy' );
grunt.task.run( 'shell:composer_install' );

done();
}
Expand Down
28 changes: 26 additions & 2 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://amp-wp.org
* Author: AMP Project Contributors
* Author URI: https://github.com/ampproject/amp-wp/graphs/contributors
* Version: 1.2.3-alpha
* Version: 1.3-alpha
* Text Domain: amp
* Domain Path: /languages/
* License: GPLv2 or later
Expand All @@ -15,7 +15,7 @@

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__VERSION', '1.2.3-alpha' );
define( 'AMP__VERSION', '1.3-alpha' );

/**
* Errors encountered while loading the plugin.
Expand Down Expand Up @@ -241,6 +241,29 @@ function _amp_incorrect_plugin_slug_admin_notice() {
add_action( 'admin_notices', '_amp_incorrect_plugin_slug_admin_notice' );
}

/**
* Print admin notice if the Xdebug extension is loaded.
*
* @since 1.3
*/
function _amp_xdebug_admin_notice() {
?>
<div class="notice notice-warning">
<p>
<?php
esc_html_e(
'Your server currently has the Xdebug PHP extension loaded. This can cause some of the AMP plugin\'s processes to timeout depending on your system resources and configuration. Please deactivate Xdebug for the best experience.',
'amp'
);
?>
</p>
</div>
<?php
}
if ( extension_loaded( 'xdebug' ) ) {
add_action( 'admin_notices', '_amp_xdebug_admin_notice' );
}

require_once AMP__DIR__ . '/includes/class-amp-autoloader.php';
AMP_Autoloader::register();

Expand Down Expand Up @@ -466,6 +489,7 @@ function amp_maybe_add_actions() {

// Prevent infinite URL space under /amp/ endpoint.
global $wp;
$path_args = [];
wp_parse_str( $wp->matched_query, $path_args );
if ( isset( $path_args[ amp_get_slug() ] ) && '' !== $path_args[ amp_get_slug() ] ) {
wp_safe_redirect( amp_get_permalink( $post->ID ), 301 );
Expand Down
Loading

0 comments on commit 9b52059

Please sign in to comment.