Make WordPress Core

Ticket #16894: 16894.5.diff

File 16894.5.diff, 1.7 KB (added by boonebgorges, 9 years ago)
  • src/wp-includes/comment-functions.php

    diff --git src/wp-includes/comment-functions.php src/wp-includes/comment-functions.php
    index 08ddfd2..6a2d652 100644
    function update_comment_cache($comments) { 
    23652365                wp_cache_add($comment->comment_ID, $comment, 'comment');
    23662366}
    23672367
     2368/**
     2369 * Lazy load comment meta when inside of a `WP_Query` loop.
     2370 *
     2371 * @since 4.4.0
     2372 *
     2373 * @param null $check      The `$check` param passed from the 'pre_comment_metadata' hook.
     2374 * @param int  $comment_id ID of the comment whose metadata is being cached.
     2375 * @return null In order not to short-circuit `get_metadata()`.
     2376 */
     2377function wp_lazyload_comment_meta( $check, $comment_id ) {
     2378        global $wp_query;
     2379
     2380        if ( ! empty( $wp_query->comments ) ) {
     2381                // Don't use `wp_list_pluck()` to avoid by-reference manipulation.
     2382                $comment_ids = array();
     2383                foreach ( $wp_query->comments as $comment ) {
     2384                        $comment_ids[] = $comment->comment_ID;
     2385                }
     2386                update_meta_cache( 'comment', $comment_ids );
     2387        }
     2388
     2389        return $check;
     2390}
     2391
    23682392//
    23692393// Internal
    23702394//
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index f9fd9c4..e9ddc47 100644
    add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); 
    200200add_filter( 'pingback_ping_source_uri', 'pingback_ping_source_uri'            );
    201201add_filter( 'xmlrpc_pingback_error',    'xmlrpc_pingback_error'               );
    202202add_filter( 'title_save_pre',           'trim'                                );
     203add_filter( 'get_comment_metadata',     'wp_lazyload_comment_meta',     10, 2 );
    203204
    204205add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 );
    205206