__('Use this Image', 'adsoft_language') )); wp_enqueue_script('adsoft_options_js'); endif; } // Display theme options page function adsoft_options_page() { $options = get_option('adsoft_options'); $theme_data = wp_get_theme(); ?>

Name; ?>

'welcome') : // Get Tab $tab = esc_attr($_GET['tab']); ?>

'. __('Welcome', 'adsoft_language') .''; else : $links[] = ''. __('Welcome', 'adsoft_language') .''; endif; // Loop to create rest of Tabs Navigation foreach( $tabs as $tab => $tabcontent ) : if ( $tab == $current ) : $links[] = ''.$tabcontent['name'].''; else : $links[] = ''.$tabcontent['name'].''; endif; endforeach; // Display Tab Navigaiton echo ''; } // Register Settings add_action('admin_init', 'adsoft_options_register_settings'); function adsoft_options_register_settings() { // Register Theme Options register_setting( 'adsoft_options', 'adsoft_options', 'adsoft_options_validate' ); // Check if active page is Theme Options panel if ( isset($_GET['page']) and $_GET['page'] == 'adsoft' ) : // Check which tab on theme options is selected if( isset ( $_GET['tab'] ) and $_GET['tab'] <> 'welcome') : // Get Tab $tab = esc_attr($_GET['tab']); // Get Theme Options array $theme_options = adsoft_options_array(); // Get Sections and Settings of selected Tab $adsoft_sections = $theme_options[$tab]['sections']; $adsoft_settings = $theme_options[$tab]['settings']; // Add Setting Sections foreach ($adsoft_sections as $section) { add_settings_section($section['id'], $section['name'], 'adsoft_options_section_text', 'adsoft'); } // Add Setting Fields foreach ($adsoft_settings as $setting) { add_settings_field($setting['id'], $setting['name'], 'adsoft_options_display_setting', 'adsoft', $setting['section'], $setting); } endif; endif; } // Display Setting Fields function adsoft_options_display_setting( $setting = array() ) { $options = get_option('adsoft_options'); if ( ! isset( $options[$setting['id']] ) ) $options[$setting['id']] = $setting['std']; switch ( $setting['type'] ) { case 'text': echo ""; echo '
'; break; case 'url': echo ""; echo '
'; break; case 'textarea': echo ""; echo '
'; break; case 'html': echo ""; echo '
'; break; case 'editor': $editor_settings = array( 'media_buttons' => false, 'teeny' => true, 'textarea_name' => 'adsoft_options['.$setting['id'].']', 'textarea_rows' => 10, 'quicktags' => true ); wp_editor( wp_kses_post($options[$setting['id']]), $setting['id'], $editor_settings); echo '
'; break; case 'info': echo '
'.$setting['desc'].'
'; break; case 'checkbox': echo "'; break; case 'multicheckbox': echo ""; foreach ( $setting['choices'] as $value => $label ) { $checkbox = $setting['id'] . '_' . $value; if ( ! isset( $options[$checkbox] ) ) $options[$checkbox] = $setting['std']; echo " " . $label . "
"; } echo ''; break; case 'select': echo ""; echo '
'; break; case 'radio': foreach ( $setting['choices'] as $value => $label ) { echo " " . $label . "
"; } echo ''; break; case 'image': echo "

"; echo ''; echo ''; echo ' '; break; case 'fontpicker': echo ""; echo '
'; echo "
Grumpy wizards make toxic brew for the evil Queen and Jack.
"; break; case 'colorpicker': echo ""; echo '
'; break; default: echo ""; echo '
'; break; } } // Validate Settings function adsoft_options_validate($input) { $options = get_option('adsoft_options'); if ( isset ( $input['validation-submit'] ) ) : $tab = $input['validation-submit']; else: $tab = 'general'; endif; // Get theme options array $theme_options = adsoft_options_array(); // Get Settings $validate_settings = $theme_options[$tab]['settings']; foreach ($validate_settings as $setting) { if ($setting['type'] == 'checkbox' and !isset($input[$setting['id']]) ) { $options[$setting['id']] = 'false'; } elseif ($setting['type'] == 'multicheckbox') { foreach ( $setting['choices'] as $value => $label ) { $checkbox = $setting['id'] . '_' . $value; if ( !isset($input[$checkbox] ) ) : $options[$checkbox] = 'false'; else : $options[$checkbox] = 'true'; endif; } } elseif ($setting['type'] == 'radio' and !isset($input[$setting['id']]) ) { $options[$setting['id']] = 1; } elseif ($setting['type'] == 'textarea') { $options[$setting['id']] = esc_textarea(trim($input[$setting['id']])); } elseif ($setting['type'] == 'html' or $setting['type'] == 'editor') { $options[$setting['id']] = wp_kses_post(trim($input[$setting['id']])); } elseif ($setting['type'] == 'url') { $options[$setting['id']] = esc_url(trim($input[$setting['id']])); } else { $options[$setting['id']] = esc_attr(trim($input[$setting['id']])); } } return $options; } // Empty Dummy function for section text function adsoft_options_section_text() {} // Change capability to edit_theme_options function adsoft_options_capability( $capability ) { return 'edit_theme_options'; } add_filter( 'option_page_capability_adsoft_options', 'adsoft_options_capability' ); // Set Default Options function adsoft_options_set_default_options() { $theme_options = get_option( 'adsoft_options' ); if ( false === $theme_options ) { $old_options = get_option( 'adsoft_options' ); if ( false === $old_options ) { $theme_options = adsoft_options_get_default_options(); } else { $theme_options = $old_options; } } update_option( 'adsoft_options', $theme_options ); } // Initialize Theme options add_action('after_setup_theme','adsoft_options_set_default_options', 9 ); // Get Default Options function adsoft_options_get_default_options() { $options = array(); // Get Theme Options array $theme_options = adsoft_options_array(); foreach( $theme_options as $tab => $tabcontent ) : // Get Settings of tab $adsoft_settings = $theme_options[$tab]['settings']; foreach ($adsoft_settings as $setting) : if ( $setting['type'] != 'multicheckbox' ) : $options[$setting['id']] = $setting['std']; else : foreach ( $setting['choices'] as $value => $label ) { $checkbox = $setting['id'] . '_' . $value; $options[$checkbox] = $setting['std']; } endif; endforeach; endforeach; return $options; } ?>