Enqueue styles in class-fl-theme.php

Hi there,

We’re working with the plugin WP Offload S3, which allows us to load CSS, JS etc from an Amazon AWS S3 server. The plugin syncs files with S3, and then it also replaces the output URLs on the website to point to Amazon rather than the website URL. In order for this to work, the assets URLs must have been added using WordPress wp_enqueue_style and wp_enqueue_script functions.

We ran into an issue with BB theme CSS files, as they are not being included using the enqueue functions. We managed to get it to work by modifying the class-fl-theme.php file (in the BB core theme) to use wp_enqueue_style instead of echo. This is in the function head() around line 337.

I was wondering if you would consider making this change, or if there is any concerns for going down this route.

Many thanks again for a great plugin, and I look forward to your response.

Nick

Hey Nick,

I’ve already assigned another member of the team to assist you with your concern. :slight_smile:

Ben

Hi Ben. That’s great, thanks!

Hey Nick,

We originally did it that way because we ran into some edge case conflicts where third party plugins were overriding the theme’s styles. In hindsight, we should have found a way to make wp_enqueue_style style work, but I’m hesitant to change that now in the off chance that it messes up someone’s site.

What if we add a filter to the FLCustomizer::css_url method so you can point that to your S3 bucket? That would look like this…

return apply_filters( 'fl_theme_css_url', $css_url );

Let me know what you think!

Justin

Hi Justin,

Thanks so much for your reply, and I completely understand the predicament.

The filter might work, although the amazon URL does change for caching reasons, which is handled by the S3 plugin. It re-syncs the files and then re-updates the asset links. If the assets is not queued up using the wp_enqueue_<css/js> method the URL will not update when the AWS cache changes.

I think that would be the case anyway. Let me know if you have any further insights, and thanks again so much for your reply.

Nick