Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ampproject/amp-wp into enhanceme…
Browse files Browse the repository at this point in the history
…nt/4070-validate-props

* 'develop' of github.com:ampproject/amp-wp: (108 commits)
  Update dependency semver to v7.1.2 (#4206)
  Update dependency @babel/core to v7.8.4 (#4199)
  Prevent errors in admin bar filters from non-array arguments (#4207)
  Discontinue preserving original style[amp-custom]
  Update dependency terser-webpack-plugin to v2.3.4 (#4189)
  Update dependency @babel/cli to v7.8.4 (#4198)
  Update dependency browserslist to v4.8.6 (#4196)
  Update dependency dealerdirect/phpcodesniffer-composer-installer to v0.6.2 (#4186)
  Split Reader mode style template part stylesheet from action-supplied styles
  Remove needless $xmlns_value_to_strip variable
  Fix PHPCS error
  Commit Weston's suggestion to use documentElement
  Use $html->hasAttributes to possibly exit early.
  If the html[lang] is "", overwrite it with the xml:lang
  Conditionally remove html[xmlns], and convert html[xml:lang] to html[lang]
  If head[profile=], strip profile, but don't create a new link
  Revert 7f60c5c (If there's already a link[rel=profile], don't create another
  Fix phpcs issues in failed Travis build
  If there's already a link[rel=profile], don't create another
  Convert head[profile] attribute to a link[rel=profile]
  ...
  • Loading branch information
westonruter committed Feb 1, 2020
2 parents fa1299e + d4de689 commit c4194fa
Show file tree
Hide file tree
Showing 42 changed files with 2,861 additions and 1,330 deletions.
10 changes: 6 additions & 4 deletions assets/css/src/admin-tables.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
color: #767676;
}

.column-sources .dashicons,
.column-sources_with_invalid_output .dashicons {
.source > .dashicons {
margin-right: 5px;
}

Expand All @@ -17,7 +16,6 @@
color: #ebb04f;
}

.column-source,
.dashicons-wordpress-alt,
.column-sources_with_invalid_output .dashicons-wordpress-alt {
color: #92b371;
Expand Down Expand Up @@ -58,10 +56,14 @@ td.column-found_elements_and_attributes div {

.column-sources .source,
.column-sources_with_invalid_output .source {
margin-bottom: 10px;
display: block;
}

.column-sources .source + .source,
.column-sources_with_invalid_output .source + .source {
margin-top: 8px;
}

.wrap .wp-heading-inline + .page-title-action {
margin-left: 1rem;
}
Expand Down
138 changes: 137 additions & 1 deletion assets/css/src/amp-validation-error-taxonomy.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ details[open] .details-attributes__summary {
}

.details-attributes__summary::after,
.single-error-detail-summary::after {
.single-error-detail-summary::after,
.toggle-stylesheet-details::after {
order: 99;
width: 12px;
height: 12px;
Expand All @@ -68,6 +69,7 @@ details[open] .details-attributes__summary {
}

tr.expanded .details-attributes__summary::after,
tr.expanded .toggle-stylesheet-details::after,
details[open] > .details-attributes__summary::after,
details[open] > .single-error-detail-summary::after {
transform: rotate(180deg);
Expand Down Expand Up @@ -362,3 +364,137 @@ body.taxonomy-amp_validation_error .wp-list-table .new th.check-column input {
font-weight: bold;
text-align: right;
}

/* Stylesheets */
.amp-stylesheet-summary {
margin-bottom: 1em;
}

.amp-stylesheet-summary th {
text-align: right;
padding-right: 1ex;
font-weight: normal;
}

.amp-stylesheet-summary td {
font-weight: bold;
text-align: right;
}

.stylesheet-details {
display: none;
}

.stylesheet.expanded + .stylesheet-details {
display: table-row;
}

.stylesheet-details dl.detailed {
margin-bottom: 0;
padding-bottom: 0;
}

.shaken-stylesheet {
display: block;
white-space: pre-wrap;
tab-size: 4;
background: none;
padding: 0;
margin: 0;
line-height: 1;
}

.shaken-stylesheet del,
.shaken-stylesheet ins {
display: block;
text-decoration: none;
padding: 1px 4px 1px 8px;
border-left: solid 4px #bbb;
}

.shaken-stylesheet.removed-styles-shown del {
border-left-color: #f00;
color: #888;
background: #fff9f9;
}

.shaken-stylesheet.removed-styles-shown ins {
border-left-color: #008000;
}

.shaken-stylesheet:not(.removed-styles-shown) del {
display: none;
}

.shaken-stylesheet .declaration-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}

#amp_stylesheets .amp-stylesheet-list th {
overflow-wrap: normal;
}

#amp_stylesheets .column-stylesheet_order {
width: 5%;
text-align: right;
}

#amp_stylesheets .column-original_size,
#amp_stylesheets .column-minified,
#amp_stylesheets .column-final_size,
#amp_stylesheets .column-percentage {
width: 10%;
text-align: right;
}

#amp_stylesheets .column-markup {
width: 10%;
white-space: nowrap;
}

#amp_stylesheets .column-origin {
width: 15%;
}

#amp_stylesheets .column-stylesheet_expand {
width: 12px;
}

#amp_stylesheets .column-priority {
width: 7%;
text-align: right;
}

#amp_stylesheets .column-stylesheet_status {
width: 5%;
white-space: nowrap;
text-align: center;
}

#amp_stylesheets .column-percentage {
text-align: center;
}

#amp_stylesheets .column-source {
width: 25%;
}

.toggle-stylesheet-details {
border: none;
background: none;
cursor: pointer;
}

.toggle-stylesheet-details::after {
display: block;
}

.stylesheet-origin-markup {
padding: 0;
}

#amp_stylesheets label {
user-select: none;
}
25 changes: 25 additions & 0 deletions assets/src/amp-validation/amp-validated-url-post-edit-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ domReady( () => {
handleStatusChange();
handleBulkActions();
watchForUnsavedChanges();
setupStylesheetsMetabox();
} );

