WCML_Currency_Switcher_Widget

The WooCommerce Multilingual WCML Currency Switcher Widget class.

Defined (1)

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

/inc/currencies/currency-switcher/class-wcml-currency-switcher-widget.php  
  1. class WCML_Currency_Switcher_Widget extends WP_Widget { 
  2.  
  3. const SLUG = 'currency_sel_widget'; 
  4.  
  5. function __construct() { 
  6. parent::__construct( 'currency_sel_widget', __('Currency switcher', 'woocommerce-multilingual'), array(), array() ); 
  7.  
  8. function widget($args, $instance) { 
  9.  
  10. echo $args['before_widget']; 
  11.  
  12. if( isset( $instance['settings']['widget_title'] ) && !empty( $instance['settings']['widget_title'] ) ) { 
  13. $widget_title = apply_filters( 'widget_title', $instance['settings']['widget_title'] ); 
  14. echo $args['before_title']. $widget_title . $args['after_title']; 
  15.  
  16. do_action( 'wcml_currency_switcher', array( 'switcher_id' => $args[ 'id' ] ) ); 
  17.  
  18. echo $args['after_widget']; 
  19.  
  20. public function update( $new_instance, $old_instance ) { 
  21.  
  22. if ( ! $new_instance ) { 
  23. $new_instance = array( 
  24. 'id' => $_POST['sidebar'],  
  25. 'settings' => WCML_Currency_Switcher::get_settings( $_POST['sidebar'] ) 
  26. ); 
  27.  
  28. return $new_instance; 
  29.  
  30. function form( $instance ) { 
  31. if ( ! isset( $instance[ 'id' ] ) ) { 
  32. $instance[ 'id' ] = ''; 
  33.  
  34. $url_to_currency_switcher = esc_url( admin_url( 'admin.php?page=wpml-wcml&tab=multi-currency#currency-switcher/' . (int) $instance[ 'id' ] ) ); 
  35. $button_text = esc_html__( 'Customize the currency switcher', 'woocommerce-multilingual' ); 
  36. printf('<p><a class="button button-secondary wcml-cs-widgets-edit-link" href="%s"><span class="otgs-ico-edit"></span> %s</a></p>', $url_to_currency_switcher, $button_text ); 
  37.