post_modified_gmt ) ) { return; } $post_time = strtotime( $post -> post_modified_gmt ); $modified_time = $post_time; if ( ( int ) $post -> comment_count > 0 ) { $comments = get_comments( array( 'post_id' => $post -> ID, 'number' => '1', 'status' => 'approve', 'orderby' => 'comment_date_gmt', ) ); if ( !empty( $comments ) && isset( $comments[0] ) ) { $comment_time = strtotime( $comments[0] -> comment_date_gmt ); if ( $comment_time > $post_time ) { $modified_time = $comment_time; } } } $last_modified = str_replace( '+0000', 'GMT', gmdate( 'r', $modified_time ) ); } if ( is_archive() || is_home() ) { global $posts; if ( empty( $posts ) ) { return; } $post = $posts[0]; if ( !isset( $post -> post_modified_gmt ) ) { return; } $post_time = strtotime( $post -> post_modified_gmt ); $modified_time = $post_time; $last_modified = str_replace( '+0000', 'GMT', gmdate( 'r', $modified_time ) ); } if ( headers_sent() ) { return; } if ( !empty( $last_modified ) ) { header( 'Last-Modified: ' . $last_modified ); if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) && strtotime( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) >= $modified_time ) { $protocol = (isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'); header( $protocol . ' 304 Not Modified' ); } } }