Filter "tribe_events_community_stylesheet_url" broken in latest version

Home Forums Calendar Products Community Events Filter "tribe_events_community_stylesheet_url" broken in latest version

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1210964
    Jonas
    Participant

    Hi,

    In the latest version of the Events Calendar Community Events plugin it’s not possible anymore to use the filter “tribe_events_community_stylesheet_url” to override the stylesheet URL. This is because the call of the register_resources() method in src/Tribe/Main.php now happens in the class constructor. This leads to the method and therewith the filter being called before a plugin or theme even has a chance to register a filter. It seems this was changed in one of the recent versions (after 4.2.5). Before the change, the register_resources() method was called in the maybeLoadAssets() method, that is properly called via the “wp” action hook and therewith allowed using the filter in the theme or a plugin to override the style sheet URL.

    Regards
    Jonas

    #1211180
    Nico
    Member

    Hi there Jonas,

    Thanks for reaching out to us to report this!

    I must admit the issue you expose here is a bit out of my technical knowledge. I’ve shared this with the dev team to get an opinion from their side.

    I will follow-up when I have something to share, please note this might take a bit more that usual as most of the team is out until next week.

    Best,
    Nico

    #1218280
    Nico
    Member

    Jonas, thanks for the patience here 🙂

    I’ve reviewed the case with one of our devs. The point you expose is valid, but this doesn’t mean you cannot modify from a simple plugin:

    <?php
    /**
    * Plugin name: Local customizations
    */
    add_filter( 'tribe_events_community_stylesheet_url', function( $url ) {
    return add_query_arg( 'modified', 'slightly', $url );
    } );

    Can you please let us know if there’s other way of implementing customizations you are trying to use? Maybe we can help out!

    Best,
    Nico

    #1218905
    Jonas
    Participant

    Hi Nico,

    thanks for getting back to me. That’s exactly the point. The code snippet you posted does not work in the latest version of the Community Events plugin. It works fine with version 4.2.5.

    I just tested it again on a clean WordPress installation (4.7.1) with Twenty Fifteen theme and only Events Calendar, Events Calendar Pro and Community Events as well as the test plugin with your code above activated. As soon as the test plugin is activated, the community events CSS is not loaded anymore. Tested with both PHP 5.5.27 and PHP 7.0.5.

    Regards
    Jonas

    • This reply was modified 7 years, 3 months ago by Jonas. Reason: Add PHP versions
    #1219113
    Nico
    Member

    Thanks for following up Jonas! I’ve tried the code and it’s not working for me also, sorry for that. It seems it was working for the dev when he tried it out. In any case, there’s another way of doing this:

    add_filter( 'tribe_asset_pre_register', function( $asset ) {
    if ( in_array( $asset->file, array(
    'tribe-events-community.css',
    'tribe-events-community.min.css'
    ) ) ) {
    $asset->url = 'http://some.url/some-stylesheet.css';
    }

    return $asset;
    } );

    Give that a try and let me know if it works for you,
    Best,
    Nico

    #1230638
    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 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Filter "tribe_events_community_stylesheet_url" broken in latest version’ is closed to new replies.