mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 08:11:52 +01:00
Say goodbye to ?replytocom=123 links and their URL pollution.
* Comment reply links continue to use JS as before. * ?replytocom=123 links are deprecated. props joostdevalk fixes #22889 Built from https://develop.svn.wordpress.org/trunk@33038 git-svn-id: http://core.svn.wordpress.org/trunk@33009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
85d7261305
commit
9d11efe23c
@ -1438,7 +1438,7 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null
|
|||||||
);
|
);
|
||||||
|
|
||||||
$link = sprintf( "<a class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
|
$link = sprintf( "<a class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
|
||||||
esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
|
esc_url( get_permalink( $post->ID ) ) . "#" . $args['respond_id'],
|
||||||
$onclick,
|
$onclick,
|
||||||
esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
|
esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
|
||||||
$args['reply_text']
|
$args['reply_text']
|
||||||
@ -1571,10 +1571,9 @@ function get_cancel_comment_reply_link( $text = '' ) {
|
|||||||
if ( empty($text) )
|
if ( empty($text) )
|
||||||
$text = __('Click here to cancel reply.');
|
$text = __('Click here to cancel reply.');
|
||||||
|
|
||||||
$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
|
$link = '#respond';
|
||||||
$link = esc_html( remove_query_arg('replytocom') ) . '#respond';
|
|
||||||
|
|
||||||
$formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';
|
$formatted_link = '<a id="cancel-comment-reply-link" href="' . $link . '">' . $text . '</a>';
|
||||||
/**
|
/**
|
||||||
* Filter the cancel comment reply link HTML.
|
* Filter the cancel comment reply link HTML.
|
||||||
*
|
*
|
||||||
@ -1610,9 +1609,8 @@ function get_comment_id_fields( $id = 0 ) {
|
|||||||
if ( empty( $id ) )
|
if ( empty( $id ) )
|
||||||
$id = get_the_ID();
|
$id = get_the_ID();
|
||||||
|
|
||||||
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
|
||||||
$result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
|
$result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
|
||||||
$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
|
$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='0' />\n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the returned comment id fields.
|
* Filter the returned comment id fields.
|
||||||
@ -1621,9 +1619,9 @@ function get_comment_id_fields( $id = 0 ) {
|
|||||||
*
|
*
|
||||||
* @param string $result The HTML-formatted hidden id field comment elements.
|
* @param string $result The HTML-formatted hidden id field comment elements.
|
||||||
* @param int $id The post ID.
|
* @param int $id The post ID.
|
||||||
* @param int $replytoid The id of the comment being replied to.
|
* @param int $deprecated No longer used.
|
||||||
*/
|
*/
|
||||||
return apply_filters( 'comment_id_fields', $result, $id, $replytoid );
|
return apply_filters( 'comment_id_fields', $result, $id, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1648,27 +1646,18 @@ function comment_id_fields( $id = 0 ) {
|
|||||||
*
|
*
|
||||||
* @param string $noreplytext Optional. Text to display when not replying to a comment.
|
* @param string $noreplytext Optional. Text to display when not replying to a comment.
|
||||||
* Default false.
|
* Default false.
|
||||||
* @param string $replytext Optional. Text to display when replying to a comment.
|
* @param string $deprecated No longer used.
|
||||||
* Default false. Accepts "%s" for the author of the comment
|
* @param string $deprecated_2 No longer used.
|
||||||
* being replied to.
|
|
||||||
* @param string $linktoparent Optional. Boolean to control making the author's name a link
|
|
||||||
* to their comment. Default true.
|
|
||||||
*/
|
*/
|
||||||
function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) {
|
function comment_form_title( $noreplytext, $deprecated = null, $deprecated_2 = null ) {
|
||||||
global $comment;
|
if ( ! is_null( $deprecated ) )
|
||||||
|
_deprecated_argument( __FUNCTION__, '4.3' );
|
||||||
|
if ( ! is_null( $deprecated_2 ) )
|
||||||
|
_deprecated_argument( __FUNCTION__, '4.3' );
|
||||||
|
|
||||||
if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
|
if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
|
||||||
if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' );
|
|
||||||
|
|
||||||
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
|
||||||
|
|
||||||
if ( 0 == $replytoid )
|
|
||||||
echo $noreplytext;
|
echo $noreplytext;
|
||||||
else {
|
|
||||||
$comment = get_comment($replytoid);
|
|
||||||
$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author();
|
|
||||||
printf( $replytext, $author );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2294,7 +2283,7 @@ function comment_form( $args = array(), $post_id = null ) {
|
|||||||
do_action( 'comment_form_before' );
|
do_action( 'comment_form_before' );
|
||||||
?>
|
?>
|
||||||
<div id="respond" class="comment-respond">
|
<div id="respond" class="comment-respond">
|
||||||
<h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3>
|
<h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( $args['title_reply'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3>
|
||||||
<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
|
<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
|
||||||
<?php echo $args['must_log_in']; ?>
|
<?php echo $args['must_log_in']; ?>
|
||||||
<?php
|
<?php
|
||||||
|
@ -231,9 +231,6 @@ add_action( 'init', 'check_theme_switched', 99 );
|
|||||||
add_action( 'after_switch_theme', '_wp_sidebars_changed' );
|
add_action( 'after_switch_theme', '_wp_sidebars_changed' );
|
||||||
add_action( 'wp_print_styles', 'print_emoji_styles' );
|
add_action( 'wp_print_styles', 'print_emoji_styles' );
|
||||||
|
|
||||||
if ( isset( $_GET['replytocom'] ) )
|
|
||||||
add_action( 'wp_head', 'wp_no_robots' );
|
|
||||||
|
|
||||||
// Login actions
|
// Login actions
|
||||||
add_action( 'login_head', 'wp_print_head_scripts', 9 );
|
add_action( 'login_head', 'wp_print_head_scripts', 9 );
|
||||||
add_action( 'login_footer', 'wp_print_footer_scripts', 20 );
|
add_action( 'login_footer', 'wp_print_footer_scripts', 20 );
|
||||||
|
@ -65,7 +65,7 @@ _deprecated_file( sprintf( __( 'Theme without %1$s' ), basename(__FILE__) ), '3.
|
|||||||
|
|
||||||
<div id="respond">
|
<div id="respond">
|
||||||
|
|
||||||
<h3><?php comment_form_title( __('Leave a Reply'), __('Leave a Reply to %s' ) ); ?></h3>
|
<h3><?php _e('Leave a Reply'); ?></h3>
|
||||||
|
|
||||||
<div id="cancel-comment-reply">
|
<div id="cancel-comment-reply">
|
||||||
<small><?php cancel_comment_reply_link() ?></small>
|
<small><?php cancel_comment_reply_link() ?></small>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-33037';
|
$wp_version = '4.3-alpha-33038';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user