of_load_only

The ColorWay Theme of load only function.

Description

of_load_only(); 

Usage

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

Defined (1)

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

/functions/admin-interface.php  
  1. function of_load_only() { 
  2.  
  3. add_action('admin_head', 'of_admin_head'); 
  4.  
  5. wp_enqueue_script('jquery-ui-core'); 
  6. wp_register_script('jquery-input-mask', get_bloginfo('stylesheet_directory').'/functions/js/jquery.maskedinput-1.2.2.js', array( 'jquery' )); 
  7. wp_enqueue_script('jquery-input-mask'); 
  8.  
  9. function of_admin_head() {  
  10.  
  11. echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('stylesheet_directory').'/functions/admin-style.css" media="screen" />'; 
  12.  
  13. // COLOR Picker ?> 
  14. <link rel="stylesheet" media="screen" type="text/css" href="<?php echo get_bloginfo('stylesheet_directory'); ?>/functions/css/colorpicker.css" /> 
  15. <script type="text/javascript" src="<?php echo get_bloginfo('stylesheet_directory'); ?>/functions/js/colorpicker.js"></script> 
  16. <script type="text/javascript" language="javascript"> 
  17. jQuery(document).ready(function() { 
  18.  
  19.  
  20. //Color Picker 
  21. <?php $options = get_option('of_template'); 
  22.  
  23. foreach($options as $option) {  
  24. if($option['type'] == 'color' OR $option['type'] == 'typography' OR $option['type'] == 'border') { 
  25. if($option['type'] == 'typography' OR $option['type'] == 'border') { 
  26. $option_id = $option['id']; 
  27. $temp_color = get_option($option_id); 
  28. $option_id = $option['id'] . '_color'; 
  29. $color = $temp_color['color']; 
  30. else { 
  31. $option_id = $option['id']; 
  32. $color = get_option($option_id); 
  33. ?> 
  34. jQuery('#<?php echo $option_id; ?>_picker').children('div').css('backgroundColor', '<?php echo $color; ?>');  
  35. jQuery('#<?php echo $option_id; ?>_picker').ColorPicker({ 
  36. color: '<?php echo $color; ?>',  
  37. onShow: function (colpkr) { 
  38. jQuery(colpkr).fadeIn(500); 
  39. return false; 
  40. },  
  41. onHide: function (colpkr) { 
  42. jQuery(colpkr).fadeOut(500); 
  43. return false; 
  44. },  
  45. onChange: function (hsb, hex, rgb) { 
  46. //jQuery(this).css('border', '1px solid red'); 
  47. jQuery('#<?php echo $option_id; ?>_picker').children('div').css('backgroundColor', '#' + hex); 
  48. jQuery('#<?php echo $option_id; ?>_picker').next('input').attr('value', '#' + hex); 
  49.  
  50. }); 
  51. <?php } } ?> 
  52.  
  53. }); 
  54.  
  55. </script> 
  56. <?php 
  57. //AJAX Upload 
  58. ?> 
  59. <script type="text/javascript" src="<?php echo get_bloginfo('stylesheet_directory'); ?>/functions/js/ajaxupload.js"></script> 
  60. <script type="text/javascript"> 
  61. jQuery(document).ready(function() { 
  62.  
  63. var flip = 0; 
  64.  
  65. jQuery('#expand_options').click(function() { 
  66. if(flip == 0) { 
  67. flip = 1; 
  68. jQuery('#of_container #of-nav').hide(); 
  69. jQuery('#of_container #content').width(755); 
  70. jQuery('#of_container .group').add('#of_container .group h2').show(); 
  71.  
  72. jQuery(this).text('[-]'); 
  73.  
  74. } else { 
  75. flip = 0; 
  76. jQuery('#of_container #of-nav').show(); 
  77. jQuery('#of_container #content').width(595); 
  78. jQuery('#of_container .group').add('#of_container .group h2').hide(); 
  79. jQuery('#of_container .group:first').show(); 
  80. jQuery('#of_container #of-nav li').removeClass('current'); 
  81. jQuery('#of_container #of-nav li:first').addClass('current'); 
  82.  
  83. jQuery(this).text('[+]'); 
  84.  
  85.  
  86. }); 
  87.  
  88. jQuery('.group').hide(); 
  89. jQuery('.group:first').fadeIn(); 
  90.  
  91. jQuery('.group .collapsed').each(function() { 
  92. jQuery(this).find('input:checked').parent().parent().parent().nextAll().each(  
  93. function() { 
  94. if (jQuery(this).hasClass('last')) { 
  95. jQuery(this).removeClass('hidden'); 
  96. return false; 
  97. jQuery(this).filter('.hidden').removeClass('hidden'); 
  98. }); 
  99. }); 
  100.  
  101. jQuery('.group .collapsed input:checkbox').click(unhideHidden); 
  102.  
  103. function unhideHidden() { 
  104. if (jQuery(this).attr('checked')) { 
  105. jQuery(this).parent().parent().parent().nextAll().removeClass('hidden'); 
  106. else { 
  107. jQuery(this).parent().parent().parent().nextAll().each(  
  108. function() { 
  109. if (jQuery(this).filter('.last').length) { 
  110. jQuery(this).addClass('hidden'); 
  111. return false; 
  112. jQuery(this).addClass('hidden'); 
  113. }); 
  114.  
  115.  
  116. jQuery('.of-radio-img-img').click(function() { 
  117. jQuery(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected'); 
  118. jQuery(this).addClass('of-radio-img-selected'); 
  119.  
  120. }); 
  121. jQuery('.of-radio-img-label').hide(); 
  122. jQuery('.of-radio-img-img').show(); 
  123. jQuery('.of-radio-img-radio').hide(); 
  124. jQuery('#of-nav li:first').addClass('current'); 
  125. jQuery('#of-nav li a').click(function(evt) { 
  126.  
  127. jQuery('#of-nav li').removeClass('current'); 
  128. jQuery(this).parent().addClass('current'); 
  129.  
  130. var clicked_group = jQuery(this).attr('href'); 
  131.  
  132. jQuery('.group').hide(); 
  133.  
  134. jQuery(clicked_group).fadeIn(); 
  135.  
  136. evt.preventDefault(); 
  137.  
  138. }); 
  139.  
  140. if('<?php if(isset($_REQUEST['reset'])) { echo $_REQUEST['reset'];} else { echo 'false';} ?>' == 'true') { 
  141.  
  142. var reset_popup = jQuery('#of-popup-reset'); 
  143. reset_popup.fadeIn(); 
  144. window.setTimeout(function() { 
  145. reset_popup.fadeOut();  
  146. }, 2000); 
  147. //alert(response); 
  148.  
  149.  
  150. //Update Message popup 
  151. jQuery.fn.center = function () { 
  152. this.animate({"top":( jQuery(window).height() - this.height() - 200 ) / 2+jQuery(window).scrollTop() + "px"}, 100); 
  153. this.css("left", 250 ); 
  154. return this; 
  155.  
  156.  
  157. jQuery('#of-popup-save').center(); 
  158. jQuery('#of-popup-reset').center(); 
  159. jQuery(window).scroll(function() {  
  160.  
  161. jQuery('#of-popup-save').center(); 
  162. jQuery('#of-popup-reset').center(); 
  163.  
  164. }); 
  165.  
  166.  
  167.  
  168. //AJAX Upload 
  169. jQuery('.image_upload_button').each(function() { 
  170.  
  171. var clickedObject = jQuery(this); 
  172. var clickedID = jQuery(this).attr('id');  
  173. new AjaxUpload(clickedID, { 
  174. action: '<?php echo admin_url("admin-ajax.php"); ?>',  
  175. name: clickedID, // File upload name 
  176. data: { // Additional data to send 
  177. action: 'of_ajax_post_action',  
  178. type: 'upload',  
  179. data: clickedID },  
  180. autoSubmit: true, // Submit file after selection 
  181. responseType: false,  
  182. onChange: function(file, extension) {},  
  183. onSubmit: function(file, extension) { 
  184. clickedObject.text('Uploading'); // change button text, when user selects file  
  185. this.disable(); // If you want to allow uploading only 1 file at time, you can disable upload button 
  186. interval = window.setInterval(function() { 
  187. var text = clickedObject.text(); 
  188. if (text.length < 13) { clickedObject.text(text + '.'); } 
  189. else { clickedObject.text('Uploading'); }  
  190. }, 200); 
  191. },  
  192. onComplete: function(file, response) { 
  193.  
  194. window.clearInterval(interval); 
  195. clickedObject.text('Upload Image');  
  196. this.enable(); // enable upload button 
  197.  
  198. // If there was an error 
  199. if(response.search('Upload Error') > -1) { 
  200. var buildReturn = '<span class="upload-error">' + response + '</span>'; 
  201. jQuery(".upload-error").remove(); 
  202. clickedObject.parent().after(buildReturn); 
  203.  
  204. else{ 
  205. var buildReturn = '<img class="hide of-option-image" id="image_'+clickedID+'" src="'+response+'" alt="" />'; 
  206.  
  207. jQuery(".upload-error").remove(); 
  208. jQuery("#image_" + clickedID).remove();  
  209. clickedObject.parent().after(buildReturn); 
  210. jQuery('img#image_'+clickedID).fadeIn(); 
  211. clickedObject.next('span').fadeIn(); 
  212. clickedObject.parent().prev('input').val(response); 
  213. }); 
  214.  
  215. }); 
  216.  
  217. //AJAX Remove (clear option value) 
  218. jQuery('.image_reset_button').click(function() { 
  219.  
  220. var clickedObject = jQuery(this); 
  221. var clickedID = jQuery(this).attr('id'); 
  222. var theID = jQuery(this).attr('title');  
  223.  
  224. var ajax_url = '<?php echo admin_url("admin-ajax.php"); ?>'; 
  225.  
  226. var data = { 
  227. action: 'of_ajax_post_action',  
  228. type: 'image_reset',  
  229. data: theID 
  230. }; 
  231.  
  232. jQuery.post(ajax_url, data, function(response) { 
  233. var image_to_remove = jQuery('#image_' + theID); 
  234. var button_to_hide = jQuery('#reset_' + theID); 
  235. image_to_remove.fadeOut(500, function() { jQuery(this).remove(); }); 
  236. button_to_hide.fadeOut(); 
  237. clickedObject.parent().prev('input').val(''); 
  238.  
  239.  
  240.  
  241. }); 
  242.  
  243. return false;  
  244.  
  245. });  
  246.  
  247. //Save everything else 
  248. jQuery('#ofform').submit(function() { 
  249.  
  250. function newValues() { 
  251. var serializedValues = jQuery("#ofform").serialize(); 
  252. return serializedValues; 
  253. jQuery(":checkbox, :radio").click(newValues); 
  254. jQuery("select").change(newValues); 
  255. jQuery('.ajax-loading-img').fadeIn(); 
  256. var serializedReturn = newValues(); 
  257.  
  258. var ajax_url = '<?php echo admin_url("admin-ajax.php"); ?>'; 
  259.  
  260. //var data = {data : serializedReturn}; 
  261. var data = { 
  262. <?php if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'optionsframework') { ?> 
  263. type: 'options',  
  264. <?php } ?> 
  265.  
  266. action: 'of_ajax_post_action',  
  267. data: serializedReturn 
  268. }; 
  269.  
  270. jQuery.post(ajax_url, data, function(response) { 
  271. var success = jQuery('#of-popup-save'); 
  272. var loading = jQuery('.ajax-loading-img'); 
  273. loading.fadeOut();  
  274. success.fadeIn(); 
  275. window.setTimeout(function() { 
  276. success.fadeOut();  
  277.  
  278.  
  279. }, 2000); 
  280. }); 
  281.  
  282. return false;  
  283.  
  284. });  
  285.  
  286. }); 
  287. </script> 
  288. <?php }