Advertisement
Guest User

Output Custom Field Data as Options/Settings in Meta Box

a guest
Feb 21st, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.86 KB | None | 0 0
  1. <?php
  2. if (class_exists("BryansAdminOptions")) {
  3.     $wsmAdminSettings = new BryansAdminOptions();
  4. }
  5. global $post;
  6.     $custom = get_post_custom($post->ID);
  7.     $contentdownloads = $custom["wsm-content-downloads"];
  8. ?>
  9.  
  10. <div id="downloads-options">
  11.    
  12.     <div id="contentdownloads" style="width:98%;float:left;">
  13.     <?php
  14.         if ($contentdownloads) {
  15.             $i = 0;
  16.                 wsm_log_debug('We\'ve found content downloads for this post, setting the value of $i to 0 to start the loop...',true,false);
  17.                 wsm_log_debug_array($contentdownloads,true);
  18.             foreach ($contentdownloads as $element) {
  19.                     wsm_log_debug('Begin foreach loop for meta box downloads output: $i ='.$i,true,false); 
  20.                 if ($i ==3){
  21.                         wsm_log_debug('variable $i equals 3, resetting $i to 0...',true,false);
  22.                     $i=0;
  23.                         wsm_log_debug('variable $i now equals '.$i,true,false);
  24.                 }else{
  25.                     wsm_log_debug('variable $i is not equal to 3 yet, so not resetting value to 0.  $i = '.$i,true,false);
  26.                 }
  27.                 $i++;
  28.                     wsm_log_debug('Incremented value of $i which now equals '.$i,true,false);
  29.                
  30.                 $select_pdf = null;
  31.                 $select_video = null;
  32.                 $select_zip = null;
  33.                 $select_resource = null;
  34.                 $select_spread = null;
  35.                 $select_other = null;
  36.                 if ($element == "PDF"){
  37.                     $select_pdf = 'selected="selected"';
  38.                     wsm_log_debug('$element == PDF, setting value of $select_pdf to '.$select_pdf,true,false);
  39.                 }
  40.                 if ($element == "Video"){
  41.                     $select_video = 'selected="selected"';
  42.                     wsm_log_debug('$element == Video, setting value of $select_video to '.$select_video,true,false);
  43.                 }
  44.                 if ($element == "Zip File"){
  45.                     $select_zip = 'selected="selected"';
  46.                     wsm_log_debug('$element == Zip File, setting value of $select_zip to '.$select_zip,true,false);
  47.                 }
  48.                 if ($element == "Resource Link"){
  49.                     $select_resource = 'selected="selected"';
  50.                     wsm_log_debug('$element == Resource Link, setting value of $select_resource to '.$select_resource,true,false);
  51.                 }
  52.                 if ($element == "Spreadsheet"){
  53.                     $select_spread = 'selected="selected"';
  54.                     wsm_log_debug('$element == Spreadsheet, setting value of $select_spread to '.$select_spread,true,false);
  55.                 }
  56.                 if ($element == "Other"){
  57.                     $select_other = 'selected="selected"';
  58.                     wsm_log_debug('$element == Other, setting value of $select_other to '.$select_other,true,false);
  59.                 }
  60.                
  61.                 $flag=0;
  62.                 if (($i % 1)==0)
  63.                     $flag=1;
  64.                 if (($i % 2)==0)
  65.                     $flag=2;
  66.                 if (($i % 3)==0)
  67.                     $flag=3;
  68.                    
  69.                 if ($flag==1){
  70.                     echo "<p><input style=\"width:25%;\" name=\"wsm-content-downloads[]\" value=\"$element\" />";  
  71.                         wsm_log_debug('$flag=1 outputting first input with the value of '.$element,true,true);             
  72.                 }
  73.                 elseif ($flag==2){
  74.                     echo " <input style=\"width:39%;\" name=\"wsm-content-downloads[]\" value=\"$element\" />";
  75.                         wsm_log_debug('$flag=2 outputting second input with the value of '.$element,true,true);
  76.                 }elseif ($flag==3) {
  77.                     echo "
  78.                     <select name=\"wsm-content-downloads[]\" class=\"inputSelect\" style=\"margin-right:5px;width:120px;\">
  79.                       <option value=\"\">-Remove-</option>
  80.                       <option $select_pdf value=\"PDF\">PDF</option>
  81.                       <option $select_video value=\"Video\">Video</option>
  82.                       <option $select_zip value=\"Zip File\">Zip File</option>
  83.                       <option $select_resource value=\"Resource Link\">Resource Link</option>
  84.                       <option $select_spread value=\"Spreadsheet\">Spreadsheet</option>
  85.                       <option $select_other value=\"Other\">Other</option>
  86.                     </select> <a href=\"#zipidey\" class=\"delete_this_download\">[delete]</a></p>";
  87.                         wsm_log_debug('$flag=3 outputting third input (download type select list) with the value of '.$element,true,true);
  88.                 }          
  89.                
  90.             }      
  91.         }
  92.     ?> 
  93.     </div>
  94.        
  95.    
  96. </div>
  97.  
  98. <div style="clear:both;">
  99. <a style="text-decoration:none;" href="#zipidey" id="append">[+] Add Download</a>
  100. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement