Amp-wp: Prevent plugin from removing styles for <amp-experiment> variants

Created on 24 Mar 2020  路  2Comments  路  Source: ampproject/amp-wp

Bug Description

When using <amp-experiment> plugin removes styles that are meant for experiments, for example body[amp-x-experimentName="experimentVariant"] { background: #000; }.
Styles are removed regardless of where they are added (theme's style.css / inline).

Expected Behaviour

Prevent plugin from removing styles that contain an attribute that starts with amp-x- OR add a possibility for adding custom styles that won't be removed by the plugin.

Steps to reproduce

  1. Create an experiment on a website with <amp-experiment>
  2. Style a variant as in documentation (https://amp.dev/documentation/components/amp-experiment/#style-a-variant) in theme's main stylesheet - style.css.
  3. Styles for variants are not being applied.

Additional context

  • WordPress version: 5.3.2
  • Plugin version: 1.4.4
  • AMP plugin template mode: Standard
  • PHP version: 7.2.24
  • OS: any
  • Browser: any
  • Device: any

_Do not alter or remove anything below. The following sections will be managed by moderators only._

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

Bug CSS

Most helpful comment

@westonruter I tested the fix and it works as expected. I tested this with styles put in Custom HTML block and custom CSS file. In both cases styles with amp-x-* attribute were applied properly, the plugin doesn't remove them.

All 2 comments

@bartesn @JacekKosciesza Please test the fix in this build: https://github.com/ampproject/amp-wp/pull/4438#issuecomment-603444246

@westonruter I tested the fix and it works as expected. I tested this with styles put in Custom HTML block and custom CSS file. In both cases styles with amp-x-* attribute were applied properly, the plugin doesn't remove them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luizeof picture luizeof  路  4Comments

miina picture miina  路  5Comments

maciejmackowiak picture maciejmackowiak  路  5Comments

westonruter picture westonruter  路  4Comments

westonruter picture westonruter  路  3Comments