-
AuthorPosts
-
November 7, 2021 at 5:15 am #1328082
Hi,
I have an enfold site with WPML with two different domains mentioned in the private section using HTTPS.
The problem is that the fonts don’t load on the english domain because enfold is trying to get the .ttf files from the french domain, which gets blocked by the browser with error: “Cross-Origin Request Blocked”
However everything else loads properly from the english domain, which shows Enfold and WPML are in sync, but it seems it’s only the .ttf fonts not sourcing from the respective domain.
When I try to regenerate the CSS files, I can confirm they both point to the french version of the fonts:
./wp-content/uploads/dynamic_avia/enfold_appwapp_en.css
./wp-content/uploads/dynamic_avia/enfold_appwapp.cssI tried manually modifying the english CSS file, but it doesn’t help, next time the CSS get regenerated, the english CSS file gets overwritten with the .ttf fonts from the french domain instead of the english domain.
I believe this is a bug in Enfold.
I bought the license just to report this issue and hopefully have it resolved.
Could you please verify and tell me if anything.
Thank you so much
- This topic was modified 3 years ago by Günter.
November 8, 2021 at 6:52 am #1328174Hey wadihcreationmw,
The second URL you posted is not working, I’m seeing some sort of ready for development message:
Yourimmigration.com
REGISTERED FOR DEVELOPMENT
This domain has been registered. If you’re interested in this domain, contact us to check availability for customer use, ownership, or other development opportunities.Best regards,
RikardNovember 8, 2021 at 7:43 pm #1328259Hi Rikard, I put the wrong tld on the second domain.
I corrected it below.
November 9, 2021 at 6:54 am #1328296Hi,
It’s not a theme problem, the resources are being blocked by the browser since they are being served from a different domain. You can check that by inspecting the page your browser. Try following this to see if it helps: https://kriesi.at/documentation/enfold/icon/#icons-are-showing-as-rectangular-boxes-
Best regards,
RikardNovember 10, 2021 at 5:10 am #1328414This reply has been marked as private.November 10, 2021 at 1:46 pm #1328494Hi,
A few lines of .htaccess code should not slow down your server, how did you test the results?
I’m not sure how you have configured WPML, but I’m guessing that your two sites are using the same WordPress installation? That means that the installation files will only be present in one place. If you are looking for a different solution than using .htaccess, then please try uploading the font in question manually to your other site, and import it with CSS.
Best regards,
RikardNovember 10, 2021 at 2:50 pm #1328515Hi,
WPML is configured properly, and Enfold is able to use the respective resources for the respective domain everywhere except for the .ttf fonts.As I explained how the behavior should be, the CSS files should be different for each language, e.g.
FR: http://www.frenchdomain.com/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-light.ttf
EN: http://www.englishdomain.com/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-light.ttf
ES: http://www.spanishdomain.com/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-light.ttfAnd so on and so forth. Your code right now generates the same CSS code for all langauges, e.g.:
FR: http://www.frenchdomain.com/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-light.ttf
EN: http://www.frenchdomain.com/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-light.ttf
ES: http://www.frenchdomain.com/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-light.ttfDo you understand the issue better now?
You may escalate this bug to the appropriate decision makers please, hoping for it to be resolved before the expiration of my license, so I can update accordingly, and everybody else can update and have this resolved at the source.
If I need to contact the authors directly, could you guide me on how I can do that?
- This reply was modified 3 years ago by wadihcreationmw.
November 12, 2021 at 9:42 am #1328763Hi,
Thank you for the info.
Did you create different directories for each language or just different domains? If there is only one directory for all languages, then they will share the same upload directory using the default path or the WordPress Address (URL) as base URL.
For installation with different directories, we may need to adjust the origin_url of the fonts in the enfold/framework/php/font-management/class-avia-type-fonts.php file around line 998.
$url = trailingslashit( $font_info[‘origin_url’] . $font_info[‘folder’] ) . $file;
Best regards,
IsmaelNovember 12, 2021 at 6:36 pm #1328813Hi,
Please refer to my previous response. Please see that CSS file on the English side which is generated by Enfold:
As you see inside, the TTF fonts are sourcing from the wrong domain (votreimmigration.ca – which is the FR version):
@font-face{font-family:'poppins';src:url('https://www.votreimmigration.ca/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-black.ttf') format('truetype');
It should be sourcing from the english domain, e.g. yourimmigration.ca.
Compare these two ENFOLD generated CSS:
French CSS:
https://www.votreimmigration.ca/wp-content/uploads/dynamic_avia/avia-merged-styles-973b1958acabc34491fb515bf8883ba0—617c6b28df629.css
English CSS: https://www.yourimmigration.ca/wp-content/uploads/dynamic_avia/avia-merged-styles-4ebd15befa0f877ffcc392d15eb52ff8—617c9f02baac0.cssWhy is the english CSS using FR domains inside? Do you see what I mean? This is the bug we need to fix.
Thank you so much
November 15, 2021 at 2:19 am #1328994Hi,
Thank you for the update.
We would like to know if you actually created different directories for each language. Can we access the site and check the WPML settings (WPML > Languages > Language URL format)? We would like to check if there is a dedicated directory for each language or just different domains. If a different domain is set for each language, then it means that they share the same directory or the same WordPress installation. This will also mean that all languages share the same upload directory, which is where the avia_fonts folder is located and where the custom fonts are placed.
The easiest way is to configure the CORS policy in the .htaccess as suggested above.
Best regards,
IsmaelNovember 15, 2021 at 4:52 pm #1329115Hi,
I don’t think you are understanding the issue. Can you please escalate to somebody with higher level of skill, the authors directly if possible? Or tell me where I can do a complaint?
The question about WPML you asked me you can already find the answer yourself by visiting the site. You will see that it is not a folder setup, but a domain setup. It is perfectly configured, everything works fine, EXCEPT the CSS generation from Enfold, using the wrong domain on the English CSS.
I tried to explain it 2 times already, I gave the links of the french CSS and the english CSS generated by enfold, and I demonstrated how the english CSS generated by enfold is wrong.
Will you please raise this bug to your developers? They will find the line in the source code causing this issue and be able to resolve it.
There should be somewhere in the Enfold source code that has to be repaired so that the english CSS starts using the english domain instead of the french domain, without the need of any .htaccess meddling (which would not be a solution, but just a patchwork).
November 15, 2021 at 6:54 pm #1329125Hi,
Sorry for the problems you have.
My knowledge about setting up WPML sites is not so good. It seem to be a problem in setup of WPML and Enfold.
If I understand it correctly you have a french domain and a seperate english domain.
Do you upload the fonts to french domain only or also to the english domain?
Second thing to check would be if you disable css file merging, save theme options (on both sites) and check the files:
../wp-content/uploads/dynamic_avia/enfold_child.css
in both domains. At the beginning you should find something like:
@font-face { font-family: 'lato'; src: url('https://localhost/wp56/wp-content/uploads/avia_fonts/type_fonts/lato/lato-black.ttf') format('truetype'); font-style: normal; font-weight: 900; font-display: auto; } @font-face { font-family: 'lato'; src: url('https://localhost/wp56/wp-content/uploads/avia_fonts/type_fonts/lato/lato-blackitalic.ttf') format('truetype'); font-style: italic; font-weight: 900; font-display: auto; } .....
It would be interesting to know the value of src: ….
If you have a staging site – can you give us WP admin access and FTP access so I can also see your backend.
It might be necessary that we get in contact with WPML support also to find a solution. So it might be necessary to forward your credentials to them also.Added 16.11.:
=============Could you please create a ticket at WPML support with reference to this thread and that they should pass it to head of compatibility team so we can find a solution.
If you give us the link to this ticket we can also get in touch with him additionally.
Best regards,
Günter- This reply was modified 3 years ago by Günter.
November 16, 2021 at 11:25 pm #1329269Hi Günter,
Thank you so much for your technical answer, finally something I can work with. I am a programmer myself, so we will speak the same language.
I had already tried disabling and enabling the cache, the minifying, I even tried modifying manually the CSS file, but when they get overwritten by Enfold, it gets overwritten with the wrong URL’s again.
To answer your question, the ttf files already works automatically with both the english and french domains, it’s already handled successfully by default.
The problem will come down to the line of code that calculates the resulting URL in your software.
I have a good relation with WPM.L, as a customer, and the ways to retrieve the proper “current” URL has changed over the years, but it’s been stable lately. I know that because I developed some custom WPM.L code before and had to change that part of the code.
I think however you guys should be experts on that plugin though, and not be an afterthought. Your clients shouldn’t have to worry about that. This is the kind of things that should be between Enfold and the authors of WPM.L.
So that I can ask WPM.L the right targeted question, could you tell me which piece of code calculates the URL in Enfold right now? It probably it uses one of their helper function, which might have become obsolete since.
Pleasure working with you on that, and looking forward to resolve that permanently. I know many Enfold people will be happy, most of them haven’t taken the time to bring it up, so I’m doing it on everyone’s behalf.
By the way is there a way we can continue this thread by email? When I write the word WPM.L twice in the same message, the display of your support site eats up everything in between those two strings. There’s a bug in the display logic of kriesi.at support forum with the word WPM.L, probably a regexp issue.
Wadih
November 17, 2021 at 1:19 pm #1329341Hi,
Currently we store the absolute URL to the ttf files in database when the font is uploaded and reuse this when we create the enfold.css file.
I think the best solution would be to use relative urls in the enfold.css file for the fonts instead of absolute.
In a first step I would suggest to activate this with an add_theme_support( … ).What I would need to do is to add the relative url to our database structure.
Is it possible for you to delete the fonts and upload them again – this would make it easier for me because I do not need to write an extra update routine to manipulate database content.
Best regards,
GünterNovember 17, 2021 at 5:07 pm #1329365Hi Günter,
Sure. I wouldn’t mind updating the record in phpmyadmin. I could give you SCP access if you like through an SSH key to the site. Or I can do any changes or checks on your behalf. I am pretty flexible.
Instead of re-uploading the font which I’m not sure of a clean way of doing that, could you tell me which hard-coded value I would change in the db? That would be easiest for me. Unless it’s a serialized value?
I will keep a backup of the site so I will be able to easily revert back if anything.
Thank you so much
November 18, 2021 at 3:57 pm #1329534Hi,
uploading the font: Theme Options -> Import/Export -> Custom Font Manager
You can upload new fonts or delete already uploaded fonts (and reupload them).
—-
But I added a solution that removes the absolute URL part when creating the file dynamic_avia/enfold(_child).css on the fly.
Please update enfold\framework\php\font-management\class-avia-type-fonts.php with the content of
Around line 988ff you find theme support ‘custom_uploaded_fonts_relative_url’ (and filter ‘avf_custom_uploaded_fonts_url’).
Adding theme support will modify the output in dynamic_avia/enfold(_child).css to e.g.:
@font-face { font-family: 'lato'; src: url('/wp56/wp-content/uploads/avia_fonts/type_fonts/lato/lato-black.ttf') format('truetype'); font-style: normal; font-weight: 900; font-display: auto; } @font-face { font-family: 'lato'; src: url('/wp56/wp-content/uploads/avia_fonts/type_fonts/lato/lato-blackitalic.ttf') format('truetype'); font-style: italic; font-weight: 900; font-display: auto; }
If WPML copies this file (or the merged files) to the other domain and the ttf files are in the same folder location there it should work.
Best regards,
GünterNovember 18, 2021 at 7:13 pm #1329564I’ve tried reuploading the font on the English side through Theme Options -> Import/Export -> Custom Font Manager , but it just flipped the problem on the other side, e.g. now both English and French CSS was loading the ttf from the same english domain yourimmigration.ca. It fixed the english side but broke the french side. So I restored the site back to what it was before that step.
Yes the files in the media library are accessible equally under all my different domains including ttf’s from my understanding, that’s the default from what I see.
So I before I can try your fix on class-avia-type-fonts.php as-is, I updated to 4.8.7.1 because I was still on v. 4.7.6.4 .
Now I replaced the file
class-avia-type-fonts.php
with your on github. What should I do next? Nothing changed yet on the english side. I tried regenerating the files, but no change. How do I activate the condition for your new code path?November 19, 2021 at 9:23 am #1329634Hi,
Sorry for not mentioning this:
To functions.php add:
add_theme_support( 'custom_uploaded_fonts_relative_url' );
This should activate the condition.
Do not forget to clear cache (if you use a cache plugin).
Edit:
And also save theme options please.
Best regards,
GünterNovember 19, 2021 at 4:31 pm #1329708Hi Günter,
I modified the following file in the official theme:
./themes/enfold/framework/php/font-management/class-avia-type-fonts.php
And added the line in functions.php child theme:
add_theme_support( 'custom_uploaded_fonts_relative_url' );
Cleared the enfold cache because I don’t use any other type of cache (by saving settings and toggling css fusioning on and off)
Unfortunately, it’s still calculating the URL wrong for the ttf’s.
Please give me your SSH public key, and I will add it for access to the site to inspect the code.
November 21, 2021 at 10:53 am #1329834November 21, 2021 at 4:08 pm #1329846Hi Gunter,
please see privateNovember 22, 2021 at 1:23 pm #1329948Hi,
I think I found the problem. When creating the merged files we change relative urls in enfold.css to absolute urls.
I added to config-templatebuilder\avia-template-builder\php\class-asset-manager.php line 677:
/** * e.g. WPML needs relative paths when using directories for languages * * @since 4.8.7.2 */ if( current_theme_supports( 'custom_uploaded_fonts_relative_url' ) ) { return $content; }
Now after merging files you find in avia-merged-styles-974f232210bc9596190f218f629b8b53—619b7b9d06faf.css the relative urls:
.... @font-face{ font-family:'poppins'; src:url('/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-black.ttf') format('truetype'); font-style:normal; font-weight:900; ont-display:auto } @font-face{ font-family:'poppins'; src:url('/wp-content/uploads/avia_fonts/type_fonts/poppins/poppins-blackitalic.ttf') format('truetype'); font-style:italic; font-weight:900; font-display:auto } ........
Can you check with the other language please.
Best regards,
GünterNovember 22, 2021 at 4:27 pm #1329993Hi Günter,
Thank you so much, it works great in both french and english now.
The fix is already applied on our site, but when you officially release 4.8.7.2 to the public, will I need to manually do anything, since we have the early fix?
Thank you so much
November 22, 2021 at 5:49 pm #1330020Hi,
Thank you for the feedback – and glad we found the solution.
No, I will merge it into 4.8.7.2. Only keep
add_theme_support( 'custom_uploaded_fonts_relative_url' );
Enjoy the theme and have a nice day.
Let us know, if you need further assistance – simply create a new topic.
Best regards,
GünterAdded:
Keep an eye on the changelog in case we might add a theme option to replace the add_theme_support in a future release.
November 22, 2021 at 5:59 pm #1330025Thanks Günter
Wish you health and safety with the recent COVID rise in Austria.
Tell me if anything.
All the best
WadihNovember 23, 2021 at 4:33 pm #1330153 -
AuthorPosts
- You must be logged in to reply to this topic.