let beforeUnloadPromptAdded = false;
Expand Down Expand Up @@ -376,3 +377,27 @@ const handleBulkActions = () => {
} );
} );
};

/**
* Set up stylesheet metabox.
*/
const setupStylesheetsMetabox = () => {
const metabox = document.getElementById( 'amp_stylesheets' );

for ( const toggleStylesheetDetailsButton of metabox.querySelectorAll( '.toggle-stylesheet-details' ) ) {
const row = toggleStylesheetDetailsButton.closest( 'tr' );
toggleStylesheetDetailsButton.addEventListener( 'click', () => {
row.classList.toggle( 'expanded' );
} );
}

for ( const stylesheetDetailsElements of metabox.querySelectorAll( '.stylesheet-details' ) ) {
const shakenStylesheetContainer = stylesheetDetailsElements.querySelector( '.shaken-stylesheet' );
const showRemovedStylesCheckbox = stylesheetDetailsElements.querySelector( '.show-removed-styles' );
if ( showRemovedStylesCheckbox ) {
showRemovedStylesCheckbox.addEventListener( 'click', () => {
shakenStylesheetContainer.classList.toggle( 'removed-styles-shown', showRemovedStylesCheckbox.checked );
} );
}
}
};
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"sabberworm/php-css-parser": "8.3.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "0.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "0.6.2",
"mikey179/vfsstream": "1.6.8",
"phpcompatibility/phpcompatibility-wp": "2.1.0",
"roave/security-advisories": "dev-master",
Expand Down
34 changes: 20 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 21 additions & 7 deletions includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,7 @@ function amp_get_content_sanitizers( $post = null ) {
],
'AMP_Block_Sanitizer' => [], // Note: Block sanitizer must come after embed / media sanitizers since its logic is using the already sanitized content.
'AMP_Script_Sanitizer' => [],
'AMP_Style_Sanitizer' => [
'include_manifest_comment' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'always' : 'when_excessive',
],
'AMP_Style_Sanitizer' => [],
'AMP_Meta_Sanitizer' => [],
'AMP_Layout_Sanitizer' => [],
'AMP_Tag_And_Attribute_Sanitizer' => [], // Note: This whitelist sanitizer must come at the end to clean up any remaining issues the other sanitizers didn't catch.
Expand All @@ -928,10 +926,26 @@ function amp_get_content_sanitizers( $post = null ) {
$sanitizers['AMP_Nav_Menu_Dropdown_Sanitizer'] = $theme_support_args['nav_menu_dropdown'];
}

if ( $amp_to_amp_linking_enabled ) {
$sanitizers['AMP_Link_Sanitizer'] = [
'paired' => ! amp_is_canonical(),
];
if ( $amp_to_amp_linking_enabled && AMP_Theme_Support::STANDARD_MODE_SLUG !== AMP_Theme_Support::get_support_mode() ) {

/**
* Filters the list of URLs which are excluded from being included in AMP-to-AMP linking.
*
* This only applies when the amp_to_amp_linking_enabled filter returns true,
* which it does by default in Transitional mode. This filter can be used to opt-in
* when in Reader mode. This does not apply in Standard mode.
* Only frontend URLs on the frontend need be excluded, as all other URLs are never made into AMP links.
*
* @since 1.5.0
*
* @param string[] The URLs to exclude from having AMP-to-AMP links.
*/
$excluded_urls = apply_filters( 'amp_to_amp_excluded_urls', [] );

$sanitizers['AMP_Link_Sanitizer'] = array_merge(
[ 'paired' => ! amp_is_canonical() ],
compact( 'excluded_urls' )
);
}

/**
Expand Down
1 change: 0 additions & 1 deletion includes/class-amp-autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class AMP_Autoloader {
'AMP_Story_Sanitizer' => 'includes/sanitizers/class-amp-story-sanitizer',
'AMP_Story_Export_Sanitizer' => 'includes/sanitizers/class-amp-story-export-sanitizer',
'AMP_Test_Stub_Sanitizer' => 'tests/php/stubs',
'AMP_Test_World_Sanitizer' => 'tests/php/stubs',
'AMP_Test_HandleValidation' => 'tests/php/validation/trait-handle-validation',
];

Expand Down
2 changes: 0 additions & 2 deletions includes/class-amp-story-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ static function( $sanitizers ) {
$slug = sanitize_title( $post->post_title, $post->ID );

$sanitizers['AMP_Story_Export_Sanitizer'] = self::get_export_args( $slug );

$sanitizers['AMP_Style_Sanitizer']['include_manifest_comment'] = 'never';
}
return $sanitizers;
},
Expand Down
Loading

0 comments on commit c4194fa

Please sign in to comment.