Skip to content

Options: Mask connector API keys on All Options screen#11158

Closed
jorgefilipecosta wants to merge 2 commits intoWordPress:trunkfrom
jorgefilipecosta:mask-connector-api-keys-options-page
Closed

Options: Mask connector API keys on All Options screen#11158
jorgefilipecosta wants to merge 2 commits intoWordPress:trunkfrom
jorgefilipecosta:mask-connector-api-keys-options-page

Conversation

@jorgefilipecosta
Copy link
Copy Markdown
Member

@jorgefilipecosta jorgefilipecosta commented Mar 4, 2026

Summary

  • Masks connector API keys on the wp-admin/options.php page using the existing _wp_connectors_mask_api_key() function
  • Keys matching connectors_*_api_key pattern are displayed with bullets + last 4 chars
  • Fields are disabled and excluded from form submission

Ticket: https://core.trac.wordpress.org/ticket/64793#ticket

Test plan

  • Navigate to wp-admin/options.php
  • Verify connector API keys show masked values (e.g., ••••••••••••PDU')
  • Verify the fields are disabled
  • Verify the Connectors settings page still works normally

Screenshot

Screenshot 2026-03-04 at 14 52 42

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jorgefilipecosta, gziolo, ocean90.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Copy Markdown
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

This works perfectly fine in my testing for the All Options screen. We can iterate when we figure out a better approach.

}
} elseif ( str_starts_with( $option->option_name, 'connectors_' )
&& str_ends_with( $option->option_name, '_api_key' )
&& function_exists( '_wp_connectors_mask_api_key' )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why would a WordPress installation not include _wp_connectors_mask_api_key()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The check was removed 👍

Connector API keys were visible in plain text on the wp-admin/options.php
page because it queries the database directly, bypassing the get_option()
filter that normally masks these values.

This adds masking for options matching the `connectors_*_api_key` pattern
using the existing `_wp_connectors_mask_api_key()` function, and disables
editing from this screen.
@jorgefilipecosta jorgefilipecosta force-pushed the mask-connector-api-keys-options-page branch from abbbdae to c192fc2 Compare March 4, 2026 17:47
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61829
GitHub commit: 676cdca

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Mar 4, 2026
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.

3 participants