856 | | $allowedtypes = array( |
857 | | 'comment' => '', |
858 | | 'pingback' => 'pingback', |
859 | | 'trackback' => 'trackback', |
860 | | ); |
861 | | |
862 | | $comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : ''; |
863 | | |
864 | | // Count comments older than this one |
| 856 | switch ( $args['type'] ) { |
| 857 | case 'comment': |
| 858 | $comtype = 'comment'; |
| 859 | $comtypewhere = " AND comment_type = ''"; |
| 860 | break; |
| 861 | case 'pingback': |
| 862 | $comtype = 'pingback'; |
| 863 | $comtypewhere = " AND comment_type = 'pingback'"; |
| 864 | break; |
| 865 | case 'trackback': |
| 866 | $comtype = 'trackback'; |
| 867 | $comtypewhere = " AND comment_type = 'trackback'"; |
| 868 | break; |
| 869 | case 'pings': |
| 870 | $comtype = 'pings'; |
| 871 | $comtypewhere = " AND ( comment_type = 'pingback' OR comment_type = 'trackback' )"; |
| 872 | break; |
| 873 | default; |
| 874 | $comtype = 'all'; |
| 875 | $comtypewhere = ''; |
| 876 | } |
| 877 | |
| 878 | $cachekey = 'post-' . $comment->comment_post_ID; |
| 879 | // Check the cache and set it up if it's not set (so we can use replace later on) |
| 880 | if ( false === $oldercoms_cache = wp_cache_get( $cachekey, 'comment_pages' ) ) { |
| 881 | $oldercoms_cache = array(); |
| 882 | wp_cache_add( $cachekey, $oldercoms_cache, 'comment_pages' ); |
| 883 | } |
| 884 | $oldercoms_cache = (array) $oldercoms_cache; |
| 885 | |
| 886 | // Get comments older than this comment |
| 887 | $oldercoms = ( isset( $oldercoms_cache[$comtype] ) && isset( $oldercoms_cache[$comtype][$comment->comment_ID] ) ) ? $oldercoms_cache[$comtype][$comment->comment_ID] : false; |
| 888 | if ( false === $oldercoms ) { |
| 903 | * Clears the cache used by get_page_of_comment(). Is designed to be attached to the |
| 904 | * 'clear_page_of_comment_cache' action inside of wp_transition_comment_status(); |
| 905 | * |
| 906 | * @since 2.9.0 |
| 907 | * @uses wp_cache_delete() Does the cache deleting. |
| 908 | * |
| 909 | * @param string $new_status Unused |
| 910 | * @param string $old_status Unused |
| 911 | * @param object $comment Comment object that had it's status changed |
| 912 | * @return bool True on successful removal, false on failure |
| 913 | */ |
| 914 | function clear_page_of_comment_cache( $new_status, $old_status, $comment ) { |
| 915 | return wp_cache_delete( 'post-' . $comment->comment_post_ID, 'comment_pages' ); |
| 916 | } |
| 917 | |
| 918 | /** |