Add Gitea base URL + token fields to settings page
This commit is contained in:
@@ -41,8 +41,10 @@ function projects_portfolio_render_settings_page() {
|
||||
}
|
||||
|
||||
// Retrieve saved settings.
|
||||
$api_token = get_option( 'projects_portfolio_github_api_token', '' );
|
||||
$share_telemetry = get_option( 'projects_portfolio_share_telemetry', '0' );
|
||||
$api_token = get_option( 'projects_portfolio_github_api_token', '' );
|
||||
$gitea_api_token = get_option( 'projects_portfolio_gitea_api_token', '' );
|
||||
$default_gitea_base_url = get_option( 'projects_portfolio_default_gitea_base_url', 'https://codeberg.org' );
|
||||
$share_telemetry = get_option( 'projects_portfolio_share_telemetry', '0' );
|
||||
|
||||
// Templates Settings.
|
||||
$templates_settings = [
|
||||
@@ -83,6 +85,27 @@ function projects_portfolio_render_settings_page() {
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2><?php esc_html_e( 'Gitea Settings', 'projects-wp' ); ?></h2>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="projects_portfolio_default_gitea_base_url"><?php esc_html_e( 'Default Gitea Base URL', 'projects-wp' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="url" id="projects_portfolio_default_gitea_base_url" name="projects_portfolio_default_gitea_base_url" value="<?php echo esc_attr( $default_gitea_base_url ); ?>" class="regular-text" placeholder="https://codeberg.org" />
|
||||
<p class="description"><?php esc_html_e( 'Used when a Gitea project has no per-project base URL override.', 'projects-wp' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="projects_portfolio_gitea_api_token"><?php esc_html_e( 'Gitea API Token', 'projects-wp' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="password" id="projects_portfolio_gitea_api_token" name="projects_portfolio_gitea_api_token" value="<?php echo esc_attr( $gitea_api_token ); ?>" class="regular-text" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2><?php esc_html_e( 'Templates Settings', 'projects-wp' ); ?></h2>
|
||||
<table class="form-table">
|
||||
<?php foreach ( $templates_settings as $key => $label ) :
|
||||
@@ -134,6 +157,8 @@ function projects_portfolio_save_settings() {
|
||||
}
|
||||
|
||||
update_option( 'projects_portfolio_github_api_token', sanitize_text_field( $_POST['projects_portfolio_github_api_token'] ?? '' ) );
|
||||
update_option( 'projects_portfolio_gitea_api_token', sanitize_text_field( $_POST['projects_portfolio_gitea_api_token'] ?? '' ) );
|
||||
update_option( 'projects_portfolio_default_gitea_base_url', esc_url_raw( $_POST['projects_portfolio_default_gitea_base_url'] ?? 'https://codeberg.org' ) );
|
||||
update_option( 'projects_portfolio_share_telemetry', isset( $_POST['projects_portfolio_share_telemetry'] ) ? '1' : '0' );
|
||||
|
||||
// Templates Settings Keys.
|
||||
|
||||
Reference in New Issue
Block a user