Open mAAdhaTTah opened 9 years ago
@mAAdhaTTah The CSS files are enqueued using wp_enqueue_style
in the load_resources
method - on line 48
What exactly did the change you made do? The CSS files were not loading at all and then this made them load? Or in a particular spot?
Yeah, the load_resources
function is being called in the wp_footer
hook. wp_enqueue_styles
wants to put the styles in the header in the <head>
, but it can't because when wp_footer
is called, the <head>
has already been output.
Generally speaking, scripts and styles should be called in the wp_enqueue_scripts
hook (or admin_enqueue_scripts
on the admin side), which is when WordPress is dealing with all its internal scripts/styles. You can also fix the way the slickQuiz.js
file is enqueued, by requiring the dependency on jquery
in that function call rather than asking WordPress to enqueue it again (which it doesn't do twice anyway), which will make sure everything is enqueued in the right order.
I know this may be a little unclear, so I can update this PR to show what I mean. The short version is the plugin enqueues its scripts/styles on the wrong hook. This fixes that.
(Also, wp_footer
is an action, not a filter, tho it seems to work anyway. That's why I changed that second line.)
I'm looking to filter off the scripts and styles on everything but single post templates, which will be easy with enqueuing of the assets. Any reason why this hasn't been merged or anything I can do to help move it along?
Currently, the
load_resources
function in the front.php file is loading the scripts and styles in the footer. On our install, we're not seeing the CSS files enqueued at all.This should be hooked into the
wp_enqueue_scripts
action. This PR fixes that.