WC_Predictive_Search_Header_Template_Settings

The WooCommerce Predictive Search LITE WC Predictive Search Header Template Settings class.

Defined (1)

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

/admin/settings/header-template-settings.php  
  1. class WC_Predictive_Search_Header_Template_Settings extends WC_Predictive_Search_Admin_UI 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $parent_tab = 'header-template-settings'; 
  7.  
  8. /** 
  9. * @var array 
  10. */ 
  11. private $subtab_data; 
  12.  
  13. /** 
  14. * @var string 
  15. * You must change to correct option name that you are working 
  16. */ 
  17. public $option_name = 'wc_predictive_search_header_template_settings'; 
  18.  
  19. /** 
  20. * @var string 
  21. * You must change to correct form key that you are working 
  22. */ 
  23. public $form_key = 'wc_predictive_search_header_template_settings'; 
  24.  
  25. /** 
  26. * @var string 
  27. * You can change the order show of this sub tab in list sub tabs 
  28. */ 
  29. private $position = 1; 
  30.  
  31. /** 
  32. * @var array 
  33. */ 
  34. public $form_fields = array(); 
  35.  
  36. /** 
  37. * @var array 
  38. */ 
  39. public $form_messages = array(); 
  40.  
  41. /**-----------------------------------------------------------------------------------*/ 
  42. /** __construct() */ 
  43. /** Settings Constructor */ 
  44. /**-----------------------------------------------------------------------------------*/ 
  45. public function __construct() { 
  46.  
  47. $this->init_form_fields(); 
  48. $this->subtab_init(); 
  49.  
  50. $this->form_messages = array( 
  51. 'success_message' => __( 'Header Template Settings successfully saved.', 'woops' ),  
  52. 'error_message' => __( 'Error: Header Template Settings can not save.', 'woops' ),  
  53. 'reset_message' => __( 'Header Template Settings successfully reseted.', 'woops' ),  
  54. ); 
  55.  
  56. add_action( $this->plugin_name . '-' . $this->form_key . '_settings_end', array( $this, 'include_script' ) ); 
  57.  
  58. add_action( $this->plugin_name . '_set_default_settings' , array( $this, 'set_default_settings' ) ); 
  59.  
  60. add_action( $this->plugin_name . '_get_all_settings' , array( $this, 'get_settings' ) ); 
  61.  
  62. /**-----------------------------------------------------------------------------------*/ 
  63. /** subtab_init() */ 
  64. /** Sub Tab Init */ 
  65. /**-----------------------------------------------------------------------------------*/ 
  66. public function subtab_init() { 
  67.  
  68. add_filter( $this->plugin_name . '-' . $this->parent_tab . '_settings_subtabs_array', array( $this, 'add_subtab' ), $this->position ); 
  69.  
  70.  
  71. /**-----------------------------------------------------------------------------------*/ 
  72. /** set_default_settings() 
  73. /** Set default settings with function called from Admin Interface */ 
  74. /**-----------------------------------------------------------------------------------*/ 
  75. public function set_default_settings() { 
  76. global $wc_predictive_search_admin_interface; 
  77.  
  78. $wc_predictive_search_admin_interface->reset_settings( $this->form_fields, $this->option_name, false ); 
  79.  
  80. /**-----------------------------------------------------------------------------------*/ 
  81. /** get_settings() 
  82. /** Get settings with function called from Admin Interface */ 
  83. /**-----------------------------------------------------------------------------------*/ 
  84. public function get_settings() { 
  85. global $wc_predictive_search_admin_interface; 
  86.  
  87. $wc_predictive_search_admin_interface->get_settings( $this->form_fields, $this->option_name ); 
  88.  
  89. /** 
  90. * subtab_data() 
  91. * Get SubTab Data 
  92. * ============================================= 
  93. * array (  
  94. * 'name' => 'my_subtab_name' : (required) Enter your subtab name that you want to set for this subtab 
  95. * 'label' => 'My SubTab Name' : (required) Enter the subtab label 
  96. * 'callback_function' => 'my_callback_function' : (required) The callback function is called to show content of this subtab 
  97. * ) 
  98. */ 
  99. public function subtab_data() { 
  100.  
  101. $subtab_data = array(  
  102. 'name' => 'header-template-settings',  
  103. 'label' => __( 'Header Template', 'woops' ),  
  104. 'callback_function' => 'wc_predictive_search_header_template_settings_form',  
  105. ); 
  106.  
  107. if ( $this->subtab_data ) return $this->subtab_data; 
  108. return $this->subtab_data = $subtab_data; 
  109.  
  110.  
  111. /**-----------------------------------------------------------------------------------*/ 
  112. /** add_subtab() */ 
  113. /** Add Subtab to Admin Init 
  114. /**-----------------------------------------------------------------------------------*/ 
  115. public function add_subtab( $subtabs_array ) { 
  116.  
  117. if ( ! is_array( $subtabs_array ) ) $subtabs_array = array(); 
  118. $subtabs_array[] = $this->subtab_data(); 
  119.  
  120. return $subtabs_array; 
  121.  
  122. /**-----------------------------------------------------------------------------------*/ 
  123. /** settings_form() */ 
  124. /** Call the form from Admin Interface 
  125. /**-----------------------------------------------------------------------------------*/ 
  126. public function settings_form() { 
  127. global $wc_predictive_search_admin_interface; 
  128.  
  129. $output = ''; 
  130. $output .= $wc_predictive_search_admin_interface->admin_forms( $this->form_fields, $this->form_key, $this->option_name, $this->form_messages ); 
  131.  
  132. return $output; 
  133.  
  134. /**-----------------------------------------------------------------------------------*/ 
  135. /** init_form_fields() */ 
  136. /** Init all fields of this form */ 
  137. /**-----------------------------------------------------------------------------------*/ 
  138. public function init_form_fields() { 
  139.  
  140. // Define settings 
  141. $this->form_fields = apply_filters( $this->form_key . '_settings_fields', array( 
  142. array( 
  143. 'name' => __( 'HEADER TEMPLATE PREMIUM', 'woops' ),  
  144. 'type' => 'heading',  
  145. 'desc' => '<img class="rwd_image_maps" src="'.WOOPS_IMAGES_URL.'/premium-header-template.png" usemap="#headerTemplateMap" style="width: auto; max-width: 100%;" border="0" /> 
  146. <map name="headerTemplateMap" id="headerTemplateMap"> 
  147. <area shape="rect" coords="300, 180, 800, 245" href="'.$this->pro_plugin_page_url.'" target="_blank" /> 
  148. </map>',  
  149. 'alway_open'=> true,  
  150. 'id' => 'predictive_search_container_box',  
  151. 'is_box' => true,  
  152. ),  
  153.  
  154. )); 
  155.  
  156. public function include_script() { 
  157. ?> 
  158. <style type="text/css"> 
  159. .a3rev_panel_container p.submit { 
  160. display: none; 
  161. </style> 
  162. <?php 
  163. wp_enqueue_script( 'jquery-rwd-image-maps' );