• Resolved brandonpeatasher

    (@brandonpeatasher)


    Noticed a 404 error on my site. The culprit is a style call with the handle font-awesome-svg-styles that lives at /wp-content/uploads/font-awesome/v6.7.2/css/svg-with-js.css.

    This file doesn’t exist and is generating the 404. If I deactivate the FA plugin, the style call and the error disappear.

    Not sure why the plugin would be looking in the uploads folder for FA assets?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator Support Moderator

    (@moderator)

    Plugin Author mlwilkerson

    (@mlwilkerson)

    @brandonpeatasher That stylesheet is required for styling the embedded SVGs, which is how the new icon chooser adds them to the page in the block editor. The stylesheet is fetched on the back end (by your WordPress server) when you activate the plugin, or any time you save changes.

    It should also fetch it when upgrading the plugin. I’ll make a quick fix for that.

    Thread Starter brandonpeatasher

    (@brandonpeatasher)

    @mlwilkerson I don’t use the block editor so I don’t believe I’ll need that. It would be ideal if this tied into some of the global Gutenberg flags so it would only be enqueued conditionally, but I’m not sure if that’s really practical on your end. I can implement on ours easily enough. Thanks!

    Plugin Author mlwilkerson

    (@mlwilkerson)

    Ok, could you tell me if this anomaly had any other noticeable effect on your site, other than showing a 404 error in the browser console when trying to fetch that stylesheet?

    Thread Starter brandonpeatasher

    (@brandonpeatasher)

    @mlwilkerson Not that I could see!

    Plugin Author mlwilkerson

    (@mlwilkerson)

    @brandonpeatasher It does appear that this stylesheet is only being enqueued on the enqueue_block_assets hook, which fires “after enqueuing block assets for both editor and front-end.”

    So the intent was to only enqueue that stylesheet when blocks are in use. I’d infer, then, that this hook is still firing on your site, even though you don’t use the block editor.

    Greetings,

    I believe this may not be the ideal solution, however, here I resolved (temporary) the 404 error by adding the following directive to the .htaccess file:

    # FIX FONT-AWESOME 404 ERROR
    redirect 301 /wp-content/uploads/font-awesome/v6.7.2/css/svg-with-js.css https://use.fontawesome.com/releases/v6.7.2/css/svg-with-js.css

    I hope this helps.

    Peace to all!

    • This reply was modified 2 weeks, 2 days ago by dotjunior.
    • This reply was modified 2 weeks, 2 days ago by dotjunior.
    Plugin Author mlwilkerson

    (@mlwilkerson)

    Regarding the workaround proposed by @dotjunior :

    This will have the effect of causing the stylesheet to be loaded on the front end from the Font Awesome CDN. One of the design goals of this release is to enable the use case where front end page loads do not use the Font Awesome CDN.

    This stylesheet will be automatically fetched into the uploads directory for self-hosting any time the plugin is activated, or any time any settings are changed for the plugin.

    That’s why the deactivate/re-activate solution works, but that’s admittedly heavy-handed. It’s a fine workaround in the meantime, if you can tolerate it.

    Another temporary workaround would be to make any change to the plugin’s settings from its settings page, and save those changes. This SVG support stylesheet is fetched any time the plugin’s settings are changed.

    Thread Starter brandonpeatasher

    (@brandonpeatasher)

    @mlwilkerson

    I’d infer, then, that this hook is still firing on your site, even though you don’t use the block editor.

    Correct. I’ve dequeued Gutenberg stuff manually with the below, so possibly there’s something I should be doing differently/additionally so the FA call fires correctly?

    add_filter('use_block_editor_for_post', '__return_false', 10);
    add_filter('use_block_editor_for_post_type', '__return_false', 10);

    function deregister_gutenberg() {
    wp_dequeue_style( 'classic-theme-styles' );
    wp_dequeue_style( 'global-styles' );
    wp_dequeue_style( 'wp-block-library' );
    }
    add_action( 'wp_enqueue_scripts', 'deregister_gutenberg', 11 );

    Plugin Author mlwilkerson

    (@mlwilkerson)

    I’ve released version 5.0.1 of the plugin. It will automatically fetch the required SVG stylesheet when loading the WP admin dashboard, as long as this plugin is activated. I also added a upgrade notice about that. This extra step is only necessary once, when upgrading to v5 from a prior version.

    Thus, it won’t be necessary to deactivate/re-activate the plugin.

    This SVG stylesheet is required for the new Block Editor features to work. So the stylesheet must be fetched. For those who do not use the Block Editor and do not want the SVG stylesheet to be loaded, the following could be added to your theme’s functions.php or equivalent:

    add_action("wp_enqueue_scripts", function () {
    wp_dequeue_style("font-awesome-svg-styles");
    });
    Thread Starter brandonpeatasher

    (@brandonpeatasher)

    @mlwilkerson Perfect, will do. Thanks!

    Plugin Author mlwilkerson

    (@mlwilkerson)

    For those who want to try some bleeding-edge testing, I’ve posted a pre-release 5.0.2-1 of the plugin on the GitHub repo here. You can download the font-awesome.zip attached to that Release and install it by uploading it to the WP plugins dashboard (Add Plugin and Upload).

    It introduces a new filter that you could add to your functions.php, or equivalent, if you prefer to entirely disable the plugin’s actions pertaining to Block Editor support, including the fetching, storing, and loading of this SVG stylesheet:

    add_filter( 'font_awesome_disable_block_editor_support', '__return_true' );

    If you try it, I’d appreciate feedback to help refine it, if need be.

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.