edit-form-comment.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <?php
  2. /**
  3. * Edit comment form for inclusion in another file.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. // Don't load directly.
  9. if ( ! defined( 'ABSPATH' ) ) {
  10. die( '-1' );
  11. }
  12. /**
  13. * @global WP_Comment $comment Global comment object.
  14. */
  15. global $comment;
  16. ?>
  17. <form name="post" action="comment.php" method="post" id="post">
  18. <?php wp_nonce_field( 'update-comment_' . $comment->comment_ID ); ?>
  19. <div class="wrap">
  20. <h1><?php _e( 'Edit Comment' ); ?></h1>
  21. <div id="poststuff">
  22. <input type="hidden" name="action" value="editedcomment" />
  23. <input type="hidden" name="comment_ID" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
  24. <input type="hidden" name="comment_post_ID" value="<?php echo esc_attr( $comment->comment_post_ID ); ?>" />
  25. <div id="post-body" class="metabox-holder columns-2">
  26. <div id="post-body-content" class="edit-form-section edit-comment-section">
  27. <?php
  28. if ( 'approved' === wp_get_comment_status( $comment ) && $comment->comment_post_ID > 0 ) :
  29. $comment_link = get_comment_link( $comment );
  30. ?>
  31. <div class="inside">
  32. <div id="comment-link-box">
  33. <strong><?php _ex( 'Permalink:', 'comment' ); ?></strong>
  34. <span id="sample-permalink">
  35. <a href="<?php echo esc_url( $comment_link ); ?>">
  36. <?php echo esc_html( $comment_link ); ?>
  37. </a>
  38. </span>
  39. </div>
  40. </div>
  41. <?php endif; ?>
  42. <div id="namediv" class="stuffbox">
  43. <div class="inside">
  44. <h2 class="edit-comment-author"><?php _e( 'Author' ); ?></h2>
  45. <fieldset>
  46. <legend class="screen-reader-text"><?php _e( 'Comment Author' ); ?></legend>
  47. <table class="form-table editcomment" role="presentation">
  48. <tbody>
  49. <tr>
  50. <td class="first"><label for="name"><?php _e( 'Name' ); ?></label></td>
  51. <td><input type="text" name="newcomment_author" size="30" value="<?php echo esc_attr( $comment->comment_author ); ?>" id="name" /></td>
  52. </tr>
  53. <tr>
  54. <td class="first"><label for="email"><?php _e( 'Email' ); ?></label></td>
  55. <td>
  56. <input type="text" name="newcomment_author_email" size="30" value="<?php echo esc_attr( $comment->comment_author_email ); ?>" id="email" />
  57. </td>
  58. </tr>
  59. <tr>
  60. <td class="first"><label for="newcomment_author_url"><?php _e( 'URL' ); ?></label></td>
  61. <td>
  62. <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" class="code" value="<?php echo esc_attr( $comment->comment_author_url ); ?>" />
  63. </td>
  64. </tr>
  65. </tbody>
  66. </table>
  67. </fieldset>
  68. </div>
  69. </div>
  70. <div id="postdiv" class="postarea">
  71. <?php
  72. echo '<label for="content" class="screen-reader-text">' . __( 'Comment' ) . '</label>';
  73. $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
  74. wp_editor(
  75. $comment->comment_content,
  76. 'content',
  77. array(
  78. 'media_buttons' => false,
  79. 'tinymce' => false,
  80. 'quicktags' => $quicktags_settings,
  81. )
  82. );
  83. wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
  84. ?>
  85. </div>
  86. </div><!-- /post-body-content -->
  87. <div id="postbox-container-1" class="postbox-container">
  88. <div id="submitdiv" class="stuffbox" >
  89. <h2><?php _e( 'Save' ); ?></h2>
  90. <div class="inside">
  91. <div class="submitbox" id="submitcomment">
  92. <div id="minor-publishing">
  93. <div id="misc-publishing-actions">
  94. <div class="misc-pub-section misc-pub-comment-status" id="comment-status">
  95. <?php _e( 'Status:' ); ?> <span id="comment-status-display">
  96. <?php
  97. switch ( $comment->comment_approved ) {
  98. case '1':
  99. _e( 'Approved' );
  100. break;
  101. case '0':
  102. _e( 'Pending' );
  103. break;
  104. case 'spam':
  105. _e( 'Spam' );
  106. break;
  107. }
  108. ?>
  109. </span>
  110. <fieldset id="comment-status-radio">
  111. <legend class="screen-reader-text"><?php _e( 'Comment status' ); ?></legend>
  112. <label><input type="radio"<?php checked( $comment->comment_approved, '1' ); ?> name="comment_status" value="1" /><?php _ex( 'Approved', 'comment status' ); ?></label><br />
  113. <label><input type="radio"<?php checked( $comment->comment_approved, '0' ); ?> name="comment_status" value="0" /><?php _ex( 'Pending', 'comment status' ); ?></label><br />
  114. <label><input type="radio"<?php checked( $comment->comment_approved, 'spam' ); ?> name="comment_status" value="spam" /><?php _ex( 'Spam', 'comment status' ); ?></label>
  115. </fieldset>
  116. </div><!-- .misc-pub-section -->
  117. <div class="misc-pub-section curtime misc-pub-curtime">
  118. <?php
  119. $submitted = sprintf(
  120. /* translators: 1: Comment date, 2: Comment time. */
  121. __( '%1$s at %2$s' ),
  122. /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
  123. date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $comment->comment_date ) ),
  124. /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
  125. date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $comment->comment_date ) )
  126. );
  127. ?>
  128. <span id="timestamp">
  129. <?php
  130. /* translators: %s: Comment date. */
  131. printf( __( 'Submitted on: %s' ), '<b>' . $submitted . '</b>' );
  132. ?>
  133. </span>
  134. <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a>
  135. <fieldset id='timestampdiv' class='hide-if-js'>
  136. <legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend>
  137. <?php
  138. /**
  139. * @global string $action
  140. */
  141. global $action;
  142. touch_time( ( 'editcomment' === $action ), 0 );
  143. ?>
  144. </fieldset>
  145. </div>
  146. <?php
  147. $post_id = $comment->comment_post_ID;
  148. if ( current_user_can( 'edit_post', $post_id ) ) {
  149. $post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
  150. $post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
  151. } else {
  152. $post_link = esc_html( get_the_title( $post_id ) );
  153. }
  154. ?>
  155. <div class="misc-pub-section misc-pub-response-to">
  156. <?php
  157. printf(
  158. /* translators: %s: Post link. */
  159. __( 'In response to: %s' ),
  160. '<b>' . $post_link . '</b>'
  161. );
  162. ?>
  163. </div>
  164. <?php
  165. if ( $comment->comment_parent ) :
  166. $parent = get_comment( $comment->comment_parent );
  167. if ( $parent ) :
  168. $parent_link = esc_url( get_comment_link( $parent ) );
  169. $name = get_comment_author( $parent );
  170. ?>
  171. <div class="misc-pub-section misc-pub-reply-to">
  172. <?php
  173. printf(
  174. /* translators: %s: Comment link. */
  175. __( 'In reply to: %s' ),
  176. '<b><a href="' . $parent_link . '">' . $name . '</a></b>'
  177. );
  178. ?>
  179. </div>
  180. <?php
  181. endif;
  182. endif;
  183. ?>
  184. <?php
  185. /**
  186. * Filters miscellaneous actions for the edit comment form sidebar.
  187. *
  188. * @since 4.3.0
  189. *
  190. * @param string $html Output HTML to display miscellaneous action.
  191. * @param WP_Comment $comment Current comment object.
  192. */
  193. echo apply_filters( 'edit_comment_misc_actions', '', $comment );
  194. ?>
  195. </div> <!-- misc actions -->
  196. <div class="clear"></div>
  197. </div>
  198. <div id="major-publishing-actions">
  199. <div id="delete-action">
  200. <?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url( 'comment.php?action=' . ( ! EMPTY_TRASH_DAYS ? 'deletecomment' : 'trashcomment' ) . "&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode( wp_get_referer() ), 'delete-comment_' . $comment->comment_ID ) . "'>" . ( ! EMPTY_TRASH_DAYS ? __( 'Delete Permanently' ) : __( 'Move to Trash' ) ) . "</a>\n"; ?>
  201. </div>
  202. <div id="publishing-action">
  203. <?php submit_button( __( 'Update' ), 'primary large', 'save', false ); ?>
  204. </div>
  205. <div class="clear"></div>
  206. </div>
  207. </div>
  208. </div>
  209. </div><!-- /submitdiv -->
  210. </div>
  211. <div id="postbox-container-2" class="postbox-container">
  212. <?php
  213. /** This action is documented in wp-admin/includes/meta-boxes.php */
  214. do_action( 'add_meta_boxes', 'comment', $comment );
  215. /**
  216. * Fires when comment-specific meta boxes are added.
  217. *
  218. * @since 3.0.0
  219. *
  220. * @param WP_Comment $comment Comment object.
  221. */
  222. do_action( 'add_meta_boxes_comment', $comment );
  223. do_meta_boxes( null, 'normal', $comment );
  224. $referer = wp_get_referer();
  225. ?>
  226. </div>
  227. <input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
  228. <input type="hidden" name="p" value="<?php echo esc_attr( $comment->comment_post_ID ); ?>" />
  229. <input name="referredby" type="hidden" id="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
  230. <?php wp_original_referer_field( true, 'previous' ); ?>
  231. <input type="hidden" name="noredir" value="1" />
  232. </div><!-- /post-body -->
  233. </div>
  234. </div>
  235. </form>
  236. <?php if ( ! wp_is_mobile() ) : ?>
  237. <script type="text/javascript">
  238. try{document.post.name.focus();}catch(e){}
  239. </script>
  240. <?php
  241. endif;