WC_Dynamic_Gallery_Global_Settings

The WooCommerce Dynamic Gallery LITE WC Dynamic Gallery Global Settings class.

Defined (1)

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

/admin/settings/global-settings.php  
  1. class WC_Dynamic_Gallery_Global_Settings extends WC_Dynamic_Gallery_Admin_UI 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. private $parent_tab = 'global-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 = ''; 
  18.  
  19. /** 
  20. * @var string 
  21. * You must change to correct form key that you are working 
  22. */ 
  23. public $form_key = 'wc_dgallery_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. $this->init_form_fields(); 
  47. $this->subtab_init(); 
  48.  
  49. $this->form_messages = array( 
  50. 'success_message' => __( 'Dynamic Gallery Settings successfully saved.', 'woo_dgallery' ),  
  51. 'error_message' => __( 'Error: Dynamic Gallery Settings can not save.', 'woo_dgallery' ),  
  52. 'reset_message' => __( 'Dynamic Gallery Settings successfully reseted.', 'woo_dgallery' ),  
  53. ); 
  54.  
  55. add_action( $this->plugin_name . '-' . $this->form_key . '_settings_end', array( $this, 'include_script' ) ); 
  56.  
  57. add_action( $this->plugin_name . '_set_default_settings' , array( $this, 'set_default_settings' ) ); 
  58.  
  59. add_action( $this->plugin_name . '-' . $this->form_key . '_settings_init' , array( $this, 'reset_default_settings' ) ); 
  60.  
  61. add_action( $this->plugin_name . '-' . $this->form_key . '_settings_init' , array( $this, 'after_save_settings' ) ); 
  62. //add_action( $this->plugin_name . '_get_all_settings' , array( $this, 'get_settings' ) ); 
  63.  
  64. /**-----------------------------------------------------------------------------------*/ 
  65. /** subtab_init() */ 
  66. /** Sub Tab Init */ 
  67. /**-----------------------------------------------------------------------------------*/ 
  68. public function subtab_init() { 
  69.  
  70. add_filter( $this->plugin_name . '-' . $this->parent_tab . '_settings_subtabs_array', array( $this, 'add_subtab' ), $this->position ); 
  71.  
  72.  
  73. /**-----------------------------------------------------------------------------------*/ 
  74. /** set_default_settings() 
  75. /** Set default settings with function called from Admin Interface */ 
  76. /**-----------------------------------------------------------------------------------*/ 
  77. public function set_default_settings() { 
  78. global $wc_dgallery_admin_interface; 
  79.  
  80. $wc_dgallery_admin_interface->reset_settings( $this->form_fields, $this->option_name, false ); 
  81.  
  82. /**-----------------------------------------------------------------------------------*/ 
  83. /** reset_default_settings() 
  84. /** Reset default settings with function called from Admin Interface */ 
  85. /**-----------------------------------------------------------------------------------*/ 
  86. public function reset_default_settings() { 
  87. global $wc_dgallery_admin_interface; 
  88.  
  89. $wc_dgallery_admin_interface->reset_settings( $this->form_fields, $this->option_name, true, true ); 
  90.  
  91. /**-----------------------------------------------------------------------------------*/ 
  92. /** after_save_settings() 
  93. /** Process when clean on deletion option is un selected */ 
  94. /**-----------------------------------------------------------------------------------*/ 
  95. public function after_save_settings() { 
  96. if ( isset( $_POST['bt_save_settings'] ) && isset( $_POST[WOO_DYNAMIC_GALLERY_PREFIX.'reset_galleries_activate'] ) ) { 
  97. delete_option( WOO_DYNAMIC_GALLERY_PREFIX.'reset_galleries_activate' ); 
  98. WC_Dynamic_Gallery_Functions::reset_products_galleries_activate();  
  99. if ( isset( $_POST['bt_save_settings'] ) && isset( $_POST[WOO_DYNAMIC_GALLERY_PREFIX.'reset_feature_image_activate'] ) ) { 
  100. delete_option( WOO_DYNAMIC_GALLERY_PREFIX.'reset_feature_image_activate' ); 
  101. WC_Dynamic_Gallery_Functions::reset_auto_feature_image_activate();  
  102. if ( ( isset( $_POST['bt_save_settings'] ) || isset( $_POST['bt_reset_settings'] ) ) && get_option( 'wc_dgallery_clean_on_deletion' ) == 'no' ) { 
  103. $uninstallable_plugins = (array) get_option('uninstall_plugins'); 
  104. unset($uninstallable_plugins[WOO_DYNAMIC_GALLERY_NAME]); 
  105. update_option('uninstall_plugins', $uninstallable_plugins); 
  106.  
  107. /**-----------------------------------------------------------------------------------*/ 
  108. /** get_settings() 
  109. /** Get settings with function called from Admin Interface */ 
  110. /**-----------------------------------------------------------------------------------*/ 
  111. public function get_settings() { 
  112. global $wc_dgallery_admin_interface; 
  113.  
  114. $wc_dgallery_admin_interface->get_settings( $this->form_fields, $this->option_name ); 
  115.  
  116. /** 
  117. * subtab_data() 
  118. * Get SubTab Data 
  119. * ============================================= 
  120. * array (  
  121. * 'name' => 'my_subtab_name' : (required) Enter your subtab name that you want to set for this subtab 
  122. * 'label' => 'My SubTab Name' : (required) Enter the subtab label 
  123. * 'callback_function' => 'my_callback_function' : (required) The callback function is called to show content of this subtab 
  124. * ) 
  125. */ 
  126. public function subtab_data() { 
  127.  
  128. $subtab_data = array(  
  129. 'name' => 'global-settings',  
  130. 'label' => __( 'Settings', 'woo_dgallery' ),  
  131. 'callback_function' => 'wc_dgallery_global_settings_form',  
  132. ); 
  133.  
  134. if ( $this->subtab_data ) return $this->subtab_data; 
  135. return $this->subtab_data = $subtab_data; 
  136.  
  137.  
  138. /**-----------------------------------------------------------------------------------*/ 
  139. /** add_subtab() */ 
  140. /** Add Subtab to Admin Init 
  141. /**-----------------------------------------------------------------------------------*/ 
  142. public function add_subtab( $subtabs_array ) { 
  143.  
  144. if ( ! is_array( $subtabs_array ) ) $subtabs_array = array(); 
  145. $subtabs_array[] = $this->subtab_data(); 
  146.  
  147. return $subtabs_array; 
  148.  
  149. /**-----------------------------------------------------------------------------------*/ 
  150. /** settings_form() */ 
  151. /** Call the form from Admin Interface 
  152. /**-----------------------------------------------------------------------------------*/ 
  153. public function settings_form() { 
  154. global $wc_dgallery_admin_interface; 
  155.  
  156. $output = ''; 
  157. $output .= $wc_dgallery_admin_interface->admin_forms( $this->form_fields, $this->form_key, $this->option_name, $this->form_messages ); 
  158.  
  159. return $output; 
  160.  
  161. /**-----------------------------------------------------------------------------------*/ 
  162. /** init_form_fields() */ 
  163. /** Init all fields of this form */ 
  164. /**-----------------------------------------------------------------------------------*/ 
  165. public function init_form_fields() { 
  166.  
  167. // Define settings 
  168. $this->form_fields = apply_filters( $this->option_name . '_settings_fields', array( 
  169.  
  170. array( 
  171. 'name' => __( 'Plugin Framework Global Settings', 'woo_dgallery' ),  
  172. 'id' => 'plugin_framework_global_box',  
  173. 'type' => 'heading',  
  174. 'first_open'=> true,  
  175. 'is_box' => true,  
  176. ),  
  177.  
  178. array( 
  179. 'name' => __( 'Customize Admin Setting Box Display', 'woo_dgallery' ),  
  180. 'desc' => __( 'By default each admin panel will open with all Setting Boxes in the CLOSED position.', 'woo_dgallery' ),  
  181. 'type' => 'heading',  
  182. ),  
  183. array( 
  184. 'type' => 'onoff_toggle_box',  
  185. ),  
  186. array( 
  187. 'name' => __( 'Google Fonts', 'woo_dgallery' ),  
  188. 'desc' => __( 'By Default Google Fonts are pulled from a static JSON file in this plugin. This file is updated but does not have the latest font releases from Google.', 'woo_dgallery' ),  
  189. 'type' => 'heading',  
  190. ),  
  191. array( 
  192. 'type' => 'google_api_key',  
  193. ),  
  194. array( 
  195. 'name' => __( 'House Keeping', 'woo_dgallery' ),  
  196. 'type' => 'heading',  
  197. ),  
  198. array( 
  199. 'name' => __( 'Clean Up On Deletion', 'woo_dgallery' ),  
  200. 'desc' => __( 'On deletion (not deactivate) the plugin will completely remove all tables and data it created, leaving no trace it was ever here.', 'woo_dgallery'),  
  201. 'id' => 'wc_dgallery_lite_clean_on_deletion',  
  202. 'type' => 'onoff_checkbox',  
  203. 'default' => 'no',  
  204. 'separate_option' => true,  
  205. 'free_version' => true,  
  206. 'checked_value' => 'yes',  
  207. 'unchecked_value' => 'no',  
  208. 'checked_label' => __( 'ON', 'woo_dgallery' ),  
  209. 'unchecked_label' => __( 'OFF', 'woo_dgallery' ),  
  210. ),  
  211.  
  212. array( 
  213. 'name' => __('Dynamic Gallery Activation', 'woo_dgallery'),  
  214. 'type' => 'heading',  
  215. 'desc' => __( 'When activated Dynamic Gallery function is applied to each products WooCommerce Default gallery images. Dynamic Gallery menu is added to each product pages WooCommerce Product Data menu. The WooCommerce Product Gallery is converted to Dynamic Product Gallery.', 'woo_dgallery' ),  
  216. 'id' => 'wc_dgallery_global_activation_box',  
  217. 'is_box' => true,  
  218. ),  
  219. array( 
  220. 'name' => __( 'Gallery Activation Default', 'woo_dgallery' ),  
  221. 'desc' => __( 'Changes to the default Gallery activation does NOT apply to existing products. It will be applied to all products created after changing the default.', 'woo_dgallery' ),  
  222. 'id' => WOO_DYNAMIC_GALLERY_PREFIX.'activate',  
  223. 'default' => 'yes',  
  224. 'type' => 'onoff_checkbox',  
  225. 'free_version' => true,  
  226. 'checked_value' => 'yes',  
  227. 'unchecked_value' => 'no',  
  228. 'checked_label' => __( 'ON', 'woo_dgallery' ),  
  229. 'unchecked_label' => __( 'OFF', 'woo_dgallery' ),  
  230. ),  
  231. array(  
  232. 'name' => __( 'Reset Activation To Default', 'woo_dgallery' ),  
  233. 'desc' => __( 'Switch ON and Save Changes will reset ALL existing and future products to the Gallery Activation Default that you have set above.', 'woo_dgallery' ),  
  234. 'id' => WOO_DYNAMIC_GALLERY_PREFIX.'reset_galleries_activate',  
  235. 'default' => 'no',  
  236. 'type' => 'onoff_checkbox',  
  237. 'free_version' => true,  
  238. 'checked_value' => 'yes',  
  239. 'unchecked_value' => 'no',  
  240. 'checked_label' => __( 'ON', 'woo_dgallery' ),  
  241. 'unchecked_label' => __( 'OFF', 'woo_dgallery' ),  
  242. ),  
  243.  
  244. array( 
  245. 'name' => __( "VARIATION GALLERIES SUPER POWERS", 'woo_dgallery' ),  
  246. 'type' => 'heading',  
  247. 'desc' => '<img class="rwd_image_maps" src="'.WOO_DYNAMIC_GALLERY_IMAGES_URL.'/variation_galleries_activation_premium.png" usemap="#productCardsMap" style="width: auto; max-width: 100%;" border="0" /> 
  248. <map name="productCardsMap" id="productCardsMap"> 
  249. <area shape="rect" coords="260, 395, 620, 330" href="'.$this->pro_plugin_page_url.'" target="_blank" /> 
  250. </map>',  
  251. 'alway_open'=> true,  
  252. 'id' => 'dgallery_icon_styles_premium_box',  
  253. 'is_box' => true,  
  254. ),  
  255. array( 
  256. 'name' => __( 'Variations Galleries Activation', 'woo_dgallery' ),  
  257. 'type' => 'heading',  
  258. 'class'=> 'pro_feature_fields pro_feature_hidden',  
  259. 'desc' => __( 'Variations Galleries are auto applied to all Variable products upon first install. A Variations Gallery is added to each WooCommerce Product Variation. Variation Gallery can be activated / deactivated from the Dynamic Gallery menu on each product edit page.', 'woo_dgallery' ),  
  260. 'id' => 'wc_dgallery_variations_activation_box',  
  261. 'is_box' => true,  
  262. ),  
  263. array(  
  264. 'name' => __( 'Variations Activation Default', 'woo_dgallery' ),  
  265. 'desc' => __( 'Changes to the default Variation Galleries activation does NOT apply to existing variable products. It will be applied to all variable products created after changing the default.', 'woo_dgallery' ),  
  266. 'id' => WOO_DYNAMIC_GALLERY_PREFIX.'show_variation',  
  267. 'default' => 'no',  
  268. 'type' => 'onoff_checkbox',  
  269. 'checked_value' => 'yes',  
  270. 'unchecked_value' => 'no',  
  271. 'checked_label' => __( 'ON', 'woo_dgallery' ),  
  272. 'unchecked_label' => __( 'OFF', 'woo_dgallery' ),  
  273. ),  
  274. array(  
  275. 'name' => __( 'Reset Activation To Default', 'woo_dgallery' ),  
  276. 'desc' => __( 'Switch ON and Save Changes will reset ALL existing and future variable products to the Variations Gallery Activation Default that you have set above.', 'woo_dgallery' ),  
  277. 'id' => WOO_DYNAMIC_GALLERY_PREFIX.'reset_variation_activate',  
  278. 'default' => 'no',  
  279. 'type' => 'onoff_checkbox',  
  280. 'checked_value' => 'yes',  
  281. 'unchecked_value' => 'no',  
  282. 'checked_label' => __( 'ON', 'woo_dgallery' ),  
  283. 'unchecked_label' => __( 'OFF', 'woo_dgallery' ),  
  284. ),  
  285.  
  286. array( 
  287. 'name' => __( 'Product Feature Image', 'woo_dgallery' ),  
  288. 'type' => 'heading',  
  289. 'desc' => '<ul> 
  290. <li>* '.__( 'ON this option and the Product Image (featured image) will show as the first image in the gallery without having to upload it to the Gallery.', 'woo_dgallery' ).'</li> 
  291. <li>* '.__( 'OFF and the uploaded Product Image (feature image) will show on the product card but not in the Gallery on Product Page.', 'woo_dgallery' ).'</li> 
  292. <li>* '.__( 'Can be turned ON or OFF for each product from the WooCommerce Product data Dynamic Gallery menu.', 'woo_dgallery' ).'</li> 
  293. </ul>',  
  294. 'id' => 'wc_dgallery_feature_image_box',  
  295. 'is_box' => true,  
  296. ),  
  297. array( 
  298. 'name' => __( 'Include in Gallery', 'woo_dgallery' ),  
  299. 'id' => WOO_DYNAMIC_GALLERY_PREFIX.'auto_feature_image',  
  300. 'default' => 'yes',  
  301. 'type' => 'onoff_checkbox',  
  302. 'free_version' => true,  
  303. 'checked_value' => 'yes',  
  304. 'unchecked_value' => 'no',  
  305. 'checked_label' => __( 'ON', 'woo_dgallery' ),  
  306. 'unchecked_label' => __( 'OFF', 'woo_dgallery' ),  
  307. ),  
  308. array(  
  309. 'name' => __( 'Reset Activation To Default', 'woo_dgallery' ),  
  310. 'desc' => __( "Switch ON and Save Changes will reset ALL existing and future products to the 'Include in Gallery' Default that you have set above.", 'woo_dgallery' ),  
  311. 'id' => WOO_DYNAMIC_GALLERY_PREFIX.'reset_feature_image_activate',  
  312. 'default' => 'no',  
  313. 'type' => 'onoff_checkbox',  
  314. 'free_version' => true,  
  315. 'checked_value' => 'yes',  
  316. 'unchecked_value' => 'no',  
  317. 'checked_label' => __( 'ON', 'woo_dgallery' ),  
  318. 'unchecked_label' => __( 'OFF', 'woo_dgallery' ),  
  319. ),  
  320.  
  321. array( 
  322. 'name' => __( 'Image Zoom Function', 'woo_dgallery' ),  
  323. 'type' => 'heading',  
  324. 'id' => 'wc_dgallery_image_zoom_box',  
  325. 'is_box' => true,  
  326. ),  
  327. array( 
  328. 'name' => __( 'Gallery Popup', 'woo_dgallery' ),  
  329. 'desc' => '',  
  330. 'id' => WOO_DYNAMIC_GALLERY_PREFIX.'popup_gallery',  
  331. 'default' => 'fb',  
  332. 'type' => 'onoff_radio',  
  333. 'free_version' => true,  
  334. 'onoff_options' => array( 
  335. array( 
  336. 'val' => 'fb',  
  337. 'text' => __( 'Fancybox', 'woo_dgallery' ),  
  338. 'checked_label' => 'ON',  
  339. 'unchecked_label' => 'OFF',  
  340. ),  
  341. array( 
  342. 'val' => 'colorbox',  
  343. 'text' => __( 'ColorBox', 'woo_dgallery' ),  
  344. 'checked_label' => 'ON',  
  345. 'unchecked_label' => 'OFF',  
  346. ),  
  347. array( 
  348. 'val' => 'deactivate',  
  349. 'text' => __( 'Deactivate', 'woo_dgallery' ),  
  350. 'checked_label' => 'ON',  
  351. 'unchecked_label' => 'OFF',  
  352. ),  
  353. ),  
  354. ),  
  355.  
  356. array( 
  357. 'name' => __('Gallery Image Dimensions', 'woo_dgallery'),  
  358. 'type' => 'heading',  
  359. 'id' => 'wc_dgallery_image_dimensions_box',  
  360. 'is_box' => true,  
  361. ),  
  362. array( 
  363. 'type' => 'heading',  
  364. 'desc' => '<table class="form-table"><tbody> 
  365. <tr valign="top"> 
  366. <th class="titledesc" scope="row"><label>' . __( 'Gallery Images', 'woo_dgallery' ) . '</label></th> 
  367. <td class="forminp">' . sprintf( __( 'Set via the <a href="%s" target="_blank">Single Product Image Dimensions and Hard Crop</a> option from WooCommerce Settings', 'woo_dgallery' ), admin_url( 'admin.php?page=wc-settings&tab=products§ion=display' ) ) . '</td> 
  368. </tr> 
  369. <tr valign="top"> 
  370. <th class="titledesc" scope="row"><label>' . __( 'Gallery Thumbnails', 'woo_dgallery' ) . '</label></th> 
  371. <td class="forminp">' . sprintf( __( 'Set via the <a href="%s" target="_blank">Product Thumbnails Dimensions and Hard Crop</a> option from WooCommerce Settings', 'woo_dgallery' ), admin_url( 'admin.php?page=wc-settings&tab=products§ion=display' ) ) . '</td> 
  372. </tr></tbody></table>',  
  373. ),  
  374. )); 
  375.  
  376. public function include_script() { 
  377. wp_enqueue_script( 'jquery-rwd-image-maps' );