/deprecated/includes/admin/sidebar.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2.  
  3. function ninja_forms_sidebar_sorter($array, $sequence) { 
  4. $tmp = array(); 
  5. foreach($sequence as $s) { 
  6. foreach($array as $key => $a) { 
  7. $s = str_replace( 'ninja_forms_metabox_', '', $s ); 
  8. if($key == $s) { 
  9. $tmp[$key] = $a; 
  10. unset( $array[$key] ); 
  11. break; 
  12. if( is_array( $array ) AND !empty( $array ) ) { 
  13. foreach( $array as $key => $a ) { 
  14. $tmp[$key] = $a; 
  15.  
  16. return $tmp; 
  17.  
  18. function ninja_forms_display_sidebars($data) { 
  19. global $ninja_forms_sidebars; 
  20. $current_tab = ninja_forms_get_current_tab(); 
  21. $current_page = esc_html( $_REQUEST['page'] ); 
  22. $opt = nf_get_settings(); 
  23. if( isset( $opt['sidebars'][$current_page][$current_tab] ) ) { 
  24. $order = $opt['sidebars'][$current_page][$current_tab]; 
  25. if ( !is_array ( $order ) ) { 
  26. $order = array(); 
  27. $ninja_forms_sidebars[$current_page][$current_tab] = ninja_forms_sidebar_sorter( $ninja_forms_sidebars[$current_page][$current_tab], $order ); 
  28. $plugin_settings = nf_get_settings(); 
  29. ?> 
  30. <div id="menu-settings-column" class="metabox-holder"> 
  31. <div id="side-sortables" class="meta-box-sortables ui-sortable"> 
  32. <?php 
  33. if(isset($ninja_forms_sidebars[$current_page][$current_tab]) AND is_array($ninja_forms_sidebars[$current_page][$current_tab])) { 
  34. foreach($ninja_forms_sidebars[$current_page][$current_tab] as $slug => $sidebar) { 
  35.  
  36. if((isset($opt['screen_options']['tab'][$current_tab]['sidebars'][$slug]['visible']) AND $opt['screen_options']['tab'][$current_tab]['sidebars'][$slug]['visible'] == 1) OR !isset($opt['screen_options']['tab'][$current_tab]['sidebars'][$slug]['visible'])) { 
  37.  
  38. if ( isset ( $plugin_settings['metabox_state'][$current_page][$current_tab][$slug] ) ) { 
  39. $state = $plugin_settings['metabox_state'][$current_page][$current_tab][$slug]; 
  40. } else { 
  41. $state = ''; 
  42. ?> 
  43. <div id="ninja_forms_metabox_<?php echo $slug;?>" class="postbox"> 
  44. <h3 class="hndl"> 
  45. <span><?php _e($sidebar['name'], 'ninja-forms');?></span> 
  46. </h3> 
  47. <span class="item-controls"> 
  48. <a class="item-edit metabox-item-edit" id="edit_id" title="<?php _e('Edit Menu Item', 'ninja-forms'); ?>" href="#"><?php _e( 'Edit Menu Item' , 'ninja-forms'); ?></a> 
  49. </span> 
  50. <div class="inside" id="ninja_forms_sidebar_<?php echo $slug;?>" style="<?php echo $state;?>"> 
  51. <?php 
  52. if(isset($sidebar['display_function']) AND !empty($sidebar['display_function'])) { 
  53. $sidebar_callback = $sidebar['display_function']; 
  54. $arguments = func_get_args(); 
  55. array_shift($arguments); // We need to remove the first arg ($function_name) 
  56. $arguments['slug'] = $slug; 
  57. $arguments['data'] = $data; 
  58. call_user_func_array($sidebar_callback, $arguments); 
  59.  
  60. if(isset($sidebar['settings']) AND !empty($sidebar['settings'])) { 
  61. foreach($sidebar['settings'] as $option) { 
  62. if( isset( $option['p_class'] ) ) { 
  63. $p_class = $option['p_class']; 
  64. }else{ 
  65. $p_class = ''; 
  66. ?> 
  67. <p class="field-controls <?php echo $p_class;?>"> 
  68. <?php 
  69. if(isset($option['display_function']) AND !empty($option['display_function'])) { 
  70. call_user_func_array($option['display_function'], $arguments); 
  71. }else{ 
  72.  
  73. $name = $option['name']; 
  74.  
  75. if( isset( $option['default_value'] ) ) { 
  76. $value = $option['default_value']; 
  77. }else{ 
  78. $value = ''; 
  79.  
  80. if( isset( $data[$name] ) ) { 
  81. $value = $data[$name]; 
  82.  
  83. if( isset( $option['class'] ) ) { 
  84. $class = $option['class']; 
  85. }else{ 
  86. $class = ''; 
  87.  
  88. switch($option['type']) { 
  89. case 'checkbox': 
  90. ?> 
  91. <input type="hidden" name="<?php echo $name;?>" value="0"> 
  92. <input type="checkbox" name="<?php echo $name;?>" id="<?php echo $name;?>" value="1" <?php checked(1, $value);?>> 
  93. <label for="<?php echo $name;?>"><?php _e($option['label'], 'ninja-forms');?></label> 
  94. <?php 
  95. break; 
  96. case 'radio': 
  97. ?> 
  98. <label for="<?php echo $name;?>"><?php _e($option['label'], 'ninja-forms');?></label> 
  99. <?php 
  100. if(isset($option['options'])) { 
  101. $x = 0; 
  102. foreach($option['options'] as $option) { 
  103. ?> 
  104. <input type="radio" id="<?php echo $name.'_'.$x;?>" value="<?php echo $option['value'];?>" <?php checked($option['value'], $value);?> name="<?php echo $name;?>"> 
  105. <label for="<?php echo $name.'_'.$x;?>"><?php echo $option['name'];?></label> 
  106. <?php 
  107. $x++; 
  108. break; 
  109. case 'select': 
  110. ?> 
  111. <label for="<?php echo $name;?>"><?php _e($option['label'], 'ninja-forms');?></label> 
  112. <select name="<?php echo $name;?>" id="<?php echo $name;?>"> 
  113. <?php 
  114. if(isset($option['options'])) { 
  115. foreach($option['options'] as $option) { 
  116. ?> 
  117. <option value="<?php echo $option['value'];?>" <?php selected($option['value'], $value);?>><?php echo $option['name'];?></option> 
  118. <?php 
  119. ?> 
  120. </select> 
  121. <?php 
  122. break; 
  123. case 'text': 
  124. ?> 
  125. <label for="<?php echo $name;?>"><?php _e($option['label'], 'ninja-forms');?></label> 
  126. <input type="text" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo $value;?>"> 
  127. <?php 
  128. break; 
  129. case 'textarea': 
  130. ?> 
  131. <label for="<?php echo $name;?>"><?php _e($option['label'], 'ninja-forms');?></label> 
  132. <textarea name="<?php echo $name;?>" id="<?php echo $name;?>"><?php echo $value;?></textarea> 
  133. <?php 
  134. break; 
  135. case 'submit': 
  136. ?> 
  137. <input type="submit" name="submit" id="" class="<?php echo $class;?>" value="<?php _e( 'View Submissions', 'ninja-forms' );?>"> 
  138. <?php 
  139. break; 
  140. if(isset($option['help']) AND !empty($option['help'])) { 
  141. ?> 
  142. <a href="#" class="tooltip"> 
  143. <img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>images/question-ico.gif" title=""> 
  144. <span> 
  145. <img class="callout" src="<?php echo NINJA_FORMS_URL;?>/images/callout.gif" /> 
  146. <?php _e($option['help'], 'ninja-forms');?> 
  147. </span> 
  148. </a> 
  149.  
  150. <?php 
  151. if(isset($option['desc']) AND !empty($option['desc'])) { 
  152. ?> 
  153. <span class="howto"><?php echo $option['desc'];?></span> 
  154. <?php 
  155. ?> 
  156. </p> 
  157. <?php 
  158. ?> 
  159. </div> 
  160.  
  161. </div> 
  162. <?php 
  163. ?> 
  164. </div> 
  165. <?php 
  166. ?> 
.