Skip to content

Add 'Generate token' link to GitHub access token settings field#1153

Open
marcusquinn wants to merge 1 commit intoafragen:developfrom
marcusquinn:feature/issue-1024-token-links
Open

Add 'Generate token' link to GitHub access token settings field#1153
marcusquinn wants to merge 1 commit intoafragen:developfrom
marcusquinn:feature/issue-1024-token-links

Conversation

@marcusquinn
Copy link
Copy Markdown
Contributor

Summary

Adds a direct Generate token link next to the GitHub access token input field in the Settings page, so users can navigate to GitHub's token creation page without leaving the settings UI.

Closes #1024

What changed

src/Git_Updater/API/GitHub_API.php
Added token_url to the add_settings_field args for github_access_token:

'token_url' => 'https://github.com/settings/tokens/new',

src/Git_Updater/Settings.php
Modified token_callback_text() to conditionally render the link when token_url is present in $args:

<?php if ( ! empty( $args['token_url'] ) ) : ?>
    &nbsp;<a href="<?php echo esc_url( $args['token_url'] ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Generate token', 'git-updater' ); ?></a>
<?php endif; ?>

Design notes

  • The token_url arg is optional — all existing callers of token_callback_text() that don't pass it are unaffected.
  • This pattern is intentionally extensible: add-on plugins (git-updater-gitlab, git-updater-bitbucket) can pass their own token_url to get the same link behaviour without any further changes to core.
  • Uses standard WordPress escaping (esc_url, esc_html_e) and rel="noopener noreferrer" for the external link.

Verification

On the Settings → Git Updater → GitHub subtab, the GitHub.com Access Token field now shows a "Generate token" link to the right of the password input. The link opens https://github.com/settings/tokens/new in a new tab.


AI disclosure: This contribution was drafted with the assistance of an AI coding tool (Claude). The implementation and diff were reviewed by the contributor before submission.

Adds a 'Generate token' link next to the GitHub access token
input field in the settings page, linking directly to the
GitHub token creation page. The token_url argument is passed
through the existing add_settings_field callback args, making
the pattern available for add-on plugins (GitLab, Bitbucket)
to follow with their own token URLs.

Closes afragen#1024
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 link to generate access token

1 participant