register-screen-options.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. $args = array(
  3. 'display_function' => 'ninja_forms_screen_option_tabs',
  4. 'save_function' => 'ninja_forms_save_screen_option_tabs',
  5. 'page' => 'ninja-forms'
  6. );
  7. //ninja_forms_register_screen_option('tabs', $args);
  8. function ninja_forms_screen_option_tabs(){
  9. global $ninja_forms_tabs, $ninja_forms_sidebars;
  10. $current_tab = ninja_forms_get_current_tab();
  11. $current_page = $_REQUEST['page'];
  12. $opt = nf_get_settings();
  13. if(isset($ninja_forms_tabs[$current_page]) AND is_array($ninja_forms_tabs[$current_page])){
  14. ?>
  15. <div class="tabs-prefs">
  16. <h5>Show These Tabs</h5>
  17. <?php
  18. foreach($ninja_forms_tabs[$current_page] as $slug => $tab){
  19. if(!isset($opt['screen_options']['tab'][$slug]['visible']) OR $opt['screen_options']['tab'][$slug]['visible'] == 1){
  20. $checked = 'checked = "checked"';
  21. }else{
  22. $checked = '';
  23. }
  24. ?>
  25. <input type="hidden" name="ninja-forms-tab[<?php echo $slug;?>]" value="0">
  26. <label for="ninja-forms-tab-<?php echo $slug;?>"><input class="hide-tab-tog" name="ninja-forms-tab[<?php echo $slug;?>]" type="checkbox" id="ninja-forms-tab-<?php echo $slug;?>" value="1" <?php echo $checked;?> ><?php echo $tab['name'];?></label>
  27. <?php
  28. }
  29. ?>
  30. <br class="clear">
  31. </div>
  32. <?php if(isset($ninja_forms_sidebars[$current_page][$current_tab]) AND is_array($ninja_forms_sidebars[$current_page][$current_tab])){?>
  33. <div class="sidebar-prefs">
  34. <h5>Show These Sidebars</h5>
  35. <?php
  36. foreach($ninja_forms_sidebars[$current_page][$current_tab] as $slug => $sidebar){
  37. if(!isset($opt['screen_options']['tab'][$current_tab]['sidebars'][$slug]['visible']) OR $opt['screen_options']['tab'][$current_tab]['sidebars'][$slug]['visible'] == 1){
  38. $checked = 'checked = "checked"';
  39. }else{
  40. $checked = '';
  41. }
  42. ?>
  43. <input type="hidden" name="ninja-forms-sidebar[<?php echo $slug;?>]" value="0">
  44. <label for="ninja-forms-sidebar-<?php echo $slug;?>"><input class="hide-sidebar-tog" name="ninja-forms-sidebar[<?php echo $slug;?>]" type="checkbox" id="ninja-forms-sidebar-<?php echo $slug;?>" value="1" <?php echo $checked;?> ><?php echo $sidebar['name'];?></label>
  45. <?php
  46. }
  47. ?>
  48. <br class="clear">
  49. </div>
  50. <?php
  51. }
  52. }
  53. }
  54. function ninja_forms_save_screen_option_tabs(){
  55. $current_tab = ninja_forms_get_current_tab();
  56. $current_page = $_REQUEST['page'];
  57. $opt = nf_get_settings();
  58. if(is_array($_POST['ninja-forms-tab'])){
  59. foreach($_POST['ninja-forms-tab'] as $slug => $val){
  60. $opt['screen_options']['tab'][$slug]['visible'] = $val;
  61. }
  62. }
  63. if(is_array($_POST['ninja-forms-sidebar'])){
  64. foreach($_POST['ninja-forms-sidebar'] as $slug => $val){
  65. $opt['screen_options']['tab'][$current_tab]['sidebars'][$slug]['visible'] = $val;
  66. }
  67. }
  68. update_option('ninja_forms_settings', $opt);
  69. }