YIT_Plugin_SubPanel

YIT Plugin Panel.

Defined (1)

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

/plugin-fw/lib/yit-plugin-subpanel.php  
  1. class YIT_Plugin_SubPanel extends YIT_Plugin_Panel { 
  2.  
  3. /** 
  4. * @var string version of class 
  5. */ 
  6. public $version = '1.0.0'; 
  7.  
  8. /** 
  9. * @var array a setting list of parameters 
  10. */ 
  11. public $settings = array(); 
  12.  
  13.  
  14. /** 
  15. * @var array 
  16. */ 
  17. private $_main_array_options = array(); 
  18.  
  19. /** 
  20. * Constructor 
  21. * @since 1.0 
  22. * @author Emanuela Castorina <emanuela.castorina@yithemes.it> 
  23. */ 
  24.  
  25. public function __construct( $args = array() ) { 
  26. if ( ! empty( $args ) ) { 
  27. $this->settings = $args; 
  28. $this->settings['parent'] = $this->settings['page']; 
  29. $this->_tabs_path_files = $this->get_tabs_path_files(); 
  30.  
  31. add_action( 'admin_init', array( $this, 'register_settings' ) ); 
  32. add_action( 'admin_menu', array( &$this, 'add_setting_page' ) ); 
  33. add_action( 'admin_bar_menu', array( &$this, 'add_admin_bar_menu' ), 100 ); 
  34. add_action( 'admin_init', array( &$this, 'add_fields' ) ); 
  35. add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); 
  36.  
  37.  
  38. /** 
  39. * Register Settings 
  40. * Generate wp-admin settings pages by registering your settings and using a few callbacks to control the output 
  41. * @return void 
  42. * @since 1.0 
  43. * @author Emanuela Castorina <emanuela.castorina@yithemes.it> 
  44. */ 
  45. public function register_settings() { 
  46. register_setting( 'yit_' . $this->settings['page'] . '_options', 'yit_' . $this->settings['page'] . '_options', array( &$this, 'options_validate' ) ); 
  47.  
  48.  
  49.  
  50. /** 
  51. * Add Setting SubPage 
  52. * add Setting SubPage to wordpress administrator 
  53. * @return array validate input fields 
  54. * @since 1.0 
  55. * @author Emanuela Castorina <emanuela.castorina@yithemes.it> 
  56. */ 
  57. public function add_setting_page() { 
  58. global $admin_page_hooks; 
  59. $logo = YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png'; 
  60.  
  61. $admin_logo = function_exists( 'yit_get_option' ) ? yit_get_option( 'admin-logo-menu' ) : ''; 
  62.  
  63. if ( isset( $admin_logo ) && !empty( $admin_logo ) && $admin_logo != '' && $admin_logo ) { 
  64. $logo = $admin_logo; 
  65.  
  66. if( ! isset( $admin_page_hooks['yit_plugin_panel'] ) ) { 
  67. $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' ); 
  68. add_menu_page( 'yit_plugin_panel', 'YITH Plugins', 'nosuchcapability', 'yit_plugin_panel', NULL, $logo, $position ); 
  69.  
  70. add_submenu_page( 'yit_plugin_panel', $this->settings['label'], $this->settings['label'], 'manage_options', $this->settings['page'], array( $this, 'yit_panel' ) ); 
  71. remove_submenu_page( 'yit_plugin_panel', 'yit_plugin_panel' ); 
  72.  
  73.  
  74. /** 
  75. * Show a tabbed panel to setting page 
  76. * a callback function called by add_setting_page => add_submenu_page 
  77. * @return void 
  78. * @since 1.0 
  79. * @author Emanuela Castorina <emanuela.castorina@yithemes.it> 
  80. */ 
  81. public function yit_panel() { 
  82.  
  83. $tabs = ''; 
  84. $current_tab = $this->get_current_tab(); 
  85.  
  86. // tabs 
  87. foreach ( $this->settings['admin-tabs'] as $tab => $tab_value ) { 
  88. $active_class = ( $current_tab == $tab ) ? ' nav-tab-active' : ''; 
  89. $tabs .= '<a class="nav-tab' . $active_class . '" href="?page=' . $this->settings['page'] . '&tab=' . $tab . '">' . $tab_value . '</a>'; 
  90. ?> 
  91. <div id="icon-themes" class="icon32"><br /></div> 
  92. <h2 class="nav-tab-wrapper"> 
  93. <?php echo $tabs ?> 
  94. </h2> 
  95.  
  96. <div id="wrap" class="plugin-option"> 
  97. <?php $this->message(); ?> 
  98. <h2><?php echo $this->get_tab_title() ?></h2> 
  99.  
  100. <?php if ( $this->is_show_form() ) : ?> 
  101. <form method="post" action="options.php"> 
  102. <?php do_settings_sections( 'yit' ); ?> 
  103. <p> </p> 
  104. <?php settings_fields( 'yit_' . $this->settings['page'] . '_options' ); ?> 
  105. <input type="hidden" name="<?php echo $this->get_name_field( 'current_tab' ) ?>" value="<?php echo esc_attr( $current_tab ) ?>" /> 
  106. <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'yith-plugin-fw' ) ?>" style="float:left;margin-right:10px;" /> 
  107. </form> 
  108. <form method="post"> 
  109. <?php $warning = __( 'If you continue with this action, you will reset all the options in this page.', 'yith-plugin-fw' ) ?> 
  110. <input type="hidden" name="yit-action" value="reset" /> 
  111. <input type="submit" name="yit-reset" class="button-secondary" value="<?php _e( 'Reset to default', 'yith-plugin-fw' ) ?>" onclick="return confirm('<?php echo $warning . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ) ?>');" /> 
  112. </form> 
  113. <p> </p> 
  114. <?php endif ?> 
  115. </div> 
  116. <?php 
  117.  
  118.  
  119.