Is it possible to add Content Warning popup for Products?

Hiya!

So I'm going to be building a MarketPress store that will end up having some "mature readers" books with explicit content in them. The adult-only content MAY be previewed in the image gallery that is shown, and so I would like some way for a content warning popup to show up if someone chooses one of these products.

I found this Content Warning plugin, and it's decent for the most part. It protects certain pages/posts, but I also noticed it works for Categories too. I was HOPING it would work with any category (including MarketPress products)...but it looks like it only lists options for published POST categories.

So is there a way I can add a content warning popup for Products in Marketpress? Or perhaps maybe there's a way to tweak this Content Warning plugin to recognize product categories?

Thanks!

  • Tyler Postle

    Hey Anton,

    You can actually use our Popup Pro plugin for this :slight_smile:

    https://premium.wpmudev.org/project/the-pop-over-plugin/

    You will need to activate the "custom taxonomies" conditional via:

    PopUp > Settings. As seen in my screenshot.

    Then you need to define the custom taxonomy you want it to use, in the wp-config.php file:

    define("POP_UP_TAXONOMY", "product_category");

    Now when you create your popup, select "On custom taxonomy" and you will be able to select the product category taxonomies from there as well choose whether it's just on the single product pages or to show the popup on archive pages as well.

    Hope that helps! Let me know if you have any further questions :slight_smile:

    Cheers,
    Tyler

  • Anton

    @Tyler Postle -

    That's great! I didn't know Popup Pro could be used with custom taxonomies. :slight_smile:

    So does the popup appear when you're taken to the product page? That's fine, but....only if:
    1). I'm able to add two buttons (one if a user clicks OK to view the product, and the other if a user is not ok with viewing the product, in which case the button takes them back to main product page). I'm assuming this is possible?
    2). I know the popups can be customized, appearance-wise -- but can you add a background overlay to obscure the screen?

    Thanks.

  • Anton

    @Tyler Postle -

    Ok, so I added Popup Pro, added the custom taxonomy to wp-config, and am playing around with it.

    I see that there's a Call to Action button, but I really need to have two. I suppose I can make the first one just a link within the popup text, saying that if you're under 18 or not ok with adult content please click here, while the actual button is reserved for the "Enter" part. However, what do I put as the button URL? I don't want people redirected elsewhere -- I just want the popup dismissed. Will just a "#" do the trick? (It doesn't work in the preview)

    And then I still need to make sure the background is obscured when the popup comes up. I can make the popup really big, but I want to keep it responsive too -- so a custom size doesn't work. (I thought maybe using percentages could do the trick, but they don't seem to work -- at least in the preview).

    Some kind of dark overlay behind the popup but over the product would be best. Is there some CSS that could work here for that?

    Any help would be greatly appreciated. Thanks!

  • Anton

    @Tyler Postle -

    Ok, so....I'm doing more tests, and there are still a few issues:

    1). Making the button hyperlink just "#" doesn't dismiss the popup. How can I add a button that also acts as a dismiss? (I know the "x" in the corner does it, but I'd rather have something more obvious)

    2). I'm still trying to figure out how to target the background overlay in order to make it darker. When I inspect the element, it always shows it with a class of something like "wpdu-16868" or some number (I feel like it changes, but so far it's stayed this last number for a while). It also shows it having a background color value of "rgba(0, 0, 0, 0.5)". If I click this off, it disappears. If I change the value to "rgba(0, 0, 0, 0.9)", it darkens the way I want it to. But if I try and target that same class and use "background: rgba(0, 0, 0, 0.9);", nothing happens -- even if I use "!important".
    I thought maybe the number appended to the class was changing, but when I inspect it again, it's the same. So how can I actually target the background overlay to make it darker??? It's driving me crazy...

    3). When I set up the popup exactly as you described (including adding the line in wp-config), and select "On custom taxonomy," it then has the field "Show on these post taxonomies:" -- but "Products" isn't an option. If I try and type it in, it shows no results. So I just left it blank to see what would happen, and....the popup didn't work. I then clicked on "Singular" when it says "Show on these taxonomy type URLs:", just for the hell of it, and....suddenly the popup appeared!! But now it appears when simply going to the homepage, or any Singular page. I want it to appear ONLY when clicking on Products with the "Mature Readers" category. How can I make this happen? And why aren't "Products" showing up in the "Show on these post taxonomies" field?

    4). When the popup DOES appear, there's a bit of a delay -- even though I select it to appear in 0 seconds, with no animation. I was hoping it would be instantaneous. Is there any way to make it appear even quicker?

    5). Ever since I added this popup and added the line to wp-config, I've been getting these "Resolving host timed out" or "Operation timed out after 5000 milliseconds with 0 bytes received" error messages on the backend whenever I save anything (see attached). I'm not 100% it's related to adding the popup, but the timing is curious, and I haven't really done anything else unusual. It doesn't seem to affect anything, and any changes are still being made -- but the error messages persist, and are annoying. There was one time it took me to a totally different page where it said the database timed out or something (I didn't write it down). It took a few back clicks and refreshes until things looked normal again.
    Any idea of what's going on here, and how I can stop the messages?

    Thanks in advance for any help you can give!

  • Tyler Postle

    Hey Anton,

    1). Making the button hyperlink just "#" doesn't dismiss the popup. How can I add a button that also acts as a dismiss? (I know the "x" in the corner does it, but I'd rather have something more obvious)

    This would require some custom Js to achieve. I think a workaround we could do to avoid that would be change the text of "Never see this message again" to "I AM 18" and then style that to be more of a button. Would that work? Then the call to action can be the button to go to a different page if they aren't 18.

    2). I'm still trying to figure out how to target the background overlay in order to make it darker. When I inspect the element, it always shows it with a class of something like "wpdu-16868" or some number (I feel like it changes, but so far it's stayed this last number for a while).

    I was seeing this problem on your site as well, I think changing the loading method to "Page Footer" would fix this; however, when I tried to get to the settings I got a 500 internal server error on your site. This is likely related to the operation timeout errors you were seeing before. That error usually indicates a lack of memory and/or your timeout limit being too small.

    However, your timeout looks to be 3600 seconds, which is very high. In that case, it's likely you have a process that won't stop running for at least an hour and it's draining server resources. You will want to reduce the max execution time to something more reasonable like 30-60 seconds.

    We have a blog post that covers increasing execution time and memory: https://premium.wpmudev.org/blog/increase-memory-limit/

    If that fails, ask your web host and they should be able to help you out :slight_smile:

    3). When I set up the popup exactly as you described (including adding the line in wp-config), and select "On custom taxonomy," it then has the field "Show on these post taxonomies:" -- but "Products" isn't an option.

    Make sure the constant is pasted in exactly as follows:

    define("POP_UP_TAXONOMY", "product_category");

    "product_category" is not a placeholder, that's the name of the custom taxonomy and for it to know which categories to pull it need to know that specific taxonomy.

    4). When the popup DOES appear, there's a bit of a delay -- even though I select it to appear in 0 seconds, with no animation. I was hoping it would be instantaneous. Is there any way to make it appear even quicker?

    This is how the Popup is meant to work. The page loads first. Sounds like you are wanting a solution that would load just the popup or redirect to it first before loading the page. In that case, unfortunately you may want to look for some alternatives. It would require fairly big customizations to the loading methods in order to load it that way.

    5). Ever since I added this popup and added the line to wp-config, I've been getting these "Resolving host timed out" or "Operation timed out after 5000 milliseconds with 0 bytes received" error messages on the backend whenever I save anything (see attached).

    See my response for #2 :slight_smile: that should cover this part as well.

    Look forward to hearing back!

    Cheers,
    Tyler

  • Anton

    Thanks for the reply, @Tyler Postle

    This would require some custom Js to achieve. I think a workaround we could do to avoid that would be change the text of "Never see this message again" to "I AM 18" and then style that to be more of a button. Would that work? Then the call to action can be the button to go to a different page if they aren't 18.

    Yes - I'm all for the workaround. That makes more sense!
    I was able to apply CSS to style the "never see this message again" link to be a button. But how do I change the text to say "I AM 18+"?

    I was seeing this problem on your site as well, I think changing the loading method to "Page Footer" would fix this; however, when I tried to get to the settings I got a 500 internal server error on your site. This is likely related to the operation timeout errors you were seeing before. That error usually indicates a lack of memory and/or your timeout limit being too small.

    However, your timeout looks to be 3600 seconds, which is very high. In that case, it's likely you have a process that won't stop running for at least an hour and it's draining server resources. You will want to reduce the max execution time to something more reasonable like 30-60 seconds.

    We have a blog post that covers increasing execution time and memory: https://premium.wpmudev.org/blog/increase-memory-limit/

    If that fails, ask your web host and they should be able to help you out :slight_smile:

    I'm always a bit nervous making these kinds of changes. It sounds kinda straightforward, but not sure what kind of limit I should be using. It's going to be a site with about 400-500 members uploading pics to their profile galleries, so it should be larger than the default WP limit. But the last comment on the link you gave (where someone said it was "really bad advice") makes me even more nervous.
    I haven't done any changes just yet with this part, but I'd love your further opinion...

    Make sure the constant is pasted in exactly as follows:

    define("POP_UP_TAXONOMY", "product_category");

    "product_category" is not a placeholder, that's the name of the custom taxonomy and for it to know which categories to pull it need to know that specific taxonomy.

    Ah! My mistake. I don't know why I had it in my head that this was a placeholder, and that the category slug was supposed to go here instead. Now I've done it the way you said, and NOW I can select the category from there.
    Thanks!

    This is how the Popup is meant to work. The page loads first. Sounds like you are wanting a solution that would load just the popup or redirect to it first before loading the page. In that case, unfortunately you may want to look for some alternatives. It would require fairly big customizations to the loading methods in order to load it that way.

    I realized I'll need to use safe images for the thumbnails anyway, and that the only "mature" images would be in the gallery section for the product -- so the popup would appear before anyone could really see those anyway....

    Thanks again, and I look forward to any further thoughts you have on changing the memory limit... (and how we can finally darken the overlay background!)

  • Tyler Postle

    Hey Anton,

    Yes - I'm all for the workaround. That makes more sense!
    I was able to apply CSS to style the "never see this message again" link to be a button. But how do I change the text to say "I AM 18+"?

    The easiest and update safe way would be to use our Ultimate Branding plugin and it's network wide text change module :slight_smile:

    That way you can change the text to show I AM 18+ instead. As seen in my screenshot.

    I'm always a bit nervous making these kinds of changes. It sounds kinda straightforward, but not sure what kind of limit I should be using. It's going to be a site with about 400-500 members uploading pics to their profile galleries, so it should be larger than the default WP limit. But the last comment on the link you gave (where someone said it was "really bad advice") makes me even more nervous.
    I haven't done any changes just yet with this part, but I'd love your further opinion...

    His comment is actually more in favour of you changing your settings here because your max_execution_time is too high. Which means you will be allowing processes to eat up a lot more resources than necessary. Normally you want a max execution time to be around 30-60 seconds. This means that if a process is still running after 30-60 seconds then it will be terminated to avoid hogging all the resources.

    In your case, with a 60 minute max execution time, if a process gets stuck running then it will continuously right for a full 60 minutes before it's terminated and will likely use a ton of memory/resources up.

    I would recommend adding these to your .htaccess:

    php_value memory_limit 512M
    php_value max_execution_time 60

    That will increase your memory and decrease your timeout to avoid using up all your memory.

    (and how we can finally darken the overlay background!)

    .wdpu-container.wdpu-background.no-img.buttons.style-simple.wdpu-16868.with-title.with-subtitle {
      background-color: rgba(0, 0, 0, 1);
    }

    I added the above to your popups custom css stylesheet and that looks to have worked :slight_smile:

    P.S. - I believe there's a small bug in the Popup Pro plugin. Often when I make changes and save, the "Singular" click box gets unchecked -- so there's always a moment when I think it's not working, and then realize I have to recheck that box again.

    I haven't seen this on my install yet nor on yours while I was testing it now. What sort of changes were you making?

    Look forward to hearing back!

    Cheers,
    Tyler

  • Anton

    @Tyler Postle

    The easiest and update safe way would be to use our Ultimate Branding plugin and it's network wide text change module :slight_smile:

    That way you can change the text to show I AM 18+ instead. As seen in my screenshot.

    Awesome, thanks!! I am ALWAYS forgetting about this plugin and how useful it is...

    I would recommend adding these to your .htaccess:

    php_value memory_limit 512M
    php_value max_execution_time 60

    The reason these types of changes always make me nervous is because I never know WHERE to add them. Currently my htaccess looks like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    I believe that's the basic kind of file that allows pretty permalinks, yes? So do I add your addition before "<IfModule mod_rewrite.c>", right before "</IfModule>", right before "# END WordPress", or what?

    I added the above to your popups custom css stylesheet and that looks to have worked :slight_smile:

    YES!! THANK YOU!!!
    (And maybe it's my imagination, but it almost appears to popup slightly quicker too...)

    I haven't seen this on my install yet nor on yours while I was testing it now. What sort of changes were you making?

    Unfortunately I wasn't paying super close attention, so I don't know the EXACT moment it happened. All I know is it happened at least twice, where suddenly the popup wasn't working after some changes, and when I would look and see what the problem was, I would notice that the "Singular/Archive" options were unchecked, and I hadn't unchecked them.
    I'll be paying much more attention now, and will let you know if it happens again and when...

  • Tyler Postle

    Hey Anton,

    I believe that's the basic kind of file that allows pretty permalinks, yes? So do I add your addition before "<IfModule mod_rewrite.c>", right before "</IfModule>", right before "# END WordPress", or what?

    You can add it after the "# END WordPress" - that should work :slight_smile: if you run into any troubles just let me know.

    Your .htaccess should look like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    php_value memory_limit 512M
    php_value max_execution_time 60

    Glad the other solutions worked and yes please do let me know if you manage to get that option issue again :slight_smile:

    Cheers,
    Tyler

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.