• Resolved Haim

    (@koostamas)


    Hi!

    I would like to display both dates (greg & heb) in the widget area. I have set up the plugin accordingly.
    However, it shows only the heb date as a widget.

    How may I display both dates?

    Thanks

    Tamás

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author hatul

    (@hatul)

    The plugin not supported it. You can add new widget with this option.

    
    class Bothdate_Widget extends Hebdate_Widget {
    	public function widget( $args, $instance ) {
    		echo $args['before_widget'];
    		if ( ! empty( $instance['title'] ) ) {
    			echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
    		}
    		echo date() . ' - ' . today_hebDate();
    		echo $args['after_widget'];
    	}
    }
    
    Thread Starter Haim

    (@koostamas)

    Thanks a lot, Hatul!

    Where should I put this code and how to use it in a widget area?

    Greetings

    Tamás

    Plugin Author hatul

    (@hatul)

    If you add the code to functions.php file then you have new widget.

    Thread Starter Haim

    (@koostamas)

    Thanks!

    I have put it at the end of the function.php file of the template.
    Like this:

    require_once( trailingslashit( get_template_directory() ) . ‘inc/functions/enqueue-scripts.php’ );
    require_once( trailingslashit( get_template_directory() ) . ‘inc/admin/custom.php’ );
    /* hebrew date extension */
    class Bothdate_Widget extends Hebdate_Widget {
    public function widget( $args, $instance ) {
    echo $args[‘before_widget’];
    if ( ! empty( $instance[‘title’] ) ) {
    echo $args[‘before_title’] . apply_filters( ‘widget_title’, $instance[‘title’] ). $args[‘after_title’];
    }
    echo date() . ‘ – ‘ . today_hebDate();
    echo $args[‘after_widget’];
    }
    }

    However, I do not see the new widget to add.

    I have read something about registering the widget, as well.
    Shouldn’t it be fine, as well?

    Thanks

    Tamás

    Plugin Author hatul

    (@hatul)

    OK. Add this code:

    function register_bothdate_widget() {
        register_widget( ' Bothdate_Widget' );
    }
    add_action( 'widgets_init', 'register_bothdate_widget' );
    Thread Starter Haim

    (@koostamas)

    Thanks again.
    However, it gives an error message now:

    https://photos.app.goo.gl/Z7nLqtSNuVqp51256

    ??

    What to do now?

    Greetings

    Tamás

    Plugin Author hatul

    (@hatul)

    Try the new version of the plugin. The date format in the widget shown by the settings.

    Thread Starter Haim

    (@koostamas)

    Beautiful!
    It really works now!
    For me and for everyone!
    Very nice!

    Thanks a lot!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Display both dates in widget’ is closed to new replies.