Add configurable Quick Create mode for translations#609
Add configurable Quick Create mode for translations#609apermo wants to merge 11 commits intolloc:masterfrom
Conversation
Add activate_quick_create checkbox to the Advanced Settings section, allowing users to enable silent translation creation without leaving the current post.
Register msls/v1/create-translation POST endpoint. Creates a draft translation post on the target blog with mapped taxonomies and MSLS links. All data is filterable via dedicated hooks.
Add a '+' button per language when no translation is linked. In classic mode it opens post-new.php in a new tab. When Quick Create is enabled, it calls the REST API and updates the UI in place.
Add tests for permission check, source not found, and successful translation creation. Update existing test expectations for new setting count.
Add uglify step for msls-quick-create.js and fix PHPStan issue in MslsRestApi taxonomy lookup.
Quick Create now applies everywhere the '+' icon appears: post listing columns and the metabox. The logic lives in MslsAdminIcon::get_a() so both contexts use the same code path. Updated setting label and allowed data attributes in wp_kses.
Replace <a href="#"> anti-pattern with a semantic <button> element. Reset button styles via CSS, add aria-label for accessibility, and replace the button with an <a> edit link on success.
There was a problem hiding this comment.
Code Review
This pull request introduces a 'Quick Create' feature for the Multisite Language Switcher plugin, allowing users to generate draft translations with a single click. The implementation includes a new REST API endpoint, frontend logic for asynchronous requests, and administrative settings. Review feedback highlights a security vulnerability where source post permissions are not verified, a missing return type hint in the REST callback, and several opportunities for defensive programming, such as verifying the existence of post types and taxonomies on target blogs to improve robustness.
| } | ||
|
|
||
| foreach ( $post_data['_msls_tax_input'] as $taxonomy => $term_ids ) { | ||
| wp_set_object_terms( $new_post_id, $term_ids, $taxonomy ); |
There was a problem hiding this comment.
There was a problem hiding this comment.
default only matches tags and categories, any custom taxonomies are to be implemented via the filters, so that is likely not an issue.
There was a problem hiding this comment.
Skipped — by default only mapped categories and tags are assigned. Custom taxonomies go through the msls_quick_create_tax_input filter where the implementer controls which taxonomies to include.
Add read_post capability check on source blog to prevent content leaking. Verify post_type exists on target blog before inserting. Guard against empty post IDs in link map iteration.
Move the 'From xx:' prefix from prepare_post_data into a public static filter callback registered on msls_quick_create_post_data. Consumers can now remove_filter to disable the prefix or replace it.
The WordPress plugin check requires the translators comment on the line directly above the __() call, not above the sprintf().
The 'From xx:' prefix breaks markup when applied to post_content. Only prefix post_title by default. Content is copied as-is from the source post.
Closes #608
Summary
post-new.phplink with a REST API callPOST msls/v1/create-translationendpoint creates a draft post on the target blog with mapped taxonomies and MSLS linksMslsAdminIcon::get_a()msls_quick_create_post_data,msls_quick_create_tax_input,msls_quick_create_after_insert,msls_quick_create_responseDetails
From [lang]:, statusdraft, mapped categories/tags<button>element witharia-labelfor the Quick Create triggerTest plan
post-new.phpas beforecomposer test— 403 tests pass