'.__('We were unable to authenticate your claimed OpenID, however you ' . 'can continue to post your comment without OpenID:', 'openid').'
'; openid_page($html, __('OpenID Authentication Error', 'openid')); } /** * Action method for completing the 'comment' action. This action is used when leaving a comment. * * @param string $identity_url verified OpenID URL */ function openid_finish_comment($identity_url) { if ($_REQUEST['action'] != 'comment') return; if (empty($identity_url)) { openid_repost_comment_anonymously($_SESSION['openid_comment_post']); } openid_set_current_user($identity_url); if (is_user_logged_in()) { // simulate an authenticated comment submission $_SESSION['openid_comment_post']['author'] = null; $_SESSION['openid_comment_post']['email'] = null; $_SESSION['openid_comment_post']['url'] = null; } else { // try to get user data from the verified OpenID $user_data =& openid_get_user_data($identity_url); if (!empty($user_data['display_name'])) { $_SESSION['openid_comment_post']['author'] = $user_data['display_name']; } if (!empty($user_data['user_email'])) { $_SESSION['openid_comment_post']['email'] = $user_data['user_email']; } $_SESSION['openid_comment_post']['url'] = $identity_url; } // record that we're about to post an OpenID authenticated comment. // We can't actually record it in the database until after the repost below. $_SESSION['openid_posted_comment'] = true; $wpp = parse_url(get_option('siteurl')); openid_repost($wpp['path'] . '/wp-comments-post.php', array_filter($_SESSION['openid_comment_post'])); } /** * Mark the specified comment as an OpenID comment. * * @param int $id id of comment to set as OpenID */ function set_comment_openid($id) { $comment = get_comment($id); $openid_comments = get_post_meta($comment->comment_post_ID, 'openid_comments', true); if (!is_array($openid_comments)) { $openid_comments = array(); } $openid_comments[] = $id; update_post_meta($comment->comment_post_ID, 'openid_comments', array_unique($openid_comments)); } /** * Unmark the specified comment as an OpenID comment * * @param int $id id of comment to set as OpenID */ function unset_comment_openid($id) { $comment = get_comment($id); $openid_comments = get_post_meta($comment->comment_post_ID, 'openid_comments', true); if (is_array($openid_comments) && in_array($id, $openid_comments)) { $new = array(); foreach($openid_comments as $c) { if ($c == $id) continue; $new[] = $c; } update_post_meta($comment->comment_post_ID, 'openid_comments', array_unique($new)); } } /** * Retrieve user data from comment form. * * @param string $identity_url OpenID to get user data about * @param reference $data reference to user data array * @see get_user_data */ function openid_get_user_data_form($data, $identity_url) { $comment = $_SESSION['openid_comment_post']; if (!$comment) { return $data; } if ($comment['email']) { $data['user_email'] = $comment['email']; } if ($comment['author']) { $data['nickname'] = $comment['author']; $data['user_nicename'] = $comment['author']; $data['display_name'] = $comment['author']; } return $data; } /** * Parse the WordPress request. If the pagename is 'openid_consumer', then the request * is an OpenID response and should be handled accordingly. * * @param WP $wp WP instance for the current request */ function openid_parse_comment_request($wp) { if (array_key_exists('openid_consumer', $_REQUEST) && $_REQUEST['action']) { finish_openid($_REQUEST['action']); } } function openid_comment_return_url($urls) { $urls[] = get_option('home'); return $urls; } ?>