WC_Compare_Comparison_Page_Global_Settings

The WooCommerce Compare Products LITE WC Compare Comparison Page Global Settings class.

Defined (1)

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

/admin/settings/comparison-page/global-settings.php  
  1. class WC_Compare_Comparison_Page_Global_Settings extends WC_Compare_Admin_UI 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $parent_tab = 'comparison-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 = 'woo_compare_comparison_page_global_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_comparison_page_global_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' => __( 'Comparison Page Settings successfully saved.', 'woocommerce-compare-products' ),  
  52. 'error_message' => __( 'Error: Comparison Page Settings can not save.', 'woocommerce-compare-products' ),  
  53. 'reset_message' => __( 'Comparison Page 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_comparison_page_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' => __( "Comparison Page Setup", 'woocommerce-compare-products' ),  
  145. 'type' => 'heading',  
  146. 'id' => 'comparison_page_configuration_box',  
  147. 'is_box' => true,  
  148. ),  
  149. array(  
  150. 'name' => __( 'Open Compare Table in', 'woocommerce-compare-products' ),  
  151. 'id' => 'open_compare_type',  
  152. 'type' => 'onoff_radio',  
  153. 'default' => 'new_page',  
  154. 'onoff_options' => array( 
  155. array( 
  156. 'val' => 'window',  
  157. 'text' => __( 'Pop-up Window', 'woocommerce-compare-products' ),  
  158. 'checked_label' => __( 'ON', 'woocommerce-compare-products' ) ,  
  159. 'unchecked_label' => __( 'OFF', 'woocommerce-compare-products' ) ,  
  160. ),  
  161. array( 
  162. 'val' => 'new_page',  
  163. 'text' => __( 'New Tab', 'woocommerce-compare-products' ) . '. '.__("(Use this if concerned about browser pop-up blockers).", 'woocommerce-compare-products' ),  
  164. 'checked_label' => __( 'ON', 'woocommerce-compare-products' ) ,  
  165. 'unchecked_label' => __( 'OFF', 'woocommerce-compare-products' ) ,  
  166. ),  
  167. ),  
  168. ),  
  169.  
  170. array( 
  171. 'name' => __( "Comparison Page Shortcode", 'woocommerce-compare-products' ),  
  172. 'desc' => __( "A 'Product Comparison' page with the shortcode [product_comparison_page] inserted should have been auto created on install. If not you need to manually create a new page and add the shortcode. Then set that page below so the plugin knows where to find it.", 'woocommerce-compare-products' ),  
  173. 'type' => 'heading',  
  174. 'id' => 'comparison_page_shortcode_box',  
  175. ),  
  176. array(  
  177. 'name' => __( 'Product Comparison Page', 'woocommerce-compare-products' ),  
  178. 'desc' => __( 'Page contents', 'woocommerce-compare-products' ).': [product_comparison_page]',  
  179. 'id' => 'product_compare_id',  
  180. 'type' => 'single_select_page',  
  181. 'default' => '',  
  182. 'separate_option' => true,  
  183. 'placeholder' => __( 'Select Page', 'woocommerce-compare-products' ),  
  184. 'css' => 'width:300px;',  
  185. ),  
  186.  
  187. ); 
  188.  
  189. include_once( $this->admin_plugin_dir() . '/settings/comparison-page/page-style-settings.php' ); 
  190. global $wc_compare_comparison_page_style_settings; 
  191. $this->form_fields = array_merge( $this->form_fields, $wc_compare_comparison_page_style_settings->form_fields ); 
  192.  
  193. $this->form_fields = array_merge( $this->form_fields, array( 
  194. array( 
  195. 'name' => __( "DYNAMIC STYLE SUPER POWERS", 'woocommerce-compare-products' ),  
  196. 'type' => 'heading',  
  197. 'desc' => '<img class="rwd_image_maps" src="'.WOOCP_IMAGES_URL.'/wc_comparison_page_premium.png" usemap="#comparisonpageMap" style="width: auto; max-width: 100%;" border="0" /> 
  198. <map name="comparisonpageMap" id="comparisonpageMap"> 
  199. <area shape="rect" coords="18, 320, 345, 365" href="'.$this->pro_plugin_page_url.'" target="_blank" /> 
  200. </map>',  
  201. 'alway_open'=> true,  
  202. 'id' => 'comparison_page_premium_box',  
  203. 'is_box' => true,  
  204. )); 
  205.  
  206. $this->form_fields = apply_filters( $this->form_key . '_settings_fields', $this->form_fields ); 
  207.  
  208. public function include_script() { 
  209. wp_enqueue_script( 'jquery-rwd-image-maps' ); 
  210.