WCPBC_Admin_Translation_Management

WCPBC_Admin_Translation_Management.

Defined (1)

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

/includes/admin/class-wcpbc-admin-translation-management.php  
  1. class WCPBC_Admin_Translation_Management { 
  2.  
  3. /** 
  4. * Get Custom plugin fields 
  5. */ 
  6. public static function custom_fields() { 
  7.  
  8. $custom_fields = array(); 
  9.  
  10. $region_keys = array_keys( WCPBC()->get_regions() ); 
  11.  
  12. foreach ( $region_keys as $key ) { 
  13.  
  14. foreach ( array( '_price', '_regular_price', '_sale_price', '_price_method' ) as $field ) { 
  15.  
  16. $custom_fields[] = '_' . $key . $field; 
  17. $custom_fields[] = '_' . $key . '_variable' . $field; 
  18.  
  19. if ( $field !== '_price_method' ) { 
  20. foreach ( array('min', 'max') as $min_or_max ) { 
  21. $custom_fields[] = '_' . $key . '_' . $min_or_max . $field . '_variation_id';  
  22. }  
  23.  
  24. return $custom_fields; 
  25.  
  26. /** 
  27. * Add customs fields to WPML Translation management  
  28. */ 
  29. public static function add_custom_fields() {  
  30. //wpml_copy_from_original_custom_fields 
  31. global $iclTranslationManagement;  
  32.  
  33. $change = false; 
  34.  
  35. foreach ( self::custom_fields() as $field) { 
  36.  
  37. if ( ! isset( $iclTranslationManagement->settings['custom_fields_translation'][$field] ) ) { 
  38.  
  39. $iclTranslationManagement->settings['custom_fields_translation'][$field] = 1; //copy 
  40.  
  41. $change = true; 
  42.  
  43. if ( $change ) { 
  44. $iclTranslationManagement->save_settings(); 
  45.  
  46. /** 
  47. * Enqueue scripts 
  48. */ 
  49. public static function wpml_scripts() { 
  50.  
  51. global $woocommerce_wpml, $pagenow; 
  52.  
  53. if ( isset($woocommerce_wpml) && is_object( $woocommerce_wpml ) && get_class($woocommerce_wpml) == 'woocommerce_wpml' ) { 
  54.  
  55. if( ($pagenow == 'post.php' && isset($_GET['post']) && get_post_type($_GET['post']) == 'product' && !$woocommerce_wpml->products->is_original_product($_GET['post']) ) || 
  56. ($pagenow == 'post-new.php' && isset($_GET['source_lang']) && isset($_GET['post_type']) && $_GET['post_type'] == 'product') &&  
  57. ! $woocommerce_wpml->settings['trnsl_interface'] ) { 
  58.  
  59. $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 
  60.  
  61. wp_register_script('wcpbc-lock-fields', WCPBC()->plugin_url() . 'assets/js/wcpbc-admin-lock-fields' . $suffix . '.js', array('jquery'), WCPBC()->version, true ); 
  62.  
  63. wp_localize_script( 'wcpbc-lock-fields', 'wcpbc_regions_keys', array_keys( WCPBC()->get_regions() ) ); 
  64.  
  65. wp_enqueue_script( 'wcpbc-lock-fields' ); 
  66.  
  67.  
  68.  
  69. /** 
  70. * Check WCML Multi currency  
  71. */  
  72. public static function check_wcml_multicurrency() { 
  73.  
  74. global $woocommerce_wpml; 
  75.  
  76. if ( isset($woocommerce_wpml) && is_object( $woocommerce_wpml ) && get_class($woocommerce_wpml) == 'woocommerce_wpml' && $woocommerce_wpml->settings['enable_multi_currency'] > 0 ) { 
  77. add_action( 'admin_notices', array( __CLASS__, 'disable_wcml_multicurrency_notice' ) );  
  78.  
  79. /** 
  80. * Diable WCML Multicurrency notice 
  81. */ 
  82. public static function disable_wcml_multicurrency_notice() { 
  83. ?> 
  84. <div class="error"> 
  85. <p><?php _e( '<strong>WooCommerce Price Based Country incompatiblity found!</strong><br />WooCommerce Multilingual Multiple currencies is incompatible with WooCommerce Price Based on Country. While WooCommerce Multilingual Multiple currencies option is active can cause unexpected results. Go to <a href="' . admin_url( 'admin.php?page=wpml-wcml' ) . '">WooCommerce Multilingual settings page</a> and disables WooCommerce Multilingual Multi Currency option.', 'wc-price-based-country' ); ?></p>  
  86. </div>  
  87. <?php 
  88.