Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into enhancement/2204-d…
Browse files Browse the repository at this point in the history
…efault-amp-endpoint

# Conflicts:
#	amp.php
#	includes/amp-helper-functions.php
#	includes/class-amp-theme-support.php
#	includes/options/class-amp-options-manager.php
#	includes/validation/class-amp-validated-url-post-type.php
  • Loading branch information
pierlon committed Mar 9, 2020
2 parents 8ecb280 + 7460a0e commit 9455eaa
Show file tree
Hide file tree
Showing 848 changed files with 29,454 additions and 37,078 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/assets/js/*.js
!assets/js/amp-service-worker-runtime-precaching.js
build/*
lib/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ built
/amphtml
.env
.idea/
/lib/*/vendor/
/lib/*/composer.lock
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/build
/tests
/vendor
/lib/optimizer
/lib/common
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,21 @@ jobs:
- bash <(curl -s https://codecov.io/bash) -cF php -f /tmp/wordpress/src/wp-content/plugins/amp/build/logs/clover.xml
- npm run test:js -- --collectCoverage
- bash <(curl -s https://codecov.io/bash) -cF javascript -f build/logs/lcov.info

- name: Libraries that are meant to be externalized (5.6)
php: "5.6"
install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
script:
- composer --working-dir=lib/common test
- composer --working-dir=lib/optimizer test

- name: Libraries that are meant to be externalized (7.3)
php: "7.3"
install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
script:
- composer --working-dir=lib/common test
- composer --working-dir=lib/optimizer test
48 changes: 15 additions & 33 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ module.exports = function( grunt ) {
// 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.*',
'patches',
'lib',
'vendor/*/*/.editorconfig',
'vendor/*/*/.git',
'vendor/*/*/.gitignore',
'vendor/*/*/composer.*',
'vendor/*/*/Doxyfile',
Expand All @@ -39,6 +40,10 @@ module.exports = function( grunt ) {
'vendor/*/*/*.yml',
'vendor/*/*/.*.yml',
'vendor/*/*/tests',
'vendor/ampproject/optimizer/bin',
'vendor/bin',
'vendor/ampproject/common/vendor',
'vendor/ampproject/optimizer/vendor',
];

grunt.initConfig( {
Expand Down Expand Up @@ -68,7 +73,14 @@ module.exports = function( grunt ) {
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( ' ' ),
command: [
'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi',
'cd build',
'composer install --no-dev -o',
'for symlinksource in $(find vendor/ampproject -type l); do symlinktarget=$(readlink "$symlinksource") && rm "$symlinksource" && cp -r "vendor/ampproject/$symlinktarget" "$symlinksource"; done',
'composer remove cweagans/composer-patches --update-no-dev -o',
'rm -r ' + productionVendorExcludedFilePatterns.join( ' ' )
].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 All @@ -85,22 +97,13 @@ module.exports = function( grunt ) {
},
},
},
http: {
google_fonts: {
options: {
url: 'https://www.googleapis.com/webfonts/v1/webfonts?fields=items&prettyPrint=false&key=' + process.env.GOOGLE_FONTS_API_KEY,
},
dest: 'includes/data/fonts.json',
},
},
} );

// Load tasks.
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-shell' );
grunt.loadNpmTasks( 'grunt-wp-deploy' );
grunt.loadNpmTasks( 'grunt-http' );

// Register tasks.
grunt.registerTask( 'default', [
Expand Down Expand Up @@ -148,6 +151,7 @@ module.exports = function( grunt ) {
} );

paths.push( 'composer.*' ); // Copy in order to be able to do run composer_install.
paths.push( 'lib/**' );
paths.push( 'assets/js/*.js' ); // @todo Also include *.map files?
paths.push( 'assets/js/*.asset.php' );
paths.push( 'assets/css/*.css' );
Expand Down Expand Up @@ -210,28 +214,6 @@ module.exports = function( grunt ) {
doNext();
} );

