Closed MiguelAxcar closed 9 months ago
Thanks for the review @kadamwhite and @goldenapples
Than, the approach you suggest is the one I am trying now.. Will flip this PR to draft.
I pushed a new commit, which is working as expected.
I think that the most straight-forward way to accomplish this feature specs is this piece of code, but it's not working as expected - Seems that it does not use this hook to create the button.
function filter_pll_duplicate_content( $value, $user_id, $meta_key, $single ) {
if ( $meta_key === 'pll_duplicate_content' ) {
return [ 'post' => true ];
}
return $value;
}
add_filter( 'get_user_metadata', 'filter_pll_duplicate_content', 10, 4 );
@kadamwhite Thank you for pointing out this concern.
Yeah, it does seem like it should go into a loop, but here's possible causes why it didn't in my tests:
pll_duplicate_content
key I'm returning false
, short-circuiting the update and and making the code to not dive into another full-blown update cycle;update_user_meta
may be smart enough to ignore actions if the new value is the same as the current one, since I'm always setting the [ 'post' => true ]
Anyway, I added a few guards to avoid it anyway.
The feature is working as expected.
@ckoerner Are there any post types where we use this translation flow, other than posts or pages? I didn't see it for Events, but might have been looking in the wrong place.
The main focus is on posts and that's where the workflow mostly happens. Pages and events are rarely translated (and that's fine).
Locks Polylang Content Duplication to Enabled
Summary
This pull request adds the function
toggle_polylang_content_duplication
, which lock the content duplication feature to "enabled" across different languages in Polylang. By updating the 'pll_duplicate_content' user meta to "enabled," the function ensure that content duplication is always active.The feature is controlled by this button, now always active:
When editing a content on WordPress admin, the feature is also expected to work if the toggle gets unchecked by user and user clicks on button "+" on the language sidebar.
Functionality
The button annotated on the screenshot below, present on all the content page, leads to a link like this.
Related Ticket
See #879
How to Test