Skip to content
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

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

andrewlimaza
Copy link
Contributor

  • ENHANCEMENT: Added functionality to look for updates via our own translations server.

All Submissions:

* ENHANCEMENT: Added functionality to look for updates via our own translations server.
@dparker1005 dparker1005 added this to the 3.4 milestone Dec 17, 2024
@andrewlimaza
Copy link
Contributor Author

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.

@andrewlimaza
Copy link
Contributor Author

Update Traduttore still works with older PHP versions (without fatal erroring) and our recommended PHP version is 7.4+, so this is okay.

@dparker1005 dparker1005 changed the base branch from dev to v3.4 January 20, 2025 19:08
return;
}

$is_pmpro_admin = ! empty( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], 'pmpro' ) !== false;
Copy link
Member

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?

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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).

Copy link
Member

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

@dparker1005 dparker1005 merged commit b309933 into strangerstudios:v3.4 Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants