• I tried upgrading from 2.15.0 to 2.16.4 and the plugin is now stripping away CSS from the “Additional Content” field as well as some tags.

    I basically had the login page formatted with divs and buttons within that area and with the upgrade, they get wiped out.

    I restored from a backup, but can you fix is so that the plugin isn’t modifying the “Additional Content” field?

    Thanks in advance!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Phil

    (@philsbury)

    Hi @wpfunfan,

    Can you send a link to the site?

    The update has deliberately done that as there was a tiny security issue with the field (a little long winded to actually make it vulnerable, but needed addressing).

    You can add elements though that you want to allow via a filter so if I can get eyes on what you’ve got in there I can give you a solid answer on how to let stuff through.

    Thanks
    Phil

    Thread Starter wpfunfan

    (@wpfunfan)

    Basically, I needed the warning text to come before the button, so I hid the original button via CSS and then put this in the “Additional Content” area.

    <div class="age-gate-warning-logo-container"><img src="/logo.png" class="age-gate-warning-logo"></div><div class="age-gate-warning-headline">NOTICE: This is an adult web site. All performers depicted on this web site were over 18 years of age at the time of the production. The content is inappropriate for minors and appropriate care should be taken to ensure that it is not viewed by anyone under 18 years of age. </div>
    <div class="age-gate-terms">By entering the website, you agree to our <a href="/termsofuse.html" target="_blank"><span style="white-space:nowrap;">terms of use</span></a> and <a href="/privacypolicy.html" target="_blank"><span style="white-space:nowrap;">privacy policy</span></a> and represent that you are of legal age in your community to view adult-oriented material.</div>
      <button type="submit" value="1" name="age_gate[confirm]" class="age-gate-submit-yes-new">Enter Super Flex<span style="font-size:14px;position:relative;top:-8px;">TM</span></button>

    Thanks in advance for your help and for the great plugin!

    Plugin Author Phil

    (@philsbury)

    Hi @wpfunfan,

    Thanks for this.

    I think you might have made things a little more complicated than you need to.

    If you just want to move the additional content above the buttons, you can do it with some css. You can find it in this thread, but I’ll put it below too as there’s a couple of other things you’ll need I think and I’ll add a couple more solutions after that too;

    Method 1: Using css and a couple of tweaks

    .age-gate-form {
      display: flex;
      flex-flow: row wrap;
      justify-content: center;
    }
    
    .age-gate-heading,
    .age-gate-subheading,
    .age-gate-challenge,
    .age-gate-error,
    .age-gate-remember-wrapper,
    .age-gate-additional-information {
      flex: 0 0 100%;
      max-width: 100%;
    }
    
    .age-gate-heading,
    .age-gate-subheading,
    .age-gate-challenge,
    .age-gate-error {
      order: 0;
    }
    
    .age-gate-additional-information {
      order: 1;
    }
    
    .age-gate-remember-wrapper,
    .age-gate-submit-yes,
    .age-gate-submit-no {
      order: 2;
    }
    
    /* you want to hide the "no" button I think */
    .age-gate-submit-no {
        display: none;
    }
    
    /* You've also got no wrap on links, do that in a non intrusive way */
    .age-gate-additional-information a {
        white-space: nowrap;
    }

    You then need the TM text. You don’t need a span with style for this, there’s an html entity, so in the age gate settings you can just change the text on the yes button to:

    Enter Super Flex&trade;

    Also, be mindful when using target="_blank" as it poses security issues – essentially add rel="noopener noreferrer" to any target="_blank".

    Option 2: Keep it as is

    If you want to just keep things as they are, then you can allow your markup. You’ll need a couple of filters in your functions.php:

    The first allows the inline style you’ve used – personally, I’d move any style to a stylesheet, but your call:

    add_filter('safe_style_css', function ($styles) {
        $styles[] = 'white-space';
        $styles[] = 'top';
        $styles[] = 'position';
        return $styles;
    });

    Then, allow the elements through the Age Gate filter:

    add_filter('age_gate/presentation/allowed_tags', function ($allowed) {
        return array_merge(
            $allowed,
            [
                'div'       => [
                    'class' => [],
    
                ],
                'span' => [
                    'class' => [],
                    'style' => []
                ],
                'button' => [
                    'type' => [],
                    'value' => [],
                    'name' => [],
                    'class' => [],
                ],
                'a'         => [
                    'href'  => [],
                    'title' => [],
                    'class' => [],
                    'target' => [],
                    'rel' => [],
                    'style' => [],
                ],
            ]
        );
    });

    Option 3: filter the messages

    A final option is to use one of the content filters and still hide everything else (either with css, filters, or setting them to empty text) for example:

    add_filter('age_gate_messaging', function () {
        return '<div class="age-gate-warning-logo-container"><img src="/logo.png" class="age-gate-warning-logo"></div><div class="age-gate-warning-headline">NOTICE: This is an adult web site. All performers depicted on this web site were over 18 years of age at the time of the production. The content is inappropriate for minors and appropriate care should be taken to ensure that it is not viewed by anyone under 18 years of age.</div><div class="age-gate-terms">By entering the website, you agree to our <a href="/termsofuse.html" target="_blank"><span style="white-space:nowrap;">terms of use</span></a> and <a href="/privacypolicy.html" target="_blank"><span style="white-space:nowrap;">privacy policy</span></a> and represent that you are of legal age in your community to view adult-oriented material.</div><button type="submit" value="1" name="age_gate[confirm]" class="age-gate-submit-yes-new">Enter Super Flex<span style="font-size:14px;position:relative;top:-8px;">TM</span></button>';
    });

    One of those should work for you, but let me know if anything doesn’t make sense!

    Thanks
    Phil

    Hi there, I’ve noticed this is striping the additional content area of any HTML tags. I’m just trying to apply some line breaks to help break up the text we need to have in this area. It strips out paragraph or even line break tags too.

    Any way to make it recognize either of those?

    PS. “Enable quicktags” is turned on too.

    Thank you!

    • This reply was modified 3 years, 7 months ago by SoloAnt.
    Plugin Author Phil

    (@philsbury)

    Hi @soloant,

    A single <br> should work ok, but you’re right, p tags are getting stripped when they shouldn’t, and a double br WordPress is converting to a p then removing :/.

    I’ll try and get a patch out over the weekend to fix it.

    Will keep you posted.

    Thanks
    Phil

    Plugin Author Phil

    (@philsbury)

    @soloant,

    If you’re super in need of it, add this to your functions.php:

    add_filter('age_gate/presentation/allowed_tags', function ($allowed) {
        return array_merge(
            $allowed,
            [
                'p'       => [
                    'class' => [],
    
                ],
            ]
        );
    });

    Thanks
    Phil

    Hi Phil, I see you pushed a quick fix before I even needed to add the function—it’s working again now.

    Thank you!

    Thread Starter wpfunfan

    (@wpfunfan)

    Option #2 worked great for me. I tried #1, but the styling was still off, so rather than futz with it, I moved on to #2 and everything matched exactly as it had been. — I wanted to be prudent and update the staging server before testing out the plugin update. That’s why it took me a bit to get back to you.

    Anyway, thanks again for the great plugin and your excellent tech support! (I donated $25 USD.)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Stripping tags from “Additional Content”’ is closed to new replies.