wp/wp-includes/class-walker-comment.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    28 
    28 
    29 	/**
    29 	/**
    30 	 * Database fields to use.
    30 	 * Database fields to use.
    31 	 *
    31 	 *
    32 	 * @since 2.7.0
    32 	 * @since 2.7.0
    33 	 * @var array
    33 	 * @var string[]
    34 	 *
    34 	 *
    35 	 * @see Walker::$db_fields
    35 	 * @see Walker::$db_fields
    36 	 * @todo Decouple this
    36 	 * @todo Decouple this
    37 	 */
    37 	 */
    38 	public $db_fields = array(
    38 	public $db_fields = array(
   155 
   155 
   156 	/**
   156 	/**
   157 	 * Starts the element output.
   157 	 * Starts the element output.
   158 	 *
   158 	 *
   159 	 * @since 2.7.0
   159 	 * @since 2.7.0
       
   160 	 * @since 5.9.0 Renamed `$comment` to `$data_object` and `$id` to `$current_object_id`
       
   161 	 *              to match parent class for PHP 8 named parameter support.
   160 	 *
   162 	 *
   161 	 * @see Walker::start_el()
   163 	 * @see Walker::start_el()
   162 	 * @see wp_list_comments()
   164 	 * @see wp_list_comments()
   163 	 * @global int        $comment_depth
   165 	 * @global int        $comment_depth
   164 	 * @global WP_Comment $comment       Global comment object.
   166 	 * @global WP_Comment $comment       Global comment object.
   165 	 *
   167 	 *
   166 	 * @param string     $output  Used to append additional content. Passed by reference.
   168 	 * @param string     $output            Used to append additional content. Passed by reference.
   167 	 * @param WP_Comment $comment Comment data object.
   169 	 * @param WP_Comment $data_object       Comment data object.
   168 	 * @param int        $depth   Optional. Depth of the current comment in reference to parents. Default 0.
   170 	 * @param int        $depth             Optional. Depth of the current comment in reference to parents. Default 0.
   169 	 * @param array      $args    Optional. An array of arguments. Default empty array.
   171 	 * @param array      $args              Optional. An array of arguments. Default empty array.
   170 	 * @param int        $id      Optional. ID of the current comment. Default 0 (unused).
   172 	 * @param int        $current_object_id Optional. ID of the current comment. Default 0.
   171 	 */
   173 	 */
   172 	public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
   174 	public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {
       
   175 		// Restores the more descriptive, specific name for use within this method.
       
   176 		$comment = $data_object;
       
   177 
   173 		$depth++;
   178 		$depth++;
   174 		$GLOBALS['comment_depth'] = $depth;
   179 		$GLOBALS['comment_depth'] = $depth;
   175 		$GLOBALS['comment']       = $comment;
   180 		$GLOBALS['comment']       = $comment;
   176 
   181 
   177 		if ( ! empty( $args['callback'] ) ) {
   182 		if ( ! empty( $args['callback'] ) ) {
   206 
   211 
   207 	/**
   212 	/**
   208 	 * Ends the element output, if needed.
   213 	 * Ends the element output, if needed.
   209 	 *
   214 	 *
   210 	 * @since 2.7.0
   215 	 * @since 2.7.0
       
   216 	 * @since 5.9.0 Renamed `$comment` to `$data_object` to match parent class for PHP 8 named parameter support.
   211 	 *
   217 	 *
   212 	 * @see Walker::end_el()
   218 	 * @see Walker::end_el()
   213 	 * @see wp_list_comments()
   219 	 * @see wp_list_comments()
   214 	 *
   220 	 *
   215 	 * @param string     $output  Used to append additional content. Passed by reference.
   221 	 * @param string     $output      Used to append additional content. Passed by reference.
   216 	 * @param WP_Comment $comment The current comment object. Default current comment.
   222 	 * @param WP_Comment $data_object Comment data object.
   217 	 * @param int        $depth   Optional. Depth of the current comment. Default 0.
   223 	 * @param int        $depth       Optional. Depth of the current comment. Default 0.
   218 	 * @param array      $args    Optional. An array of arguments. Default empty array.
   224 	 * @param array      $args        Optional. An array of arguments. Default empty array.
   219 	 */
   225 	 */
   220 	public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
   226 	public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
   221 		if ( ! empty( $args['end-callback'] ) ) {
   227 		if ( ! empty( $args['end-callback'] ) ) {
   222 			ob_start();
   228 			ob_start();
   223 			call_user_func( $args['end-callback'], $comment, $args, $depth );
   229 			call_user_func(
       
   230 				$args['end-callback'],
       
   231 				$data_object, // The current comment object.
       
   232 				$args,
       
   233 				$depth
       
   234 			);
   224 			$output .= ob_get_clean();
   235 			$output .= ob_get_clean();
   225 			return;
   236 			return;
   226 		}
   237 		}
   227 		if ( 'div' === $args['style'] ) {
   238 		if ( 'div' === $args['style'] ) {
   228 			$output .= "</div><!-- #comment-## -->\n";
   239 			$output .= "</div><!-- #comment-## -->\n";