Make WordPress Core

Ticket #31590: 31590.1.diff

File 31590.1.diff, 2.7 KB (added by peterwilsoncc, 8 years ago)

obtrusive with expiring method queue

  • src/wp-includes/default-filters.php

    diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php
    index b1f69ea..b5462ae 100644
    a b add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); 
    230230add_action( 'init',                'check_theme_switched',            99    );
    231231add_action( 'after_switch_theme',  '_wp_sidebars_changed'                   );
    232232add_action( 'wp_print_styles',     'print_emoji_styles'                     );
     233add_action( 'wp_print_scripts',    'wp_save_early_comment_reply_clicks', 99 );
    233234
    234235if ( isset( $_GET['replytocom'] ) )
    235236    add_action( 'wp_head', 'wp_no_robots' );
  • src/wp-includes/js/comment-reply.js

    diff --git a/src/wp-includes/js/comment-reply.js b/src/wp-includes/js/comment-reply.js
    index 2f2e3b3..334356a 100644
    a b  
    1 var addComment = {
     1window.wp=window.wp||{};
     2wp.commentQueue=wp.commentQueue||[];
     3window.addComment = {
     4        c : function(){},
     5
     6        checkQueue: function(){
     7                if ( 4 === wp.commentQueue.length ) {
     8                        a = wp.commentQueue;
     9                        addComment.moveForm(a[0],a[1],a[2],a[3]);
     10                }
     11                wp.commentQueue = [];
     12        },
     13
    214        moveForm : function(commId, parentId, respondId, postId) {
    315                var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
    416
    var addComment = { 
    4557                return document.getElementById(e);
    4658        }
    4759};
     60addComment.checkQueue();
     61 No newline at end of file
  • src/wp-includes/script-loader.php

    diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
    index 3e55a11..9b36328 100644
    a b function wp_just_in_time_script_localization() { 
    783783}
    784784
    785785/**
     786 * Save clicks on a comment reply link before the script has loaded
     787 *
     788 * On long comment threads, it's possible a visitor will click a reply link
     789 * before the comment-reply script loads. React gracefully.
     790 *
     791 * @since 4.2
     792 */
     793function wp_save_early_comment_reply_clicks() {
     794
     795        // check if comment reply script is enqueued
     796        // if so, create a 1second method queue for quick clicks
     797        if ( wp_script_is( 'comment-reply' ) ) {
     798                echo "<script>\n";
     799                echo "window.wp=window.wp||{};";
     800                echo "wp.commentQueue = [];";
     801                echo "window.addComment = {
     802                        moveForm : function(a,b,c,d) { wp.commentQueue = [a,b,c,d]; setTimeout( addComment.c, 500 ); return false; },
     803                        c : function() { wp.commentQueue = [];} }\n";
     804                echo "</script>\n";
     805        }
     806
     807}
     808
     809
     810/**
    786811 * Administration Screen CSS for changing the styles.
    787812 *
    788813 * If installing the 'wp-admin/' directory will be replaced with './'.