TICA_Events::POST_TYPE . '_widget', 'description' => 'TICA Upcoming Events', ] ); } protected function enqueue_scripts() { $type = TICA_Events::POST_TYPE; wp_enqueue_style( "{$type}-swiper-css", plugins_url( 'public/css/swiper.css', dirname( __FILE__ ) ) ); wp_enqueue_script( "{$type}-swiper-js", plugins_url( 'public/js/swiper.js', dirname( __FILE__ ) ), [ 'jquery' ] ); } protected function get_events() { $query = new WP_Query( [ 'post_type' => TICA_Events::POST_TYPE, 'posts_per_page' => -1, 'meta_key' => TICA_Events::POST_TYPE . '_from_date', 'orderby' => 'meta_value_datetime', 'order' => 'DESC', 'meta_query' => [ [ 'key' => TICA_Events::POST_TYPE . '_from_date', 'value' => date('Y-m-d'), 'type' => 'DATE', 'compare' => '>=' ] ], ] ); return $query->posts; } function widget( $args, $instance ) { $type = TICA_Events::POST_TYPE; $events = $this->get_events(); if ( ! $events ) { return; } $id = $name = $description = $class = $before_widget = $after_widget = $before_title = $after_title = $widget_id = $widget_name = ''; extract( $args ); $this->enqueue_scripts(); echo $before_widget, $before_title, 'Upcoming Events', $after_title; ?>