• Resolved TeslaThemes

    (@teslathemes)


    The registered sidebar args are not passed into the widget’s view and with debug true there are notices showing up, since you have code inconsistency here :

    public function render_html($pagepath, $data)
          {
            ob_start();
            extract($data);
            $args = $data;//this line must be added to pass $args to widget view
          ...

    Please add it to update or fix it your way.
    Kind Regards.

    https://wordpress.org/plugins/woocommerce-currency-switcher/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author RealMag777

    (@realmag777)

    Hello

    Thank you, I will do it …

    Plugin Author RealMag777

    (@realmag777)

    Hello

    Just looked the code http://clip2net.com/s/3qxRuok – what code you mean exactly? Looks like you are using old versio of the plugin, now code of the widget is:

    <?php if (!defined('ABSPATH')) die('No direct access allowed'); ?>
    <?php
    
    class WOOCS_SELECTOR extends WP_Widget
    {
    
        public function __construct()
        {
            parent::__construct(__CLASS__, __('WooCommerce Currency Switcher', 'woocommerce-currency-switcher'), array(
                'classname' => __CLASS__,
                'description' => __('WooCommerce Currency Switcher by realmag777', 'woocommerce-currency-switcher')
                    )
            );
            //$this->WP_Widget(__CLASS__, __('WooCommerce Currency Switcher', 'woocommerce-currency-switcher'), $settings);
        }
    
        public function widget($args, $instance)
        {
            $args['instance'] = $instance;
            wp_enqueue_script('jquery');
            global $WOOCS;
            echo $WOOCS->render_html(WOOCS_PATH . 'views/widgets/selector.php', $args);
        }
    
        public function update($new_instance, $old_instance)
        {
            $instance = $old_instance;
            $instance['title'] = $new_instance['title'];
            $instance['show_flags'] = $new_instance['show_flags'];
            $instance['width'] = $new_instance['width'];
            $instance['flag_position'] = $new_instance['flag_position'];
            $instance['txt_type'] = $new_instance['txt_type'];
    
            return $instance;
        }
    
        public function form($instance)
        {
            $defaults = array(
                'title' => __('WooCommerce Currency Switcher', 'woocommerce-currency-switcher'),
                'show_flags' => 'true',
                'width' => '100%',
                'flag_position' => 'right',
                'txt_type' => 'code'
            );
            $instance = wp_parse_args((array) $instance, $defaults);
            $args = array();
            $args['instance'] = $instance;
            $args['widget'] = $this;
            global $WOOCS;
            echo $WOOCS->render_html(WOOCS_PATH . 'views/widgets/selector_form.php', $args);
        }
    
    }

    No , we are using the latest version.
    We altered the code in there to make it work.

    But all you really need to do is add $args = $data; to pass $args to the view of the widget /views/selector.php

    In the widget class you pass to the render_html() function the $args array that is being extracted and variables created (e.g. $before_widget) , but in the view you check for $args['before_widget'] .

    I think it goes for all widget views

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sidebar data not passed to widget View’ is closed to new replies.