WC_Predictive_Search_Input_Box_Settings

The WooCommerce Predictive Search LITE WC Predictive Search Input Box Settings class.

Defined (1)

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

/admin/settings/search-box-settings.php  
  1. class WC_Predictive_Search_Input_Box_Settings extends WC_Predictive_Search_Admin_UI 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $parent_tab = 'search-box-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_input_box_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_input_box_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' => __( 'Search Box Settings successfully saved.', 'woocommerce-predictive-search' ),  
  52. 'error_message' => __( 'Error: Search Box Settings can not save.', 'woocommerce-predictive-search' ),  
  53. 'reset_message' => __( 'Search Box Settings successfully reseted.', 'woocommerce-predictive-search' ),  
  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 . '_settings_' . 'predictive_search_searchbox_text' . '_start', array( $this, 'predictive_search_searchbox_text' ) ); 
  61.  
  62. add_action( $this->plugin_name . '-' . $this->form_key . '_settings_init' , array( $this, 'after_save_settings' ) ); 
  63.  
  64. add_action( $this->plugin_name . '_get_all_settings' , array( $this, 'get_settings' ) ); 
  65.  
  66. /**-----------------------------------------------------------------------------------*/ 
  67. /** subtab_init() */ 
  68. /** Sub Tab Init */ 
  69. /**-----------------------------------------------------------------------------------*/ 
  70. public function subtab_init() { 
  71.  
  72. add_filter( $this->plugin_name . '-' . $this->parent_tab . '_settings_subtabs_array', array( $this, 'add_subtab' ), $this->position ); 
  73.  
  74.  
  75. /**-----------------------------------------------------------------------------------*/ 
  76. /** set_default_settings() 
  77. /** Set default settings with function called from Admin Interface */ 
  78. /**-----------------------------------------------------------------------------------*/ 
  79. public function set_default_settings() { 
  80. global $wc_predictive_search_admin_interface; 
  81.  
  82. $wc_predictive_search_admin_interface->reset_settings( $this->form_fields, $this->option_name, false ); 
  83.  
  84. /**-----------------------------------------------------------------------------------*/ 
  85. /** after_save_settings() 
  86. /** Process when clean on deletion option is un selected */ 
  87. /**-----------------------------------------------------------------------------------*/ 
  88. public function after_save_settings() { 
  89.  
  90. if ( isset( $_REQUEST['woocommerce_search_box_text']) ) { 
  91. update_option('woocommerce_search_box_text', $_REQUEST['woocommerce_search_box_text'] ); 
  92.  
  93. /**-----------------------------------------------------------------------------------*/ 
  94. /** get_settings() 
  95. /** Get settings with function called from Admin Interface */ 
  96. /**-----------------------------------------------------------------------------------*/ 
  97. public function get_settings() { 
  98. global $wc_predictive_search_admin_interface; 
  99.  
  100. $wc_predictive_search_admin_interface->get_settings( $this->form_fields, $this->option_name ); 
  101.  
  102. /** 
  103. * subtab_data() 
  104. * Get SubTab Data 
  105. * ============================================= 
  106. * array (  
  107. * 'name' => 'my_subtab_name' : (required) Enter your subtab name that you want to set for this subtab 
  108. * 'label' => 'My SubTab Name' : (required) Enter the subtab label 
  109. * 'callback_function' => 'my_callback_function' : (required) The callback function is called to show content of this subtab 
  110. * ) 
  111. */ 
  112. public function subtab_data() { 
  113.  
  114. $subtab_data = array(  
  115. 'name' => 'search-box-settings',  
  116. 'label' => __( 'Search Box', 'woocommerce-predictive-search' ),  
  117. 'callback_function' => 'wc_predictive_search_input_box_settings_form',  
  118. ); 
  119.  
  120. if ( $this->subtab_data ) return $this->subtab_data; 
  121. return $this->subtab_data = $subtab_data; 
  122.  
  123.  
  124. /**-----------------------------------------------------------------------------------*/ 
  125. /** add_subtab() */ 
  126. /** Add Subtab to Admin Init 
  127. /**-----------------------------------------------------------------------------------*/ 
  128. public function add_subtab( $subtabs_array ) { 
  129.  
  130. if ( ! is_array( $subtabs_array ) ) $subtabs_array = array(); 
  131. $subtabs_array[] = $this->subtab_data(); 
  132.  
  133. return $subtabs_array; 
  134.  
  135. /**-----------------------------------------------------------------------------------*/ 
  136. /** settings_form() */ 
  137. /** Call the form from Admin Interface 
  138. /**-----------------------------------------------------------------------------------*/ 
  139. public function settings_form() { 
  140. global $wc_predictive_search_admin_interface; 
  141.  
  142. $output = ''; 
  143. $output .= $wc_predictive_search_admin_interface->admin_forms( $this->form_fields, $this->form_key, $this->option_name, $this->form_messages ); 
  144.  
  145. return $output; 
  146.  
  147. /**-----------------------------------------------------------------------------------*/ 
  148. /** init_form_fields() */ 
  149. /** Init all fields of this form */ 
  150. /**-----------------------------------------------------------------------------------*/ 
  151. public function init_form_fields() { 
  152.  
  153. // Define settings  
  154. $this->form_fields = apply_filters( $this->option_name . '_settings_fields', array( 
  155.  
  156. array( 
  157. 'name' => __( 'Global Search Box Text', 'woocommerce-predictive-search' ),  
  158. 'type' => 'heading',  
  159. 'id' => 'predictive_search_searchbox_text',  
  160. 'is_box' => true,  
  161. ),  
  162.  
  163. array( 
  164. 'name' => __( 'Dropdown Results Animation', 'woocommerce-predictive-search' ),  
  165. 'desc' => '<img class="rwd_image_maps" src="'.WOOPS_IMAGES_URL.'/premium-results-animation.png" usemap="#resultsAnimationMap" style="width: auto; max-width: 100%;" border="0" /> 
  166. <map name="resultsAnimationMap" id="resultsAnimationMap"> 
  167. <area shape="rect" coords="0, 400, 360, 460" href="'.$this->pro_plugin_page_url.'" target="_blank" /> 
  168. </map>',  
  169. 'type' => 'heading',  
  170. 'id' => 'predictive_search_animiation_box',  
  171. 'is_box' => true,  
  172. ),  
  173.  
  174. array( 
  175. 'name' => __( 'Search In Category Feature', 'woocommerce-predictive-search' ),  
  176. 'desc' => '<img class="rwd_image_maps" src="'.WOOPS_IMAGES_URL.'/premium-search-category-cache.png" usemap="#searchInCategoryMap" style="width: auto; max-width: 100%;" border="0" /> 
  177. <map name="searchInCategoryMap" id="searchInCategoryMap"> 
  178. <area shape="rect" coords="410, 160, 930, 230" href="'.$this->pro_plugin_page_url.'" target="_blank" /> 
  179. </map>',  
  180. 'id' => 'predictive_search_category_cache_box',  
  181. 'type' => 'heading',  
  182. 'is_box' => true,  
  183. ),  
  184. )); 
  185.  
  186. function predictive_search_searchbox_text() { 
  187. if ( class_exists('SitePress') ) { 
  188. $woocommerce_search_box_text = get_option('woocommerce_search_box_text', array() ); 
  189. if ( !is_array( $woocommerce_search_box_text) ) $woocommerce_search_box_text = array(); 
  190.  
  191. global $sitepress; 
  192. $active_languages = $sitepress->get_active_languages(); 
  193. if ( is_array($active_languages) && count($active_languages) > 0 ) { 
  194. ?> 
  195. <tr valign="top" class=""> 
  196. <td class="forminp" colspan="2"> 
  197. <?php _e("Enter the translated search box text for each language for WPML to show it correct on the front end.", 'woocommerce-predictive-search' ); ?> 
  198. </td> 
  199. </tr> 
  200. <?php 
  201. foreach ( $active_languages as $language ) { 
  202. ?> 
  203. <tr valign="top" class=""> 
  204. <th class="titledesc" scope="row"><label for="woocommerce_search_box_text_<?php echo $language['code']; ?>"><?php _e('Text to Show', 'woocommerce-predictive-search' );?> (<?php echo $language['display_name']; ?>)</label></th> 
  205. <td class="forminp"> 
  206. <input type="text" class="" value="<?php if (isset($woocommerce_search_box_text[$language['code']]) ) esc_attr_e( stripslashes( $woocommerce_search_box_text[$language['code']] ) ); ?>" style="min-width:300px;" id="woocommerce_search_box_text_<?php echo $language['code']; ?>" name="woocommerce_search_box_text[<?php echo $language['code']; ?>]" /> <span class="description"><?php _e('<empty> shows nothing', 'woocommerce-predictive-search' ); ?></span> 
  207. </td> 
  208. </tr> 
  209. <?php 
  210.  
  211. } else { 
  212. $woocommerce_search_box_text = get_option('woocommerce_search_box_text', '' ); 
  213. if ( is_array( $woocommerce_search_box_text) ) $woocommerce_search_box_text = ''; 
  214. ?> 
  215. <tr valign="top" class=""> 
  216. <th class="titledesc" scope="row"><label for="woocommerce_search_box_text"><?php _e('Text to Show', 'woocommerce-predictive-search' );?></label></th> 
  217. <td class="forminp"> 
  218. <input type="text" class="" value="<?php esc_attr_e( stripslashes( $woocommerce_search_box_text ) ); ?>" style="min-width:300px;" id="woocommerce_search_box_text" name="woocommerce_search_box_text" /> <span class="description"><?php _e('<empty> shows nothing', 'woocommerce-predictive-search' ); ?></span> 
  219. </td> 
  220. </tr> 
  221. <?php } 
  222.  
  223. public function include_script() { 
  224. wp_enqueue_script( 'jquery-rwd-image-maps' ); 
  225. ?> 
  226. <?php