grunt.registerTask( 'process-fonts', function() {
const fileName = 'includes/data/fonts.json';
let map = grunt.file.readJSON( fileName );
map = JSON.stringify( map );
map = JSON.parse( map );
if ( map ) {
const stripped = map.items.map( ( font ) => {
return {
family: font.family,
variants: font.variants,
category: font.category,
};
} );
grunt.file.write( fileName, JSON.stringify( stripped ) );
}
} );

grunt.registerTask( 'download-fonts', [
'http',
'process-fonts',
] );

grunt.registerTask( 'create-build-zip', [
'shell:create_build_zip',
] );
Expand Down
32 changes: 14 additions & 18 deletions amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__DIR__', __DIR__ );
define( 'AMP__VERSION', '1.5.0-alpha' );

/**
Expand Down Expand Up @@ -45,8 +45,10 @@
'curl' => array(
'functions' => array(
'curl_close',
'curl_errno',
'curl_error',
'curl_exec',
'curl_getinfo',
'curl_init',
'curl_setopt',
),
Expand Down Expand Up @@ -373,26 +375,20 @@ function amp_init() {
add_action( 'wp_loaded', 'amp_add_options_menu' );
add_action( 'wp_loaded', 'amp_bootstrap_admin' );

if ( AMP_Options_Manager::is_website_experience_enabled() ) {
amp_set_rewrite_rule();
AMP_Post_Type_Support::add_post_type_support();
add_action( 'init', array( 'AMP_Post_Type_Support', 'add_post_type_support' ), 1000 ); // After post types have been defined.
add_action( 'admin_bar_menu', 'amp_add_admin_bar_view_link', 100 );
add_action( 'wp_loaded', 'amp_editor_core_blocks' );
amp_set_rewrite_rule();
AMP_Post_Type_Support::add_post_type_support();
add_action( 'init', array( 'AMP_Post_Type_Support', 'add_post_type_support' ), 1000 ); // After post types have been defined.
add_action( 'admin_bar_menu', 'amp_add_admin_bar_view_link', 100 );
add_action( 'wp_loaded', 'amp_editor_core_blocks' );
add_action( 'amp_plugin_update', 'remove_amp_story_templates' );

if ( ! is_amp_url_overridden() ) {
add_action( 'parse_query', 'amp_correct_query_when_is_front_page' );
add_filter( 'request', 'amp_force_query_var_value' );
}

// Redirect the old url of amp page to the updated url.
add_filter( 'old_slug_redirect_url', 'amp_redirect_old_slug_to_new_url' );
if ( ! is_amp_url_overridden() ) {
add_action( 'parse_query', 'amp_correct_query_when_is_front_page' );
add_filter( 'request', 'amp_force_query_var_value' );
}

AMP_Story_Post_Type::register();

// Does its own is_stories_experience_enabled() check.
add_action( 'wp_loaded', 'amp_story_templates' );
// Redirect the old url of amp page to the updated url.
add_filter( 'old_slug_redirect_url', 'amp_redirect_old_slug_to_new_url' );

if ( defined( 'WP_CLI' ) && WP_CLI ) {
if ( class_exists( 'WP_CLI\Dispatcher\CommandNamespace' ) ) {
Expand Down
16 changes: 0 additions & 16 deletions assets/css/src/amp-block-editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@
display: none;
}

/* Latest Stories block */
.amp-block-latest-stories > .latest-stories-carousel {
display: flex;
flex-wrap: nowrap;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
overflow-y: hidden;
margin: 0;
padding: 0;
}

.latest-stories-carousel .latest-stories__slide {
flex: 0 0 auto;
margin-right: 1rem;
}

/* AMP preview button wrapper */
.wp-core-ui #amp-wrapper-post-preview {
margin-left: -6px;
Expand Down
165 changes: 0 additions & 165 deletions assets/css/src/amp-stories-frontend.css

This file was deleted.

Loading

0 comments on commit 9455eaa

Please sign in to comment.