Support » Plugin: The Events Calendar Category Colors » override widgets.php

  • Resolved caspero

    (@caspero)


    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

    (@afragen)

    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

    (@caspero)

    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

    (@afragen)

    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

    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

    (@caspero)

    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

    (@afragen)

    What is the normal path of the template you are trying to override?

    Thread Starter caspero

    (@caspero)

    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

    Plugin Author Andy Fragen

    (@afragen)

    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

    (@caspero)

    Thanks! That pushed me in the right direction and it is now working.

    Plugin Author Andy Fragen

    (@afragen)

    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.