WC_Compare_Grid_View_Global_Settings

The WooCommerce Compare Products LITE WC Compare Grid View Global Settings class.

Defined (1)

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

/admin/settings/gridview-style/global-settings.php  
  1. class WC_Compare_Grid_View_Global_Settings extends WC_Compare_Admin_UI 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $parent_tab = 'product-cards'; 
  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 = 'woo_compare_grid_view_settings'; 
  18.  
  19. /** 
  20. * @var string 
  21. * You must change to correct form key that you are working 
  22. */ 
  23. public $form_key = 'woo_compare_grid_view_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. add_action( 'plugins_loaded', array( $this, 'init_form_fields' ), 1 ); 
  48. $this->subtab_init(); 
  49.  
  50. $this->form_messages = array( 
  51. 'success_message' => __( 'Product Card Settings successfully saved.', 'woocommerce-compare-products' ),  
  52. 'error_message' => __( 'Error: Product Card Settings can not save.', 'woocommerce-compare-products' ),  
  53. 'reset_message' => __( 'Product Card 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' => 'product-card-settings',  
  103. 'label' => __( 'Product Card Settings', 'woocommerce-compare-products' ),  
  104. 'callback_function' => 'wc_compare_grid_view_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.  
  143. array( 
  144. 'name' => __( "Add to Compare from Product Cards", 'woocommerce-compare-products' ),  
  145. 'type' => 'heading',  
  146. 'id' => 'product_cards_compare_box',  
  147. 'is_box' => true,  
  148. ),  
  149. array(  
  150. 'name' => __( "Compare Feature", 'woocommerce-compare-products' ),  
  151. 'class' => 'disable_grid_view_compare',  
  152. 'id' => 'disable_grid_view_compare',  
  153. 'type' => 'onoff_checkbox',  
  154. 'default' => 0,  
  155. 'checked_value' => 0,  
  156. 'unchecked_value' => 1,  
  157. 'checked_label' => __( 'ON', 'woocommerce-compare-products' ),  
  158. 'unchecked_label' => __( 'OFF', 'woocommerce-compare-products' ),  
  159. ),  
  160.  
  161. array( 
  162. 'name' => __( "Position on Product Cards", 'woocommerce-compare-products' ),  
  163. 'desc' => __('Position applies to all product cards on the Shop, Product Category and Product Tag pages.', 'woocommerce-compare-products' ),  
  164. 'class' => 'grid_view_compare_activate_container',  
  165. 'type' => 'heading',  
  166. 'id' => 'product_cards_compare_button_position_box',  
  167. 'is_box' => true,  
  168. ),  
  169. array(  
  170. 'name' => __( 'Vertical Position', 'woocommerce-compare-products' ),  
  171. 'desc' => __( 'Position relative to Add to Cart Button. Tip: Change position if Compare Button/Link does not show.', 'woocommerce-compare-products' ),  
  172. 'id' => 'grid_view_button_position',  
  173. 'type' => 'switcher_checkbox',  
  174. 'default' => 'above',  
  175. 'checked_value' => 'above',  
  176. 'unchecked_value' => 'below',  
  177. 'checked_label' => __( 'Above', 'woocommerce-compare-products' ),  
  178. 'unchecked_label' => __( 'Below', 'woocommerce-compare-products' ),  
  179. ),  
  180. array(  
  181. 'name' => __( 'Button Margin', 'woocommerce-compare-products' ),  
  182. 'id' => 'grid_view_button_margin',  
  183. 'type' => 'array_textfields',  
  184. 'ids' => array(  
  185. array(  
  186. 'id' => 'grid_view_button_margin_top',  
  187. 'name' => __( 'Top', 'woocommerce-compare-products' ),  
  188. 'css' => 'width:40px;',  
  189. 'default' => 10 ),  
  190.  
  191. array( 'id' => 'grid_view_button_margin_bottom',  
  192. 'name' => __( 'Bottom', 'woocommerce-compare-products' ),  
  193. 'css' => 'width:40px;',  
  194. 'default' => 10 ),  
  195.  
  196. array(  
  197. 'id' => 'grid_view_button_margin_left',  
  198. 'name' => __( 'Left', 'woocommerce-compare-products' ),  
  199. 'css' => 'width:40px;',  
  200. 'default' => 0 ),  
  201.  
  202. array(  
  203. 'id' => 'grid_view_button_margin_right',  
  204. 'name' => __( 'Right', 'woocommerce-compare-products' ),  
  205. 'css' => 'width:40px;',  
  206. 'default' => 0 ),  
  207. ),  
  208.  
  209. array( 
  210. 'name' => __( "DYNAMIC STYLE SUPER POWERS", 'woocommerce-compare-products' ),  
  211. 'type' => 'heading',  
  212. 'desc' => '<img class="rwd_image_maps" src="'.WOOCP_IMAGES_URL.'/wc_product_cards_premium.png" usemap="#productCardsMap" style="width: auto; max-width: 100%;" border="0" /> 
  213. <map name="productCardsMap" id="productCardsMap"> 
  214. <area shape="rect" coords="555, 60, 935, 104" href="'.$this->pro_plugin_page_url.'" target="_blank" /> 
  215. </map>',  
  216. 'alway_open'=> true,  
  217. 'id' => 'product_cards_premium_box',  
  218. 'is_box' => true,  
  219. ),  
  220.  
  221. ); 
  222.  
  223. $this->form_fields = apply_filters( $this->form_key . '_settings_fields', $this->form_fields ); 
  224.  
  225. public function include_script() { 
  226. wp_enqueue_script( 'jquery-rwd-image-maps' ); 
  227. ?> 
  228. <script> 
  229. (function($) { 
  230.  
  231. $(document).ready(function() { 
  232.  
  233. if ( $("input.disable_grid_view_compare:checked").val() != '0') { 
  234. $(".grid_view_compare_activate_container").css( {'visibility': 'hidden', 'height' : '0px', 'overflow' : 'hidden', 'margin-bottom' : '0px'} ); 
  235.  
  236. $(document).on( "a3rev-ui-onoff_checkbox-switch", '.disable_grid_view_compare', function( event, value, status ) { 
  237. $(".grid_view_compare_activate_container").attr('style', 'display:none;'); 
  238. if ( status == 'true' ) { 
  239. $(".grid_view_compare_activate_container").slideDown(); 
  240. }); 
  241. }); 
  242.  
  243. })(jQuery); 
  244. </script> 
  245. <?php 
  246.