I’m trying to build out a plugin from a tutorial that will access my google calendar. So far I’m stuck on just trying to register the widget. Here is a link to the tutorial:
https://code.tutsplus.com/tutorials/how-to-create-a-google-calendar-plugin-for-wordpress–cms-32710
I keep running into the problem of the ‘add_action’ function at the bottom of the script. I keep getting an error of ‘syntax error, unexpected ‘add_action’. I’m not even sure I’m building this correctly.
<?php
/**
* Plugin Name: My gCal Plugin
* Description: Displays upcoming events from Google calender
* version: 1.0.0
*
*
*/
class My_gCal_Widget extends WP_Widget
{
public function __construct()
{
parent::__construct(
'my_gcal_widget',
'My_gCal_Widget',
array(
'classname' => 'my-gcal-widget',
'description' => 'Shows events from a calendar'
)
);
}
public function widget($args, $instance)
{
}
}
add_action('widgets_init', function () {
register_widget('My_gCal_Widget');
});