Home › Forums › Calendar Products › Events Calendar PRO › Load stylesheet for home-build widget
- This topic has 3 replies, 2 voices, and was last updated 7 years, 7 months ago by
racekatten.
-
AuthorPosts
-
August 22, 2018 at 3:51 am #1602838
racekatten
ParticipantHi,
I have made my own widget for the calendar, where I would like to load stylesheet, when the widget is activated.
But I can see that this code is now deprecated?
Tribe__Events__Template_Factory::asset_package( ‘events-css’ );
How can I replace it?
Thank you!
August 23, 2018 at 8:33 pm #1604683Cliff
MemberHi. The way to do this is via tribe_asset(), which is in /wp-content/plugins/the-events-calendar/common/src/functions/template-tags/general.php
You can see some examples of its usage within /wp-content/plugins/the-events-calendar/src/Tribe/Assets.php
And here’s something that might be a helpful starter snippet for you:
tribe_asset( tribe( 'tec.main' ), 'my-widgets-style', 'full-path-to-the-file', array(), 'wp_enqueue_scripts', array( 'groups' => array( 'events-styles' ), // Passing the group will ensure it will load with the widget 'priority' => 15, 'conditionals' => array( array( $this, 'should_enqueue_frontend' ), ), ) );Please let me know how this goes for you.
August 24, 2018 at 11:45 pm #1605660racekatten
ParticipantNo, I still cannot make it work.
I just want to load your stylesheet:
http://<domain>/wp/content/plugins/the-events-calendar/src/resources/css/tribe-events-full.min.cssWhen my widget is active:
tribe-events-list-rk-widgetAnd I’m not really sure where to place tribe_asset()
I have tried inside the class for my widget.Before I was using:
function my_loadStyle() {
if ( is_active_widget( false, false, ‘tribe-events-list-rk-widget’ ) ) {
Tribe__Events__Template_Factory::asset_package( ‘events-css’ );
}
}
add_action( ‘wp_enqueue_scripts’, ‘my_loadStyle’ );
Which I could place where ever I wanted in my functions.phpAugust 25, 2018 at 5:49 am #1605685Cliff
MemberCould you please send me the zip of your plugin or a gist link of your widget class?
September 16, 2018 at 9:35 am #1622979Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Load stylesheet for home-build widget’ is closed to new replies.
