Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 43.27 KB | None | 0 0
  1. <?php
  2. if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
  3.     tk_theme_install();
  4. }
  5. function populate_theme_options(){
  6.     GLOBAL $tabs,$wp_version;
  7.     $pages = @get_all_pages();
  8.     foreach ($tabs as $r1) {
  9.         foreach ($r1 as $r2) {
  10.             if (count($r2) > 0) {
  11.                 foreach ((array)$r2 as $r3) {
  12.                     if(@$r3['value'] != '' && strlen($r3['name']) != 1 && $r3['type'] != 'select' && $r3['type'] != 'radio' && $r3['type'] != 'checkbox'){
  13.                         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']);}
  14.                     }
  15.                 }
  16.             }
  17.         }
  18.     }
  19. }
  20.  
  21. function tk_theme_install() {
  22.    global $wpdb;
  23.    populate_theme_options(); //populate options from file
  24. }
  25.  
  26. add_action('wp_head', 'tk_theme_head', 99);
  27.  
  28. function tk_theme_head(){
  29.     if(isset($_REQUEST['ipn'])){
  30.         if($_REQUEST['ipn'] == 'paypal'){
  31.             include("ipn_paypal.php");
  32.         }//ipn from paypal
  33.         if($_REQUEST['ipn'] == '2co'){
  34.             include("ipn_2co.php");
  35.         }//ipn from 2checkout.com
  36.     }//isset ipn
  37. }
  38.  
  39. function get_theme_option($option_name){
  40.     GLOBAL $tabs;
  41.     $option_value = get_option($option_name);
  42.  
  43.     if(is_array($option_value)){
  44.         if(count($option_value) > 2){
  45.             return stripslashes_deep($option_value);
  46.         }else{
  47.             return (stripslashes($option_value['0']));
  48.         }
  49.     }else{
  50.         if($option_value != ''){
  51.             return (stripslashes($option_value));
  52.         }
  53.     }
  54. }
  55.  
  56. function my_admin_scripts() {
  57.     wp_enqueue_script('media-upload');
  58.     wp_enqueue_script('thickbox');
  59.     wp_enqueue_script('my-upload');
  60. }
  61.  
  62. function my_admin_styles() {
  63.     wp_enqueue_style('thickbox');
  64. }
  65.  
  66. if (isset($_GET['page']) && isset($_GET['page'])) {
  67.     add_action('admin_print_scripts', 'my_admin_scripts');
  68.     add_action('admin_print_styles', 'my_admin_styles');
  69. }
  70.  
  71. add_action('admin_head', 'includeScript');
  72.  
  73. function get_first_tab() {
  74.     GLOBAL $tabs;
  75.     require_once('admin-settings.php');
  76.     $i = 0;
  77.     foreach ($tabs as $tab) {
  78.         if ($tab['pg']['slug'] == $_GET['page']) {
  79.             if ($i == 0) {
  80.                 return $tab['id'];
  81.             }
  82.         }
  83.     }
  84. }
  85.  
  86. function get_all_pages() {
  87.     GLOBAL $tabs;
  88.     $pages = array();
  89.     require_once('admin-settings.php');
  90.     $i = 0;
  91.     $last_val = '';
  92.     foreach ((array)$tabs as $tab) {
  93.         if ($last_val != $tab['pg']) {
  94.             $pages[] = $tab['pg'];
  95.             $last_val = $tab['pg'];
  96.         }
  97.     }
  98.     return $pages;
  99. }
  100.  
  101. function includeScript() {
  102.     ?>
  103. <script type='text/javascript'>
  104.  
  105.        jQuery(document).ready(function() {
  106.  
  107.        var formfield;
  108.            jQuery('.st_upload_button').click(function() {
  109.                formfield ='checker';
  110.                targetfield = jQuery(this).prev('.upload-url');
  111.                post_id = '';
  112.                tb_show('', 'media-upload.php?post_id='+post_id+'&type=image&amp;TB_iframe=true');
  113.                return false;
  114.            });
  115.  
  116.      window.original_send_to_editor = window.send_to_editor;
  117.      window.send_to_editor = function(html){
  118.  
  119.        if (formfield) {
  120.                     imgurl = jQuery(html).attr('href');
  121.                     jQuery(targetfield).val(imgurl);
  122.                     formfield = null;
  123.                     tb_remove();
  124.                }
  125.  
  126.                else {
  127.            window.original_send_to_editor(html);
  128.                        formfield = null;
  129.        }
  130.            }
  131.  
  132. // Repeatable meta boxes
  133.     jQuery('.repeatable-add').click(function() {
  134.         field = jQuery(this).closest('td').find('.custom_repeatable li:last').clone(true);
  135.         fieldLocation = jQuery(this).closest('td').find('.custom_repeatable li:last');
  136.         jQuery('.upload-url', field).val('').attr('name', function(index, name) {
  137.             return name.replace(/(\d+)/, function(fullMatch, n) {
  138.                 return Number(n) + 1;
  139.             });
  140.         })
  141.         field.insertAfter(fieldLocation, jQuery(this).closest('td'))
  142.         return false;
  143.     });
  144.  
  145.     jQuery('.repeatable-remove').click(function(){
  146.         jQuery(this).parent().remove();
  147.         return false;
  148.     });
  149.  
  150. <?php
  151. function check_is_admin_post(){
  152. $current_page = basename($_SERVER['REQUEST_URI'], ".php");
  153. if (preg_match("/post-new/i", $current_page) || isset($_GET['post'])) {
  154. return true;
  155.     }else{
  156.         return false;
  157.     }
  158. }
  159.  
  160. if(check_is_admin_post()){
  161. ?>
  162.     jQuery('.custom_repeatable').sortable({
  163.         opacity: 0.6,
  164.         revert: true,
  165.         cursor: 'move',
  166.         handle: '.sort'
  167.     });
  168.         <?php } ?>
  169.  
  170.            jQuery( ".admin-datepicker" ).datepicker({ dateFormat: "dd-mm-yy" });
  171.  
  172.  
  173.        });
  174.  
  175. </script>
  176. <script type="text/javascript" src="<?php echo get_template_directory_uri().'/script/jscolor/jscolor.js';?>"></script>
  177.  
  178.        
  179.  
  180.     <script type="text/javascript" src="<?php echo get_stylesheet_directory_uri().'/script/jscolor/jscolor.js';?>"></script>
  181.     <link rel="stylesheet" media="screen" href="<?php echo get_stylesheet_directory_uri().'/script/datepicker/css/smoothness/jquery-ui-1.10.3.custom.css';?>" type="text/css" />
  182.     <script type="text/javascript" src="<?php echo get_stylesheet_directory_uri().'/script/datepicker/js/jquery-ui-1.10.3.custom.min.js';?>"></script>
  183.  
  184.  
  185.     <?php
  186. }
  187.  
  188.  
  189. add_action('admin_menu', 'tk_settings_page_init');
  190. $tabs = '';
  191.  
  192. function tk_settings_page_init() {
  193.     global $wp_version;
  194.     $tk_theme_name = get_option('tk_theme_name');
  195.     $pages = @get_all_pages();
  196.     if ( version_compare( $wp_version, '3.4', '>=' ) ) {$theme_data = wp_get_theme(TEMPLATEPATH . '/style.css');}else{$theme_data = get_theme_data(TEMPLATEPATH . '/style.css');}
  197.     $settings_page = '';
  198.     for ($i = 0; $i <= count($pages) - 1; $i++) {
  199.         if ($i == 0) {
  200.             $settings_page .= add_menu_page($pages[$i]['slug'], ucfirst(tk_theme_name), 'edit_theme_options', $pages[$i]['slug'], 'tk_settings_page');
  201.             $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');
  202.         } else {
  203.             $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');
  204.         }
  205.     }
  206. }
  207.  
  208.     if (@$_POST["ilc-settings-submit"] == 'Y') {
  209.         if (@$_GET['tab'] == '') {
  210.             $tab = get_first_tab();
  211.         } else {
  212.             $tab = @$_GET['tab'];
  213.         }
  214.         $required_error = 0;
  215.  
  216.         foreach ($_POST as $var => $value) {
  217.             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
  218.                 if (@$_POST[$var . '_required'] == 'yes') {
  219.                     if ($_POST[$var] == '') {
  220.                         $required_error++;
  221.                     }
  222.                 }
  223.             }
  224.         }
  225.  
  226.         if ($required_error == 0) {
  227.             tk_save_theme_settings();
  228.             $url_parameters = isset($tab) ? 'updated=true&tab=' . $tab : 'updated=true';
  229.         } else {
  230.             $url_parameters = isset($tab) ? 'error=true&tab=' . $tab : 'error=true';
  231.         }
  232.         wp_redirect(admin_url('admin.php?page=' . $_GET['page'] . '&' . $url_parameters));
  233.     }
  234.    
  235.    
  236. function tk_advert() {
  237.     include('advert-widget.php');
  238. }
  239.  
  240. function tk_save_theme_settings() {
  241.     global $pagenow;
  242.     $tk_theme_name = get_option('tk_theme_name');
  243.     if (@$_GET['tab'] == '') {
  244.         $tab = get_first_tab();
  245.     } else {
  246.         $tab = @$_GET['tab'];
  247.     }
  248.     if ($pagenow == 'admin.php' && isset($_GET['page'])) {
  249.         if (isset($tab)) {
  250.  
  251.             foreach ($_POST as $var => $value) {
  252.                 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
  253.                     update_option($tk_theme_name.'_'.$tab . '_' . $var, $value);
  254.                 }
  255.             }
  256.         }
  257.     }
  258. }
  259.  
  260. function tk_admin_tabs($current) {
  261.     GLOBAL $tabs;
  262.  
  263.     if ($current == '') {
  264.         $current = get_first_tab();
  265.     }
  266.  
  267.     require_once('admin-settings.php');
  268.  
  269.     echo '<div id="icon-themes" class="icon32"><br></div>';
  270.     echo '<h2 class="nav-tab-wrapper">';
  271.  
  272.     $i = 0;
  273.     foreach ($tabs as $tab) {
  274.         if ($tab['pg']['slug'] == $_GET['page']) {
  275.             if ($i == 0) {
  276.                 $i++;
  277.             }
  278.             $class = ( $tab['id'] == $current ) ? ' nav-tab-active' : '';
  279.             echo '<a class="nav-tab' . $class . '"  href="?page=' . $_GET['page'] . '&tab=', $tab['id'], '">', $tab['name'], '</a>';
  280.         }
  281.     }
  282.     echo '</h2>';
  283. }
  284.  
  285. function tk_settings_page($par) {
  286.     global $pagenow, $wp_version;
  287.     $settings = get_option("tk_theme_settings");
  288.     if ( version_compare( $wp_version, '3.4', '>=' ) ) {$theme_data = wp_get_theme(TEMPLATEPATH . '/style.css');}else{$theme_data = get_theme_data(TEMPLATEPATH . '/style.css');}
  289.     ?>
  290.  
  291.     <div class="wrap">
  292.         <h2><?php
  293.     $pages = @get_all_pages();
  294.     for ($i = 0; $i <= count($pages) - 1; $i++) {
  295.         if ($pages[$i]['slug'] == $_GET['page']) {
  296.             echo $pages[$i]['page_title'];
  297.         }
  298.     }
  299.     ?></h2>
  300.  
  301.         <?php
  302.         if ('true' == esc_attr(@$_GET['error']))
  303.             echo '<div class="error" ><p>All fields marked with (*) are required.</p></div>';
  304.         if ('true' == esc_attr(@$_GET['updated']))
  305.             echo '<div class="updated" ><p>Theme Settings updated.</p></div>';
  306.  
  307.         if (isset($_GET['tab']))
  308.             tk_admin_tabs($_GET['tab']); else
  309.             tk_admin_tabs(get_first_tab());
  310.         ?>
  311.  
  312.         <div id="poststuff">
  313.             <form method="post" action="<?php admin_url('admin.php?page=' . $_GET['page']); ?>">
  314.                 <?php
  315.                 wp_nonce_field("ilc-settings-page");
  316.                 if ($pagenow == 'admin.php' && isset($_GET['page'])) {
  317.                     if (isset($_GET['tab']))
  318.                         $tab = $_GET['tab'];
  319.                     else
  320.                         $tab = get_first_tab();
  321.  
  322.                     echo '<table class="form-table">';
  323.  
  324.  
  325.                     GLOBAL $tabs;
  326.                     $tk_theme_name = get_option('tk_theme_name');
  327.                     foreach ($tabs as $r1) {
  328.                         if ($r1['id'] == $tab) {
  329.                             $row_items = 1;
  330.                             foreach ($r1 as $r2) {
  331.  
  332.                                 if ($row_items == 4) {
  333.                                     if (count($r2) > 0) {
  334.  
  335.                                         foreach ($r2 as $r3) {
  336.  
  337.                                             if (@$r3['options']['required'] == 'yes') {
  338.                                                 $required = '* ';
  339.                                                 $required_hidden_field = '<input type="hidden" name="' . $r3['name'] . '_required" value="yes">';
  340.                                             } else {
  341.                                                 $required = '';
  342.                                                 $required_hidden_field = '<input type="hidden" name="' . $r3['name'] . '_required" value="no">';
  343.                                             }
  344.  
  345.                                             if(isset($_GET['dev'])){
  346.                                                 $dev = '<br /><font color="red">'.$tk_theme_name.'_'.$tab . '_' . $r3['name'].'</font>';
  347.                                             }else{
  348.                                                 $dev = '';
  349.                                             }
  350.  
  351.                                             if ($r3['type'] == 'text') {//TYPE: TEXT
  352.  
  353.                                                 if (isset($r3['options']['size'])) {
  354.                                                     $size = 'size = "'.$r3['options']['size'].'"';
  355.                                                 }else{
  356.                                                     $size = '';
  357.                                                 }
  358.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  359.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  360.  
  361.                                                 } else {
  362.                                                     $val = $r3['value'];
  363.  
  364.                                                 }
  365.  
  366.  
  367.                                                 echo '<tr>
  368.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  369.                                                                        <td>
  370.                                                                            <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="' . $r3['type'] . '" value="' . htmlspecialchars(stripslashes($val)) . '" ' . @$r3['options']['readonly'] . ' '.$size.' />
  371.                                                                            <span class="description"><br />' . $r3['desc'] . '</span>
  372.                                                                            ' . $required_hidden_field . '
  373.                                                                        </td>
  374.                                                                    </tr>';
  375.                                             }
  376.  
  377.                                             if ($r3['type'] == 'label') {//TYPE: LABEL
  378.  
  379.                                                 if (isset($r3['options']['size'])) {
  380.                                                     $size = 'size = "'.$r3['options']['size'].'"';
  381.                                                 }else{
  382.                                                     $size = '';
  383.                                                 }
  384.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  385.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  386.  
  387.                                                 } else {
  388.                                                     $val = $r3['value'];
  389.  
  390.                                                 }
  391.  
  392.  
  393.                                                 echo '<tr>
  394.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  395.                                                                    </tr>';
  396.                                             }
  397.  
  398.                                             if ($r3['type'] == 'colorpicker') {//TYPE: COLORPICKER
  399.  
  400.                                                 if (isset($r3['options']['size'])) {
  401.                                                     $size = 'size = "'.$r3['options']['size'].'"';
  402.                                                 }else{
  403.                                                     $size = '';
  404.                                                 }
  405.  
  406.  
  407.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  408.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  409.  
  410.                                                 } else {
  411.                                                     $val = $r3['value'];
  412.  
  413.                                                 }
  414.                                                 if(!empty($r3['clear']) && $r3['clear']=='yes'){$clear = '<input type="button" value="Clear" style="margin-left:15px" name="clear'.$r3['id'].'" id="clear'.$r3['id'].'"/>';}else{$clear='';}
  415.                                                 echo '<tr>
  416.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  417.                                                                        <td>
  418.                                                                            <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="text" value="' . $val . '" class="color" '.$size.' />
  419.                                                                            <span class="description">' . $r3['desc'] . '</span><input type="button" value="Reset" style="margin-left:15px" name="button'.$r3['id'].'" id="button_'.$r3['id'].'"/>
  420.                                                                            ' .$clear. $required_hidden_field . '
  421.                                                                        </td>
  422.                                                                    </tr>';?>
  423.  
  424.                                             <script type="text/javascript">
  425.                                                 jQuery(document).ready(function(){
  426.                                                     jQuery('#button_<?php echo $r3['id']?>').live('click', function(){
  427.                                                         jQuery('#<?php echo $r3['id']?>').val('<?php echo $r3['value']?>');
  428.                                                     })
  429.                                                 })
  430.                                             </script>
  431.  
  432.                                             <?php
  433.                                             }
  434.  
  435.                                             if ($r3['type'] == 'datepicker') {//TYPE: DATEPICKER
  436.  
  437.                                                 if (isset($r3['options']['size'])) {
  438.                                                     $size = 'size = "'.$r3['options']['size'].'"';
  439.                                                 }else{
  440.                                                     $size = '';
  441.                                                 }
  442.  
  443.  
  444.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  445.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  446.  
  447.                                                 } else {
  448.                                                     $val = $r3['value'];
  449.  
  450.                                                 }
  451.  
  452.                                                 echo '<tr>
  453.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  454.                                                                        <td>
  455.                                                                            <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="text" value="' . $val . '" class="admin-datepicker" '.$size.' />
  456.                                                                            <span class="description">' . $r3['desc'] . '</span>
  457.                                                                            ' . $required_hidden_field . '
  458.                                                                        </td>
  459.                                                                    </tr>';
  460.                                             }
  461.  
  462.                                             if ($r3['type'] == 'hidden') {//TYPE: HIDDEN
  463.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  464.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  465.                                                 } else {
  466.                                                     $val = $r3['value'];
  467.                                                 }
  468.                                                 echo '<tr>'.$dev.'
  469.                                                                        <td>
  470.                                                                            <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="' . $r3['type'] . '" value="' . stripslashes($val) . '" />
  471.                                                                                ' . $required_hidden_field . '
  472.                                                                        </td>
  473.                                                                    </tr>';
  474.                                             }
  475.  
  476.                                             if ($r3['type'] == 'password') {//TYPE: PASSWORD
  477.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  478.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  479.                                                 } else {
  480.                                                     $val = $r3['value'];
  481.                                                 }
  482.                                                 echo '<tr>
  483.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  484.                                                                        <td>
  485.                                                                            <input id="' . $r3['id'] . '" name="' . $r3['name'] . '" type="' . $r3['type'] . '" value="' . $val . '" />
  486.                                                                            <span class="description">' . $r3['desc'] . '</span>
  487.                                                                                ' . $required_hidden_field . '
  488.                                                                        </td>
  489.                                                                    </tr>';
  490.                                             }
  491.  
  492.                                             if ($r3['type'] == 'radio') {//TYPE: RADIO
  493.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  494.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  495.                                                 } else {
  496.                                                     $val = $r3['value'];
  497.                                                 }
  498.                                                 echo '<tr>
  499.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  500.                                                                        <td>';
  501.  
  502.                                                 for ($i = 0; $i < (count($r3['value'])); $i++) {
  503.                                                     if ($r3['value'][$i] == $val) {
  504.                                                         $checked = 'checked="checked"';
  505.                                                     } else {
  506.                                                         $checked = '';
  507.                                                     }
  508.                                                     echo '<input type="' . $r3['type'] . '" name="' . $r3['name'] . '" value="' . $r3['value'][$i] . '" ' . $checked . ' /> ' . $r3['caption'][$i] . '<br />';
  509.                                                 }
  510.  
  511.  
  512.                                                 echo '
  513.                                                                            <span class="description">' . $r3['desc'] . '</span>
  514.                                                                                ' . $required_hidden_field . '
  515.                                                                        </td>
  516.                                                                    </tr>';
  517.                                             }
  518.  
  519.                                             if ($r3['type'] == 'checkbox') {//TYPE: CHECKBOX
  520.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  521.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  522.                                                     @$val_database = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  523.                                                 } else {
  524.                                                     $val = $r3['value'];
  525.                                                     @$val_database = array();
  526.                                                 }
  527.                                                 echo '<tr>
  528.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  529.                                                                        <td>';
  530.  
  531.                                                 for ($i = 0; $i < (count($r3['value'])); $i++) {
  532.  
  533.                                                     if (@in_array($r3['value'][$i], $val_database)) {
  534.                                                         $checked = 'checked="checked"';
  535.  
  536.                                                     } else {
  537.                                                         $checked = '';
  538.                                                     }
  539.  
  540.                                                     echo '<input type="' . $r3['type'] . '" name="' . $r3['name'] . '[]" value="' . $r3['value'][$i] . '" ' . $checked . ' /> ' . $r3['caption'][$i] . '<br />';
  541.                                                 }
  542.  
  543.                                                 echo '<input type="' . $r3['type'] . '" name="' . $r3['name'] . '[]" value="" style="display:none;" checked />';
  544.  
  545.                                                 echo '
  546.                                                                            <span class="description">' . $r3['desc'] . '</span>
  547.                                                                                ' . $required_hidden_field . '
  548.                                                                        </td>
  549.                                                                    </tr>';
  550.                                             }
  551.  
  552.                                             if ($r3['type'] == 'select') {//TYPE: SELECT
  553.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  554.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  555.                                                 } else {
  556.                                                     $val = $r3['value'];
  557.                                                 }
  558.                                                 echo '<tr>
  559.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  560.                                                                        <td>
  561.                                                                            <select name="' . $r3['name'] . '" id="' . $r3['id'] . '">';
  562.  
  563.                                                 for ($i = 0; $i < (count($r3['value'])); $i++) {
  564.                                                     if ($r3['value'][$i][1] == $val) {
  565.                                                         $selected = 'selected="selected"';
  566.                                                     } else {
  567.                                                         $selected = '';
  568.                                                     }
  569.                                                     echo '<option value="' . $r3['value'][$i][1] . '" ' . $selected . '>' . $r3['value'][$i][0] . '</option>';
  570.                                                 }
  571.  
  572.  
  573.                                                 echo '</select>
  574.                                                                            <span class="description"><br />' . $r3['desc'] . '</span>
  575.                                                                            ' . $required_hidden_field . '
  576.                                                                        </td>
  577.                                                                    </tr>';
  578.                                             }
  579.  
  580.  
  581.                                             //TYPE: STYLE CHANGER
  582.                                             if ($r3['type']  == 'stylechanger') {
  583.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  584.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  585.                                                 } else {
  586.                                                     $val = $r3['value'];
  587.                                                 }
  588.                                                 ?>
  589.                                             <div class="option-section" style="max-width: 960px;">
  590.  
  591.                                                 <?php foreach ($r3['styles'] as $styleobject) {
  592.                                                     if ($styleobject == $val) {
  593.                                                         $checked = 'checked="checked"';
  594.                                                     } else {
  595.                                                         $checked = '';
  596.                                                     }
  597.                                                     ?>
  598.                                             <div class="one-style" style="display: inline-block;margin: 50px 10px 10px 10px">
  599.                                             <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?> >
  600.                                             <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>
  601.                                             </div>
  602.                                                     <?php } ?>
  603.                                             <label class="option-description"><?php echo $r3['description']?></label>
  604.                                             </div>
  605.                                                 <?php   }
  606.  
  607.  
  608.                                             if ($r3['type'] == 'textarea') {//TYPE: TEXTAREA
  609.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  610.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  611.                                                 } else {
  612.                                                     $val = $r3['value'];
  613.                                                 }
  614.                                                 echo '<tr>
  615.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  616.                                                                        <td>
  617.                                                                            <textarea name="' . $r3['name'] . '" id="' . $r3['id'] . '" rows="' . @$r3['options']['rows'] . '" cols="' . @$r3['options']['cols'] . '">' . stripslashes($val) . '</textarea><br />
  618.                                                                            <span class="description">' . $r3['desc'] . '</span>
  619.                                                                                ' . $required_hidden_field . '
  620.                                                                        </td>
  621.                                                                    </tr>';
  622.                                             }
  623.  
  624.                                             if ($r3['type'] == 'file') {//TYPE: FILE
  625.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  626.  
  627.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  628.                                                 } else {
  629.                                                     $val = $r3['value'];
  630.                                                 }
  631.                                                 if(!empty($r3['clear']) && $r3['clear']=='yes'){$clear = '<input type="button" value="Clear" style="margin-left:15px" name="clear'.$r3['id'].'" id="clear'.$r3['id'].'"/>';}else{$clear='';}
  632.                                                 echo '<tr valign="top">
  633.                                                                        <th scope="row">' . $required . '' . $r3['label'] . ' '.$dev.'</th>
  634.                                                                        <td><label for="' . $r3['id'] . '">
  635.                                                                        <input class="upload-url" id="' . $r3['id'] . '" type="text" size="36" name="' . $r3['name'] . '" value="' . $val . '" />
  636.                                                                        <input class="st_upload_button" id="' . $r3['id'] . '_button" type="button" value="Upload" />'.$clear.'
  637.                                                                        <br /><span class="description">' . $r3['desc'] . '</span>
  638.                                                                        </label></td>
  639.                                                                        ' . $required_hidden_field . '
  640.                                                                      </tr>';
  641.                                             }
  642.  
  643.  
  644.                                             if ($r3['type'] == 'file_image') {//TYPE: FILE IMAGE
  645.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  646.  
  647.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  648.                                                 } else {
  649.                                                     $val = $r3['value'];
  650.                                                 }
  651.                                                 echo '<tr valign="top">
  652.                                                                        <th scope="row">' . $required . '' . $r3['label'] . ' '.$dev.'</th>
  653.                                                                        <td><label for="' . $r3['id'] . '">
  654.  
  655.                                                                        <input class="upload-url" id="' . $r3['id'] . '" type="text" size="36" name="' . $r3['name'] . '" value="' . $val . '" />
  656.                                                                        <input class="st_upload_button" id="' . $r3['id'] . '_button" type="button" value="Upload" />';
  657.                                                 if ($val != '') {
  658.                                                     echo '<img src="' . $val . '" width="30" height="30" />';
  659.                                                 }
  660.                                                 echo '<br /><span class="description">' . $r3['desc'] . '</span>
  661.                                                                            </label></td>
  662.                                                                            ' . $required_hidden_field . '
  663.                                                                      </tr>';
  664.                                             }
  665.  
  666.                                             if ($r3['type'] == 'hr') {//TYPE: HR (horizontal line)
  667.  
  668.                                                 echo '<tr valign="top">
  669.                                                        <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>
  670.                                                      </tr>';
  671.                                             }
  672.  
  673.                                             if ($r3['type'] == 'button') {//TYPE: button (custom button)
  674.  
  675.                                                 echo '<tr valign="top">
  676.                                                        <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>
  677.                                                      </tr>';
  678.                                             }
  679.  
  680.                                             if ($r3['type'] == 'pages') {//TYPE: dropdown Pages
  681.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  682.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  683.                                                 } else {
  684.                                                     $val = $r3['value'];
  685.                                                 }
  686.                                                 echo '<tr>
  687.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  688.                                                                        <td>';
  689.  
  690.                                                                         $args = array(
  691.                                                                            'selected'         => $val,
  692.                                                                             'echo'             => 1,
  693.                                                                             'name'             => $r3['name']);
  694.                                                                              wp_dropdown_pages( $args );
  695.                                                                             '<span class="description"><br />' . $r3['desc'] . '</span>
  696.                                                                            ' . $required_hidden_field . '
  697.                                                                        </td>
  698.                                                                    </tr>';
  699.  
  700.                                                 }
  701.  
  702.                                             if ($r3['type'] == 'category') {//TYPE: dropdown Categories
  703.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  704.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  705.                                                 } else {
  706.                                                     $val = $r3['value'];
  707.                                                 }
  708.                                                 echo '<tr>
  709.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  710.                                                                        <td>';
  711.  
  712.                                                                         $args = array(
  713.                                                                            'selected'         => $val,
  714.                                                                             'echo'             => 1,
  715.                                                                             'name'             => $r3['name']);
  716.                                                                              wp_dropdown_categories( $args );
  717.                                                                             '<span class="description"><br />' . $r3['desc'] . '</span>
  718.                                                                            ' . $required_hidden_field . '
  719.                                                                        </td>
  720.                                                                    </tr>';
  721.  
  722.                                                 }
  723.  
  724.                                             if ($r3['type'] == 'author') {//TYPE: dropdown Authors
  725.                                                 if (get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']) != '') {
  726.                                                     $val = get_option($tk_theme_name.'_'.$tab . '_' . $r3['name']);
  727.                                                 } else {
  728.                                                     $val = $r3['value'];
  729.                                                 }
  730.                                                 echo '<tr>
  731.                                                                        <th><label>' . $required . '' . $r3['label'] . '</label>'.$dev.'</th>
  732.                                                                        <td>';
  733.  
  734.                                                                         $args = array(
  735.                                                                            'selected'         => $val,
  736.                                                                             'name'             => $r3['name']);
  737.                                                                              wp_dropdown_users( $args );
  738.                                                                             '<span class="description"><br />' . $r3['desc'] . '</span>
  739.                                                                            ' . $required_hidden_field . '
  740.                                                                        </td>
  741.                                                                    </tr>';
  742.  
  743.                                                 }
  744.                                                                              
  745.                                                
  746.                                                
  747.                                                
  748.                                                
  749.                                         }
  750.                                     }
  751.                                 }
  752.                                 $row_items++;
  753.                             }
  754.                         }
  755.                     }
  756.  
  757.  
  758.                     echo '</table>';
  759.                 }
  760.                 ?>
  761.                 <p class="submit" style="clear: both;">
  762.                     <input type="submit" name="Submit"  class="button-primary" value="Update Settings" />
  763.                     <input type="hidden" name="ilc-settings-submit" value="Y" />
  764.                 </p>
  765.             </form>
  766.         </div>
  767.     </div>
  768.  
  769.         <script type="text/javascript">
  770.  
  771.         jQuery(document).ready(function(){
  772.  
  773.             jQuery('#button_test').live('click', function(){
  774.  
  775.                 jQuery.ajax({
  776.                     type: "POST",
  777.                     url: "<?php echo get_template_directory_uri()?>/inc/reset_colors.php"
  778.                 }).done(function( ) {
  779.                     alert( 'Colors now have default values again!' );
  780.                 });
  781.  
  782.  
  783.             })
  784.  
  785.         })
  786.  
  787.     </script>
  788. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement