WCML_Pointers

The WooCommerce Multilingual WCML Pointers class.

Defined (1)

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

/inc/admin-menus/class-wcml-pointers.php  
  1. class WCML_Pointers{ 
  2.  
  3. public function __construct() { 
  4. add_action( 'admin_head', array( $this, 'setup') ); 
  5.  
  6. public function setup() { 
  7. $current_screen = get_current_screen(); 
  8.  
  9. if( empty($current_screen) ) { 
  10. return; 
  11.  
  12. $tab = isset( $_GET['tab'] ) ? $_GET['tab'] : ''; 
  13. $section = isset( $_GET['section'] ) ? $_GET['section'] : ''; 
  14. wp_register_style( 'wcml-pointers', WCML_PLUGIN_URL . '/res/css/wcml-pointers.css' ); 
  15.  
  16. if( $current_screen->id == 'edit-product' ) { 
  17. add_action( 'admin_footer', array( $this, 'add_products_translation_link' ), 100 ); 
  18. }elseif( $current_screen->id == 'woocommerce_page_wc-settings' && $tab == 'shipping' && $section == 'classes' ) { 
  19. add_action( 'admin_footer', array( $this, 'add_shipping_classes_translation_link' ) ); 
  20. }elseif( $current_screen->id == 'woocommerce_page_wc-settings' && ( $tab == 'general' || empty($tab) ) ) { 
  21. add_filter( 'woocommerce_general_settings', array( $this, 'add_multi_currency_link' ) ); 
  22. }elseif( $current_screen->id == 'woocommerce_page_wc-settings' && $tab == 'account') { 
  23. add_filter( 'woocommerce_account_settings', array( $this, 'add_endpoints_translation_link' ) ); 
  24.  
  25.  
  26. public function add_products_translation_link() { 
  27. $link = admin_url('admin.php?page=wpml-wcml'); 
  28. $name = __('Translate WooCommerce products', 'woocommerce-multilingual'); 
  29. wp_enqueue_style( 'wcml-pointers'); 
  30. ?> 
  31. <script type="text/javascript"> 
  32. jQuery(".subsubsub").append('<a class="button button-small button-wpml wcml-pointer-products_translation" href="<?php echo $link ?>"><?php echo $name ?></a>'); 
  33. </script> 
  34. <?php 
  35.  
  36. public function add_shipping_classes_translation_link() { 
  37. $link = admin_url('admin.php?page=wpml-wcml&tab=product_shipping_class'); 
  38. $name = __('Translate shipping classes', 'woocommerce-multilingual'); 
  39. wp_enqueue_style( 'wcml-pointers'); 
  40. ?> 
  41. <script type="text/javascript"> 
  42. jQuery(".wc-shipping-classes").before('<a class="button button-small button-wpml wcml-pointer-shipping_classes_translation" href="<?php echo $link ?>"><?php echo $name ?></a>'); 
  43. </script> 
  44. <?php 
  45.  
  46. public function add_multi_currency_link( $settings ) { 
  47. $link = admin_url('admin.php?page=wpml-wcml&tab=multi-currency'); 
  48. $name = __('Configure multi-currency for multilingual sites', 'woocommerce-multilingual'); 
  49. wp_enqueue_style( 'wcml-pointers'); 
  50. foreach( $settings as $key => $value ) { 
  51. if( $value['id'] == 'pricing_options' && isset( $value['desc'] ) ) { 
  52.  
  53. $settings[$key]['desc'] = '<a class="button button-small button-wpml wcml-pointer-multi_currency" href="' . $link . '">' . $name .'</a><br />' . $value['desc']; 
  54.  
  55. return $settings; 
  56.  
  57. public function add_endpoints_translation_link( $settings ) { 
  58. $link = admin_url('admin.php?page=wpml-wcml&tab=slugs'); 
  59. $name = __('Translate endpoints', 'woocommerce-multilingual'); 
  60. wp_enqueue_style( 'wcml-pointers'); 
  61. foreach( $settings as $key => $value ) { 
  62. if( $value['id'] == 'account_endpoint_options' && isset( $value['desc'] ) ) { 
  63.  
  64. $settings[$key]['desc'] = '<a class="button button-small button-wpml wcml-pointer-endpoints_translation" href="' . $link . '">' . $name .'</a><br />' . $value['desc']; 
  65.  
  66. return $settings; 
  67.