diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php
index 6b3e4a5..073877e 100644
a
|
b
|
function wp_admin_canonical_url() { |
1167 | 1167 | $filtered_url = remove_query_arg( $removable_query_args, $current_url ); |
1168 | 1168 | ?> |
1169 | 1169 | <link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" /> |
1170 | | <script> |
1171 | | if ( window.history.replaceState ) { |
1172 | | window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash ); |
1173 | | } |
1174 | | </script> |
1175 | 1170 | <?php |
| 1171 | wp_remove_feedback_query_args( 'wp-admin-canonical' ); |
1176 | 1172 | } |
1177 | 1173 | |
1178 | 1174 | /** |
diff --git a/src/wp-comments-post.php b/src/wp-comments-post.php
index 5c33e87..d24ba03 100644
a
|
b
|
do_action( 'set_comment_cookies', $comment, $user, $cookies_consent ); |
57 | 57 | $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; |
58 | 58 | |
59 | 59 | /** |
| 60 | * Add specific query arguments to display the awaiting moderation message |
| 61 | * to users who did not consent to cookies. |
| 62 | */ |
| 63 | if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) ) { |
| 64 | $location = add_query_arg( array( |
| 65 | 'unapproved' => $comment->comment_ID, |
| 66 | 'moderation-hash' => wp_hash( $comment->comment_date_gmt ), |
| 67 | ), $location ); |
| 68 | } |
| 69 | |
| 70 | /** |
60 | 71 | * Filters the location URI to send the commenter after posting. |
61 | 72 | * |
62 | 73 | * @since 2.0.5 |
diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php
index 918238f..70e66b5 100644
a
|
b
|
function get_comment_reply_link( $args = array(), $comment = null, $post = null |
1690 | 1690 | |
1691 | 1691 | $link = sprintf( |
1692 | 1692 | "<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>", |
1693 | | esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . '#' . $args['respond_id'], |
| 1693 | esc_url( add_query_arg( array( |
| 1694 | 'replytocom' => $comment->comment_ID, |
| 1695 | 'unapproved' => false, |
| 1696 | 'moderation-hash' => false, |
| 1697 | ) ) ) . "#" . $args['respond_id'], |
1694 | 1698 | $data_attribute_string, |
1695 | 1699 | esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), |
1696 | 1700 | $args['reply_text'] |
… |
… |
function comment_form( $args = array(), $post_id = null ) { |
2253 | 2257 | $commenter = wp_get_current_commenter(); |
2254 | 2258 | $user = wp_get_current_user(); |
2255 | 2259 | $user_identity = $user->exists() ? $user->display_name : ''; |
| 2260 | $fields = array(); |
| 2261 | |
| 2262 | if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) ) { |
| 2263 | $consent = ''; |
| 2264 | if ( isset( $commenter['cookies_consent'] ) && true === $commenter['cookies_consent'] ) { |
| 2265 | $consent = ' checked="checked"'; |
| 2266 | |
| 2267 | // User has not consent coookies, reset the $commenter to empty the comment form. |
| 2268 | } else { |
| 2269 | $commenter = array_fill_keys( array_keys( $commenter ), '' ); |
| 2270 | } |
| 2271 | |
| 2272 | // Set cookies consent comment field. |
| 2273 | $fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' . |
| 2274 | '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>'; |
| 2275 | } |
2256 | 2276 | |
2257 | 2277 | $args = wp_parse_args( $args ); |
2258 | 2278 | if ( ! isset( $args['format'] ) ) { |
… |
… |
function comment_form( $args = array(), $post_id = null ) { |
2262 | 2282 | $req = get_option( 'require_name_email' ); |
2263 | 2283 | $html_req = ( $req ? " required='required'" : '' ); |
2264 | 2284 | $html5 = 'html5' === $args['format']; |
2265 | | $fields = array( |
| 2285 | // Set regular comment fields making sure the cookies consent is the last one. |
| 2286 | $fields = array_merge( array( |
2266 | 2287 | 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2267 | 2288 | '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>', |
2268 | 2289 | 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2269 | 2290 | '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>', |
2270 | 2291 | 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
2271 | 2292 | '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
2272 | | ); |
2273 | | |
2274 | | if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) { |
2275 | | $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; |
2276 | | $fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' . |
2277 | | '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>'; |
| 2293 | ), $fields ); |
2278 | 2294 | |
2279 | | // Ensure that the passed fields include cookies consent. |
2280 | | if ( isset( $args['fields'] ) && ! isset( $args['fields']['cookies'] ) ) { |
2281 | | $args['fields']['cookies'] = $fields['cookies']; |
2282 | | } |
| 2295 | // Ensure that the passed fields include cookies consent. |
| 2296 | if ( isset( $args['fields'] ) && ! isset( $args['fields']['cookies'] ) ) { |
| 2297 | $args['fields']['cookies'] = $fields['cookies']; |
2283 | 2298 | } |
2284 | 2299 | |
2285 | 2300 | $required_text = sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' ); |
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index e95d395..132cbcb 100644
a
|
b
|
function _clear_modified_cache_on_transition_comment_status( $new_status, $old_s |
1731 | 1731 | * @see sanitize_comment_cookies() Use to sanitize cookies |
1732 | 1732 | * |
1733 | 1733 | * @since 2.0.4 |
| 1734 | * @since 5.1.0 Tries to get a query parameter containing the comment ID to |
| 1735 | * set the comment author data when the user has not consented |
| 1736 | * to cookies. |
1734 | 1737 | * |
1735 | | * @return array Comment author, email, url respectively. |
| 1738 | * @return array Comment author, email, url, cookies consent respectively. |
1736 | 1739 | */ |
1737 | 1740 | function wp_get_current_commenter() { |
1738 | 1741 | // Cookies should already be sanitized. |
… |
… |
function wp_get_current_commenter() { |
1752 | 1755 | $comment_author_url = $_COOKIE[ 'comment_author_url_' . COOKIEHASH ]; |
1753 | 1756 | } |
1754 | 1757 | |
| 1758 | $comment_author_data = compact( 'comment_author', 'comment_author_email', 'comment_author_url' ); |
| 1759 | |
| 1760 | if ( ! array_filter( $comment_author_data ) ) { |
| 1761 | // Set the current commenter using the just posted comment ID. |
| 1762 | if ( is_singular() && isset( $_GET['unapproved'] ) ) { |
| 1763 | $comment = get_comment( $_GET['unapproved'], ARRAY_A ); |
| 1764 | |
| 1765 | if ( isset( $_GET['moderation-hash'] ) && isset( $comment['comment_date_gmt'] ) && wp_hash( $comment['comment_date_gmt'] ) === $_GET['moderation-hash'] ) { |
| 1766 | $comment_author_data = array_intersect_key( $comment, $comment_author_data ); |
| 1767 | } |
| 1768 | } |
| 1769 | |
| 1770 | $comment_author_data['cookies_consent'] = false; |
| 1771 | } else { |
| 1772 | $comment_author_data['cookies_consent'] = true; |
| 1773 | } |
| 1774 | |
1755 | 1775 | /** |
1756 | 1776 | * Filters the current commenter's name, email, and URL. |
1757 | 1777 | * |
… |
… |
function wp_get_current_commenter() { |
1763 | 1783 | * @type string $comment_author The name of the author of the comment. Default empty. |
1764 | 1784 | * @type string $comment_author_email The email address of the `$comment_author`. Default empty. |
1765 | 1785 | * @type string $comment_author_url The URL address of the `$comment_author`. Default empty. |
| 1786 | * @type boolean $cookies_consent Whether the user consented to cookies or not. Default false. |
1766 | 1787 | * } |
1767 | 1788 | */ |
1768 | | return apply_filters( 'wp_get_current_commenter', compact( 'comment_author', 'comment_author_email', 'comment_author_url' ) ); |
| 1789 | return apply_filters( 'wp_get_current_commenter', $comment_author_data ); |
1769 | 1790 | } |
1770 | 1791 | |
1771 | 1792 | /** |
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 39de147..010334a 100644
a
|
b
|
function wp_removable_query_args() { |
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
| 1045 | * Removes query variables used to provide user feedbacks from the current URL. |
| 1046 | * |
| 1047 | * @since 4.9.9 |
| 1048 | * |
| 1049 | * @param string $canonical_id The canonical URL link tag's id attribute. |
| 1050 | */ |
| 1051 | function wp_remove_feedback_query_args( $canonical_id = 'wp-canonical' ) { |
| 1052 | $query_args = array(); |
| 1053 | |
| 1054 | if ( ! is_admin() ) { |
| 1055 | $query_args = wp_parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY ); |
| 1056 | |
| 1057 | if ( ! $query_args ) { |
| 1058 | return; |
| 1059 | } else { |
| 1060 | $query_args = wp_parse_args( $query_args, array() ); |
| 1061 | |
| 1062 | if ( ! isset( $query_args['unapproved'] ) ) { |
| 1063 | return; |
| 1064 | } |
| 1065 | |
| 1066 | // Remove the reserved query var key without altering the others. |
| 1067 | $query_args = array_diff_key( $query_args, array_flip( array( |
| 1068 | 'unapproved', |
| 1069 | 'moderation-hash', |
| 1070 | ) ) ); |
| 1071 | } |
| 1072 | } |
| 1073 | printf( ' |
| 1074 | <script> |
| 1075 | var canonicalUrl = document.getElementById( \'%1$s\' ).href.split( \'#\' )[0], |
| 1076 | qv = %2$s; |
| 1077 | |
| 1078 | if ( \'object\' === typeof qv && undefined === qv.length ) { |
| 1079 | canonicalUrl += \'?\' + Object.keys( qv ).map( k => k + \'=\' + qv[k] ).join( \'&\' ); |
| 1080 | } |
| 1081 | |
| 1082 | if ( window.history.replaceState ) { |
| 1083 | window.history.replaceState( null, null, canonicalUrl + window.location.hash ); |
| 1084 | } |
| 1085 | </script> |
| 1086 | ', $canonical_id, json_encode( $query_args ) ); |
| 1087 | } |
| 1088 | |
| 1089 | /** |
1045 | 1090 | * Walks the array while sanitizing the contents. |
1046 | 1091 | * |
1047 | 1092 | * @since 0.71 |
diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php
index 0e746be..0fb5aa1 100644
a
|
b
|
function rel_canonical() { |
3740 | 3740 | $url = wp_get_canonical_url( $id ); |
3741 | 3741 | |
3742 | 3742 | if ( ! empty( $url ) ) { |
3743 | | echo '<link rel="canonical" href="' . esc_url( $url ) . '" />' . "\n"; |
| 3743 | echo '<link id="wp-canonical" rel="canonical" href="' . esc_url( $url ) . '" />' . "\n"; |
| 3744 | wp_remove_feedback_query_args(); |
3744 | 3745 | } |
3745 | 3746 | } |
3746 | 3747 | |