Skip to content

Add create/edit translation button to editor metabox#607

Open
apermo wants to merge 9 commits intolloc:masterfrom
apermo:feature/606-metabox-create-new-button
Open

Add create/edit translation button to editor metabox#607
apermo wants to merge 9 commits intolloc:masterfrom
apermo:feature/606-metabox-create-new-button

Conversation

@apermo
Copy link
Copy Markdown
Contributor

@apermo apermo commented Apr 14, 2026

Closes #606

Summary

  • Add an action button next to each language's select/autocomplete in the editor metabox
  • No translation linked: shows dashicons-plus — Quick Create button (when enabled) or classic post-new.php link with msls_id/msls_lang params opening in a new tab
  • Translation linked: shows dashicons-external — link to the translation's edit page in a new tab
  • Only appears when the current post has been saved (not auto-draft)
  • In autocomplete mode, toggles dynamically between create and edit states
  • Quick Create success in the metabox uses dashicons-external (not dashicons-edit like in the listing)
  • Fixes for attribute on metabox labels (CSS classes moved to class attribute)
  • Moves Quick Create button CSS into the LESS source

Test plan

  • Open a saved post with no translations — verify "+" appears per language
  • Quick Create enabled: click "+" — draft created, icon changes to external arrow
  • Quick Create disabled: click "+" — new tab opens post-new.php?msls_id=...&msls_lang=...
  • Post with existing translations — external arrow icon per linked language
  • Autocomplete mode: select a post — "+" hides, arrow shows; clear field — reverses
  • Auto-draft post — no action buttons appear
  • composer test — 408 tests pass

@apermo apermo requested a review from lloc as a code owner April 14, 2026 19:07
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a 'create new translation' link within the MslsMetaBox for both select and input rendering modes. The implementation includes logic to verify post status, a new private helper method for link generation, and JavaScript to toggle link visibility based on user selection. Review feedback identifies that the for attributes in the generated HTML labels are improperly used to store CSS classes, which violates HTML standards and hinders accessibility; these classes should be moved to a class attribute.

Comment thread includes/MslsMetaBox.php Outdated
Comment thread includes/MslsMetaBox.php Outdated
@apermo apermo marked this pull request as draft April 14, 2026 20:02
@apermo
Copy link
Copy Markdown
Contributor Author

apermo commented Apr 15, 2026

This will continue after #609 is merged and will be rebased on top of it. The metabox button will then support both modes: classic (open post-new.php) and quick create (via the REST API from #609).

@apermo
Copy link
Copy Markdown
Contributor Author

apermo commented Apr 20, 2026

Ty for merging @lloc i'll continue here later

apermo added 5 commits April 20, 2026 17:45
Update render_select and render_input tests to expect
the new create/edit action element and the additional
WordPress function mocks.
Add an action button next to each language row in the
editor metabox. Shows dashicons-plus when no translation
is linked (Quick Create button or classic post-new.php
link) and dashicons-external when linked (edit link
opening in a new tab). Only visible for saved posts.

Closes lloc#606
Hide create button and show edit link when a post is
selected via autocomplete. Reverse when the field
is cleared.
After Quick Create succeeds in the metabox, use
dashicons-external instead of dashicons-edit and
open the link in a new tab.
Add styles for create-new and edit-link buttons in
the metabox. Move Quick Create button reset and
loading animation into the LESS source.
@apermo apermo force-pushed the feature/606-metabox-create-new-button branch from 4a886f0 to 04fa5a3 Compare April 20, 2026 15:49
@apermo apermo changed the title Add create new translation button to editor metabox Add create/edit translation button to editor metabox Apr 20, 2026
@apermo apermo marked this pull request as ready for review April 20, 2026 15:50
When get_edit_post_link returns null (post does not
exist on the target blog or stale link), show the
create button instead of an empty-href edit link.
@apermo apermo marked this pull request as draft April 20, 2026 16:03
@apermo
Copy link
Copy Markdown
Contributor Author

apermo commented Apr 20, 2026

still fixing some bugs, will ping when review is finished.

apermo added 2 commits April 20, 2026 18:14
Add the created post's title to the REST response so
the metabox input/select can display it immediately.
Set the autocomplete text input and select option
text to the new post's title after a successful
Quick Create call.
@apermo apermo marked this pull request as ready for review April 20, 2026 16:26
@apermo
Copy link
Copy Markdown
Contributor Author

apermo commented Apr 20, 2026

@lloc ready for review, feels like magic, i love it :)

The plugin checker requires the translators comment
on the line directly above the __() call.
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.

Add 'create new translation' button to editor metabox

1 participant