I cannot figure out how to make changes to the Calendar widget without making said changes to the core plugin files, which will of course be overwritten when the plugin is updated.
In espresso-calendar.php – how do I modify the Espresso_Calendar_Widget class? I have tried copying/pasting some code into my custom_functions.php file add_action('widgets_init', 'espresso_calendar_widget_init');function espresso_calendar_widget_init() {
register_widget('Espresso_Calendar_Widget'); // registers our widget
}class Espresso_Calendar_Widget extends WP_Widget { // etc code.
I change the names of things where necessary to avoid “You cannot redeclare X funciton/class” errors, but still I can’t get it to create a new custom widget without other errors. When I go to the widgets page with WP_DEBUG turned on, I get the following errors:
Warning: Missing argument 2 for WP_Widget::__construct(), called in /server-path/www.sparkexperience.com/web/content/projects/jfe/wp-includes/widgets.php on line 324 and defined in /server-path/www.sparkexperience.com/web/content/projects/jfe/wp-includes/widgets.php on line 93 Notice: Undefined variable: name in /server-path/www.sparkexperience.com/web/content/projects/jfe/wp-includes/widgets.php on line 95
In addition, a blank draggable widget appears on the Widgets page.
Any ideas on how to edit the Calendar widget? Really what I’m after is using my own espresso-calendar-widget.php and removing the if (!is_page($calendar_page)) conditional. I have successfully made these, but I just can’t figure out how to make them in the custom_functions.php file.
In order to copy a function into the custom_functions.php file so it will override an existing function, the function has to be pluggable. This means the function will be wrapped in an if (!function_exists('function_name))
In the case of the calendar widget, the main calendar widget function isn’t pluggable. What you could do as a work around would be to create a new plugin using your modified code, and prefix the function names so this new plugin doesn’t conflict with the existing one.
I noticed it wasn’t pluggable, which is why I’m having problems. Like I said, I tried making my own functions by changing the names (prefixing) but it didn’t work. It seemed like there was just something else that needed to be prefixed that I couldn’t find.
Viewing 2 reply threads
The support post ‘Custom functions for Calendar plugin?’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.