Load stylesheet for home-build widget

Home Forums Calendar Products Events Calendar PRO Load stylesheet for home-build widget

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1602838
    racekatten
    Participant

    Hi,

    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!

    #1604683
    Cliff
    Member

    Hi. 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.

    #1605660
    racekatten
    Participant

    No, 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.css

    When my widget is active:
    tribe-events-list-rk-widget

    And 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.php

    #1605685
    Cliff
    Member

    Could you please send me the zip of your plugin or a gist link of your widget class?

    #1622979
    Support Droid
    Keymaster

    Hey 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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Load stylesheet for home-build widget’ is closed to new replies.