Make WordPress Core

Changeset 3903


Ignore:
Timestamp:
06/22/2006 10:09:17 PM (20 years ago)
Author:
ryan
Message:

wp_get_current_commenter()

Location:
branches/2.0
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/wp-content/themes/classic/comments-popup.php

    r3115 r3903  
    3030<?php
    3131// this line is WordPress' motor, do not delete it.
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
     32$commenter = wp_get_current_commenter();
     33extract($commenter);
    3534$comments = get_approved_comments($id);
    3635$commentstatus = get_post($id);
  • branches/2.0/wp-content/themes/default/comments-popup.php

    r3115 r3903  
    3030<?php
    3131// this line is WordPress' motor, do not delete it.
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
     32$commenter = wp_get_current_commenter();
     33extract($commenter);
    3534$comments = get_approved_comments($id);
    3635$post = get_post($id);
  • branches/2.0/wp-includes/comment-functions.php

    r3888 r3903  
    66        global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
    77
    8         if ( is_single() || is_page() || $withcomments ) :
    9                 $req = get_settings('require_name_email');
    10                 $comment_author = '';
    11                 if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
    12                         $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
    13                         $comment_author = stripslashes($comment_author);
    14                         $comment_author = wp_specialchars($comment_author, true);
    15                 }
    16                 $comment_author_email = '';
    17                 if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
    18                         $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
    19                         $comment_author_email = stripslashes($comment_author_email);
    20                         $comment_author_email = wp_specialchars($comment_author_email, true);           
    21                 }
    22                 $comment_author_url = '';
    23                 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
    24                         $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
    25                         $comment_author_url = stripslashes($comment_author_url);
    26                         $comment_author_url = wp_specialchars($comment_author_url, true);               
    27                 }
    28 
     8        if ( ! (is_single() || is_page() || $withcomments) )
     9                return;
     10
     11        $req = get_settings('require_name_email');
     12        $commenter = wp_get_current_commenter();
     13        extract($commenter);
     14
     15        // TODO: Use API instead of SELECTs.
    2916        if ( empty($comment_author) ) {
    3017                $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
     
    4128        else
    4229                require( ABSPATH . 'wp-content/themes/default/comments.php');
    43 
    44         endif;
    4530}
    4631
     
    909894}
    910895
     896function sanitize_comment_cookies() {
     897        if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
     898                $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
     899                $comment_author = stripslashes($comment_author);
     900                $comment_author = wp_specialchars($comment_author, true);
     901                $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
     902        }
     903
     904        if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
     905                $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
     906                $comment_author_email = stripslashes($comment_author_email);
     907                $comment_author_email = wp_specialchars($comment_author_email, true);   
     908                $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
     909        }
     910
     911        if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
     912                $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
     913                $comment_author_url = stripslashes($comment_author_url);
     914                $comment_author_url = wp_specialchars($comment_author_url, true);
     915                $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
     916        }
     917}
     918
     919function wp_get_current_commenter() {
     920        // Cookies should already be sanitized.
     921
     922        $comment_author = '';
     923        if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
     924                $comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
     925
     926        $comment_author_email = '';
     927        if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
     928                $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
     929
     930        $comment_author_url = '';
     931        if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
     932                $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
     933
     934        return compact('comment_author', 'comment_author_email', 'comment_author_url');
     935}
     936
    911937?>
  • branches/2.0/wp-includes/default-filters.php

    r3832 r3903  
    117117add_action('publish_post', 'generic_ping');
    118118add_action('wp_head', 'rsd_link');
     119add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
    119120
    120121?>
  • branches/2.0/wp-settings.php

    r3580 r3903  
    199199$_SERVER = add_magic_quotes($_SERVER);
    200200
     201do_action('sanitize_comment_cookies');
     202
    201203$wp_query   = new WP_Query();
    202204$wp_rewrite = new WP_Rewrite();
Note: See TracChangeset for help on using the changeset viewer.