• Resolved rudolfl

    (@rudolfl)


    Hi all,

    My WP_CONTENT_URL (and WP_CONTENT_DIR) is not standard (don’t ask why, I inherited it like that).

    From Autoptimizer FAQ:
    —-
    Does this work with non-default WP_CONTENT_URL ?

    No, Autoptimize does not support a non-default WP_CONTENT_URL out-of-the-box, but this can be accomplished with a couple of lines of code hooking into Autoptimize’s API.
    —-

    Can someone share those “couple of lines”?
    Thanks,
    Rudolf

    • This topic was modified 3 years, 10 months ago by rudolfl.
    • This topic was modified 3 years, 10 months ago by rudolfl.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    Let’s take a step back; before you disabled AO was it aggregating/ minfifying CSS/ JS? Or was the only problem with the fonts?

    Thread Starter rudolfl

    (@rudolfl)

    Hi,

    Correct — Autoptimize was working as intended, combining CSS and JS, but font files were not served through CDN.
    I did try to add the snippet suggested. Cleared all caches, but result was same.

    I do have few more sites running off same server in pretty much same plugins configuration. They are working fine. So, I started to look at what may be different between sites. There are only two things that really come to mind — different themes and site in question is using non-standard WP_CONTENT_URL. Your FAQ suggests this may affect Autoptimize, so, I think, it is worth trying to fix this first.

    Thank you for your help
    Rudolf

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    the wp-content thing is unlikely the issue, as JS & CSS were aggregated/ minified OK .. can you share the URL of the site with the font-CDN-issue?

    Thread Starter rudolfl

    (@rudolfl)

    Hi,

    I switched site back to using Autoptimize.

    https://www.hatsfromoz.com.au

    As you can see font files that are loaded through “automptimised” files are not CDNed.

    Those, not loaded through autoptimize, are caught by bunnyCDN plugin and served through CDN.

    Also, confirming following code is added to the site:
    add_filter( ‘autoptimize_filter_css_fonts_cdn’, ‘__return_true’ );

    Rudolf

    • This reply was modified 3 years, 10 months ago by rudolfl.
    Thread Starter rudolfl

    (@rudolfl)

    OK,

    I found the problem, but have no idea at the moment how to fix it.

    For some reason, original site developers did a very strange thing — WordPress files are placed into directory /wordpress, while rest of the site is in directory /content. And here lies the problem!
    /public_html
    – /wordpress
    — /wp-admin
    – /content

    Wordpress functions to get site url are correctly getting https://www.hatsfromoz.com.au/wordpress
    And this is what Autoptimizer relies on to set AUTOPTIMIZE_WP_SITE_URL constant
    But, in my case, this constant should be set to “https://www.hatsfromoz.com.au”

    I temporarily “fixed” the problem by setting

    define( ‘AUTOPTIMIZE_WP_SITE_URL’, “https://www.hatsfromoz.com.au” )

    Is there a hook I can call before setup() function is run to set those constant in there?

    Rudolf

    • This reply was modified 3 years, 10 months ago by rudolfl.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I temporarily “fixed” the problem by setting

    define( ‘AUTOPTIMIZE_WP_SITE_URL’, “https://www.hatsfromoz.com.au” )

    as far as I’m concerned that is the fix; AO specifically checks if the constant is set to allow “others” to set it differently, just like you’re doing ??

    Thread Starter rudolfl

    (@rudolfl)

    Thanks,

    I thought so too.
    Could not do it in the theme.
    Had to do it in plugin by hooking into ‘plugins_loaded’ at priority < 10 as this hook is used by Autoptimized at default priority and this action is aclled before theme is loaded.

    Thank you again for looking into it.

    Rudolf

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    ah, but typically constant are set in wp-config.php no? anyway, if you have it working another way why not ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Non-Standard WP_CONTENT_URL’ is closed to new replies.