WowPress-Tailwind/theme/options/options.php

64 lines
2.4 KiB
PHP
Raw Normal View History

2024-04-15 16:00:49 +02:00
<?php
/* ------------------ */
/* theme options page */
/* ------------------ */
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
// Einstellungen registrieren (http://codex.wordpress.org/Function_Reference/register_setting)
function theme_options_init(){
register_setting( 'wowpress_options', 'wowpress_api', 'kb_validate_options' );
}
// Seite in der Dashboard-Navigation erstellen
function theme_options_add_page() {
add_theme_page('API-Einstellungen', 'API-Einstellungen', 'edit_theme_options', 'api_options', 'wowpress_api_options_page' ); // Seitentitel, Titel in der Navi, Berechtigung zum Editieren (http://codex.wordpress.org/Roles_and_Capabilities) , Slug, Funktion
}
// Optionen-Seite erstellen
function wowpress_api_options_page() {
global $select_options, $radio_options;
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?>
<div class="wrap">
<?php screen_icon(); ?><h2>API-Optionen für <?php bloginfo('name'); ?></h2>
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade">
<p><strong>Einstellungen gespeichert!</strong></p>
</div>
<?php endif; ?>
<form method="post" action="options.php">
<?php settings_fields( 'wowpress_options' ); ?>
<?php $options = get_option( 'wowpress_api' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">BattleNet - Identifier</th>
<td><input id="wowpress_api[bnet][id]" class="regular-text" type="text" name="wowpress_api[bnet][id]" value="<?php esc_attr_e( $options['bnet']['id'] ); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">BattleNet - Key</th>
<td><input id="wowpress_api[bnet][key]" class="regular-text" type="text" name="wowpress_api[bnet][key]" value="<?php esc_attr_e( $options['bnet']['key'] ); ?>" /></td>
</tr>
</table>
<!-- submit -->
<p class="submit"><input type="submit" class="button-primary" value="Einstellungen speichern" /></p>
</form>
</div>
<?php }
// Strip HTML-Code:
// Hier kann definiert werden, ob HTML-Code in einem Eingabefeld
// automatisch entfernt werden soll. Soll beispielsweise im
// Copyright-Feld KEIN HTML-Code erlaubt werden, kommentiert die Zeile
// unten wieder ein. http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses
function kb_validate_options( $input ) {
// $input['copyright'] = wp_filter_nohtml_kses( $input['copyright'] );
return $input;
}