-
AuthorPosts
-
March 27, 2019 at 2:26 pm #1083618
I install my sites using bedrock from roots.io and have a problem with the theme when the assets are being built.
Here is an example of error from the asset manager class:
Warning: file_get_contents(/var/www/site.com/public/wp/http://site.com/app/themes/enfold/css/base.css): failed to open stream: No such file or directory in /var/www/site.com/public/app/themes/enfold/config-templatebuilder/avia-template-builder/php/asset-manager.class.php on line 328
when running
$this->set_path($enqueued->registered[$file]->src)
,site_url()
is being used to find the url in the asset file, however the site_url contains /wp when all the asset files live under the app folder. In addition to this, if I change the code to use thehome_url()
the path will be correct, however, the file_get_contents is still incorrect as theABSPATH
for wp is set to /wp.Every time I update enfold I have to manually make this change again and create a new minor version on my repo which sucks. :(
Is there a possibility that you could either give me a filter to work with to write my own custom replacement method for the $data array on line 264 / the file get contents path on line 332?
- This topic was modified 5 years, 8 months ago by Vince.
March 31, 2019 at 8:23 pm #1085162Hey Vince,
Sorry for the late reply, I am forwarding your request to the dev team. I believe they are working on an issue with the paths now, but I couldn’t say if this will help you in the future, so I’ll ask them to comment.
Thank you for your patience.Best regards,
MikeApril 1, 2019 at 11:50 am #1085439Hi!
I added filter avf_asset_mgr_get_file_data.
Please check https://github.com/KriesiMedia/enfold-library/blob/master/temp_fixes/Enfold_4_5_5/Filter_asset_manager/asset-manager.class.php.
Does that help you?
If you need more parameters let us know.
Is In the pull requests for the next update.Needs 4.5.5
Regards,
GünterApril 2, 2019 at 11:48 am #1086030hey Günter the one you posted here in this thread : https://kriesi.at/support/topic/again-one-problem-with-merged-css/
has worked perfectly – but the new on github does not work in that way – again the merged urls are wrongthis one you posted me on that topic before works:
https://pastebin.com/q8eXS3aRApril 3, 2019 at 11:52 am #1086478Hi,
@Vince
I added 2 more filters: avf_asset_mgr_get_file_data and avf_compress_file_content_path
These are 2 different things.
The filters in this topic refer to the files to be compressed – this actually should work fine but Vince asked for filters to build his own replacements.
The other replacements are done for the dynamic css file (links to images).
Best regards,
GünterApril 3, 2019 at 12:07 pm #1086482You guys are magic!
Thank you so much. I will run through all of this at the weekend and send feedback.
I did run into a problem the other day with my hook where it was throwing errors with google captcha CSS :( – will investigate.April 3, 2019 at 4:51 pm #1086615@Günter : I’m already aware of this, but should we now handle two versions of a temp fix? Would a file that has the fix in it for both purposes be better?
April 3, 2019 at 6:12 pm #1086642Hi,
Kriesi is planning a release probably next week – and for testing purpose I wanted to keep this seperate. If I get the OK and Kriesi does not make a release at beginning of next week I will merge the 2 fixes into 1.
IMO this fix here is not really needed by many users.
Best regards,
GünterJuly 4, 2019 at 3:05 am #1115614Hi Guys,
I’ve bought the Enfold theme (4.5.7) today. And if I use the theme child (with Bedrock too) the errors (reported above) appear. Can you fix that? I need to use the theme child for customize some things.
Tks a lot.
July 4, 2019 at 3:21 am #1115615Just an update.
It occurs with the main theme too.
July 4, 2019 at 11:00 am #1115708Hi,
Thank you for using Enfold.
The filter avf_asset_mgr_get_file_data is included in 4.5.7 (enfold\config-templatebuilder\avia-template-builder\php\asset-manager.class.php around line 278).
I do not know what bedrock is exactly doing – and we do not support this plugin. So this is customization and out of scope of support.
In case you need an additional filter you can let us know and we can check if it is possible to add to core.You can contact the plugin author and ask for assistance there – or hire a freelancer.
Best regards,
GünterJuly 8, 2019 at 1:31 am #1116523Hi Günter,
First of all, thanks for your response.
And just one question, how I use this filter? Do I need to change it on my functions.php (in the child theme)? Or I need to change in the asset-manager.class.php file directly?
Tks.
July 8, 2019 at 11:09 am #1116619Hi,
You can (should) us filters in the functions.php of your child theme – than you need not think about when theme updates of the parent theme are coming.
Best regards,
GünterJuly 8, 2019 at 2:17 pm #1116685Hi Günter,
Can you post an example please? I think that it can be useful for other people that are using this wonderful theme with bedrock.
Thanks a lot,
Kan
July 8, 2019 at 4:25 pm #1116713Hi,
I added the frame how to add the filter to functions.php and an dummy example:
You have to check with bedrock what exactly needs to be changed.
Best regards,
GünterJuly 9, 2019 at 1:58 pm #1117058Hi Günter,
Thanks a lot. It worked smoothly.
I’ll put the code below for future reference:
// functions.php /** * Allows to alter $data content like: * - path * - url * * @since 4.5.6 * @param array $data * @param int $enqueued_to_do_index $enqueued->to_do index * @param string $file_type 'js' | 'css' * @param string $file_group_name 'avia-head-scripts' | 'avia-footer-scripts' | 'avia-merged-styles' * @param WP_Scripts $enqueued * @param array $conditions */ function custom_asset_mgr_get_file_data( array $data, $enqueued_to_do_index, $file_type, $file_group_name, WP_Scripts $enqueued, array $conditions ) { /** * This is only an example how to alter the path to a file. * Make sure to add the correct path otherwise merging will fail */ $file = $enqueued->to_do[ $enqueued_to_do_index ]; $key = $file . '-' . $file_type; if( 'avia-compat-js' == $key ) { $new_path = str_replace(HOME_URL, '', $data['remove'][ $key ]['path']); // enter your changed path here !!!! $data['remove'][ $key ]['path'] = $new_path; } /** * ****************** End of example *********************** */ return $data; } add_filter( 'avf_asset_mgr_get_file_data', 'custom_asset_mgr_get_file_data', 10, 6 );
-
AuthorPosts
- You must be logged in to reply to this topic.