ninja_forms_display_sidebars

The Ninja Forms ninja forms display sidebars function.

Description

ninja_forms_display_sidebars( $data ); 

Parameters (1)

0. $data
The data.

Usage

  1. if ( !function_exists( 'ninja_forms_display_sidebars' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/sidebar.php'; 
  3.  
  4. // The data. 
  5. $data = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ninja_forms_display_sidebars($data); 
  9.  

Defined (1)

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

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