Skip to content

Add create new translation button to editor metabox#607

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

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

Conversation

@apermo
Copy link
Copy Markdown
Contributor

@apermo apermo commented Apr 14, 2026

Summary

  • Add a "+" button to the editor metabox (both select and autocomplete modes) for creating a new translation directly from the post editor
  • The button opens post-new.php?msls_id=NNN&msls_lang=XX in a new tab, matching the listing column behavior
  • Only visible when no translation is linked and the current post has been saved (not auto-draft)
  • In autocomplete mode, the button dynamically hides/shows when selecting or clearing a post
  • Also passes msls_id and msls_lang to the existing icon link URLs in the metabox

Closes #606

Test plan

  • Open a saved post with no translations linked — verify "+" buttons appear for each language
  • Click a "+" button — verify it opens a new tab with the correct msls_id and msls_lang params
  • On the new post, verify the metabox pre-fills the link back to the source post
  • Open a post with existing translations — verify no "+" appears (select mode) / "+" is hidden (autocomplete mode)
  • In autocomplete mode: clear a linked post field — verify "+" reappears
  • In autocomplete mode: select a post via autocomplete — verify "+" hides
  • Create a new post (auto-draft) — verify no "+" buttons appear until the post is saved

apermo added 3 commits April 14, 2026 21:06
Update render_select and render_input tests to expect
the new "create new translation" link and the required
additional WordPress function mocks.
Add a "+" button to the editor metabox that opens
post-new.php with msls_id and msls_lang params in a
new tab. Visible when no post is linked and the
current post has been saved.

Closes lloc#606
Hide the create new button when a post is selected
via autocomplete and show it again when the field
is cleared.
@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.

apermo added 3 commits April 14, 2026 21:11
Remove underline and add proper color to the create
new translation button in the metabox.
The label for attribute was polluted with CSS classes
which is invalid HTML. Move msls-icon-wrapper and
icon type to a proper class attribute.
The WordPress plugin checker requires the translators
comment on the line directly above the __() call.
@apermo apermo marked this pull request as draft April 14, 2026 20:02
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