Missing dependency – Comment-reply

  • Venutius

    #49633

    Hi there,

    On one of my sites I’m getting an error that there is a missing dependency loading graphene.js – comment-reply.

    I can see in the code that graphene.js is loaded in scripts.php, but I can’t see where you load comment-reply?

    Thanks

    Admin

    Syahir Hakim

    #49641

    The comment-reply.js script is only loaded if threaded comment is enabled in WP Admin > Settings > Discussions. We’ll remove this dependency in the next theme update.

    Venutius

    #49644

    Thanks for the reply, I checked and I had threaded replies set to on, so it should have loaded, but also I set threaded replies to off but no change in the error.

    Venutius

    #49652

    I scanned my copy of Graphene and could not see where you enqueue comment-reply.js, so I enqueued it myself and the problem went away.

    Admin

    Syahir Hakim

    #49665

    In previous version, the line that specifies comment-reply.js as dependency is this:

    wp_enqueue_script( 'graphene', GRAPHENE_ROOTURI . '/js/graphene.js', array( 'bootstrap', 'comment-reply', 'infinite-scroll' ), $version );
    

    In WordPress, whenever you reply a script as a dependency for another script, that script will automatically be loaded first before the dependent script is loaded. Therefore, there’s no need to have a separate call to queue the dependency scripts, unless those scripts have not been registered yet.

    In the current version, we’ve changed the script loading to this:

    if ( ( get_option( 'thread_comments' ) == 1 ) ) wp_enqueue_script( 'comment-reply' );
    wp_enqueue_script( 'graphene', GRAPHENE_ROOTURI . '/js/graphene.js', array( 'bootstrap', 'infinite-scroll' ), $version );
    

    In this version, the comment-reply.js will only be loaded if threaded comments is enabled in WordPress discussion settings.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.