wp_get_current_commenter()
git-svn-id: http://svn.automattic.com/wordpress/trunk@3902 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4b02c602d1
commit
1034767a9a
|
@ -29,9 +29,8 @@ foreach ($posts as $post) { start_wp();
|
|||
|
||||
<?php
|
||||
// this line is WordPress' motor, do not delete it.
|
||||
$comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
|
||||
$comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
|
||||
$comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
|
||||
$commenter = wp_get_current_commenter();
|
||||
extract($commenter);
|
||||
$comments = get_approved_comments($id);
|
||||
$commentstatus = get_post($id);
|
||||
if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $commentstatus->post_password) { // and it doesn't match the cookie
|
||||
|
|
|
@ -29,9 +29,8 @@ foreach ($posts as $post) { start_wp();
|
|||
|
||||
<?php
|
||||
// this line is WordPress' motor, do not delete it.
|
||||
$comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
|
||||
$comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
|
||||
$comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
|
||||
$commenter = wp_get_current_commenter();
|
||||
extract($commenter);
|
||||
$comments = get_approved_comments($id);
|
||||
$post = get_post($id);
|
||||
if (!empty($post->post_password) && $_COOKIE['wp-postpass_'. COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
|
||||
|
|
|
@ -273,26 +273,12 @@ function pings_open() {
|
|||
function comments_template( $file = '/comments.php' ) {
|
||||
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
|
||||
|
||||
if ( is_single() || is_page() || $withcomments ) :
|
||||
if ( ! (is_single() || is_page() || $withcomments) )
|
||||
return;
|
||||
|
||||
$req = get_settings('require_name_email');
|
||||
$comment_author = '';
|
||||
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
|
||||
$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
|
||||
$comment_author = stripslashes($comment_author);
|
||||
$comment_author = wp_specialchars($comment_author, true);
|
||||
}
|
||||
$comment_author_email = '';
|
||||
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
|
||||
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
|
||||
$comment_author_email = stripslashes($comment_author_email);
|
||||
$comment_author_email = wp_specialchars($comment_author_email, true);
|
||||
}
|
||||
$comment_author_url = '';
|
||||
if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
|
||||
$comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
|
||||
$comment_author_url = stripslashes($comment_author_url);
|
||||
$comment_author_url = wp_specialchars($comment_author_url, true);
|
||||
}
|
||||
$commenter = wp_get_current_commenter();
|
||||
extract($commenter);
|
||||
|
||||
// TODO: Use API instead of SELECTs.
|
||||
if ( empty($comment_author) ) {
|
||||
|
@ -309,8 +295,6 @@ function comments_template( $file = '/comments.php' ) {
|
|||
require( $include );
|
||||
else
|
||||
require( ABSPATH . 'wp-content/themes/default/comments.php');
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
function comments_popup_script($width=400, $height=400, $file='') {
|
||||
|
|
|
@ -146,6 +146,29 @@ function get_lastcommentmodified($timezone = 'server') {
|
|||
return $lastcommentmodified;
|
||||
}
|
||||
|
||||
function sanitize_comment_cookies() {
|
||||
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
|
||||
$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
|
||||
$comment_author = stripslashes($comment_author);
|
||||
$comment_author = wp_specialchars($comment_author, true);
|
||||
$_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
|
||||
}
|
||||
|
||||
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
|
||||
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
|
||||
$comment_author_email = stripslashes($comment_author_email);
|
||||
$comment_author_email = wp_specialchars($comment_author_email, true);
|
||||
$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
|
||||
}
|
||||
|
||||
if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
|
||||
$comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
|
||||
$comment_author_url = stripslashes($comment_author_url);
|
||||
$comment_author_url = wp_specialchars($comment_author_url, true);
|
||||
$_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
|
||||
}
|
||||
}
|
||||
|
||||
function wp_allow_comment($commentdata) {
|
||||
global $wpdb;
|
||||
extract($commentdata);
|
||||
|
@ -275,6 +298,24 @@ function wp_get_comment_status($comment_id) {
|
|||
}
|
||||
}
|
||||
|
||||
function wp_get_current_commenter() {
|
||||
// Cookies should already be sanitized.
|
||||
|
||||
$comment_author = '';
|
||||
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
|
||||
$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
|
||||
|
||||
$comment_author_email = '';
|
||||
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
|
||||
$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
|
||||
|
||||
$comment_author_url = '';
|
||||
if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
|
||||
$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
|
||||
|
||||
return compact('comment_author', 'comment_author_email', 'comment_author_url');
|
||||
}
|
||||
|
||||
function wp_insert_comment($commentdata) {
|
||||
global $wpdb;
|
||||
extract($commentdata);
|
||||
|
|
|
@ -127,4 +127,5 @@ add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
|
|||
add_action('do_feed_atom', 'do_feed_atom', 10, 1);
|
||||
add_action('do_pings', 'do_all_pings', 10, 1);
|
||||
add_action('do_robots', 'do_robots');
|
||||
add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
|
||||
?>
|
||||
|
|
|
@ -204,6 +204,8 @@ $_POST = add_magic_quotes($_POST );
|
|||
$_COOKIE = add_magic_quotes($_COOKIE);
|
||||
$_SERVER = add_magic_quotes($_SERVER);
|
||||
|
||||
do_action('sanitize_comment_cookies');
|
||||
|
||||
$wp_query = new WP_Query();
|
||||
$wp_rewrite = new WP_Rewrite();
|
||||
$wp = new WP();
|
||||
|
|
Loading…
Reference in New Issue