| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Edit comment form for inclusion in another file. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 // Don't load directly. 10 if ( ! defined( 'ABSPATH' ) ) { 11 exit; 12 } 13 14 /** 15 * @global WP_Comment $comment Global comment object. 16 */ 17 global $comment; 18 ?> 19 <form name="post" action="comment.php" method="post" id="post"> 20 <?php wp_nonce_field( 'update-comment_' . $comment->comment_ID ); ?> 21 <div class="wrap"> 22 <h1><?php _e( 'Edit Comment' ); ?></h1> 23 24 <div id="poststuff"> 25 <input type="hidden" name="action" value="editedcomment" /> 26 <input type="hidden" name="comment_ID" value="<?php echo esc_attr( $comment->comment_ID ); ?>" /> 27 <input type="hidden" name="comment_post_ID" value="<?php echo esc_attr( $comment->comment_post_ID ); ?>" /> 28 29 <div id="post-body" class="metabox-holder columns-2"> 30 <div id="post-body-content" class="edit-form-section edit-comment-section"> 31 <?php 32 if ( 'approved' === wp_get_comment_status( $comment ) && $comment->comment_post_ID > 0 ) : 33 $comment_link = get_comment_link( $comment ); 34 ?> 35 <div class="inside"> 36 <div id="comment-link-box"> 37 <strong><?php _ex( 'Permalink:', 'comment' ); ?></strong> 38 <span id="sample-permalink"> 39 <a href="<?php echo esc_url( $comment_link ); ?>"> 40 <?php echo esc_html( $comment_link ); ?> 41 </a> 42 </span> 43 </div> 44 </div> 45 <?php endif; ?> 46 <div id="namediv" class="stuffbox"> 47 <div class="inside"> 48 <h2 class="edit-comment-author"><?php _e( 'Author' ); ?></h2> 49 <fieldset> 50 <legend class="screen-reader-text"> 51 <?php 52 /* translators: Hidden accessibility text. */ 53 _e( 'Comment Author' ); 54 ?> 55 </legend> 56 <table class="form-table editcomment" role="presentation"> 57 <tbody> 58 <tr> 59 <td class="first"><label for="name"><?php _e( 'Name' ); ?></label></td> 60 <td><input type="text" name="newcomment_author" size="30" value="<?php echo esc_attr( $comment->comment_author ); ?>" id="name" /></td> 61 </tr> 62 <tr> 63 <td class="first"><label for="email"><?php _e( 'Email' ); ?></label></td> 64 <td> 65 <input type="text" name="newcomment_author_email" size="30" class="code" value="<?php echo esc_attr( $comment->comment_author_email ); ?>" id="email" /> 66 </td> 67 </tr> 68 <tr> 69 <td class="first"><label for="newcomment_author_url"><?php _e( 'URL' ); ?></label></td> 70 <td> 71 <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" class="code" value="<?php echo esc_url( $comment->comment_author_url ); ?>" /> 72 </td> 73 </tr> 74 </tbody> 75 </table> 76 </fieldset> 77 </div> 78 </div> 79 80 <div id="postdiv" class="postarea"> 81 <label for="content" class="screen-reader-text"> 82 <?php 83 /* translators: Hidden accessibility text. */ 84 _e( 'Comment' ); 85 ?> 86 </label> 87 <?php 88 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); 89 wp_editor( 90 $comment->comment_content, 91 'content', 92 array( 93 'media_buttons' => false, 94 'tinymce' => false, 95 'quicktags' => $quicktags_settings, 96 ) 97 ); 98 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 99 ?> 100 </div> 101 </div><!-- /post-body-content --> 102 103 <div id="postbox-container-1" class="postbox-container"> 104 <div id="submitdiv" class="stuffbox" > 105 <h2><?php _e( 'Save' ); ?></h2> 106 <div class="inside"> 107 <div class="submitbox" id="submitcomment"> 108 <div id="minor-publishing"> 109 110 <div id="misc-publishing-actions"> 111 112 <div class="misc-pub-section misc-pub-comment-status" id="comment-status"> 113 <?php _e( 'Status:' ); ?> <span id="comment-status-display"> 114 <?php 115 switch ( $comment->comment_approved ) { 116 case '1': 117 _e( 'Approved' ); 118 break; 119 case '0': 120 _e( 'Pending' ); 121 break; 122 case 'spam': 123 _e( 'Spam' ); 124 break; 125 } 126 ?> 127 </span> 128 129 <fieldset id="comment-status-radio"> 130 <legend class="screen-reader-text"> 131 <?php 132 /* translators: Hidden accessibility text. */ 133 _e( 'Comment status' ); 134 ?> 135 </legend> 136 <label><input type="radio"<?php checked( $comment->comment_approved, '1' ); ?> name="comment_status" value="1" /><?php _ex( 'Approved', 'comment status' ); ?></label><br /> 137 <label><input type="radio"<?php checked( $comment->comment_approved, '0' ); ?> name="comment_status" value="0" /><?php _ex( 'Pending', 'comment status' ); ?></label><br /> 138 <label><input type="radio"<?php checked( $comment->comment_approved, 'spam' ); ?> name="comment_status" value="spam" /><?php _ex( 'Spam', 'comment status' ); ?></label> 139 </fieldset> 140 </div><!-- .misc-pub-section --> 141 142 <div class="misc-pub-section curtime misc-pub-curtime"> 143 <?php 144 $submitted = sprintf( 145 /* translators: 1: Comment date, 2: Comment time. */ 146 __( '%1$s at %2$s' ), 147 /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */ 148 date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $comment->comment_date ) ), 149 /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */ 150 date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $comment->comment_date ) ) 151 ); 152 ?> 153 <span id="timestamp"> 154 <?php 155 /* translators: %s: Comment date. */ 156 printf( __( 'Submitted on: %s' ), '<b>' . $submitted . '</b>' ); 157 ?> 158 </span> 159 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"> 160 <?php 161 /* translators: Hidden accessibility text. */ 162 _e( 'Edit date and time' ); 163 ?> 164 </span></a> 165 <fieldset id='timestampdiv' class='hide-if-js'> 166 <legend class="screen-reader-text"> 167 <?php 168 /* translators: Hidden accessibility text. */ 169 _e( 'Date and time' ); 170 ?> 171 </legend> 172 <?php 173 /** 174 * @global string $action 175 */ 176 global $action; 177 178 touch_time( ( 'editcomment' === $action ), 0 ); 179 ?> 180 </fieldset> 181 </div> 182 183 <?php 184 $post_id = $comment->comment_post_ID; 185 if ( current_user_can( 'edit_post', $post_id ) ) { 186 $post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>"; 187 $post_link .= esc_html( get_the_title( $post_id ) ) . '</a>'; 188 } else { 189 $post_link = esc_html( get_the_title( $post_id ) ); 190 } 191 ?> 192 193 <div class="misc-pub-section misc-pub-response-to"> 194 <?php 195 printf( 196 /* translators: %s: Post link. */ 197 __( 'In response to: %s' ), 198 '<b>' . $post_link . '</b>' 199 ); 200 ?> 201 </div> 202 203 <?php 204 $parent_display = __( 'None' ); 205 206 if ( $comment->comment_parent ) { 207 $parent = get_comment( $comment->comment_parent ); 208 209 if ( $parent ) { 210 $parent_display = sprintf( 211 '<a href="%s">%s</a>', 212 esc_url( get_comment_link( $parent ) ), 213 esc_html( get_comment_author( $parent ) ) 214 ); 215 } 216 } 217 218 // The parent can only be changed when threaded comments are enabled. 219 $comment_threading_enabled = get_option( 'thread_comments' ); 220 221 if ( $comment_threading_enabled ) { 222 $max_thread_depth = (int) get_option( 'thread_comments_depth' ); 223 224 // Pending comments may be nested under pending parents, but approved comments require publicly visible parents. 225 $parent_statuses = '1' === $comment->comment_approved ? 'approve' : array( 'approve', 'hold' ); 226 227 // Limit the number of comments to keep memory usage and the size of the dropdown reasonable on busy posts. 228 $post_comments = get_comments( 229 array( 230 'post_id' => $comment->comment_post_ID, 231 'type' => 'comment', 232 'status' => $parent_statuses, 233 'orderby' => 'comment_date_gmt', 234 'order' => 'DESC', 235 'number' => 100, 236 ) 237 ); 238 239 // Restore chronological order for display. 240 $post_comments = array_reverse( $post_comments ); 241 242 // Index the comments by ID and by parent, to compute depths and find descendants. 243 $post_comments_by_id = array(); 244 $comments_by_parent = array(); 245 246 foreach ( $post_comments as $post_comment ) { 247 $post_comments_by_id[ (int) $post_comment->comment_ID ] = $post_comment; 248 $comments_by_parent[ (int) $post_comment->comment_parent ][] = (int) $post_comment->comment_ID; 249 } 250 251 // Walk the descendants level by level, which also gives the height of the subtree that moves with the comment. 252 $comment_descendants = array(); 253 $comment_subtree_height = 1; 254 $comment_level = array( (int) $comment->comment_ID ); 255 256 while ( $comment_level ) { 257 $next_level = array(); 258 259 foreach ( $comment_level as $level_comment_id ) { 260 if ( isset( $comments_by_parent[ $level_comment_id ] ) ) { 261 foreach ( $comments_by_parent[ $level_comment_id ] as $descendant_id ) { 262 $comment_descendants[ $descendant_id ] = true; 263 $next_level[] = $descendant_id; 264 } 265 } 266 } 267 268 if ( $next_level ) { 269 ++$comment_subtree_height; 270 } 271 272 $comment_level = $next_level; 273 } 274 275 // Compute each comment's depth, since comments at the maximum threading depth cannot become a parent. 276 $comment_depths = array(); 277 278 foreach ( $post_comments as $post_comment ) { 279 $depth = 1; 280 $ancestor_id = (int) $post_comment->comment_parent; 281 282 while ( $ancestor_id && isset( $post_comments_by_id[ $ancestor_id ] ) ) { 283 ++$depth; 284 $ancestor_id = (int) $post_comments_by_id[ $ancestor_id ]->comment_parent; 285 } 286 287 $comment_depths[ (int) $post_comment->comment_ID ] = $depth; 288 } 289 } 290 ?> 291 <div class="misc-pub-section misc-pub-reply-to"> 292 <span id="comment-parent-display"> 293 <?php 294 printf( 295 /* translators: %s: Parent comment link, or 'None'. */ 296 __( 'In reply to: %s' ), 297 '<b>' . $parent_display . '</b>' 298 ); 299 ?> 300 </span> 301 <?php if ( $comment_threading_enabled ) : ?> 302 <a href="#edit_comment_parent" class="edit-comment-parent hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"> 303 <?php 304 /* translators: Hidden accessibility text. */ 305 _e( 'Edit parent comment' ); 306 ?> 307 </span></a> 308 <fieldset id="comment-parent-div" class="hide-if-js"> 309 <legend class="screen-reader-text"> 310 <?php 311 /* translators: Hidden accessibility text. */ 312 _e( 'Parent comment' ); 313 ?> 314 </legend> 315 <label for="comment_parent"><?php _e( 'Parent comment' ); ?></label> 316 <select name="comment_parent" id="comment_parent"> 317 <option value="0"<?php selected( 0, (int) $comment->comment_parent ); ?>> 318 <?php 319 /* translators: Option in the parent comment dropdown, meaning the comment has no parent. */ 320 _e( 'None (top-level comment)' ); 321 ?> 322 </option> 323 <?php 324 $current_parent_listed = false; 325 326 foreach ( $post_comments as $post_comment ) { 327 $post_comment_id = (int) $post_comment->comment_ID; 328 329 if ( $post_comment_id === (int) $comment->comment_ID || isset( $comment_descendants[ $post_comment_id ] ) ) { 330 continue; 331 } 332 333 // The comment and the replies that move with it must stay within the maximum threading depth. 334 if ( $max_thread_depth && $comment_depths[ $post_comment_id ] + $comment_subtree_height > $max_thread_depth ) { 335 continue; 336 } 337 338 if ( $post_comment_id === (int) $comment->comment_parent ) { 339 $current_parent_listed = true; 340 } 341 342 $option_label = sprintf( 343 /* translators: 1: Comment author, 2: Comment excerpt. */ 344 __( '%1$s: %2$s' ), 345 get_comment_author( $post_comment ), 346 wp_html_excerpt( get_comment_excerpt( $post_comment ), 50, '…' ) 347 ); 348 349 printf( 350 "\t<option value='%d' data-author='%s'%s>%s</option>\n", 351 $post_comment_id, 352 esc_attr( get_comment_author( $post_comment ) ), 353 selected( $post_comment_id, (int) $comment->comment_parent, false ), 354 esc_html( $option_label ) 355 ); 356 } 357 358 // The current parent may not be listed, e.g. a pingback or a comment no longer publicly visible. 359 if ( $comment->comment_parent && ! $current_parent_listed && isset( $parent ) ) { 360 $option_label = sprintf( 361 /* translators: 1: Comment author, 2: Comment excerpt. */ 362 __( '%1$s: %2$s' ), 363 get_comment_author( $parent ), 364 wp_html_excerpt( get_comment_excerpt( $parent ), 50, '…' ) 365 ); 366 367 printf( 368 "\t<option value='%d' data-author='%s' selected>%s</option>\n", 369 (int) $comment->comment_parent, 370 esc_attr( get_comment_author( $parent ) ), 371 esc_html( $option_label ) 372 ); 373 } 374 ?> 375 </select> 376 <input type="hidden" id="hidden_comment_parent" value="<?php echo esc_attr( $comment->comment_parent ); ?>" /> 377 <p> 378 <a href="#edit_comment_parent" class="save-comment-parent hide-if-no-js button"><?php _e( 'OK' ); ?></a> 379 <a href="#edit_comment_parent" class="cancel-comment-parent hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a> 380 </p> 381 </fieldset> 382 <?php endif; ?> 383 </div> 384 385 <?php 386 /** 387 * Filters miscellaneous actions for the edit comment form sidebar. 388 * 389 * @since 4.3.0 390 * 391 * @param string $html Output HTML to display miscellaneous action. 392 * @param WP_Comment $comment Current comment object. 393 */ 394 echo apply_filters( 'edit_comment_misc_actions', '', $comment ); 395 ?> 396 397 </div> <!-- misc actions --> 398 <div class="clear"></div> 399 </div> 400 401 <div id="major-publishing-actions"> 402 <div id="delete-action"> 403 <?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url( 'comment.php?action=' . ( ! EMPTY_TRASH_DAYS ? 'deletecomment' : 'trashcomment' ) . "&c=$comment->comment_ID&_wp_original_http_referer=" . urlencode( wp_get_referer() ), 'delete-comment_' . $comment->comment_ID ) . "'>" . ( ! EMPTY_TRASH_DAYS ? __( 'Delete Permanently' ) : __( 'Move to Trash' ) ) . "</a>\n"; ?> 404 </div> 405 <div id="publishing-action"> 406 <?php submit_button( __( 'Update' ), 'primary large', 'save', false ); ?> 407 </div> 408 <div class="clear"></div> 409 </div> 410 </div> 411 </div> 412 </div><!-- /submitdiv --> 413 </div> 414 415 <div id="postbox-container-2" class="postbox-container"> 416 <?php 417 /** This action is documented in wp-admin/includes/meta-boxes.php */ 418 do_action( 'add_meta_boxes', 'comment', $comment ); 419 420 /** 421 * Fires when comment-specific meta boxes are added. 422 * 423 * @since 3.0.0 424 * 425 * @param WP_Comment $comment Comment object. 426 */ 427 do_action( 'add_meta_boxes_comment', $comment ); 428 429 do_meta_boxes( null, 'normal', $comment ); 430 431 $referer = wp_get_referer(); 432 ?> 433 </div> 434 435 <input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" /> 436 <input type="hidden" name="p" value="<?php echo esc_attr( $comment->comment_post_ID ); ?>" /> 437 <input name="referredby" type="hidden" id="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" /> 438 <?php wp_original_referer_field( true, 'previous' ); ?> 439 <input type="hidden" name="noredir" value="1" /> 440 441 </div><!-- /post-body --> 442 </div> 443 </div> 444 </form> 445 446 <?php if ( ! wp_is_mobile() ) : ?> 447 <script> 448 try{document.post.name.focus();}catch(e){} 449 </script> 450 <?php 451 endif;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Fri Jul 24 08:20:19 2026 | Cross-referenced by PHPXref |