function tk_settings_page($par) { global $pagenow, $wp_version; $settings = get_option("tk_theme_settings"); if (version_compare($wp_version, '3.4', '>=')) { $theme_data = wp_get_theme(TEMPLATEPATH . '/style.css'); } else { $theme_data = get_theme_data(TEMPLATEPATH . '/style.css'); } ?> <div class="wrap"> <h2><?php $pages = @get_all_pages(); for ($i = 0; $i <= count($pages) - 1; $i++) { if ($pages[$i]['slug'] == $_GET['page']) { echo $pages[$i]['page_title']; } } ?> </h2> <?php if ('true' == esc_attr(@$_GET['error'])) { echo '<div class="error" ><p>All fields marked with (*) are required.</p></div>'; } if ('true' == esc_attr(@$_GET['updated'])) { echo '<div class="updated" ><p>Theme Settings updated.</p></div>'; } if (isset($_GET['tab'])) { tk_admin_tabs($_GET['tab']); } else { tk_admin_tabs(get_first_tab()); } ?> <div id="poststuff"> <form method="post" action="<?php admin_url('admin.php?page=' . $_GET['page']); ?> "> <?php wp_nonce_field("ilc-settings-page"); if ($pagenow == 'admin.php' && isset($_GET['page'])) { if (isset($_GET['tab'])) { $tab = $_GET['tab']; } else { $tab = get_first_tab(); } echo '<table class="form-table">'; global $tabs; $tk_theme_name = get_option('tk_theme_name'); foreach ($tabs as $r1) { if ($r1['id'] == $tab) { $row_items = 1; foreach ($r1 as $r2) { if ($row_items == 4) { if (count($r2) > 0) { foreach ($r2 as $r3) { if (@$r3['options']['required'] == 'yes') { $required = '* '; $required_hidden_field = '<input type="hidden" name="' . $r3['name'] . '_required" value="yes">'; } else { $required = ''; $required_hidden_field = '<input type="hidden" name="' . $r3['name'] . '_required" value="no">'; } if (isset($_GET['dev'])) { $dev = '<br /><font color="red">' . $tk_theme_name . '_' . $tab . '_' . $r3['name'] . '</font>'; } else { $dev = ''; } if ($r3['type'] == 'text') { //TYPE: TEXT if (isset($r3['options']['size'])) { $size = 'size = "' . $r3['options']['size'] . '"'; } else { $size = ''; } if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td> <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="' . $r3['type'] . '" value="' . htmlspecialchars(stripslashes($val)) . '" ' . @$r3['options']['readonly'] . ' ' . $size . ' /> <span class="description"><br />' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'colorpicker') { //TYPE: COLORPICKER if (isset($r3['options']['size'])) { $size = 'size = "' . $r3['options']['size'] . '"'; } else { $size = ''; } if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td> <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="text" value="' . $val . '" class="color" ' . $size . ' /> <span class="description">' . $r3['desc'] . '</span><input type="button" value="Reset" style="margin-left:15px" name="button' . $r3['id'] . '" id="button_' . $r3['id'] . '"/> ' . $required_hidden_field . ' </td> </tr>'; ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#button_<?php echo $r3['id']; ?> ').live('click', function(){ jQuery('#<?php echo $r3['id']; ?> ').val('<?php echo $r3['value']; ?> '); }) }) </script> <?php } if ($r3['type'] == 'datepicker') { //TYPE: DATEPICKER if (isset($r3['options']['size'])) { $size = 'size = "' . $r3['options']['size'] . '"'; } else { $size = ''; } if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td> <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="text" value="' . $val . '" class="admin-datepicker" ' . $size . ' /> <span class="description">' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'hidden') { //TYPE: HIDDEN if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr>' . $dev . ' <td> <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="' . $r3['type'] . '" value="' . stripslashes($val) . '" /> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'password') { //TYPE: PASSWORD if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td> <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="' . $r3['type'] . '" value="' . $val . '" /> <span class="description">' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'radio') { //TYPE: RADIO if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td>'; for ($i = 0; $i < count($r3['value']); $i++) { if ($r3['value'][$i] == $val) { $checked = 'checked="checked"'; } else { $checked = ''; } echo '<input type="' . $r3['type'] . '" name="' . $r3['name'] . '" value="' . $r3['value'][$i] . '" ' . $checked . ' /> ' . $r3['caption'][$i] . '<br />'; } echo ' <span class="description">' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'checkbox') { //TYPE: CHECKBOX if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); @($val_database = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name'])); } else { $val = $r3['value']; @($val_database = array()); } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td>'; for ($i = 0; $i < count($r3['value']); $i++) { if (@in_array($r3['value'][$i], $val_database)) { $checked = 'checked="checked"'; } else { $checked = ''; } echo '<input type="' . $r3['type'] . '" name="' . $r3['name'] . '[]" value="' . $r3['value'][$i] . '" ' . $checked . ' /> ' . $r3['caption'][$i] . '<br />'; } echo '<input type="' . $r3['type'] . '" name="' . $r3['name'] . '[]" value="" style="display:none;" checked />'; echo ' <span class="description">' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'select') { //TYPE: SELECT if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td> <select name="' . $r3['name'] . '" id="' . $r3['id'] . '">'; for ($i = 0; $i < count($r3['value']); $i++) { if ($r3['value'][$i] == $val) { $selected = 'selected="selected"'; } else { $selected = ''; } echo '<option value="' . $r3['value'][$i] . '" ' . $selected . '>' . $r3['value'][$i] . '</option>'; } echo '</select> <span class="description"><br />' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } //TYPE: STYLE CHANGER if ($r3['type'] == 'stylechanger') { if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } ?> <div class="option-section" style="max-width: 960px;"> <?php foreach ($r3['styles'] as $styleobject) { if ($styleobject == $val) { $checked = 'checked="checked"'; } else { $checked = ''; } ?> <div class="one-style" style="display: inline-block;margin: 50px 10px 10px 10px"> <input type="radio" name="<?php echo $r3['name']; ?> " style="display: inline-block;position: relative;left: 50%;top: -170px;" value="<?php echo $styleobject; ?> " class="style-radio" <?php echo $checked; ?> > <div class="style-preview" style="background-image:url(<?php echo get_template_directory_uri(); ?> /style/stylechanger/<?php echo $styleobject; ?> .png);background-position: center center;width: 150px;height: 150px;display: inline-block;border:1px solid #DFDFDF"></div> </div> <?php } ?> <label class="option-description"><?php echo $r3['description']; ?> </label> </div> <?php } if ($r3['type'] == 'label') { //TYPE: LABEL if (isset($r3['options']['size'])) { $size = 'size = "' . $r3['options']['size'] . '"'; } else { $size = ''; } if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> </tr>'; } if ($r3['type'] == 'textarea') { //TYPE: TEXTAREA if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td> <textarea name="' . $r3['name'] . '" id="' . $r3['id'] . '" rows="' . @$r3['options']['rows'] . '" cols="' . @$r3['options']['cols'] . '">' . stripslashes($val) . '</textarea><br /> <span class="description">' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'file') { //TYPE: FILE if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr valign="top"> <th scope="row">' . $required . '' . $r3['label'] . ' ' . $dev . '</th> <td><label for="' . $r3['id'] . '"> <input class="upload-url" id="' . $r3['id'] . '" type="text" size="36" name="' . $r3['name'] . '" value="' . $val . '" /> <input class="st_upload_button" id="' . $r3['id'] . '_button" type="button" value="Upload" /> <br /><span class="description">' . $r3['desc'] . '</span> </label></td> ' . $required_hidden_field . ' </tr>'; } if ($r3['type'] == 'file_image') { //TYPE: FILE IMAGE if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr valign="top"> <th scope="row">' . $required . '' . $r3['label'] . ' ' . $dev . '</th> <td><label for="' . $r3['id'] . '"> <input class="upload-url" id="' . $r3['id'] . '" type="text" size="36" name="' . $r3['name'] . '" value="' . $val . '" /> <input class="st_upload_button" id="' . $r3['id'] . '_button" type="button" value="Upload" />'; if ($val != '') { echo '<img src="' . $val . '" width="30" height="30" />'; } echo '<br /><span class="description">' . $r3['desc'] . '</span> </label></td> ' . $required_hidden_field . ' </tr>'; } if ($r3['type'] == 'hr') { //TYPE: HR (horizontal line) echo '<tr valign="top"> <td colspan="2"><hr class="hr2" style="background-color: ' . @$r3['options']['color'] . ';color: ' . @$r3['options']['color'] . ';width: ' . @$r3['options']['width'] . ';height: 1px;border: 0 none;"></td> </tr>'; } if ($r3['type'] == 'button') { //TYPE: button (custom button) echo '<tr valign="top"> <td colspan="2" style="margin-left:0;padding-left:0"><input type="button" class="button-secondary" value="' . $r3['value'] . '" name="' . $r3['name'] . '" id="' . $r3['id'] . '"/></td> </tr>'; } if ($r3['type'] == 'pages') { //TYPE: dropdown Pages if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td>'; $args = array('selected' => $val, 'echo' => 1, 'name' => $r3['name']); wp_dropdown_pages($args); '<span class="description"><br />' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'category') { //TYPE: dropdown Categories if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td>'; $args = array('selected' => $val, 'echo' => 1, 'name' => $r3['name']); wp_dropdown_categories($args); '<span class="description"><br />' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } if ($r3['type'] == 'author') { //TYPE: dropdown Authors if (get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']) != '') { $val = get_option($tk_theme_name . '_' . $tab . '_' . $r3['name']); } else { $val = $r3['value']; } echo '<tr> <th><label>' . $required . '' . $r3['label'] . '</label>' . $dev . '</th> <td>'; $args = array('selected' => $val, 'name' => $r3['name']); wp_dropdown_users($args); '<span class="description"><br />' . $r3['desc'] . '</span> ' . $required_hidden_field . ' </td> </tr>'; } } } } $row_items++; } } } echo '</table>'; } ?> <p class="submit" style="clear: both;"> <input type="submit" name="Submit" class="button-primary" value="Update Settings" /> <input type="hidden" name="ilc-settings-submit" value="Y" /> </p> </form> </div> </div> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#button_test').live('click', function(){ jQuery.ajax({ type: "POST", url: "<?php echo get_template_directory_uri(); ?> /inc/reset_colors.php" }).done(function( ) { alert( 'Colors now have default values again!' ); }); }) }) </script> <?php }
function tk_settings_page($par) { global $pagenow, $wp_version; $settings = get_option("tk_theme_settings"); $theme_data = wp_get_theme(get_template_directory() . '/style.css'); ?> <div class="wrap"> <h2><?php $pages = @get_all_pages(); for ($i = 0; $i <= count($pages) - 1; $i++) { if ($pages[$i]['slug'] == $_GET['page']) { echo $pages[$i]['page_title']; } } ?> </h2> <?php if ('true' == esc_attr(@$_GET['error'])) { echo '<div class="error" ><p>All fields marked with (*) are required.</p></div>'; } if ('true' == esc_attr(@$_GET['updated'])) { echo '<div class="updated" ><p>Theme Settings updated.</p></div>'; } if (isset($_GET['tab'])) { tk_admin_tabs($_GET['tab']); } else { tk_admin_tabs(get_first_tab()); } ?> <div id="poststuff"> <form method="post" action="<?php admin_url('admin.php?page=' . $_GET['page']); ?> "> <p class="submit" style="clear: both;"> <input type="submit" name="Submit" class="button-primary" value="Update Settings" /> <input type="hidden" name="ilc-settings-submit" value="Y" /> </p> <?php wp_nonce_field("ilc-settings-page"); if ($pagenow == 'admin.php' && isset($_GET['page'])) { if (isset($_GET['tab'])) { $tab = $_GET['tab']; } else { $tab = get_first_tab(); } echo '<table class="form-table">'; global $tabs; foreach ($tabs as $r1) { if ($r1['id'] == $tab) { $row_items = 1; foreach ($r1 as $r2) { if ($row_items == 4) { if (count($r2) > 0) { foreach ($r2 as $r3) { if (@$r3['options']['required'] == 'yes') { $required = '* '; $required_hidden_field = '<input type="hidden" name="' . $r3['name'] . '_required" value="yes">'; } else { $required = ''; $required_hidden_field = '<input type="hidden" name="' . $r3['name'] . '_required" value="no">'; } if (isset($_GET['dev'])) { $dev = '<br /><font color="red">' . wp_get_theme()->name . '_' . $tab . '_' . $r3['name'] . '</font>'; } else { $dev = ''; } // call block text function if ($r3['type'] == 'text') { tk_block_text($r3, $tab, $dev, $required, $required_hidden_field); } // call block label function if ($r3['type'] == 'label') { tk_block_label($r3, $tab, $dev, $required); } // call block label function if ($r3['type'] == 'colorpicker') { tk_block_colorpicker($r3, $tab, $dev, $required, $required_hidden_field); } // call block label function if ($r3['type'] == 'datepicker') { tk_block_datepicker($r3, $tab, $dev, $required, $required_hidden_field); } // call block hidden function if ($r3['type'] == 'hidden') { tk_block_hidden($r3, $tab, $dev, $required_hidden_field); } // call block password function if ($r3['type'] == 'password') { tk_block_password($r3, $tab, $dev, $required, $required_hidden_field); } // call block radio function if ($r3['type'] == 'radio') { tk_block_radio($r3, $tab, $dev, $required, $required_hidden_field); } // call block checkbox function if ($r3['type'] == 'checkbox') { tk_block_checkbox($r3, $tab, $dev, $required, $required_hidden_field); } // call block font preview function if ($r3['type'] == 'font_preview') { tk_block_font_preview($r3, $tab, $dev, $required, $required_hidden_field); } // call block select function if ($r3['type'] == 'select') { if (isset($r3['class'])) { tk_block_select($r3, $tab, $dev, $required, $required_hidden_field, $r3['class']); } else { tk_block_select($r3, $tab, $dev, $required, $required_hidden_field); } } // call block stylechanger function if ($r3['type'] == 'stylechanger') { tk_block_stylechanger($r3, $tab); } // call block textarea function if ($r3['type'] == 'textarea') { tk_block_textarea($r3, $tab, $dev, $required, $required_hidden_field); } // call block widgetareas function if ($r3['type'] == 'widgetareas') { tk_block_widgetareas($r3, $dev, $required, $required_hidden_field); } // call block file function if ($r3['type'] == 'file') { tk_block_file($r3, $tab, $dev, $required, $required_hidden_field); } // call block file function if ($r3['type'] == 'file_image') { tk_block_file_image($r3, $tab, $dev, $required, $required_hidden_field); } // call block hr function if ($r3['type'] == 'hr') { tk_block_hr($r3); } // call block button function if ($r3['type'] == 'button') { tk_block_custom_button($r3); } // call block pages function if ($r3['type'] == 'pages') { tk_block_pages($r3, $tab, $dev, $required, $required_hidden_field); } // call block pages function if ($r3['type'] == 'posts') { tk_block_posts($r3, $tab, $dev, $required); } // call block category function if ($r3['type'] == 'category') { tk_block_categories($r3, $tab, $dev, $required, $required_hidden_field); } // call block author function if ($r3['type'] == 'author') { tk_block_authors($r3, $tab, $dev, $required, $required_hidden_field); } if ($r3['type'] == 'include') { //TYPE: include include $r3['value']; } // include } } } $row_items++; } } } ?> <?php echo '</table>'; } ?> <p class="submit" style="clear: both;"> <input type="submit" name="Submit" class="button-primary" value="Update Settings" /> <input type="hidden" name="ilc-settings-submit" value="Y" /> </p> </form> </div> </div> <?php }