inkthemes_ajax_callback

The Black Rider Lite Responsive Theme inkthemes ajax callback function.

Description

inkthemes_ajax_callback(); 

Usage

  1. if ( !function_exists( 'inkthemes_ajax_callback' ) ) { 
  2. require_once '/functions/admin-interface.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = inkthemes_ajax_callback(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions/admin-interface.php  
  1. function inkthemes_ajax_callback() { 
  2. global $wpdb; // this is how you get access to the database 
  3.  
  4.  
  5. $save_type = $_POST['type']; 
  6. //Uploads 
  7. if ($save_type == 'upload') { 
  8.  
  9. $clickedID = $_POST['data']; // Acts as the name 
  10. $filename = $_FILES[$clickedID]; 
  11. $filename['name'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', $filename['name']); 
  12.  
  13. $override['test_form'] = false; 
  14. $override['action'] = 'wp_handle_upload'; 
  15. $uploaded_file = wp_handle_upload($filename, $override); 
  16.  
  17. $upload_tracking[] = $clickedID; 
  18. inkthemes_update_option($clickedID, $uploaded_file['url']); 
  19.  
  20. if (!empty($uploaded_file[error])) { 
  21. echo 'Upload Error: ' . $uploaded_file[error]; 
  22. } else { 
  23. echo $uploaded_file['url']; 
  24. } // Is the Response 
  25. } elseif ($save_type == 'image_reset') { 
  26.  
  27. $id = $_POST['data']; // Acts as the name 
  28. } elseif ($save_type == 'options' OR $save_type == 'framework') { 
  29. $data = $_POST['data']; 
  30.  
  31. parse_str($data, $output); 
  32. //print_r($output); 
  33. //Pull options 
  34. $options = inkthemes_get_option('of_template'); 
  35.  
  36. foreach ($options as $option_array) { 
  37. $id = $option_array['id']; 
  38. $old_value = inkthemes_get_option($id); 
  39. $new_value = ''; 
  40.  
  41. if (isset($output[$id])) { 
  42. $new_value = $output[$option_array['id']]; 
  43.  
  44. if (isset($option_array['id'])) { // Non - Headings... 
  45. $type = $option_array['type']; 
  46.  
  47. if (is_array($type)) { 
  48. foreach ($type as $array) { 
  49. if ($array['type'] == 'text') { 
  50. $id = $array['id']; 
  51. $std = $array['std']; 
  52. $new_value = $output[$id]; 
  53. if ($new_value == '') { 
  54. $new_value = $std; 
  55. inkthemes_update_option($id, stripslashes($new_value)); 
  56. } elseif ($new_value == '' && $type == 'checkbox') { // Checkbox Save 
  57. inkthemes_update_option($id, 'false'); 
  58. } elseif ($new_value == 'true' && $type == 'checkbox') { // Checkbox Save 
  59. inkthemes_update_option($id, 'true'); 
  60. } elseif ($type == 'multicheck') { // Multi Check Save 
  61. $option_options = $option_array['options']; 
  62.  
  63. foreach ($option_options as $options_id => $options_value) { 
  64.  
  65. $multicheck_id = $id . "_" . $options_id; 
  66.  
  67. if (!isset($output[$multicheck_id])) { 
  68. inkthemes_update_option($multicheck_id, 'false'); 
  69. } else { 
  70. inkthemes_update_option($multicheck_id, 'true'); 
  71. } elseif ($type == 'typography') { 
  72.  
  73. $typography_array = array(); 
  74.  
  75. $typography_array['size'] = $output[$option_array['id'] . '_size']; 
  76.  
  77. $typography_array['face'] = stripslashes($output[$option_array['id'] . '_face']); 
  78.  
  79. $typography_array['style'] = $output[$option_array['id'] . '_style']; 
  80.  
  81. $typography_array['color'] = $output[$option_array['id'] . '_color']; 
  82.  
  83. inkthemes_update_option($id, $typography_array); 
  84. } elseif ($type == 'border') { 
  85.  
  86. $border_array = array(); 
  87.  
  88. $border_array['width'] = $output[$option_array['id'] . '_width']; 
  89.  
  90. $border_array['style'] = $output[$option_array['id'] . '_style']; 
  91.  
  92. $border_array['color'] = $output[$option_array['id'] . '_color']; 
  93.  
  94. inkthemes_update_option($id, $border_array); 
  95. } elseif ($type != 'upload_min') { 
  96.  
  97. inkthemes_update_option($id, stripslashes($new_value)); 
  98. die();