plas71k

codelock - decoded - admin-interface - free version

Nov 22nd, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.24 KB | None | 0 0
  1. <?php
  2. /*-----------------------------------------------------------------------------------*/
  3. /* Admin Interface
  4. /*-----------------------------------------------------------------------------------*/
  5. $functions_path = THEME_ADMIN . '/';
  6. function siteoptions_add_admin() {
  7.  
  8.     global $query_string;
  9.    
  10.     if ( isset($_REQUEST['page']) && $_REQUEST['page'] == 'siteoptions' ) {
  11.         if (isset($_REQUEST['of_save']) && 'reset' == $_REQUEST['of_save']) {
  12.             $options =  get_option('of_template');
  13.             of_reset_options($options,'siteoptions');
  14.             header("Location: admin.php?page=siteoptions&reset=true");
  15.             die;
  16.         }
  17.     }
  18.        
  19.     $tt_page = add_theme_page('Chameleon Setting', 'Chameleon Setting', 'edit_theme_options', 'siteoptions','siteoptions_options_page');
  20.     add_action("admin_print_scripts-$tt_page", 'of_load_only');
  21.     add_action("admin_print_styles-$tt_page",'of_style_only');
  22. }
  23.  
  24. add_action('admin_menu', 'siteoptions_add_admin');
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. /*-----------------------------------------------------------------------------------*/
  33. /* Reset Function
  34. /*-----------------------------------------------------------------------------------*/
  35.  
  36. function of_reset_options($options,$page = ''){
  37.  
  38.     global $wpdb;
  39.     $query_inner = '';
  40.     $count = 0;
  41.    
  42.     $excludes = array( 'blogname' , 'blogdescription' );
  43.    
  44.     foreach($options as $option){          
  45.         if(isset($option['id'])){
  46.             $count++;
  47.             $option_id = $option['id'];
  48.             $option_type = $option['type'];
  49.            
  50.             //Skip assigned id's
  51.             if(in_array($option_id,$excludes)) { continue; }
  52.            
  53.             if($count > 1){ $query_inner .= ' OR '; }
  54.             if($option_type == 'multicheck'){
  55.                 $multicount = 0;
  56.                 foreach($option['options'] as $option_key => $option_option){
  57.                     $multicount++;
  58.                     if($multicount > 1){ $query_inner .= ' OR '; }
  59.                     $query_inner .= "option_name = '" . $option_id . "_" . $option_key . "'";
  60.                    
  61.                 }
  62.                
  63.             } else if(is_array($option_type)) {
  64.                 $type_array_count = 0;
  65.                 foreach($option_type as $inner_option){
  66.                     $type_array_count++;
  67.                     $option_id = $inner_option['id'];
  68.                     if($type_array_count > 1){ $query_inner .= ' OR '; }
  69.                     $query_inner .= "option_name = '$option_id'";
  70.                 }
  71.                
  72.             } else {
  73.                 $query_inner .= "option_name = '$option_id'";
  74.             }
  75.         }
  76.            
  77.     }
  78.    
  79.     //When Theme Options page is reset - Add the of_options option
  80.     if($page == 'siteoptions'){
  81.         $query_inner .= " OR option_name = 'of_options'";
  82.     }
  83.    
  84.     //echo $query_inner;
  85.    
  86.     $query = "DELETE FROM $wpdb->options WHERE $query_inner";
  87.     $wpdb->query($query);
  88.     $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/styledefault.css";
  89.     $handle = fopen($filename, "r");
  90.     $contents = fread($handle, filesize($filename));
  91.     fclose($handle);
  92.     // Let's make sure the file exists and is writable first.
  93.     $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/style.css";
  94.     if (is_writable($filename)) {
  95.         if (!$handle = fopen($filename, 'w+')) {
  96.             echo "Cannot open file ($filename)<br>";
  97.             exit;
  98.         }
  99.     // Write $contents to our opened file.
  100.        if (fwrite($handle, $contents) === FALSE) {
  101.             echo "Cannot write file ($filename)<br>";
  102.             exit;
  103.         }
  104.     } else {
  105.         echo "File $filename has not write permission.<br>";
  106.         exit;
  107.     }
  108.     $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/images/price-tagori.png";
  109.     $handle = fopen($filename, "r");
  110.     $contents = fread($handle, filesize($filename));
  111.     fclose($handle);
  112.     // Let's make sure the file exists and is writable first.
  113.     $filename = $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/ts_chameleon/images/price-tag.png";
  114.     if (is_writable($filename)) {
  115.         if (!$handle = fopen($filename, 'w+')) {
  116.             echo "Cannot open file ($filename)<br>";
  117.             exit;
  118.         }
  119.     // Write $contents to our opened file.
  120.        if (fwrite($handle, $contents) === FALSE) {
  121.             echo "Cannot write file ($filename)<br>";
  122.             exit;
  123.         }
  124.     } else {
  125.         echo "File $filename has not write permission.<br>";
  126.         exit;
  127.     }
  128. }
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. /*-----------------------------------------------------------------------------------*/
  140. /* Build the Options Page
  141. /*-----------------------------------------------------------------------------------*/
  142.  
  143. function siteoptions_options_page(){
  144.     $options =  get_option('of_template');      
  145.     $themename =  get_option('of_themename');
  146.     if (get_option('ts_chameleon_license'))
  147.     {
  148.         $myLicense = get_option('ts_chameleon_license');
  149.         $maindomain = trim(ts_chameleon_maindomain(home_url()));
  150.         $compareLicensePro = substr(md5($maindomain.'proch4m3l30nth3m35070173'.$myLicense['email']),0,32);
  151.         $compareLicenseFree = substr(md5($maindomain.'070173ch4m3l30nth3m354fr33'.$myLicense['email']),0,32);
  152.         if ( ($compareLicensePro==$myLicense['license']) || ($compareLicenseFree==$myLicense['license']) )
  153.         {
  154.             ?>
  155.             <div class="wrap" id="truethemes_container">
  156.               <div id="of-popup-save" class="of-save-popup">
  157.                 <div class="of-save-save">Options Updated</div>
  158.               </div>
  159.               <div id="of-popup-reset" class="of-save-popup">
  160.                 <div class="of-save-reset">Options Reset</div>
  161.               </div>
  162.               <form action="" enctype="multipart/form-data" id="ofform">
  163.                 <div id="header">
  164.                   <div class="logo">
  165.                     <h2>Chameleon Setting</h2>
  166.                   </div>
  167.                   <div class="icon-option"> </div>
  168.                   <div class="clear"></div>
  169.                 </div>
  170.                 <?php
  171.                     // Rev up the Options Machine
  172.                     $return = siteoptions_machine($options);
  173.                     ?>
  174.                 <div id="main">
  175.                   <div id="of-nav">
  176.                     <ul>
  177.                       <?php echo $return[1] ?>
  178.                     </ul>
  179.                   </div>
  180.                   <div id="content"> <?php echo $return[0]; /* Settings */ ?> </div>
  181.                   <div class="clear"></div>
  182.                 </div>
  183.                 <div class="save_bar_top">
  184.                 <img style="display:none;" src="<?php echo get_template_directory_uri() ?>/admin/images/wpspin_light.gif" class="ajax-loading-img ajax-loading-img-bottom" alt="Working..." />
  185.                 <input type="submit" value="Save All Changes" class="button-primary" />
  186.               </form>
  187.               <form action="<?php echo esc_attr( $_SERVER['REQUEST_URI'] ) ?>" method="post" style="display:inline" id="ofform-reset">
  188.                 <span class="submit-footer-reset">
  189.                 <input name="reset" type="submit" value="Reset Options" class="button submit-button reset-button" onclick="return confirm('CAUTION: Any and all settings will be lost! Click OK to reset.');" />
  190.                 <input type="hidden" name="of_save" value="reset" />
  191.                 </span>
  192.               </form>
  193.             </div>
  194.             <?php  if (!empty($update_message)) echo $update_message; ?>
  195.             <div style="clear:both;"></div>
  196.             </div>
  197.             <!--wrap-->
  198.             <?php
  199.         } else {
  200.             echo '<h3>Your ACTIVATION KEY is invalid.</h3><div>Please input your right ACTIVATION KEY or request one by click on <strong>Chameleon Setting</strong> under <strong>Appearance</strong> menu.</div>';
  201.             delete_option('ts_chameleon_license');
  202.         }
  203.     } else {
  204.         ts_chameleon_license();
  205.     }
  206. }
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215. /*-----------------------------------------------------------------------------------*/
  216. /* Load required styles for Options Page
  217. /*-----------------------------------------------------------------------------------*/
  218. require_once(TEMPLATEPATH . '/admin/admin-library.php');
  219. function of_style_only() {
  220.     wp_enqueue_style('admin-style', get_template_directory_uri().'/admin/admin-style.css');
  221.     wp_enqueue_style('color-picker', get_template_directory_uri().'/admin/colorpicker.css');
  222.     $color = get_user_option('admin_color');
  223.     if ($color == "fresh")
  224.         {
  225.         wp_enqueue_style('admin-style-grey', get_template_directory_uri().'/admin/admin-style-grey.css');
  226.         wp_enqueue_style('color-picker', get_template_directory_uri().'/admin/colorpicker.css');
  227.         }
  228. }
  229.  
  230. /*-----------------------------------------------------------------------------------*/
  231. /* Load required javascripts for Options Page
  232. /*-----------------------------------------------------------------------------------*/
  233.  
  234. function of_load_only() {
  235.  
  236.     add_action('admin_head', 'of_admin_head');
  237.     wp_enqueue_script('jquery-ui-core');
  238.     wp_register_script('jquery-input-mask', get_template_directory_uri().'/admin/js/jquery.maskedinput-1.2.2.js', array( 'jquery' ));
  239.     wp_enqueue_script('jquery-input-mask');
  240.     wp_enqueue_script('color-picker', get_template_directory_uri().'/admin/js/colorpicker.js', array('jquery'));
  241.     wp_enqueue_script('ajaxupload', get_template_directory_uri().'/admin/js/ajaxupload.js', array('jquery'));
  242.    
  243.     function of_admin_head() {
  244.     ?>
  245.    
  246.    
  247. <script type="text/javascript" language="javascript">
  248.  
  249.         jQuery(document).ready(function(){
  250.        
  251.         // Race condition to make sure js files are loaded
  252.         if (typeof AjaxUpload != 'function') {
  253.             return ++counter < 6 && window.setTimeout(init, counter * 500);
  254.         }
  255.        
  256.             //Color Picker
  257.             <?php $options = get_option('of_template');
  258.            
  259.             foreach($options as $option){
  260.             if($option['type'] == 'color' OR $option['type'] == 'typography' OR $option['type'] == 'border'){
  261.                 if($option['type'] == 'typography' OR $option['type'] == 'border'){
  262.                     $option_id = $option['id'];
  263.                     $temp_color = get_option($option_id);
  264.                     $option_id = $option['id'] . '_color';
  265.                     $color = $temp_color['color'];
  266.                 }
  267.                 else {
  268.                     $option_id = $option['id'];
  269.                     $color = get_option($option_id);
  270.                 }
  271.                 ?>
  272.                  jQuery('#<?php echo $option_id; ?>_picker').children('div').css('backgroundColor', '<?php echo $color; ?>');    
  273.                  jQuery('#<?php echo $option_id; ?>_picker').ColorPicker({
  274.                     color: '<?php echo $color; ?>',
  275.                     onShow: function (colpkr) {
  276.                         jQuery(colpkr).fadeIn(500);
  277.                         return false;
  278.                     },
  279.                     onHide: function (colpkr) {
  280.                         jQuery(colpkr).fadeOut(500);
  281.                         return false;
  282.                     },
  283.                     onChange: function (hsb, hex, rgb) {
  284.                         //jQuery(this).css('border','1px solid red');
  285.                         jQuery('#<?php echo $option_id; ?>_picker').children('div').css('backgroundColor', '#' + hex);
  286.                         jQuery('#<?php echo $option_id; ?>_picker').next('input').attr('value','#' + hex);
  287.                        
  288.                     }
  289.                   });
  290.               <?php } } ?>
  291.          
  292.         });
  293.        
  294.         </script>
  295.        
  296.         <?php
  297.         //AJAX Upload
  298.         ?>
  299. <script type="text/javascript">
  300.             jQuery(document).ready(function(){
  301.                
  302.                 var i = 0;
  303.                 jQuery('#of-nav li a').attr('id', function() {
  304.                    i++;
  305.                    return 'item'+i;
  306.                 });
  307.  
  308.            
  309.             var flip = 0;
  310.                
  311.             jQuery('#expand_options').click(function(){
  312.                 if(flip == 0){
  313.                     flip = 1;
  314.                     jQuery('#truethemes_container #of-nav').hide();
  315.                     jQuery('#truethemes_container #content').width(755);
  316.                     jQuery('#truethemes_container .group').add('#truethemes_container .group h2').show();
  317.    
  318.                     jQuery(this).text('[-]');
  319.                    
  320.                 } else {
  321.                     flip = 0;
  322.                     jQuery('#truethemes_container #of-nav').show();
  323.                     jQuery('#truethemes_container #content').width(579);
  324.                     jQuery('#truethemes_container .group').add('#truethemes_container .group h2').hide();
  325.                     jQuery('#truethemes_container .group:first').show();
  326.                     jQuery('#truethemes_container #of-nav li').removeClass('current');
  327.                     jQuery('#truethemes_container #of-nav li:first').addClass('current');
  328.                    
  329.                     jQuery(this).text('[+]');
  330.                
  331.                 }
  332.            
  333.             });
  334.            
  335.                 jQuery('.group').hide();
  336.                 jQuery('.group:first').fadeIn();
  337.                
  338.                 jQuery('.group .collapsed').each(function(){
  339.                     jQuery(this).find('input:checked').parent().parent().parent().nextAll().each(
  340.                         function(){
  341.                             if (jQuery(this).hasClass('last')) {
  342.                                 jQuery(this).removeClass('hidden');
  343.                                 return false;
  344.                             }
  345.                             jQuery(this).filter('.hidden').removeClass('hidden');
  346.                         });
  347.                 });
  348.                            
  349.                 jQuery('.group .collapsed input:checkbox').click(unhideHidden);
  350.                
  351.                 function unhideHidden(){
  352.                     if (jQuery(this).attr('checked')) {
  353.                         jQuery(this).parent().parent().parent().nextAll().removeClass('hidden');
  354.                     }
  355.                     else {
  356.                         jQuery(this).parent().parent().parent().nextAll().each(
  357.                             function(){
  358.                                 if (jQuery(this).filter('.last').length) {
  359.                                     jQuery(this).addClass('hidden');
  360.                                     return false;
  361.                                 }
  362.                                 jQuery(this).addClass('hidden');
  363.                             });
  364.                            
  365.                     }
  366.                 }
  367.                
  368.                 jQuery('.of-radio-img-img').click(function(){
  369.                     jQuery(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
  370.                     jQuery(this).addClass('of-radio-img-selected');
  371.                    
  372.                 });
  373.                 jQuery('.of-radio-img-label').hide();
  374.                 jQuery('.of-radio-img-img').show();
  375.                 jQuery('.of-radio-img-radio').hide();
  376.                 jQuery('#of-nav li:first').addClass('current');
  377.                 jQuery('#of-nav li a').click(function(evt){
  378.                
  379.                         jQuery('#of-nav li').removeClass('current');
  380.                         jQuery(this).parent().addClass('current');
  381.                        
  382.                         var clicked_group = jQuery(this).attr('href');
  383.          
  384.                         jQuery('.group').hide();
  385.                        
  386.                             jQuery(clicked_group).fadeIn();
  387.        
  388.                         evt.preventDefault();
  389.                        
  390.                     });
  391.                
  392.                 if('<?php if(isset($_REQUEST['reset'])) { echo $_REQUEST['reset'];} else { echo 'false';} ?>' == 'true'){
  393.                    
  394.                     var reset_popup = jQuery('#of-popup-reset');
  395.                     reset_popup.fadeIn();
  396.                     window.setTimeout(function(){
  397.                            reset_popup.fadeOut();                        
  398.                         }, 2000);
  399.                         //alert(response);
  400.                    
  401.                 }
  402.                    
  403.             //Update Message popup
  404.             jQuery.fn.center = function () {
  405.                 this.animate({"top":( jQuery(window).height() - this.height() - 200 ) / 2+jQuery(window).scrollTop() + "px"},100);
  406.                 this.css("left", 250 );
  407.                 return this;
  408.             }
  409.        
  410.            
  411.             jQuery('#of-popup-save').center();
  412.             jQuery('#of-popup-reset').center();
  413.             jQuery(window).scroll(function() {
  414.            
  415.                 jQuery('#of-popup-save').center();
  416.                 jQuery('#of-popup-reset').center();
  417.            
  418.             });
  419.            
  420.            
  421.        
  422.             //AJAX Upload
  423.             jQuery('.image_upload_button').each(function(){
  424.            
  425.             var clickedObject = jQuery(this);
  426.             var clickedID = jQuery(this).attr('id');   
  427.             new AjaxUpload(clickedID, {
  428.                   action: '<?php echo admin_url("admin-ajax.php"); ?>',
  429.                   name: clickedID, // File upload name
  430.                   data: { // Additional data to send
  431.                         action: 'of_ajax_post_action',
  432.                         type: 'upload',
  433.                         data: clickedID },
  434.                   autoSubmit: true, // Submit file after selection
  435.                   responseType: false,
  436.                   onChange: function(file, extension){},
  437.                   onSubmit: function(file, extension){
  438.                         clickedObject.text('Uploading'); // change button text, when user selects file 
  439.                         this.disable(); // If you want to allow uploading only 1 file at time, you can disable upload button
  440.                         interval = window.setInterval(function(){
  441.                             var text = clickedObject.text();
  442.                             if (text.length < 13){  clickedObject.text(text + '.'); }
  443.                             else { clickedObject.text('Uploading'); }
  444.                         }, 200);
  445.                   },
  446.                   onComplete: function(file, response) {
  447.                    
  448.                     window.clearInterval(interval);
  449.                     clickedObject.text('Upload Image');
  450.                     this.enable(); // enable upload button
  451.                    
  452.                     // If there was an error
  453.                     if(response.search('Upload Error') > -1){
  454.                         var buildReturn = '<span class="upload-error">' + response + '</span>';
  455.                         jQuery(".upload-error").remove();
  456.                         clickedObject.parent().after(buildReturn);
  457.                    
  458.                     }
  459.                     else{
  460.                         var buildReturn = '<img class="hide of-option-image" id="image_'+clickedID+'" src="'+response+'" alt="" />';
  461.  
  462.                         jQuery(".upload-error").remove();
  463.                         jQuery("#image_" + clickedID).remove();
  464.                         clickedObject.parent().after(buildReturn);
  465.                         jQuery('img#image_'+clickedID).fadeIn();
  466.                         clickedObject.next('span').fadeIn();
  467.                         clickedObject.parent().prev('input').val(response);
  468.                     }
  469.                   }
  470.                 });
  471.            
  472.             });
  473.            
  474.             //AJAX Remove (clear option value)
  475.             jQuery('.image_reset_button').click(function(){
  476.            
  477.                     var clickedObject = jQuery(this);
  478.                     var clickedID = jQuery(this).attr('id');
  479.                     var theID = jQuery(this).attr('title');
  480.    
  481.                     var ajax_url = '<?php echo admin_url("admin-ajax.php"); ?>';
  482.                
  483.                     var data = {
  484.                         action: 'of_ajax_post_action',
  485.                         type: 'image_reset',
  486.                         data: theID
  487.                     };
  488.                    
  489.                     jQuery.post(ajax_url, data, function(response) {
  490.                         var image_to_remove = jQuery('#image_' + theID);
  491.                         var button_to_hide = jQuery('#reset_' + theID);
  492.                         image_to_remove.fadeOut(500,function(){ jQuery(this).remove(); });
  493.                         button_to_hide.fadeOut();
  494.                         clickedObject.parent().prev('input').val('');
  495.                        
  496.                        
  497.                        
  498.                     });
  499.                    
  500.                     return false;
  501.                    
  502.                 });
  503.                
  504.                
  505.                
  506.  
  507. /* Top save button   
  508. jQuery(document).ready( function(){
  509.   // bind "click" event for links with title="submit"
  510.   jQuery("a[title=submit]").click( function(){
  511.     // it submits the form it is contained within
  512.     jQuery(this).parents("form").submit();
  513.   });
  514. }); */
  515.                        
  516.            
  517.             //Save everything else
  518.             jQuery('#ofform').submit(function(){
  519.                
  520.                     function newValues() {
  521.                       var serializedValues = jQuery("#ofform").serialize();
  522.                       return serializedValues;
  523.                     }
  524.                     jQuery(":checkbox, :radio").click(newValues);
  525.                     jQuery("select").change(newValues);
  526.                     jQuery('.ajax-loading-img').fadeIn();
  527.                     var serializedReturn = newValues();
  528.                      
  529.                     var ajax_url = '<?php echo admin_url("admin-ajax.php"); ?>';
  530.                
  531.                      //var data = {data : serializedReturn};
  532.                     var data = {
  533.                         <?php if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'siteoptions'){ ?>
  534.                         type: 'options',
  535.                         <?php } ?>
  536.  
  537.                         action: 'of_ajax_post_action',
  538.                         data: serializedReturn
  539.                     };
  540.                    
  541.                     jQuery.post(ajax_url, data, function(response) {
  542.                         var success = jQuery('#of-popup-save');
  543.                         var loading = jQuery('.ajax-loading-img');
  544.                         loading.fadeOut();  
  545.                         success.fadeIn();
  546.                         window.setTimeout(function(){
  547.                            success.fadeOut();
  548.                            
  549.                                                
  550.                         }, 2000);
  551.                     });
  552.                    
  553.                     return false;
  554.                    
  555.                 });        
  556.                
  557.             });
  558.         </script>
  559. <?php }
  560. }
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572. /*-----------------------------------------------------------------------------------*/
  573. /* Ajax Save Action
  574. /*-----------------------------------------------------------------------------------*/
  575.  
  576. add_action('wp_ajax_of_ajax_post_action', 'of_ajax_callback');
  577.  
  578. function of_ajax_callback() {
  579.     global $wpdb; // this is how you get access to the database
  580.    
  581.        
  582.     $save_type = $_POST['type'];
  583.     //Uploads
  584.     if($save_type == 'upload'){
  585.        
  586.         $clickedID = $_POST['data']; // Acts as the name
  587.         $filename = $_FILES[$clickedID];
  588.         $filename['name'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', $filename['name']);
  589.        
  590.         $override['test_form'] = false;
  591.         $override['action'] = 'wp_handle_upload';    
  592.         $uploaded_file = wp_handle_upload($filename,$override);
  593.          
  594.                 $upload_tracking[] = $clickedID;
  595.                 update_option( $clickedID , $uploaded_file['url'] );
  596.                
  597.          if(!empty($uploaded_file['error'])) {echo 'Upload Error: ' . $uploaded_file['error']; }   
  598.          else { echo $uploaded_file['url']; } // Is the Response
  599.     }
  600.     elseif($save_type == 'image_reset'){
  601.            
  602.             $id = $_POST['data']; // Acts as the name
  603.             global $wpdb;
  604.             $query = "DELETE FROM $wpdb->options WHERE option_name LIKE '$id'";
  605.             $wpdb->query($query);
  606.    
  607.     }  
  608.     elseif ($save_type == 'options' OR $save_type == 'framework') {
  609.         $data = $_POST['data'];
  610.        
  611.         parse_str($data,$output);
  612.         //print_r($output);
  613.        
  614.         //Pull options
  615.             $options = get_option('of_template');
  616.        
  617.         foreach($options as $option_array){
  618.  
  619.             $id = $option_array['id'];
  620.             $old_value = get_option($id);
  621.             $new_value = '';
  622.            
  623.             if(isset($output[$id])){
  624.                 $new_value = $output[$option_array['id']];
  625.             }
  626.    
  627.             if(isset($option_array['id'])) { // Non - Headings...
  628.  
  629.            
  630.                     $type = $option_array['type'];
  631.                    
  632.                     if ( is_array($type)){
  633.                         foreach($type as $array){
  634.                             if($array['type'] == 'text'){
  635.                                 $id = $array['id'];
  636.                                 $std = $array['std'];
  637.                                 $new_value = $output[$id];
  638.                                 if($new_value == ''){ $new_value = $std; }
  639.                                 update_option( $id, stripslashes($new_value));
  640.                             }
  641.                         }                
  642.                     }
  643.                     elseif($new_value == '' && $type == 'checkbox'){ // Checkbox Save
  644.                        
  645.                         update_option($id,'false');
  646.                     }
  647.                     elseif ($new_value == 'true' && $type == 'checkbox'){ // Checkbox Save
  648.                        
  649.                         update_option($id,'true');
  650.                     }
  651.                     elseif($type == 'multicheck'){ // Multi Check Save
  652.                        
  653.                         $option_options = $option_array['options'];
  654.                        
  655.                         foreach ($option_options as $options_id => $options_value){
  656.                            
  657.                             $multicheck_id = $id . "_" . $options_id;
  658.                            
  659.                             if(!isset($output[$multicheck_id])){
  660.                               update_option($multicheck_id,'false');
  661.                             }
  662.                             else{
  663.                                update_option($multicheck_id,'true');
  664.                             }
  665.                         }
  666.                     }
  667.    
  668.                     elseif($type != 'upload_min'){
  669.                    
  670.                         update_option($id,stripslashes($new_value));
  671.                     }
  672.                 }
  673.             }  
  674.         ts_change_style_css();
  675.     }
  676.  
  677.   die();
  678.  
  679. }
  680.  
  681.  
  682.  
  683. /*-----------------------------------------------------------------------------------*/
  684. /* Cases fpr various option types
  685. /*-----------------------------------------------------------------------------------*/
  686.  
  687. function siteoptions_machine($options) {
  688.        
  689.     $counter = 0;
  690.     $menu = '';
  691.     $output = '';
  692.     foreach ($options as $value) {
  693.        
  694.         $counter++;
  695.         $val = '';
  696.         //Start Heading
  697.          if ( $value['type'] != "heading" )
  698.          {
  699. //========================================= PAYMENT =============================================//
Add Comment
Please, Sign In to add comment