-
Notifications
You must be signed in to change notification settings - Fork 125
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
Create hooks to allow the implementation of Cross-PTEs #537
Comments
Re-using an existing permssion seems wrong, why not create a new permission and use the existing hooks in |
Well, Cross-Locale PTE is probably something very WordPress.org specific. If we introduced another permission, I'd need to add checks for that in several places. As you can see in my example plugin implementation I actually do use the permission system for a |
All the checks you need should be in place already (GP checks for approver rights in all the required places), I'd think it would be a simple hook at the Then the whole thing could be done as a plugin without any changes to GP. |
Something like:
|
@toolstack The important part of this is that we also have to check permissions per translation/original, not translation sets. |
@ocean90 perhaps I'm missing something but based on the requirements, per translation permissions seems to be overkill. Correct me if I'm wrong but it looks like the idea is to block a cross-PTE from overwriting and translation from a PTE or a GTE? I guess my basic problem with the approach is that it's effectively creating a second permission system via the filters for setting the status of a translation. That seems like a hack that should have a more general solution that would work for other things as well. Perhaps creating a second
|
$can_approve = $this->can(
'approve',
'translation-set',
$translation_set->id,
[ 'translation' => $t ]
); |
Making the fourth parameter available makes sense in general, but I'd still keep it as a separate call. We're really extending the existing permission system to allow for per translation permissions, which seems like a separate logical check. That way it's easy to capture as part of the There could be an argument for removing the |
FWIW I tried to introduce a Apart from that, the reason I like the filter solution is because it only minimally changes the logic within GlotPress, so if it were for me, I'd still go with that solution. |
I think we'd have to leave both in for the time being for backwards compatibility. There may be plugins that expect it so they can filter the existing permissions. It might work to remove them by adding a default filter for the |
Yeah, that's what I have been doing but I am currently struggling with the cascade of filters when trying to implement the cross-locale plugin. |
It might be easier just to remove the default filter and replace it in the plugin. |
@toolstack thanks for the suggestion, that made it easier indeed. See the new implementation in #538. |
In this new implementation I've taken up both of your suggestions and made it work by leaving |
This is in response to the efforts to create Cross-PTEs on WordPress.org.
We are planning to achieve this with a special permission that achieves the behavior by re-using the
approve
permission and will need to add a filter.The text was updated successfully, but these errors were encountered: