Phil
Forum Replies Created
-
Forum: Plugins
In reply to: [Age Gate] error in order sidebar meta box with HPOS enabledThis should be fixed in the latest version. It wasn’t actually there prior to HPOS, but was reliant on orders being a post type!
Thanks
PhilForum: Plugins
In reply to: [Age Gate] Echo Current YearSo add this to your functions:
add_shortcode('year', fn() => date('Y'));
Of if you are on less that PHP 7.4 use:
add_shortcode('year', function() { return date('Y'); });
Then put
? [year] BrandNameHere. All Rights Reserved.
in the options boxThanks
PhilForum: Plugins
In reply to: [Age Gate] Echo Current YearHi @soloant, which field are you doing it in? If it’s the Additional Content that allows shortcodes so you could create a super simple one like
add_shortcode('year', fn() => date('Y'));
Then just add
[year]
to the box?If it’s another field, that’ll need a bit more thought (from me!)
Thanks
PhilForum: Plugins
In reply to: [Age Gate] Change date formatHi @ondway2legend,
This isn’t possible out of the box right now, but there’s possible options to make it happen with code. You could style the input boxes to look like a single field and enable the auto tab option. Maybe a bit ropey but would probably work.
An alternative would be to do some template overrides and custom javascript, here’s a basic example;
In the root of your theme, create a file:
age-gate/partials/form/sections/inputs.php
Here you can override the default fields, you’ll still need the normal fields too, so that’s what is in the for loop:
<input type="date" class="my-age-gate-field" /> <?php foreach ($fields as $key => $field) : ?> <input type="hidden" name="age_gate[<?php echo esc_attr($key) ?>]" required> <?php endforeach; ?>
We’ll use the new
date
field to populate the hidden fields, for that we’ll need some javascript and to listen for the age_gate_shown event (could be done with jQueryon
too); in yourfunctions.php
addadd_action( 'wp_footer', function() { ?> <script> window.addEventListener('age_gate_shown', function() { document.querySelector('.my-age-gate-field').addEventListener('change', function(e) { var parts = e.target.value.split('-'); document.querySelector('[name="age_gate[y]"]').value = parts[0]; document.querySelector('[name="age_gate[m]"]').value = parts[1]; document.querySelector('[name="age_gate[d]"]').value = parts[2]; }); }); </script> <?php });
And that’ll do it as a basic example, style up how you need
Thanks
PhilForum: Plugins
In reply to: [Age Gate] Fatal error with Independent AnalyticsHi @tuukie,
I think this is a conflict between composer packages used in the two plugins. From looking at the free version of the plugin you mention I think it’s set to use php v7.3 versions of dependencies. Age Gate uses 7.4 inline with WordPress’ recommendations. Might be worth seeing if the author of that plugin can bring the dependencies up.
I did not it only did a fatal during activation, so possible during database table creation.
Thanks
PhilForum: Plugins
In reply to: [Age Gate] Age gate keeps showing after refreshing pageHi @noche70
The scroll one is a little easier to work out and I don’t think you actually need a refresh on it;
While default scroll is disabled your scrolljacking is still being picked up. But based on how that works, you can force it back to the top when age gate is passed by changing the hash like this:
window.addEventListener('age_gate_passed', event => window.location.hash = 1);
As for the cookie, the API response has
set_cookie
set tofalse
. That only happens from a filter, so can you check your code for andything filteringage_gate/cookie/set
?Thanks
PhilGoing to address this over at the new topic
Forum: Plugins
In reply to: [Age Gate] Google Fetch and Render BotHi @aarond13,
Looks like the “can be a part or full user agent string” may not be true so I’ll look into that. In the meantime you can add the full UA strings and it should work:
Mozilla/5.0 (compatible; Google-InspectionTool/1.0;)
And
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; Google-InspectionTool/1.0;)
Thanks
PhilForum: Plugins
In reply to: [Age Gate] error in order sidebar meta box with HPOS enabledHi @dunkoh,
There’s two issues here I think:
- HPOS doesn’t use a
post
anymore so it passes an instance ofOrder
into the metabox which is a little unexpected. I can fix this, but; - In reality, that metabox probably shouldn’t even be on an order, would anyone ever need to age restrict an order itself? I can’t imagine they would
Will look into getting one or both or those options into a release.
Thanks
PhilForum: Plugins
In reply to: [Age Gate] Age Gate Formatting@tuckerjohns this looks like it’s probably something to do with your cache, especially if you’re seeing it fine when logged in. Try clearing all the caches and if that also compresses the CSS into one lump, compress that too.
Also make sure the “Layout” option is enabled on the Age Gate -> Appearance settings page
Forum: Plugins
In reply to: [Age Gate] Not Working as expectedClosing the browser doesn’t necessarily clear the cookies. On Windows it might, on Mac it would require the application to be quit entirely. Phones are probably something different again. These aren’t things we can easily control from the application as they’re browser specific.
The above would make it work, but for every page, every time. So even if they’ve passed it once.
Forum: Plugins
In reply to: [Age Gate] Pass the Date Fields Data to another FormI think you’ll have to test a couple of options here, but I’d be leaning towards a custom JS approach as:
Option 1 – you’d have to find an manipulate any links to the page with your form on, probably via JS if you’re caching anyway which feels like more work
Option 2 – does setting the default happen over AJAX/REST/Similar as if not, it’ll probably cache the first response.
I think this is how I’d do it – all demo so give it a good test if you haven’t got a solution already:
PHP:
add_action('age_gate/submission/success', function($data) { // data contains: // $data['age_gate_d'] // $data['age_gate_m'] // $data['age_gate_y'] // you can store these how you need // lets just store this in YYYY-MM-DD for the sake of a demo // This should work for all instances - unless you are on the form page itself perhaps setcookie('dob', sprintf('%s-%s-%s', $data['age_gate_y'], $data['age_gate_m'], $data['age_gate_d']), 0, '/'); });
Then in JS:
// lifted from the internet so just a demo. function getCookie(name) { let cookie = {}; document.cookie.split(';').forEach(function (el) { let split = el.split('='); cookie[split[0].trim()] = split.slice(1).join("="); }) return cookie[name]; } window.addEventListener('DOMContentLoaded', () => { // if the form is loaded in after the fact (like ninja forms do), there may be a different event to use above document.querySelectorAll('selector of your form field').forEach(field => field.value = getCookie('dob')); });
Forum: Plugins
In reply to: [Age Gate] popup on all sitesIf it’s just the home page, this in a JS file/script somewhere should work as long as the hooks are loaded, but it fire before age gate:
AgeGateHooks.addFilter('age_gate_show', 'AgeGateHooks', (status) => { if (window.location.pathname === '/') { return true; } return status; });
If it’s every page every time, then in functions.php:
add_filter('age_gate/cookie/set', '__return_false');
Forum: Plugins
In reply to: [Age Gate] Custom column on posts/pages not displayedHi @gregross,
Thanks for this, however we only need to know if it’s truthy as we are just checking if Age Gate is disabled for the current post type – which we get from the
$typenow
global.If the column isn’t showing it’s either not enabled in the screen options or a different bug of some kind. If it’s not the first one, let me know and I’ll dig deeper.
Thanks
PhilForum: Plugins
In reply to: [Age Gate] Stopped working@justinrogers, @dannyfoo – this should be fixed in 3.3.1, but if not do let me know.
Thanks
Phil - HPOS doesn’t use a