-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom translation updates (GlotPress) #3211
Conversation
* ENHANCEMENT: Added functionality to look for updates via our own translations server.
One concern I have here is that Traduttore requires PHP 7.1 or higher, while this is outdated we still have sites using older PHP versions (but maybe it's okay) - https://wearerequired.github.io/traduttore/plugin-theme.html#:~:text=Note%3A%20Traduttore%20Registry%20requires%20PHP%207.1%20or%20higher. |
Prefixed the namespace to avoid conflicts.
Update Traduttore still works with older PHP versions (without fatal erroring) and our recommended PHP version is 7.4+, so this is okay. |
return; | ||
} | ||
|
||
$is_pmpro_admin = ! empty( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], 'pmpro' ) !== false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do a similar check here: https://github.com/strangerstudios/paid-memberships-pro/blob/dev/includes/admin.php#L327-L331
Maybe we should have a function in includes/admin.php or adminpages/functions.php for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of having an admin function that checks is a pmpro setting page. We're starting to do this more.
* Don't delete the cache if the transient gets changed multiple times | ||
* during a single request. Set cache lifetime to maximum 15 seconds. | ||
*/ | ||
$cache_lifespan = 15; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we document how the caching works? Maybe WP core is doing it's own caching too.
How often will the site hit our servers? Ideally we don't want the admin pages to be hitting our servers every time they load a plugins page or our settings pages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get way more aggressive with the cache. I'd be okay to bump it up by a day or two (we have a way to manually download the translation as well or they could delete the transient to ping the server when needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent some time looking into this. TLDR: our clean_translations_cache()
here that clears caches older than 15 seconds should only be run twice daily (by default) on the core set_site_transient_update_plugins
hook or whenever plugins are manually rechecked or a plugin is updated triggering the delete_site_transient_update_plugins
hook.
So in a sense, we do have some built-in caching from WP. It looks like the 15 second delay is really just there to prevent updating translations for a plugin multiple times on a single page load
All Submissions: