2003-04-01 09:12:34 -05:00
|
|
|
<?php
|
2008-05-25 11:50:15 -04:00
|
|
|
/**
|
|
|
|
* Handles Comment Post to WordPress and prevents duplicate comment posting.
|
|
|
|
*
|
2008-06-20 16:56:40 -04:00
|
|
|
* @package WordPress
|
2008-05-25 11:50:15 -04:00
|
|
|
*/
|
|
|
|
|
2007-07-04 12:12:37 -04: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 13:34:42 -04:00
|
|
|
}
|
2008-05-25 11:50:15 -04:00
|
|
|
|
|
|
|
/** Sets up the WordPress Environment. */
|
2008-05-21 01:59:27 -04:00
|
|
|
require( dirname(__FILE__) . '/wp-load.php' );
|
2003-04-01 09:12:34 -05:00
|
|
|
|
2005-11-05 17:08:56 -05:00
|
|
|
nocache_headers();
|
|
|
|
|
2015-10-03 10:47:26 -04: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 15:17:24 -05:00
|
|
|
}
|
2007-03-14 19:10:57 -04:00
|
|
|
}
|
2004-12-15 21:57:05 -05:00
|
|
|
|
2015-10-03 10:47:26 -04:00
|
|
|
$user = wp_get_current_user();
|
2013-09-05 12:05:09 -04:00
|
|
|
|
|
|
|
/**
|
2013-09-05 21:38:09 -04:00
|
|
|
* Perform other actions when comment cookies are set.
|
2013-09-05 12:05:09 -04:00
|
|
|
*
|
|
|
|
* @since 3.4.0
|
|
|
|
*
|
2015-09-03 14:17:24 -04:00
|
|
|
* @param WP_Comment $comment Comment object.
|
|
|
|
* @param WP_User $user User object. The user may not exist.
|
2013-09-05 12:05:09 -04:00
|
|
|
*/
|
|
|
|
do_action( 'set_comment_cookies', $comment, $user );
|
2003-04-07 02:55:21 -04:00
|
|
|
|
2015-10-03 10:47:26 -04:00
|
|
|
$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
|
2013-09-05 12:05:09 -04:00
|
|
|
|
|
|
|
/**
|
2014-02-09 15:12:12 -05:00
|
|
|
* Filter the location URI to send the commenter after posting.
|
2013-09-05 12:05:09 -04:00
|
|
|
*
|
2014-02-09 15:12:12 -05:00
|
|
|
* @since 2.0.5
|
2013-09-05 12:05:09 -04:00
|
|
|
*
|
2015-09-03 14:17:24 -04:00
|
|
|
* @param string $location The 'redirect_to' URI sent via $_POST.
|
|
|
|
* @param WP_Comment $comment Comment object.
|
2013-09-05 12:05:09 -04:00
|
|
|
*/
|
|
|
|
$location = apply_filters( 'comment_post_redirect', $location, $comment );
|
2004-10-05 12:22:31 -04:00
|
|
|
|
2012-04-10 13:21:17 -04:00
|
|
|
wp_safe_redirect( $location );
|
2010-12-09 13:02:54 -05:00
|
|
|
exit;
|