2003-04-01 14:12:34 +00:00
|
|
|
<?php
|
2008-05-25 15:50:15 +00:00
|
|
|
/**
|
|
|
|
* Handles Comment Post to WordPress and prevents duplicate comment posting.
|
|
|
|
*
|
2008-06-20 20:56:40 +00:00
|
|
|
* @package WordPress
|
2008-05-25 15:50:15 +00:00
|
|
|
*/
|
|
|
|
|
2007-07-04 16:12:37 +00:00
|
|
|
if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
|
|
|
|
header('Allow: POST');
|
|
|
|
header('HTTP/1.1 405 Method Not Allowed');
|
|
|
|
header('Content-Type: text/plain');
|
|
|
|
exit;
|
2007-03-28 17:34:42 +00:00
|
|
|
}
|
2008-05-25 15:50:15 +00:00
|
|
|
|
|
|
|
/** Sets up the WordPress Environment. */
|
2008-05-21 05:59:27 +00:00
|
|
|
require( dirname(__FILE__) . '/wp-load.php' );
|
2003-04-01 14:12:34 +00:00
|
|
|
|
2005-11-05 22:08:56 +00:00
|
|
|
nocache_headers();
|
|
|
|
|
2015-10-03 14:47:26 +00:00
|
|
|
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
|
|
|
|
if ( is_wp_error( $comment ) ) {
|
|
|
|
$data = $comment->get_error_data();
|
|
|
|
if ( ! empty( $data ) ) {
|
|
|
|
wp_die( $comment->get_error_message(), $data );
|
|
|
|
} else {
|
|
|
|
exit;
|
2014-11-26 20:17:24 +00:00
|
|
|
}
|
2007-03-14 23:10:57 +00:00
|
|
|
}
|
2004-12-16 02:57:05 +00:00
|
|
|
|
2015-10-03 14:47:26 +00:00
|
|
|
$user = wp_get_current_user();
|
2013-09-05 16:05:09 +00:00
|
|
|
|
|
|
|
/**
|
2013-09-06 01:38:09 +00:00
|
|
|
* Perform other actions when comment cookies are set.
|
2013-09-05 16:05:09 +00:00
|
|
|
*
|
|
|
|
* @since 3.4.0
|
|
|
|
*
|
2015-09-03 18:17:24 +00:00
|
|
|
* @param WP_Comment $comment Comment object.
|
|
|
|
* @param WP_User $user User object. The user may not exist.
|
2013-09-05 16:05:09 +00:00
|
|
|
*/
|
|
|
|
do_action( 'set_comment_cookies', $comment, $user );
|
2003-04-07 06:55:21 +00:00
|
|
|
|
2015-10-03 14:47:26 +00:00
|
|
|
$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
|
2013-09-05 16:05:09 +00:00
|
|
|
|
|
|
|
/**
|
2014-02-09 20:12:12 +00:00
|
|
|
* Filter the location URI to send the commenter after posting.
|
2013-09-05 16:05:09 +00:00
|
|
|
*
|
2014-02-09 20:12:12 +00:00
|
|
|
* @since 2.0.5
|
2013-09-05 16:05:09 +00:00
|
|
|
*
|
2015-09-03 18:17:24 +00:00
|
|
|
* @param string $location The 'redirect_to' URI sent via $_POST.
|
|
|
|
* @param WP_Comment $comment Comment object.
|
2013-09-05 16:05:09 +00:00
|
|
|
*/
|
|
|
|
$location = apply_filters( 'comment_post_redirect', $location, $comment );
|
2004-10-05 16:22:31 +00:00
|
|
|
|
2012-04-10 17:21:17 +00:00
|
|
|
wp_safe_redirect( $location );
|
2010-12-09 18:02:54 +00:00
|
|
|
exit;
|