WC_PS_All_Results_Page_Settings

The WooCommerce Predictive Search LITE WC PS All Results Page Settings class.

Defined (1)

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

/admin/settings/all-results-page-settings.php  
  1. class WC_PS_All_Results_Page_Settings extends WC_Predictive_Search_Admin_UI 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $parent_tab = 'all-results-page'; 
  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 = ''; 
  18.  
  19. /** 
  20. * @var string 
  21. * You must change to correct form key that you are working 
  22. */ 
  23. public $form_key = 'wc_ps_all_results_pages_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. $this->init_form_fields(); 
  47. $this->subtab_init(); 
  48.  
  49. $this->form_messages = array( 
  50. 'success_message' => __( 'All Results Pages successfully saved.', 'woocommerce-predictive-search' ),  
  51. 'error_message' => __( 'Error: All Results Pages can not save.', 'woocommerce-predictive-search' ),  
  52. 'reset_message' => __( 'All Results Pages successfully reseted.', 'woocommerce-predictive-search' ),  
  53. ); 
  54.  
  55. add_action( $this->plugin_name . '_set_default_settings' , array( $this, 'set_default_settings' ) ); 
  56. //add_action( $this->plugin_name . '_get_all_settings' , array( $this, 'get_settings' ) ); 
  57.  
  58.  
  59. /**-----------------------------------------------------------------------------------*/ 
  60. /** subtab_init() */ 
  61. /** Sub Tab Init */ 
  62. /**-----------------------------------------------------------------------------------*/ 
  63. public function subtab_init() { 
  64.  
  65. add_filter( $this->plugin_name . '-' . $this->parent_tab . '_settings_subtabs_array', array( $this, 'add_subtab' ), $this->position ); 
  66.  
  67.  
  68. /**-----------------------------------------------------------------------------------*/ 
  69. /** set_default_settings() 
  70. /** Set default settings with function called from Admin Interface */ 
  71. /**-----------------------------------------------------------------------------------*/ 
  72. public function set_default_settings() { 
  73. global $wc_predictive_search_admin_interface; 
  74.  
  75. $wc_predictive_search_admin_interface->reset_settings( $this->form_fields, $this->option_name, false ); 
  76.  
  77. /**-----------------------------------------------------------------------------------*/ 
  78. /** get_settings() 
  79. /** Get settings with function called from Admin Interface */ 
  80. /**-----------------------------------------------------------------------------------*/ 
  81. public function get_settings() { 
  82. global $wc_predictive_search_admin_interface; 
  83.  
  84. $wc_predictive_search_admin_interface->get_settings( $this->form_fields, $this->option_name ); 
  85.  
  86. /** 
  87. * subtab_data() 
  88. * Get SubTab Data 
  89. * ============================================= 
  90. * array (  
  91. * 'name' => 'my_subtab_name' : (required) Enter your subtab name that you want to set for this subtab 
  92. * 'label' => 'My SubTab Name' : (required) Enter the subtab label 
  93. * 'callback_function' => 'my_callback_function' : (required) The callback function is called to show content of this subtab 
  94. * ) 
  95. */ 
  96. public function subtab_data() { 
  97.  
  98. $subtab_data = array(  
  99. 'name' => 'all-results-page',  
  100. 'label' => __( 'All Results Pages', 'woocommerce-predictive-search' ),  
  101. 'callback_function' => 'wc_ps_all_results_page_settings_form',  
  102. ); 
  103.  
  104. if ( $this->subtab_data ) return $this->subtab_data; 
  105. return $this->subtab_data = $subtab_data; 
  106.  
  107.  
  108. /**-----------------------------------------------------------------------------------*/ 
  109. /** add_subtab() */ 
  110. /** Add Subtab to Admin Init 
  111. /**-----------------------------------------------------------------------------------*/ 
  112. public function add_subtab( $subtabs_array ) { 
  113.  
  114. if ( ! is_array( $subtabs_array ) ) $subtabs_array = array(); 
  115. $subtabs_array[] = $this->subtab_data(); 
  116.  
  117. return $subtabs_array; 
  118.  
  119. /**-----------------------------------------------------------------------------------*/ 
  120. /** settings_form() */ 
  121. /** Call the form from Admin Interface 
  122. /**-----------------------------------------------------------------------------------*/ 
  123. public function settings_form() { 
  124. global $wc_predictive_search_admin_interface; 
  125.  
  126. $output = ''; 
  127. $output .= $wc_predictive_search_admin_interface->admin_forms( $this->form_fields, $this->form_key, $this->option_name, $this->form_messages ); 
  128.  
  129. return $output; 
  130.  
  131. /**-----------------------------------------------------------------------------------*/ 
  132. /** init_form_fields() */ 
  133. /** Init all fields of this form */ 
  134. /**-----------------------------------------------------------------------------------*/ 
  135. public function init_form_fields() { 
  136.  
  137. // Define settings  
  138. $this->form_fields = apply_filters( $this->option_name . '_settings_fields', array( 
  139.  
  140. array( 
  141. 'name' => __( 'Search results page settings', 'woocommerce-predictive-search' ),  
  142. 'type' => 'heading',  
  143. 'id' => 'predictive_search_results_settings_box',  
  144. 'is_box' => true,  
  145. ),  
  146. array(  
  147. 'name' => __( 'Results', 'woocommerce-predictive-search' ),  
  148. 'desc' => __('The number of results to show before endless scroll click to see more results.', 'woocommerce-predictive-search' ),  
  149. 'id' => 'woocommerce_search_result_items',  
  150. 'type' => 'text',  
  151. 'css' => 'width:40px;',  
  152. 'default' => 10 
  153. ),  
  154. array(  
  155. 'name' => __( 'Description character count', 'woocommerce-predictive-search' ),  
  156. 'desc' => __('The number of characters from product descriptions that shows with each search result.', 'woocommerce-predictive-search' ),  
  157. 'id' => 'woocommerce_search_text_lenght',  
  158. 'type' => 'text',  
  159. 'css' => 'width:40px;',  
  160. 'default' => 100 
  161. ),  
  162. array(  
  163. 'name' => __( 'SKU', 'woocommerce-predictive-search' ),  
  164. 'desc' => __('ON to show product SKU with search results', 'woocommerce-predictive-search' ),  
  165. 'id' => 'woocommerce_search_sku_enable',  
  166. 'type' => 'onoff_checkbox',  
  167. 'default' => 'yes',  
  168. 'checked_value' => 'yes',  
  169. 'unchecked_value' => 'no',  
  170. 'checked_label' => __( 'ON', 'woocommerce-predictive-search' ),  
  171. 'unchecked_label' => __( 'OFF', 'woocommerce-predictive-search' ),  
  172. ),  
  173. array(  
  174. 'name' => __( 'Price', 'woocommerce-predictive-search' ),  
  175. 'desc' => __('ON to show product price with search results', 'woocommerce-predictive-search' ),  
  176. 'id' => 'woocommerce_search_price_enable',  
  177. 'type' => 'onoff_checkbox',  
  178. 'default' => 'yes',  
  179. 'checked_value' => 'yes',  
  180. 'unchecked_value' => 'no',  
  181. 'checked_label' => __( 'ON', 'woocommerce-predictive-search' ),  
  182. 'unchecked_label' => __( 'OFF', 'woocommerce-predictive-search' ),  
  183. ),  
  184. array(  
  185. 'name' => __( 'Add to cart', 'woocommerce-predictive-search' ),  
  186. 'desc' => __('On to show Add to cart button with search results', 'woocommerce-predictive-search' ),  
  187. 'id' => 'woocommerce_search_addtocart_enable',  
  188. 'type' => 'onoff_checkbox',  
  189. 'default' => 'yes',  
  190. 'checked_value' => 'yes',  
  191. 'unchecked_value' => 'no',  
  192. 'checked_label' => __( 'ON', 'woocommerce-predictive-search' ),  
  193. 'unchecked_label' => __( 'OFF', 'woocommerce-predictive-search' ),  
  194. ),  
  195. array(  
  196. 'name' => __( 'Product Categories', 'woocommerce-predictive-search' ),  
  197. 'desc' => __('On to show categories with search results', 'woocommerce-predictive-search' ),  
  198. 'id' => 'woocommerce_search_categories_enable',  
  199. 'type' => 'onoff_checkbox',  
  200. 'default' => 'yes',  
  201. 'checked_value' => 'yes',  
  202. 'unchecked_value' => 'no',  
  203. 'checked_label' => __( 'ON', 'woocommerce-predictive-search' ),  
  204. 'unchecked_label' => __( 'OFF', 'woocommerce-predictive-search' ),  
  205. ),  
  206. array(  
  207. 'name' => __( 'Product Tags', 'woocommerce-predictive-search' ),  
  208. 'desc' => __('On to show tags with search results', 'woocommerce-predictive-search' ),  
  209. 'id' => 'woocommerce_search_tags_enable',  
  210. 'type' => 'onoff_checkbox',  
  211. 'default' => 'yes',  
  212. 'checked_value' => 'yes',  
  213. 'unchecked_value' => 'no',  
  214. 'checked_label' => __( 'ON', 'woocommerce-predictive-search' ),  
  215. 'unchecked_label' => __( 'OFF', 'woocommerce-predictive-search' ),  
  216. ),  
  217.  
  218. )); 
  219.