WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Plugin Dependencies] Script load order bug (5 posts)

  1. elyobo
    Member
    Posted 2 years ago #

    The plugin dependencies plugin echos a script in the admin_footer action; this fires *before* admin print scripts, so this fails if we've followed best practice and pushed our scripts into the footer.

    The issue can easily be resolved by outputing the same javascript in the admin_print_footer_scripts action instead, using a weight greater than 10, to ensure that it goes out after any other scripts. This will continue to work with code that queues JS in the head, but will also work with JS queued in the footer.

    Replace

    add_action( 'admin_footer', array( __CLASS__, 'admin_footer' ) );

    with

    add_action( 'admin_print_footer_scripts', array( __CLASS__, 'admin_footer' ), 20 );
  2. scribu
    Member
    Posted 2 years ago #

    The few lines of JavaScript have only jQuery as a dependency, which normally loads in the header.

    Are you saying that you made jQuery load in the footer?

  3. elyobo
    Member
    Posted 2 years ago #

    Indeed.

  4. scribu
    Member
    Posted 2 years ago #

    Done. Will be present in the next release. Thanks for the suggestion.

  5. elyobo
    Member
    Posted 2 years ago #

    Thanks :)

Topic Closed

This topic has been closed to new replies.

About this Topic