wp/wp-admin/comment.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    34 	} elseif ( 'trash' === $_GET['dt'] ) {
    34 	} elseif ( 'trash' === $_GET['dt'] ) {
    35 		$action = 'trash';
    35 		$action = 'trash';
    36 	}
    36 	}
    37 }
    37 }
    38 
    38 
    39 $comment_id = absint( $_GET['c'] );
    39 if ( isset( $_REQUEST['c'] ) ) {
    40 $comment    = get_comment( $comment_id );
    40 	$comment_id = absint( $_REQUEST['c'] );
    41 
    41 	$comment    = get_comment( $comment_id );
    42 // Prevent actions on a comment associated with a trashed post.
    42 
    43 if ( 'trash' === get_post_status( $comment->comment_post_ID ) ) {
    43 	// Prevent actions on a comment associated with a trashed post.
    44 	wp_die(
    44 	if ( $comment && 'trash' === get_post_status( $comment->comment_post_ID ) ) {
    45 		__( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' )
    45 		wp_die(
    46 	);
    46 			__( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' )
       
    47 		);
       
    48 	}
       
    49 } else {
       
    50 	$comment = null;
    47 }
    51 }
    48 
    52 
    49 switch ( $action ) {
    53 switch ( $action ) {
    50 
    54 
    51 	case 'editcomment':
    55 	case 'editcomment':
   161 		?>
   165 		?>
   162 <div id="message" class="notice notice-warning"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo $caution_msg; ?></p></div>
   166 <div id="message" class="notice notice-warning"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo $caution_msg; ?></p></div>
   163 
   167 
   164 <table class="form-table comment-ays">
   168 <table class="form-table comment-ays">
   165 <tr>
   169 <tr>
   166 <th scope="row"><?php _e( 'Author' ); ?></th>
   170 	<th scope="row"><?php _e( 'Author' ); ?></th>
   167 <td><?php comment_author( $comment ); ?></td>
   171 	<td><?php comment_author( $comment ); ?></td>
   168 </tr>
   172 </tr>
   169 		<?php if ( get_comment_author_email( $comment ) ) { ?>
   173 		<?php if ( get_comment_author_email( $comment ) ) { ?>
   170 <tr>
   174 <tr>
   171 <th scope="row"><?php _e( 'Email' ); ?></th>
   175 	<th scope="row"><?php _e( 'Email' ); ?></th>
   172 <td><?php comment_author_email( $comment ); ?></td>
   176 	<td><?php comment_author_email( $comment ); ?></td>
   173 </tr>
   177 </tr>
   174 <?php } ?>
   178 <?php } ?>
   175 		<?php if ( get_comment_author_url( $comment ) ) { ?>
   179 		<?php if ( get_comment_author_url( $comment ) ) { ?>
   176 <tr>
   180 <tr>
   177 <th scope="row"><?php _e( 'URL' ); ?></th>
   181 	<th scope="row"><?php _e( 'URL' ); ?></th>
   178 <td><a href="<?php comment_author_url( $comment ); ?>"><?php comment_author_url( $comment ); ?></a></td>
   182 	<td><a href="<?php comment_author_url( $comment ); ?>"><?php comment_author_url( $comment ); ?></a></td>
   179 </tr>
   183 </tr>
   180 <?php } ?>
   184 <?php } ?>
   181 <tr>
   185 <tr>
   182 	<th scope="row"><?php /* translators: Column name or table row header. */ _e( 'In response to' ); ?></th>
   186 	<th scope="row"><?php /* translators: Column name or table row header. */ _e( 'In response to' ); ?></th>
   183 	<td>
   187 	<td>
   201 				'<a href="' . $parent_link . '">' . $name . '</a>'
   205 				'<a href="' . $parent_link . '">' . $name . '</a>'
   202 			);
   206 			);
   203 		}
   207 		}
   204 		?>
   208 		?>
   205 	</td>
   209 	</td>
   206 	</tr>
   210 </tr>
   207 	<tr>
   211 <tr>
   208 	<th scope="row"><?php _e( 'Submitted on' ); ?></th>
   212 	<th scope="row"><?php _e( 'Submitted on' ); ?></th>
   209 	<td>
   213 	<td>
   210 		<?php
   214 		<?php
   211 		$submitted = sprintf(
   215 		$submitted = sprintf(
   212 			/* translators: 1: Comment date, 2: Comment time. */
   216 			/* translators: 1: Comment date, 2: Comment time. */
   213 			__( '%1$s at %2$s' ),
   217 			__( '%1$s at %2$s' ),
   214 			/* translators: Comment date format. See https://www.php.net/date */
   218 			/* translators: Comment date format. See https://www.php.net/manual/datetime.format.php */
   215 			get_comment_date( __( 'Y/m/d' ), $comment ),
   219 			get_comment_date( __( 'Y/m/d' ), $comment ),
   216 			/* translators: Comment time format. See https://www.php.net/date */
   220 			/* translators: Comment time format. See https://www.php.net/manual/datetime.format.php */
   217 			get_comment_date( __( 'g:i a' ), $comment )
   221 			get_comment_date( __( 'g:i a' ), $comment )
   218 		);
   222 		);
   219 		if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
   223 		if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
   220 			echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
   224 			echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
   221 		} else {
   225 		} else {
   222 			echo $submitted;
   226 			echo $submitted;
   223 		}
   227 		}
   224 		?>
   228 		?>
   225 		</td>
   229 	</td>
   226 	</tr>
   230 </tr>
   227 	<tr>
   231 <tr>
   228 	<th scope="row"><?php /* translators: Field name in comment form. */ _ex( 'Comment', 'noun' ); ?></th>
   232 	<th scope="row"><?php /* translators: Field name in comment form. */ _ex( 'Comment', 'noun' ); ?></th>
   229 	<td class="comment-content">
   233 	<td class="comment-content">
   230 		<?php comment_text( $comment ); ?>
   234 		<?php comment_text( $comment ); ?>
   231 	<p class="edit-comment"><a href="<?php echo admin_url( "comment.php?action=editcomment&amp;c={$comment->comment_ID}" ); ?>"><?php esc_html_e( 'Edit' ); ?></a></p>
   235 		<p class="edit-comment">
       
   236 			<a href="<?php echo esc_url( admin_url( "comment.php?action=editcomment&c={$comment->comment_ID}" ) ); ?>"><?php esc_html_e( 'Edit' ); ?></a>
       
   237 		</p>
   232 	</td>
   238 	</td>
   233 	</tr>
   239 </tr>
   234 	</table>
   240 </table>
   235 
   241 
   236 	<form action="comment.php" method="get" class="comment-ays-submit">
   242 <form action="comment.php" method="get" class="comment-ays-submit">
   237 
       
   238 	<p>
   243 	<p>
   239 		<?php submit_button( $button, 'primary', 'submit', false ); ?>
   244 		<?php submit_button( $button, 'primary', 'submit', false ); ?>
   240 	<a href="<?php echo admin_url( 'edit-comments.php' ); ?>" class="button-cancel"><?php esc_html_e( 'Cancel' ); ?></a>
   245 		<a href="<?php echo esc_url( admin_url( 'edit-comments.php' ) ); ?>" class="button-cancel"><?php esc_html_e( 'Cancel' ); ?></a>
   241 	</p>
   246 	</p>
   242 
   247 
   243 		<?php wp_nonce_field( $nonce_action ); ?>
   248 		<?php wp_nonce_field( $nonce_action ); ?>
   244 	<input type="hidden" name="action" value="<?php echo esc_attr( $formaction ); ?>" />
   249 	<input type="hidden" name="action" value="<?php echo esc_attr( $formaction ); ?>" />
   245 	<input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
   250 	<input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
   246 	<input type="hidden" name="noredir" value="1" />
   251 	<input type="hidden" name="noredir" value="1" />
   247 	</form>
   252 </form>
   248 
   253 
   249 	</div>
   254 </div>
   250 		<?php
   255 		<?php
   251 		break;
   256 		break;
   252 
   257 
   253 	case 'deletecomment':
   258 	case 'deletecomment':
   254 	case 'trashcomment':
   259 	case 'trashcomment':