Title: override widgets.php
Last modified: April 18, 2019

---

# override widgets.php

 *  Resolved [caspero](https://wordpress.org/support/users/caspero/)
 * (@caspero)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/)
 * First of all, Thanks for adding colors to our events.
 * I made a child theme where the Widget of the Events Calender is changed, so it
   is not using H4 anymore, but just a P tag. I then realized that the colors where
   gone and found out i might need to override something in your module.
 * I found the Widgets.php file where you make the CSS and have copied it over to
   a folder in /child-theme/teccc/widgets.php and tried to save my colors, but it
   seems not to affect anything.
 * Could you help me in the right direction ?

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11444919)
 * You will need to look at the original widgets.php file and ensure that all the
   relevant CSS classes are present in the selectors.
 * Obviously CSS is selector dependent and significantly changing the selectors 
   will cause the CSS not to work.
 *  Thread Starter [caspero](https://wordpress.org/support/users/caspero/)
 * (@caspero)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11445128)
 * I have tried to edit the original widgets.php and it shows my changes, after 
   I have hit “save changes” in the “Category Colors Settings”.
 * I reverted to the original widgets.php, hitted “save changes” again and it looks
   like before. Then I made a copy of it and moved it to /child-theme/teccc/widgets.
   php. Then I changed it, like I did before. and then again hitting “save changes”…
   And nothing changed.
 * The thing is, im not sure if it should be placed in root of of the teccc folder
   of my child theme. I have also tried with teccc/src/Category_Colors/ but still
   didn’t seems to work.
 *  Plugin Author [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11445228)
 * I believe it needs to be placed in the same folder structure inside of the `/
   child-theme/tribe-events/` folder.
 * [https://github.com/afragen/the-events-calendar-category-colors/wiki/Setting-up-template-overrides](https://github.com/afragen/the-events-calendar-category-colors/wiki/Setting-up-template-overrides)
 * Please remember, this is for overriding templates of this plugin. Any template
   overrides of The Events Calendar need to be done according to their directions.
 *  Thread Starter [caspero](https://wordpress.org/support/users/caspero/)
 * (@caspero)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11445295)
 * ah yes, sorry. I did put it in
    /child-theme/tribe-events/teccc/Widgets.php
 * Now i have also tried a few other solutions, without much luck so far sadly.
 * /child-theme/tribe-events/teccc/Widgets.php
    /child-theme/tribe-events/teccc/
   src/Category_Colors/Widgets.php /child-theme/tribe-events/teccc/Category_Colors/
   Widgets.php
 * That was the 3 options i have tested wihtout much luck so far
 *  Plugin Author [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11445301)
 * What is the normal path of the template you are trying to override?
 *  Thread Starter [caspero](https://wordpress.org/support/users/caspero/)
 * (@caspero)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11445307)
 * This is the file i want to override, if possible. I dont Think its a template
   but more like a class ?
 * [https://github.com/afragen/the-events-calendar-category-colors/blob/develop/src/Category_Colors/Widgets.php](https://github.com/afragen/the-events-calendar-category-colors/blob/develop/src/Category_Colors/Widgets.php)
 *  Plugin Author [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11445367)
 * OK so you want to override the built in `Widgets.php` class.
 * To do that you will need to create a new class. The new class would likely be
   something like the following. You could add the new class to your child theme
   and remember to load the class in your `functions.php`.
 *     ```
       <?php
   
       class My_Widgets {
   
       	public static function add_widget_link_css( $slug ) {
       		$css = array();
   
       		$css[] = '';
       		$css   = implode( "\n", $css );
       		echo $css;
       	}
   
       	public static function add_widget_background_css( $slug ) {
       		$css = array();
   
       		$css[] = '';
       		$css   = implode( "\n", $css );
       		echo $css;
       	}
       }
       ```
   
 * You would also need to create a temple override of `category.css.php`. The lines
   in `category.css.php` that reference `<?php Widgets:: ... ?>` would need to be
   changed to reference `<?php \My_Widgets:: ... ?>`
 * The template override would be located in `<child-theme>/tribe-events/teccc/category.
   css.php`
 *  Thread Starter [caspero](https://wordpress.org/support/users/caspero/)
 * (@caspero)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11446243)
 * Thanks! That pushed me in the right direction and it is now working.
 *  Plugin Author [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11447026)
 * Excellent! If you have the time could you leave a review? Thnanks.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘override widgets.php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/the-events-calendar-category-colors_52b1d1.
   svg)
 * [The Events Calendar: Category Colors](https://wordpress.org/plugins/the-events-calendar-category-colors/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar-category-colors/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar-category-colors/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar-category-colors/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar-category-colors/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar-category-colors/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/override-widgets-php/#post-11447026)
 * Status: resolved