• I am trying to add a widget for my simple calendar. When I choose the widget type I get to choose a title and a calendar. But the calendar drop down is empty.

    I am using the calendar on other pages, and it shows under calendars from the dashboard.

    I have also ensured I was on the latest version of simple calendar. I am on wordpress 5.8.3 and php 7.4.27

    Anyone have any thoughts?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I had the same issue. Its caused by WP 5.8 using block editor to manage widgets. Plugin will not load available calendars for it.
    To fix it, you can replace lines 56-62 in includes/widgets/calendar.php with

    if ( is_admin() || wp_is_json_request() ) {
    	$this->calendars = simcal_get_calendars();
    }

    Hope that helps!

    Thread Starter randrp

    (@randrp)

    Thanks for the reply.
    My files names are slightly different, and that code looks rather different than anything in the function that is at the point.
    So I think we might be looking at different code.

    My file is wp-includes/widgets/class-wp-widget-calendar.php

    But the function at the spot does seem related.

    The function at those line numbers is
    public function widget( $args, $instance ) {

    It’s description matches the goal
    * Outputs the content for the current Calendar widget instance.

    I don’t know php specifically, but I know lots of other languages. The function appears to output html. It looks to get the title from $title which is populated from $instance[‘title’].

    Since I don’t see anything using $this-calendars my best guess is that I would need to override $instance with the call to simcal_get_calendars(). But that seems odd as the instance was passed in, and instance is singular, while simcal_get_calendars implies it would return multiple calendars.

    Here is the whole function for reference…


    /**
    * Outputs the content for the current Calendar widget instance.
    *
    * @since 2.8.0
    *
    * @param array $args Display arguments including ‘before_title’, ‘after_title’,
    * ‘before_widget’, and ‘after_widget’.
    * @param array $instance The settings for the particular instance of the widget.
    */
    public function widget( $args, $instance ) {
    $title = ! empty( $instance[‘title’] ) ? $instance[‘title’] : ”;

    /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    $title = apply_filters( ‘widget_title’, $title, $instance, $this->id_base );

    echo $args[‘before_widget’];
    if ( $title ) {
    echo $args[‘before_title’] . $title . $args[‘after_title’];
    }
    if ( 0 === self::$instance ) {
    echo ‘<div id=”calendar_wrap” class=”calendar_wrap”>’;
    } else {
    echo ‘<div class=”calendar_wrap”>’;
    }
    get_calendar();
    echo ‘</div>’;
    echo $args[‘after_widget’];

    self::$instance++;
    }

    Any thoughts on why the files are named different and the code seems so different?

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Calendar drop down empty’ is closed to new replies.