diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/comment-template.php
--- a/wp/wp-includes/comment-template.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-includes/comment-template.php Mon Oct 14 18:28:13 2019 +0200
@@ -18,17 +18,18 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author.
- * Default current comment.
+ * Default current comment.
* @return string The comment author
*/
function get_comment_author( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
if ( empty( $comment->comment_author ) ) {
- if ( $comment->user_id && $user = get_userdata( $comment->user_id ) )
+ if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) {
$author = $user->display_name;
- else
- $author = __('Anonymous');
+ } else {
+ $author = __( 'Anonymous' );
+ }
} else {
$author = $comment->comment_author;
}
@@ -53,7 +54,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author.
- * Default current comment.
+ * Default current comment.
*/
function comment_author( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
@@ -78,7 +79,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email.
- * Default current comment.
+ * Default current comment.
* @return string The current comment author's email
*/
function get_comment_author_email( $comment_ID = 0 ) {
@@ -101,7 +102,7 @@
* Display the email of the author of the current global $comment.
*
* Care should be taken to protect the email address and assure that email
- * harvesters do not capture your commentors' email address. Most assume that
+ * harvesters do not capture your commenter's email address. Most assume that
* their email address will not appear in raw form on the site. Doing so will
* enable anyone, including those that people don't want to get the email
* address and use it for their own means good and bad.
@@ -110,7 +111,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email.
- * Default current comment.
+ * Default current comment.
*/
function comment_author_email( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
@@ -132,7 +133,7 @@
* Display the html email link to the author of the current comment.
*
* Care should be taken to protect the email address and assure that email
- * harvesters do not capture your commentors' email address. Most assume that
+ * harvesters do not capture your commenter's email address. Most assume that
* their email address will not appear in raw form on the site. Doing so will
* enable anyone, including those that people don't want to get the email
* address and use it for their own means good and bad.
@@ -156,7 +157,7 @@
* Return the html email link to the author of the current comment.
*
* Care should be taken to protect the email address and assure that email
- * harvesters do not capture your commentors' email address. Most assume that
+ * harvesters do not capture your commenter's email address. Most assume that
* their email address will not appear in raw form on the site. Doing so will
* enable anyone, including those that people don't want to get the email
* address and use it for their own means good and bad.
@@ -189,11 +190,11 @@
*/
$email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
- if ((!empty($email)) && ($email != '@')) {
- $display = ($linktext != '') ? $linktext : $email;
+ if ( ( ! empty( $email ) ) && ( $email != '@' ) ) {
+ $display = ( $linktext != '' ) ? $linktext : $email;
$return = $before;
$return .= sprintf( '%2$s', esc_url( 'mailto:' . $email ), esc_html( $display ) );
- $return .= $after;
+ $return .= $after;
return $return;
} else {
return '';
@@ -210,7 +211,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link.
- * Default current comment.
+ * Default current comment.
* @return string The comment author name or HTML link for author's URL.
*/
function get_comment_author_link( $comment_ID = 0 ) {
@@ -218,10 +219,11 @@
$url = get_comment_author_url( $comment );
$author = get_comment_author( $comment );
- if ( empty( $url ) || 'http://' == $url )
+ if ( empty( $url ) || 'http://' == $url ) {
$return = $author;
- else
+ } else {
$return = "$author";
+ }
/**
* Filters the comment author's link for display.
@@ -244,7 +246,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link.
- * Default current comment.
+ * Default current comment.
*/
function comment_author_link( $comment_ID = 0 ) {
echo get_comment_author_link( $comment_ID );
@@ -257,7 +259,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address.
- * Default current comment.
+ * Default current comment.
* @return string Comment author's IP address.
*/
function get_comment_author_IP( $comment_ID = 0 ) {
@@ -283,7 +285,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address.
- * Default current comment.
+ * Default current comment.
*/
function comment_author_IP( $comment_ID = 0 ) {
echo esc_html( get_comment_author_IP( $comment_ID ) );
@@ -296,17 +298,17 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL.
- * Default current comment.
+ * Default current comment.
* @return string Comment author URL.
*/
function get_comment_author_url( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
- $url = '';
- $id = 0;
+ $url = '';
+ $id = 0;
if ( ! empty( $comment ) ) {
$author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url;
- $url = esc_url( $author_url, array( 'http', 'https' ) );
- $id = $comment->comment_ID;
+ $url = esc_url( $author_url, array( 'http', 'https' ) );
+ $id = $comment->comment_ID;
}
/**
@@ -329,7 +331,7 @@
* @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
*
* @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL.
- * Default current comment.
+ * Default current comment.
*/
function comment_author_url( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
@@ -371,13 +373,13 @@
* @return string The HTML link between the $before and $after parameters.
*/
function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) {
- $url = get_comment_author_url( $comment );
- $display = ($linktext != '') ? $linktext : $url;
+ $url = get_comment_author_url( $comment );
+ $display = ( $linktext != '' ) ? $linktext : $url;
$display = str_replace( 'http://www.', '', $display );
$display = str_replace( 'http://', '', $display );
- if ( '/' == substr($display, -1) ) {
- $display = substr($display, 0, -1);
+ if ( '/' == substr( $display, -1 ) ) {
+ $display = substr( $display, 0, -1 );
}
$return = "$before$display$after";
@@ -428,10 +430,11 @@
function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) {
// Separates classes with a single space, collates classes for comment DIV
$class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';
- if ( $echo)
+ if ( $echo ) {
echo $class;
- else
+ } else {
return $class;
+ }
}
/**
@@ -467,19 +470,22 @@
$classes[] = 'byuser';
$classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
// For comment authors who are the author of the post
- if ( $post = get_post($post_id) ) {
+ if ( $post = get_post( $post_id ) ) {
if ( $comment->user_id === $post->post_author ) {
$classes[] = 'bypostauthor';
}
}
}
- if ( empty($comment_alt) )
+ if ( empty( $comment_alt ) ) {
$comment_alt = 0;
- if ( empty($comment_depth) )
+ }
+ if ( empty( $comment_depth ) ) {
$comment_depth = 1;
- if ( empty($comment_thread_alt) )
+ }
+ if ( empty( $comment_thread_alt ) ) {
$comment_thread_alt = 0;
+ }
if ( $comment_alt % 2 ) {
$classes[] = 'odd';
@@ -503,20 +509,21 @@
$classes[] = "depth-$comment_depth";
- if ( !empty($class) ) {
- if ( !is_array( $class ) )
- $class = preg_split('#\s+#', $class);
- $classes = array_merge($classes, $class);
+ if ( ! empty( $class ) ) {
+ if ( ! is_array( $class ) ) {
+ $class = preg_split( '#\s+#', $class );
+ }
+ $classes = array_merge( $classes, $class );
}
- $classes = array_map('esc_attr', $classes);
+ $classes = array_map( 'esc_attr', $classes );
/**
* Filters the returned CSS classes for the current comment.
*
* @since 2.7.0
*
- * @param array $classes An array of comment classes.
+ * @param string[] $classes An array of comment classes.
* @param string $class A comma-separated list of additional classes added to the list.
* @param int $comment_id The comment id.
* @param WP_Comment $comment The comment object.
@@ -538,10 +545,11 @@
*/
function get_comment_date( $d = '', $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
- if ( '' == $d )
- $date = mysql2date(get_option('date_format'), $comment->comment_date);
- else
- $date = mysql2date($d, $comment->comment_date);
+ if ( '' == $d ) {
+ $date = mysql2date( get_option( 'date_format' ), $comment->comment_date );
+ } else {
+ $date = mysql2date( $d, $comment->comment_date );
+ }
/**
* Filters the returned comment date.
*
@@ -583,9 +591,9 @@
* @return string The maybe truncated comment with 20 words or less.
*/
function get_comment_excerpt( $comment_ID = 0 ) {
- $comment = get_comment( $comment_ID );
+ $comment = get_comment( $comment_ID );
$comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
- $words = explode( ' ', $comment_text );
+ $words = explode( ' ', $comment_text );
/**
* Filters the amount of words used in the comment excerpt.
@@ -702,7 +710,7 @@
function get_comment_link( $comment = null, $args = array() ) {
global $wp_rewrite, $in_comment_loop;
- $comment = get_comment($comment);
+ $comment = get_comment( $comment );
// Back-compat.
if ( ! is_array( $args ) ) {
@@ -716,7 +724,7 @@
'max_depth' => '',
'cpage' => null,
);
- $args = wp_parse_args( $args, $defaults );
+ $args = wp_parse_args( $args, $defaults );
$link = get_permalink( $comment->comment_post_ID );
@@ -724,15 +732,15 @@
if ( ! is_null( $args['cpage'] ) ) {
$cpage = $args['cpage'];
- // No 'cpage' is provided, so we calculate one.
+ // No 'cpage' is provided, so we calculate one.
} else {
if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) {
- $args['per_page'] = get_option('comments_per_page');
+ $args['per_page'] = get_option( 'comments_per_page' );
}
if ( empty( $args['per_page'] ) ) {
$args['per_page'] = 0;
- $args['page'] = 0;
+ $args['page'] = 0;
}
$cpage = $args['page'];
@@ -765,7 +773,6 @@
} elseif ( $cpage ) {
$link = add_query_arg( 'cpage', $cpage, $link );
}
-
}
if ( $wp_rewrite->using_permalinks() ) {
@@ -799,7 +806,7 @@
* @return string The link to the comments.
*/
function get_comments_link( $post_id = 0 ) {
- $hash = get_comments_number( $post_id ) ? '#comments' : '#respond';
+ $hash = get_comments_number( $post_id ) ? '#comments' : '#respond';
$comments_link = get_permalink( $post_id ) . $hash;
/**
@@ -822,10 +829,12 @@
* @param string $deprecated_2 Not Used.
*/
function comments_link( $deprecated = '', $deprecated_2 = '' ) {
- if ( !empty( $deprecated ) )
+ if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '0.72' );
- if ( !empty( $deprecated_2 ) )
+ }
+ if ( ! empty( $deprecated_2 ) ) {
_deprecated_argument( __FUNCTION__, '1.3.0' );
+ }
echo esc_url( get_comments_link() );
}
@@ -844,7 +853,7 @@
if ( ! $post ) {
$count = 0;
} else {
- $count = $post->comment_count;
+ $count = $post->comment_count;
$post_id = $post->ID;
}
@@ -1011,10 +1020,11 @@
$comment = get_comment();
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
- if ( '' == $d )
- $date = mysql2date(get_option('time_format'), $comment_date, $translate);
- else
- $date = mysql2date($d, $comment_date, $translate);
+ if ( '' == $d ) {
+ $date = mysql2date( get_option( 'time_format' ), $comment_date, $translate );
+ } else {
+ $date = mysql2date( $d, $comment_date, $translate );
+ }
/**
* Filters the returned comment time.
@@ -1038,7 +1048,7 @@
* @param string $d Optional. The format of the time. Default user's settings.
*/
function comment_time( $d = '' ) {
- echo get_comment_time($d);
+ echo get_comment_time( $d );
}
/**
@@ -1053,8 +1063,9 @@
*/
function get_comment_type( $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
- if ( '' == $comment->comment_type )
+ if ( '' == $comment->comment_type ) {
$comment->comment_type = 'comment';
+ }
/**
* Filters the returned comment type.
@@ -1063,7 +1074,7 @@
* @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
*
* @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
- * @param int $comment_ID The comment ID.
+ * @param int $comment_ID The comment ID.
* @param WP_Comment $comment The comment object.
*/
return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
@@ -1079,18 +1090,24 @@
* @param string $pingbacktxt Optional. String to display for pingback type. Default false.
*/
function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
- if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
- if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
- if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
+ if ( false === $commenttxt ) {
+ $commenttxt = _x( 'Comment', 'noun' );
+ }
+ if ( false === $trackbacktxt ) {
+ $trackbacktxt = __( 'Trackback' );
+ }
+ if ( false === $pingbacktxt ) {
+ $pingbacktxt = __( 'Pingback' );
+ }
$type = get_comment_type();
- switch( $type ) {
- case 'trackback' :
+ switch ( $type ) {
+ case 'trackback':
echo $trackbacktxt;
break;
- case 'pingback' :
+ case 'pingback':
echo $pingbacktxt;
break;
- default :
+ default:
echo $commenttxt;
}
}
@@ -1107,10 +1124,11 @@
* @return string The trackback URL after being filtered.
*/
function get_trackback_url() {
- if ( '' != get_option('permalink_structure') )
- $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
- else
- $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
+ if ( '' != get_option( 'permalink_structure' ) ) {
+ $tb_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' );
+ } else {
+ $tb_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID();
+ }
/**
* Filters the returned trackback URL.
@@ -1133,9 +1151,12 @@
*/
function trackback_url( $deprecated_echo = true ) {
if ( true !== $deprecated_echo ) {
- _deprecated_argument( __FUNCTION__, '2.5.0',
+ _deprecated_argument(
+ __FUNCTION__,
+ '2.5.0',
/* translators: %s: get_trackback_url() */
- sprintf( __( 'Use %s instead if you do not want the value echoed.' ),
+ sprintf(
+ __( 'Use %s instead if you do not want the value echoed.' ),
'get_trackback_url()
'
)
);
@@ -1171,17 +1192,21 @@
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
' . + 'email' => '
' . '
', - 'url' => '' . + 'url' => '
' . '
', ); @@ -2223,29 +2302,29 @@ * * @since 3.0.0 * - * @param array $fields The default comment fields. + * @param string[] $fields Array of the default comment fields. */ - $fields = apply_filters( 'comment_form_default_fields', $fields ); + $fields = apply_filters( 'comment_form_default_fields', $fields ); $defaults = array( 'fields' => $fields, 'comment_field' => '', /** This filter is documented in wp-includes/link-template.php */ 'must_log_in' => '
' . sprintf( - /* translators: %s: login URL */ - __( 'You must be logged in to post a comment.' ), - wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) - ) . '
', + /* translators: %s: login URL */ + __( 'You must be logged in to post a comment.' ), + wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) + ) . '', /** This filter is documented in wp-includes/link-template.php */ 'logged_in_as' => '' . sprintf( - /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ - __( 'Logged in as %3$s. Log out?' ), - get_edit_user_link(), - /* translators: %s: user name */ - esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), - $user_identity, - wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) - ) . '
', - 'comment_notes_before' => '' . __( 'Your email address will not be published.' ) . ''. ( $req ? $required_text : '' ) . '
', + /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ + __( 'Logged in as %3$s. Log out?' ), + get_edit_user_link(), + /* translators: %s: user name */ + esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), + $user_identity, + wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) + ) . '', + 'comment_notes_before' => '' . __( 'Your email address will not be published.' ) . '' . ( $req ? $required_text : '' ) . '
', 'comment_notes_after' => '', 'action' => site_url( '/wp-comments-post.php' ), 'id_form' => 'commentform', @@ -2301,7 +2380,7 @@ echo $args['title_reply_after']; - if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : + if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) : echo $args['must_log_in']; /** * Fires after the HTML-formatted 'must log in after' message in the comment form. @@ -2309,7 +2388,8 @@ * @since 3.0.0 */ do_action( 'comment_form_must_log_in_after' ); - else : ?> + else : + ?>