Plugin Directory


Opened 5 years ago

Closed 5 years ago

#1600 closed defect (fixed)

Gravatar Hovercards uses wp_enqueue_script incorrectly.

Reported by: ericmann Owned by: mdawaffe
Priority: normal Severity: normal
Plugin: jetpack Keywords: has-patch


The code in the Gravatar Hovercards module uses wp_enqueue_scripts() to queue up its script files and various dependencies. It then uses wp_localize_scripts() to add some PHP variables for use in JS.

But then the system calls wp_print_scripts() directly (hooked onto the wp_footer action) to output its script files to the page. While this works, it's not the right action or the right approach for printing footer scripts. Other plugins/modules cannot hook in to change the execution order or unhook the scripts if needed. Also, the dependency of the module on jQuery can cause the library to be loaded twice in some situations (i.e. when jQuery is automatically concatenated with other scripts by a separate plugin).

Instead of hooking to wp_footer, the code should be using the in_footer parameter of wp_enqueue_scripts() and hooking to the wp_enqueue_scripts action. This is the recommended way of deferring JS files to the footer.

Attachments (1)

jetpack-1600.patch (1.9 KB) - added by ericmann 5 years ago.
Use wp_enqueue_scripts

Download all attachments as: .zip

Change History (2)

@ericmann5 years ago

Use wp_enqueue_scripts

comment:1 @mdawaffe5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

In 621541:

Error: Failed to load processor CommitTicketReference
No macro or processor named 'CommitTicketReference' found
Note: See TracTickets for help on using tickets.