0) { foreach ((array)$r2 as $r3) { if(@$r3['value'] != '' && strlen($r3['name']) != 1 && $r3['type'] != 'select' && $r3['type'] != 'radio' && $r3['type'] != 'checkbox'){ if ( version_compare( $wp_version, '3.4', '>=' ) ) {update_option(wp_get_theme().'_'.$r1['id'].'_'.$r3['name'], $r3['value']);}else{update_option(get_current_theme().'_'.$r1['id'].'_'.$r3['name'], $r3['value']);} } } } } } } function tk_theme_install() { global $wpdb; populate_theme_options(); //populate options from file } add_action('wp_head', 'tk_theme_head', 99); function tk_theme_head(){ if(isset($_REQUEST['ipn'])){ if($_REQUEST['ipn'] == 'paypal'){ include("ipn_paypal.php"); }//ipn from paypal if($_REQUEST['ipn'] == '2co'){ include("ipn_2co.php"); }//ipn from 2checkout.com }//isset ipn } function get_theme_option($option_name){ GLOBAL $tabs; $option_value = get_option($option_name); if(is_array($option_value)){ if(count($option_value) > 2){ return stripslashes_deep($option_value); }else{ return (stripslashes($option_value['0'])); } }else{ if($option_value != ''){ return (stripslashes($option_value)); } } } function my_admin_scripts() { wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_script('my-upload'); } function my_admin_styles() { wp_enqueue_style('thickbox'); } if (isset($_GET['page']) && isset($_GET['page'])) { add_action('admin_print_scripts', 'my_admin_scripts'); add_action('admin_print_styles', 'my_admin_styles'); } add_action('admin_head', 'includeScript'); function get_first_tab() { GLOBAL $tabs; require_once('admin-settings.php'); $i = 0; foreach ($tabs as $tab) { if ($tab['pg']['slug'] == $_GET['page']) { if ($i == 0) { return $tab['id']; } } } } function get_all_pages() { GLOBAL $tabs; $pages = array(); require_once('admin-settings.php'); $i = 0; $last_val = ''; foreach ((array)$tabs as $tab) { if ($last_val != $tab['pg']) { $pages[] = $tab['pg']; $last_val = $tab['pg']; } } return $pages; } function includeScript() { ?> =' ) ) {$theme_data = wp_get_theme(TEMPLATEPATH . '/style.css');}else{$theme_data = get_theme_data(TEMPLATEPATH . '/style.css');} $settings_page = ''; for ($i = 0; $i <= count($pages) - 1; $i++) { if ($i == 0) { $settings_page .= add_menu_page($pages[$i]['slug'], ucfirst(tk_theme_name), 'edit_theme_options', $pages[$i]['slug'], 'tk_settings_page'); $settings_page .= add_submenu_page($pages[0]['slug'], $pages[$i]['page_title'], $pages[$i]['menu_title'], 'edit_theme_options', $pages[$i]['slug'], 'tk_settings_page'); } else { $settings_page .= add_submenu_page($pages[0]['slug'], $pages[$i]['page_title'], $pages[$i]['menu_title'], 'edit_theme_options', $pages[$i]['slug'], 'tk_settings_page'); } } } if (@$_POST["ilc-settings-submit"] == 'Y') { if (@$_GET['tab'] == '') { $tab = get_first_tab(); } else { $tab = @$_GET['tab']; } $required_error = 0; foreach ($_POST as $var => $value) { if ($var != '_wpnonce' && $var != '_wp_http_referer' && $var != 'Submit' && $var != 'ilc-settings-submit' && !preg_match("/_required/i", $var)) {//$_POST variables which we don't want to save as options if (@$_POST[$var . '_required'] == 'yes') { if ($_POST[$var] == '') { $required_error++; } } } } if ($required_error == 0) { tk_save_theme_settings(); $url_parameters = isset($tab) ? 'updated=true&tab=' . $tab : 'updated=true'; } else { $url_parameters = isset($tab) ? 'error=true&tab=' . $tab : 'error=true'; } wp_redirect(admin_url('admin.php?page=' . $_GET['page'] . '&' . $url_parameters)); } function tk_advert() { include('advert-widget.php'); } function tk_save_theme_settings() { global $pagenow; $tk_theme_name = get_option('tk_theme_name'); if (@$_GET['tab'] == '') { $tab = get_first_tab(); } else { $tab = @$_GET['tab']; } if ($pagenow == 'admin.php' && isset($_GET['page'])) { if (isset($tab)) { foreach ($_POST as $var => $value) { if ($var != '_wpnonce' && $var != '_wp_http_referer' && $var != 'Submit' && $var != 'ilc-settings-submit' && !preg_match("/_required/i", $var)) {//$_POST variables which we don't want to save as options update_option($tk_theme_name.'_'.$tab . '_' . $var, $value); } } } } } function tk_admin_tabs($current) { GLOBAL $tabs; if ($current == '') { $current = get_first_tab(); } require_once('admin-settings.php'); echo '
All fields marked with (*) are required.
Theme Settings updated.