Wordpress Theme Options Page - Radio Buttons not updating correctly
I am currently working on the Theme Options Page of my Wordpress Theme.
As a base I'm using the "SAMPLE WORDPRESS THEME OPTIONS PAGE" by Ian Steward:
The Situation:
I've implemented two sets of radio-buttons like so:
The Problem:
They work as planned, the chosen options are applied.
Only problem: after saving the chosen radio buttons aren't selected anymore.
For the image above: If I would change both radio buttons and click save
only the very first radio button is selected, after the page has loaded
again.
The Code:
From the theme-options.php:
// Normal/Fixed Navigation Options
$fixed_navigation_options = array(
'Normal' => array(
'value' => ' ',
'label' => __( 'Normal', 'arrowcatch' )
),
'Fixed' => array(
'value' => 'is-fixed',
'label' => __( 'Fixed', 'arrowcatch' )
)
);
// Full-width/Contained Navigation Options
$contained_navigation_options = array(
'Full-width' => array(
'value' => ' ',
'label' => __( 'Full-width', 'arrowcatch' )
),
'Contained' => array(
'value' => 'is-contained',
'label' => __( 'Contained', 'arrowcatch' )
)
);
function arrowcatch_theme_options_page() {
global $select_options, $fixed_navigation_options,
$contained_navigation_options;
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false; ?>
<div class="wrap">
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade">
<p><strong>Options saved!</strong></p>
</div>
<?php endif; ?>
<!-- Normal/Fixed Navigation -->
<tr valign="top"><th scope="row"><?php _e( 'Navigation Normal/Fixed',
'arrowcatch' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e(
'Navigation Normal/Fixed', 'arrowcatch' ); ?></span></legend>
<?php
if ( ! isset( $checked ) )
$checked = '';
foreach ( $fixed_navigation_options as $option ) {
$fixed_navigation_setting = $options['fixed_navigation'];
if ( '' != $fixed_navigation_setting ) {
if ( $options['fixed_navigation'] ==
$option['value'] ) {
$checked = "checked=\"checked\"";
} else {
$checked = '';
}
}
?>
<label class="description"><input type="radio"
name="arrowcatch_theme_options[fixed_navigation]"
value="<?php esc_attr_e( $option['value'] ); ?>" <?php
echo $checked; ?> /> <?php echo $option['label'];
?></label><br />
<?php
}
?>
</fieldset>
</td>
</tr>
<!-- Full-width/Contained Navigation -->
<tr valign="top"><th scope="row"><?php _e( 'Navigation
Full-width/Contained', 'arrowcatch' ); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e(
'Navigation Full-width/Contained', 'arrowcatch' );
?></span></legend>
<?php
if ( ! isset( $checked ) )
$checked = '';
foreach ( $contained_navigation_options as $option ) {
$contained_navigation_setting =
$options['contained_navigation'];
if ( '' != $contained_navigation_setting ) {
if ( $options['fixed_navigation'] ==
$option['value'] ) {
$checked = "checked=\"checked\"";
} else {
$checked = '';
}
}
?>
<label class="description"><input type="radio"
name="arrowcatch_theme_options[contained_navigation]"
value="<?php esc_attr_e( $option['value'] ); ?>" <?php
echo $checked; ?> /> <?php echo $option['label'];
?></label><br />
<?php
}
?>
</fieldset>
</td>
</tr>
Hope that's all the code thats needed.
Not sure what's going on there.
I'm very thankfull for any push in the right direction.
Thank you!
No comments:
Post a Comment