WC_Compare_Widget_Global_Settings

The WooCommerce Compare Products LITE WC Compare Widget Global Settings class.

Defined (1)

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

/admin/settings/widget-style/compare-widget-settings.php  
  1. class WC_Compare_Widget_Global_Settings extends WC_Compare_Admin_UI 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $parent_tab = 'compare-widget'; 
  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 = 'woo_compare_widget_style'; 
  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. add_action( 'plugins_loaded', array( $this, 'init_form_fields' ), 1 ); 
  48. $this->subtab_init(); 
  49.  
  50. $this->form_messages = array( 
  51. 'success_message' => __( 'Compare Widget General Settings successfully saved.', 'woocommerce-compare-products' ),  
  52. 'error_message' => __( 'Error: Compare Widget General Settings can not save.', 'woocommerce-compare-products' ),  
  53. 'reset_message' => __( 'Compare Widget General Settings successfully reseted.', 'woocommerce-compare-products' ),  
  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_compare_admin_interface; 
  77.  
  78. $wc_compare_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_compare_admin_interface; 
  86.  
  87. $wc_compare_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' => 'general-settings',  
  103. 'label' => __( 'General Settings', 'woocommerce-compare-products' ),  
  104. 'callback_function' => 'wc_compare_widget_global_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_compare_admin_interface; 
  128.  
  129. $output = ''; 
  130. $output .= $wc_compare_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 = array( 
  142. array( 
  143. 'name' => __( "COMPARE WIDGET STYLE SUPER POWERS", 'woocommerce-compare-products' ),  
  144. 'type' => 'heading',  
  145. 'desc' => '<img class="rwd_image_maps" src="'.WOOCP_IMAGES_URL.'/wc_compare_widget_premium.png" usemap="#compareWidgetMap" style="width: auto; max-width: 100%;" border="0" /> 
  146. <map name="compareWidgetMap" id="compareWidgetMap"> 
  147. <area shape="rect" coords="330, 195, 795, 252" href="'.$this->pro_plugin_page_url.'" target="_blank" /> 
  148. </map>',  
  149. 'alway_open'=> true,  
  150. 'id' => 'compare_widget_premium_box',  
  151. 'is_box' => true,  
  152. ),  
  153.  
  154. ); 
  155.  
  156. $this->form_fields = apply_filters( $this->form_key . '_settings_fields', $this->form_fields ); 
  157.  
  158. public function include_script() { 
  159. ?> 
  160. <style type="text/css"> 
  161. .a3rev_panel_container p.submit { 
  162. display: none; 
  163. </style> 
  164. <?php 
  165. wp_enqueue_script( 'jquery-rwd-image-maps' );