2015-09-09 04:41:24 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2015-09-22 15:43:25 +02:00
|
|
|
* Comment API: Walker_Comment class
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Comments
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2016-03-22 18:36:26 +01:00
|
|
|
* Core walker class used to create an HTML list of comments.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 2.7.0
|
2016-03-22 18:34:25 +01:00
|
|
|
*
|
|
|
|
* @see Walker
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
|
|
|
class Walker_Comment extends Walker {
|
2016-03-22 18:34:25 +01:00
|
|
|
|
2015-09-09 04:41:24 +02:00
|
|
|
/**
|
|
|
|
* What the class handles.
|
|
|
|
*
|
|
|
|
* @since 2.7.0
|
|
|
|
* @var string
|
2016-03-22 18:34:25 +01:00
|
|
|
*
|
|
|
|
* @see Walker::$tree_type
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
|
|
|
public $tree_type = 'comment';
|
|
|
|
|
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Database fields to use.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 2.7.0
|
|
|
|
* @var array
|
2016-03-22 18:34:25 +01:00
|
|
|
*
|
|
|
|
* @see Walker::$db_fields
|
|
|
|
* @todo Decouple this
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
public $db_fields = array(
|
|
|
|
'parent' => 'comment_parent',
|
|
|
|
'id' => 'comment_ID',
|
|
|
|
);
|
2015-09-09 04:41:24 +02:00
|
|
|
|
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Starts the list before the elements are added.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 2.7.0
|
|
|
|
*
|
2016-03-22 18:34:25 +01:00
|
|
|
* @see Walker::start_lvl()
|
2015-09-09 04:41:24 +02:00
|
|
|
* @global int $comment_depth
|
|
|
|
*
|
2017-10-03 00:14:46 +02:00
|
|
|
* @param string $output Used to append additional content (passed by reference).
|
2016-03-22 18:41:27 +01:00
|
|
|
* @param int $depth Optional. Depth of the current comment. Default 0.
|
|
|
|
* @param array $args Optional. Uses 'style' argument for type of HTML list. Default empty array.
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
|
|
|
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
|
|
|
$GLOBALS['comment_depth'] = $depth + 1;
|
|
|
|
|
|
|
|
switch ( $args['style'] ) {
|
|
|
|
case 'div':
|
|
|
|
break;
|
|
|
|
case 'ol':
|
|
|
|
$output .= '<ol class="children">' . "\n";
|
|
|
|
break;
|
|
|
|
case 'ul':
|
|
|
|
default:
|
|
|
|
$output .= '<ul class="children">' . "\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Ends the list of items after the elements are added.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 2.7.0
|
|
|
|
*
|
2016-03-22 18:34:25 +01:00
|
|
|
* @see Walker::end_lvl()
|
2015-09-09 04:41:24 +02:00
|
|
|
* @global int $comment_depth
|
|
|
|
*
|
2017-10-03 00:14:46 +02:00
|
|
|
* @param string $output Used to append additional content (passed by reference).
|
2016-03-22 18:41:27 +01:00
|
|
|
* @param int $depth Optional. Depth of the current comment. Default 0.
|
|
|
|
* @param array $args Optional. Will only append content if style argument value is 'ol' or 'ul'.
|
|
|
|
* Default empty array.
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
|
|
|
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
|
|
|
$GLOBALS['comment_depth'] = $depth + 1;
|
|
|
|
|
|
|
|
switch ( $args['style'] ) {
|
|
|
|
case 'div':
|
|
|
|
break;
|
|
|
|
case 'ol':
|
|
|
|
$output .= "</ol><!-- .children -->\n";
|
|
|
|
break;
|
|
|
|
case 'ul':
|
|
|
|
default:
|
|
|
|
$output .= "</ul><!-- .children -->\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Traverses elements to create list from elements.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* This function is designed to enhance Walker::display_element() to
|
|
|
|
* display children of higher nesting levels than selected inline on
|
|
|
|
* the highest depth level displayed. This prevents them being orphaned
|
|
|
|
* at the end of the comment list.
|
|
|
|
*
|
|
|
|
* Example: max_depth = 2, with 5 levels of nested content.
|
2015-10-09 23:00:27 +02:00
|
|
|
* 1
|
|
|
|
* 1.1
|
|
|
|
* 1.1.1
|
|
|
|
* 1.1.1.1
|
|
|
|
* 1.1.1.1.1
|
|
|
|
* 1.1.2
|
|
|
|
* 1.1.2.1
|
|
|
|
* 2
|
|
|
|
* 2.2
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
2016-03-22 18:34:25 +01:00
|
|
|
* @since 2.7.0
|
|
|
|
*
|
2015-09-09 04:41:24 +02:00
|
|
|
* @see Walker::display_element()
|
|
|
|
* @see wp_list_comments()
|
|
|
|
*
|
2016-03-22 18:46:27 +01:00
|
|
|
* @param WP_Comment $element Comment data object.
|
|
|
|
* @param array $children_elements List of elements to continue traversing. Passed by reference.
|
|
|
|
* @param int $max_depth Max depth to traverse.
|
|
|
|
* @param int $depth Depth of the current element.
|
|
|
|
* @param array $args An array of arguments.
|
|
|
|
* @param string $output Used to append additional content. Passed by reference.
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
|
|
|
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $element ) {
|
2015-09-09 04:41:24 +02:00
|
|
|
return;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2015-09-09 04:41:24 +02:00
|
|
|
|
|
|
|
$id_field = $this->db_fields['id'];
|
2017-12-01 00:11:00 +01:00
|
|
|
$id = $element->$id_field;
|
2015-09-09 04:41:24 +02:00
|
|
|
|
|
|
|
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
|
|
|
|
2015-10-09 23:03:25 +02:00
|
|
|
/*
|
2016-03-22 18:41:27 +01:00
|
|
|
* If at the max depth, and the current element still has children, loop over those
|
|
|
|
* and display them at this level. This is to prevent them being orphaned to the end
|
|
|
|
* of the list.
|
2015-10-09 23:03:25 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $max_depth <= $depth + 1 && isset( $children_elements[ $id ] ) ) {
|
|
|
|
foreach ( $children_elements[ $id ] as $child ) {
|
2015-09-09 04:41:24 +02:00
|
|
|
$this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output );
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2015-09-09 04:41:24 +02:00
|
|
|
|
|
|
|
unset( $children_elements[ $id ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Starts the element output.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 2.7.0
|
Code Modernization: Fix last parameter name mismatches for parent/child classes in `Walker::start_el()`.
The parent class uses `$current_object_id` while most of the child classes use `$id`. As the parent class' is more descriptive, renaming the last parameter in each of child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
- In cases where the original parameter name was too generic or misleading, renamed (when reassigning) to a more descriptive name for use within the method.
Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189], [51739].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51779
git-svn-id: http://core.svn.wordpress.org/trunk@51386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 14:39:59 +02:00
|
|
|
* @since 5.9.0 Renamed `$comment` to `$data_object` and `$id` to `$current_object_id`
|
|
|
|
* to match parent class for PHP 8 named parameter support.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @see Walker::start_el()
|
|
|
|
* @see wp_list_comments()
|
2015-10-10 17:45:25 +02:00
|
|
|
* @global int $comment_depth
|
2019-10-05 00:19:57 +02:00
|
|
|
* @global WP_Comment $comment Global comment object.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
Code Modernization: Fix last parameter name mismatches for parent/child classes in `Walker::start_el()`.
The parent class uses `$current_object_id` while most of the child classes use `$id`. As the parent class' is more descriptive, renaming the last parameter in each of child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
- In cases where the original parameter name was too generic or misleading, renamed (when reassigning) to a more descriptive name for use within the method.
Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189], [51739].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51779
git-svn-id: http://core.svn.wordpress.org/trunk@51386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 14:39:59 +02:00
|
|
|
* @param string $output Used to append additional content. Passed by reference.
|
|
|
|
* @param WP_Comment $data_object Comment data object.
|
|
|
|
* @param int $depth Optional. Depth of the current comment in reference to parents. Default 0.
|
|
|
|
* @param array $args Optional. An array of arguments. Default empty array.
|
|
|
|
* @param int $current_object_id Optional. ID of the current comment. Default 0.
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
Code Modernization: Fix last parameter name mismatches for parent/child classes in `Walker::start_el()`.
The parent class uses `$current_object_id` while most of the child classes use `$id`. As the parent class' is more descriptive, renaming the last parameter in each of child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
- In cases where the original parameter name was too generic or misleading, renamed (when reassigning) to a more descriptive name for use within the method.
Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189], [51739].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51779
git-svn-id: http://core.svn.wordpress.org/trunk@51386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 14:39:59 +02:00
|
|
|
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::start_el()`.
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword.
In each child class: renames the corresponding parameter to match the parent's method signature.
Why?
PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
- in cases where the original parameter name was too generic, renamed (when reassigning) to a more descriptive name for use within the method.
Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51739
git-svn-id: http://core.svn.wordpress.org/trunk@51347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 17:36:59 +02:00
|
|
|
// Restores the more descriptive, specific name for use within this method.
|
|
|
|
$comment = $data_object;
|
|
|
|
|
2015-09-09 04:41:24 +02:00
|
|
|
$depth++;
|
|
|
|
$GLOBALS['comment_depth'] = $depth;
|
2017-12-01 00:11:00 +01:00
|
|
|
$GLOBALS['comment'] = $comment;
|
2015-09-09 04:41:24 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! empty( $args['callback'] ) ) {
|
2015-09-09 04:41:24 +02:00
|
|
|
ob_start();
|
|
|
|
call_user_func( $args['callback'], $comment, $args, $depth );
|
|
|
|
$output .= ob_get_clean();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
if ( 'comment' === $comment->comment_type ) {
|
2020-06-02 23:45:10 +02:00
|
|
|
add_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40, 2 );
|
2020-06-02 22:12:07 +02:00
|
|
|
}
|
|
|
|
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) && $args['short_ping'] ) {
|
2015-09-09 04:41:24 +02:00
|
|
|
ob_start();
|
|
|
|
$this->ping( $comment, $depth, $args );
|
|
|
|
$output .= ob_get_clean();
|
|
|
|
} elseif ( 'html5' === $args['format'] ) {
|
|
|
|
ob_start();
|
|
|
|
$this->html5_comment( $comment, $depth, $args );
|
|
|
|
$output .= ob_get_clean();
|
|
|
|
} else {
|
|
|
|
ob_start();
|
|
|
|
$this->comment( $comment, $depth, $args );
|
|
|
|
$output .= ob_get_clean();
|
|
|
|
}
|
2020-06-02 22:12:07 +02:00
|
|
|
|
|
|
|
if ( 'comment' === $comment->comment_type ) {
|
2021-05-05 20:54:57 +02:00
|
|
|
remove_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40 );
|
2020-06-02 22:12:07 +02:00
|
|
|
}
|
2015-09-09 04:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ends the element output, if needed.
|
|
|
|
*
|
|
|
|
* @since 2.7.0
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::end_el()`.
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51780
git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:03:55 +02:00
|
|
|
* @since 5.9.0 Renamed `$comment` to `$data_object` to match parent class for PHP 8 named parameter support.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @see Walker::end_el()
|
|
|
|
* @see wp_list_comments()
|
|
|
|
*
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::end_el()`.
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51780
git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:03:55 +02:00
|
|
|
* @param string $output Used to append additional content. Passed by reference.
|
|
|
|
* @param WP_Comment $data_object Comment data object.
|
|
|
|
* @param int $depth Optional. Depth of the current comment. Default 0.
|
|
|
|
* @param array $args Optional. An array of arguments. Default empty array.
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::end_el()`.
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51780
git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:03:55 +02:00
|
|
|
public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! empty( $args['end-callback'] ) ) {
|
2015-09-09 04:41:24 +02:00
|
|
|
ob_start();
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::end_el()`.
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51780
git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:03:55 +02:00
|
|
|
call_user_func(
|
|
|
|
$args['end-callback'],
|
|
|
|
$data_object, // The current comment object.
|
|
|
|
$args,
|
|
|
|
$depth
|
|
|
|
);
|
2015-09-09 04:41:24 +02:00
|
|
|
$output .= ob_get_clean();
|
|
|
|
return;
|
|
|
|
}
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( 'div' === $args['style'] ) {
|
2015-09-09 04:41:24 +02:00
|
|
|
$output .= "</div><!-- #comment-## -->\n";
|
2017-12-01 00:11:00 +01:00
|
|
|
} else {
|
2015-09-09 04:41:24 +02:00
|
|
|
$output .= "</li><!-- #comment-## -->\n";
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2015-09-09 04:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Outputs a pingback comment.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @see wp_list_comments()
|
|
|
|
*
|
|
|
|
* @param WP_Comment $comment The comment object.
|
2016-03-22 18:41:27 +01:00
|
|
|
* @param int $depth Depth of the current comment.
|
2015-09-09 04:41:24 +02:00
|
|
|
* @param array $args An array of arguments.
|
|
|
|
*/
|
|
|
|
protected function ping( $comment, $depth, $args ) {
|
2020-05-16 20:42:12 +02:00
|
|
|
$tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2015-09-11 08:12:24 +02:00
|
|
|
<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( '', $comment ); ?>>
|
2015-09-09 04:41:24 +02:00
|
|
|
<div class="comment-body">
|
2015-09-11 08:21:25 +02:00
|
|
|
<?php _e( 'Pingback:' ); ?> <?php comment_author_link( $comment ); ?> <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?>
|
2015-09-09 04:41:24 +02:00
|
|
|
</div>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2015-09-09 04:41:24 +02:00
|
|
|
}
|
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
/**
|
2020-06-02 23:45:10 +02:00
|
|
|
* Filters the comment text.
|
|
|
|
*
|
2021-02-17 14:08:05 +01:00
|
|
|
* Removes links from the pending comment's text if the commenter did not consent
|
|
|
|
* to the comment cookies.
|
2020-06-02 22:12:07 +02:00
|
|
|
*
|
|
|
|
* @since 5.4.2
|
|
|
|
*
|
|
|
|
* @param string $comment_text Text of the current comment.
|
2020-06-02 23:45:10 +02:00
|
|
|
* @param WP_Comment|null $comment The comment object. Null if not found.
|
|
|
|
* @return string Filtered text of the current comment.
|
2020-06-02 22:12:07 +02:00
|
|
|
*/
|
2020-06-02 23:45:10 +02:00
|
|
|
public function filter_comment_text( $comment_text, $comment ) {
|
2020-06-02 22:12:07 +02:00
|
|
|
$commenter = wp_get_current_commenter();
|
|
|
|
$show_pending_links = ! empty( $commenter['comment_author'] );
|
|
|
|
|
2020-06-02 23:45:10 +02:00
|
|
|
if ( $comment && '0' == $comment->comment_approved && ! $show_pending_links ) {
|
|
|
|
$comment_text = wp_kses( $comment_text, array() );
|
2020-06-02 22:12:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $comment_text;
|
|
|
|
}
|
|
|
|
|
2015-09-09 04:41:24 +02:00
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Outputs a single comment.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @see wp_list_comments()
|
|
|
|
*
|
2016-03-22 18:44:25 +01:00
|
|
|
* @param WP_Comment $comment Comment to display.
|
2016-03-22 18:46:27 +01:00
|
|
|
* @param int $depth Depth of the current comment.
|
|
|
|
* @param array $args An array of arguments.
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
|
|
|
protected function comment( $comment, $depth, $args ) {
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( 'div' === $args['style'] ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
$tag = 'div';
|
2015-09-09 04:41:24 +02:00
|
|
|
$add_below = 'comment';
|
|
|
|
} else {
|
2017-12-01 00:11:00 +01:00
|
|
|
$tag = 'li';
|
2015-09-09 04:41:24 +02:00
|
|
|
$add_below = 'div-comment';
|
|
|
|
}
|
2019-01-21 23:46:49 +01:00
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
$commenter = wp_get_current_commenter();
|
|
|
|
$show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author'];
|
2021-02-17 14:08:05 +01:00
|
|
|
|
|
|
|
if ( $commenter['comment_author_email'] ) {
|
|
|
|
$moderation_note = __( 'Your comment is awaiting moderation.' );
|
|
|
|
} else {
|
|
|
|
$moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' );
|
|
|
|
}
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2015-09-11 08:12:24 +02:00
|
|
|
<<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?> id="comment-<?php comment_ID(); ?>">
|
2020-05-16 20:42:12 +02:00
|
|
|
<?php if ( 'div' !== $args['style'] ) : ?>
|
2015-09-09 04:41:24 +02:00
|
|
|
<div id="div-comment-<?php comment_ID(); ?>" class="comment-body">
|
|
|
|
<?php endif; ?>
|
|
|
|
<div class="comment-author vcard">
|
2017-12-01 00:11:00 +01:00
|
|
|
<?php
|
|
|
|
if ( 0 != $args['avatar_size'] ) {
|
2020-06-02 22:12:07 +02:00
|
|
|
echo get_avatar( $comment, $args['avatar_size'] );
|
|
|
|
}
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2016-08-24 01:33:28 +02:00
|
|
|
<?php
|
2020-06-02 22:12:07 +02:00
|
|
|
$comment_author = get_comment_author_link( $comment );
|
2020-06-02 23:45:10 +02:00
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
if ( '0' == $comment->comment_approved && ! $show_pending_links ) {
|
|
|
|
$comment_author = get_comment_author( $comment );
|
|
|
|
}
|
2020-06-02 23:45:10 +02:00
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
printf(
|
|
|
|
/* translators: %s: Comment author link. */
|
|
|
|
__( '%s <span class="says">says:</span>' ),
|
|
|
|
sprintf( '<cite class="fn">%s</cite>', $comment_author )
|
|
|
|
);
|
2016-08-24 01:33:28 +02:00
|
|
|
?>
|
2015-09-09 04:41:24 +02:00
|
|
|
</div>
|
2021-02-17 14:08:05 +01:00
|
|
|
<?php if ( '0' == $comment->comment_approved ) : ?>
|
|
|
|
<em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
|
|
|
|
<br />
|
|
|
|
<?php endif; ?>
|
2015-09-09 04:41:24 +02:00
|
|
|
|
2020-10-15 17:07:09 +02:00
|
|
|
<div class="comment-meta commentmetadata">
|
2015-09-09 04:41:24 +02:00
|
|
|
<?php
|
2020-10-15 17:07:09 +02:00
|
|
|
printf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
esc_url( get_comment_link( $comment, $args ) ),
|
|
|
|
sprintf(
|
|
|
|
/* translators: 1: Comment date, 2: Comment time. */
|
|
|
|
__( '%1$s at %2$s' ),
|
|
|
|
get_comment_date( '', $comment ),
|
|
|
|
get_comment_time()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-10-15 17:26:05 +02:00
|
|
|
edit_comment_link( __( '(Edit)' ), ' ', '' );
|
|
|
|
?>
|
2015-09-09 04:41:24 +02:00
|
|
|
</div>
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
<?php
|
|
|
|
comment_text(
|
2018-08-17 03:51:36 +02:00
|
|
|
$comment,
|
|
|
|
array_merge(
|
|
|
|
$args,
|
|
|
|
array(
|
2017-12-01 00:11:00 +01:00
|
|
|
'add_below' => $add_below,
|
|
|
|
'depth' => $depth,
|
|
|
|
'max_depth' => $args['max_depth'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2015-09-09 04:41:24 +02:00
|
|
|
|
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
comment_reply_link(
|
|
|
|
array_merge(
|
2018-08-17 03:51:36 +02:00
|
|
|
$args,
|
|
|
|
array(
|
2017-12-01 00:11:00 +01:00
|
|
|
'add_below' => $add_below,
|
|
|
|
'depth' => $depth,
|
|
|
|
'max_depth' => $args['max_depth'],
|
|
|
|
'before' => '<div class="reply">',
|
|
|
|
'after' => '</div>',
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2015-09-09 04:41:24 +02:00
|
|
|
?>
|
|
|
|
|
2020-05-16 20:42:12 +02:00
|
|
|
<?php if ( 'div' !== $args['style'] ) : ?>
|
2015-09-09 04:41:24 +02:00
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2015-09-09 04:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-22 18:34:25 +01:00
|
|
|
* Outputs a comment in the HTML5 format.
|
2015-09-09 04:41:24 +02:00
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @see wp_list_comments()
|
|
|
|
*
|
2016-03-22 18:44:25 +01:00
|
|
|
* @param WP_Comment $comment Comment to display.
|
2016-03-22 18:46:27 +01:00
|
|
|
* @param int $depth Depth of the current comment.
|
|
|
|
* @param array $args An array of arguments.
|
2015-09-09 04:41:24 +02:00
|
|
|
*/
|
|
|
|
protected function html5_comment( $comment, $depth, $args ) {
|
|
|
|
$tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
|
2019-01-21 23:46:49 +01:00
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
$commenter = wp_get_current_commenter();
|
|
|
|
$show_pending_links = ! empty( $commenter['comment_author'] );
|
2021-02-17 14:08:05 +01:00
|
|
|
|
|
|
|
if ( $commenter['comment_author_email'] ) {
|
|
|
|
$moderation_note = __( 'Your comment is awaiting moderation.' );
|
|
|
|
} else {
|
|
|
|
$moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' );
|
|
|
|
}
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2015-09-11 08:12:24 +02:00
|
|
|
<<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>>
|
2015-09-09 04:41:24 +02:00
|
|
|
<article id="div-comment-<?php comment_ID(); ?>" class="comment-body">
|
|
|
|
<footer class="comment-meta">
|
|
|
|
<div class="comment-author vcard">
|
2017-12-01 00:11:00 +01:00
|
|
|
<?php
|
|
|
|
if ( 0 != $args['avatar_size'] ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
echo get_avatar( $comment, $args['avatar_size'] );
|
|
|
|
}
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2016-08-24 01:33:28 +02:00
|
|
|
<?php
|
2020-06-02 22:12:07 +02:00
|
|
|
$comment_author = get_comment_author_link( $comment );
|
2020-06-02 23:45:10 +02:00
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
if ( '0' == $comment->comment_approved && ! $show_pending_links ) {
|
|
|
|
$comment_author = get_comment_author( $comment );
|
|
|
|
}
|
2020-06-02 23:45:10 +02:00
|
|
|
|
2020-06-02 22:12:07 +02:00
|
|
|
printf(
|
|
|
|
/* translators: %s: Comment author link. */
|
|
|
|
__( '%s <span class="says">says:</span>' ),
|
|
|
|
sprintf( '<b class="fn">%s</b>', $comment_author )
|
|
|
|
);
|
2016-08-24 01:33:28 +02:00
|
|
|
?>
|
2015-09-09 04:41:24 +02:00
|
|
|
</div><!-- .comment-author -->
|
|
|
|
|
|
|
|
<div class="comment-metadata">
|
2020-10-15 17:07:09 +02:00
|
|
|
<?php
|
|
|
|
printf(
|
|
|
|
'<a href="%s"><time datetime="%s">%s</time></a>',
|
|
|
|
esc_url( get_comment_link( $comment, $args ) ),
|
|
|
|
get_comment_time( 'c' ),
|
|
|
|
sprintf(
|
|
|
|
/* translators: 1: Comment date, 2: Comment time. */
|
|
|
|
__( '%1$s at %2$s' ),
|
|
|
|
get_comment_date( '', $comment ),
|
|
|
|
get_comment_time()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-10-15 17:26:05 +02:00
|
|
|
edit_comment_link( __( 'Edit' ), ' <span class="edit-link">', '</span>' );
|
|
|
|
?>
|
2015-09-09 04:41:24 +02:00
|
|
|
</div><!-- .comment-metadata -->
|
|
|
|
|
2021-02-17 14:08:05 +01:00
|
|
|
<?php if ( '0' == $comment->comment_approved ) : ?>
|
|
|
|
<em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
|
|
|
|
<?php endif; ?>
|
2015-09-09 04:41:24 +02:00
|
|
|
</footer><!-- .comment-meta -->
|
|
|
|
|
|
|
|
<div class="comment-content">
|
|
|
|
<?php comment_text(); ?>
|
|
|
|
</div><!-- .comment-content -->
|
|
|
|
|
|
|
|
<?php
|
2020-06-02 22:12:07 +02:00
|
|
|
if ( '1' == $comment->comment_approved || $show_pending_links ) {
|
|
|
|
comment_reply_link(
|
|
|
|
array_merge(
|
|
|
|
$args,
|
|
|
|
array(
|
|
|
|
'add_below' => 'div-comment',
|
|
|
|
'depth' => $depth,
|
|
|
|
'max_depth' => $args['max_depth'],
|
|
|
|
'before' => '<div class="reply">',
|
|
|
|
'after' => '</div>',
|
|
|
|
)
|
2017-12-01 00:11:00 +01:00
|
|
|
)
|
2020-06-02 22:12:07 +02:00
|
|
|
);
|
|
|
|
}
|
2015-09-09 04:41:24 +02:00
|
|
|
?>
|
|
|
|
</article><!-- .comment-body -->
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2015-09-09 04:41:24 +02:00
|
|
|
}
|
|
|
|
}
|