Académique Documents
Professionnel Documents
Culture Documents
$parent_file = 'edit-comments.php';
$submenu_file = 'edit-comments.php';
/**
* @global string $action
*/
global $action;
wp_reset_vars( array( 'action' ) );
if ( isset( $_POST['deletecomment'] ) ) {
$action = 'deletecomment';
}
if ( 'cdc' == $action ) {
$action = 'delete';
} elseif ( 'mac' == $action ) {
$action = 'approve';
}
if ( isset( $_GET['dt'] ) ) {
if ( 'spam' == $_GET['dt'] ) {
$action = 'spam';
} elseif ( 'trash' == $_GET['dt'] ) {
$action = 'trash';
}
}
switch ( $action ) {
case 'editcomment':
$title = __( 'Edit Comment' );
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'You can edit the information left in a comment if needed.
This is often useful when you notice that a commenter has made a
typographical error.' ) . '</p>' .
'<p>' . __( 'You can also moderate the comment from this screen using
the Status box, where you can also change the timestamp of the
comment.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
'<p>' . __( '<a
href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation
on Comments</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) .
'</p>'
);
wp_enqueue_script( 'comment' );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
-1-
C:\wamp64\www\wordpress\wp-admin\comment.php miércoles, 20 de noviembre de 2019 11:53
if ( 'trash' == $comment->comment_approved ) {
comment_footer_die( __( 'This comment is in the Trash. Please move it out of the
Trash if you want to edit it.' ) );
}
break;
case 'delete':
case 'approve':
case 'trash':
case 'spam':
$title = __( 'Moderate Comment' );
?>
<div class="wrap">
<?php
switch ( $action ) {
case 'spam':
$caution_msg = __( 'You are about to mark the following comment as spam:' );
$button = _x( 'Mark as Spam', 'comment' );
break;
case 'trash':
$caution_msg = __( 'You are about to move the following comment to the
Trash:' );
$button = __( 'Move to Trash' );
-2-
C:\wamp64\www\wordpress\wp-admin\comment.php miércoles, 20 de noviembre de 2019 11:53
break;
case 'delete':
$caution_msg = __( 'You are about to delete the following comment:' );
$button = __( 'Permanently Delete Comment' );
break;
default:
$caution_msg = __( 'You are about to approve the following comment:' );
$button = __( 'Approve Comment' );
break;
}
if ( $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );
$parent_link = esc_url( get_comment_link( $parent ) );
-3-
C:\wamp64\www\wordpress\wp-admin\comment.php miércoles, 20 de noviembre de 2019 11:53
$name = get_comment_author( $parent );
printf(
/* translators: %s: comment link */
' | ' . __( 'In reply to %s.' ),
'<a href="' . $parent_link . '">' . $name . '</a>'
);
}
?>
</td>
</tr>
<tr>
<th scope="row"><?php _e( 'Submitted on' ); ?></th>
<td>
<?php
/* translators: 1: comment date, 2: comment time */
$submitted = sprintf(
__( '%1$s at %2$s' ),
/* translators: comment date format. See https://secure.php.net/date */
get_comment_date( __( 'Y/m/d' ), $comment ),
get_comment_date( __( 'g:i a' ), $comment )
);
if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->
comment_post_ID ) ) {
echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted .
'</a>';
} else {
echo $submitted;
}
?>
</td>
</tr>
<tr>
<th scope="row"><?php /* translators: field name in comment form */ _ex( 'Comment',
'noun' ); ?></th>
<td class="comment-content">
<?php comment_text( $comment ); ?>
<p class="edit-comment"><a href="<?php echo admin_url(
"comment.php?action=editcomment&c={$comment->comment_ID}" ); ?>"><?php esc_html_e(
'Edit' ); ?></a></p>
</td>
</tr>
</table>
<p>
<?php submit_button( $button, 'primary', 'submit', false ); ?>
<a href="<?php echo admin_url( 'edit-comments.php' ); ?>" class="button-cancel"><?php
esc_html_e( 'Cancel' ); ?></a>
</p>
</div>
<?php
break;
case 'deletecomment':
case 'trashcomment':
case 'untrashcomment':
case 'spamcomment':
case 'unspamcomment':
case 'approvecomment':
case 'unapprovecomment':
-4-
C:\wamp64\www\wordpress\wp-admin\comment.php miércoles, 20 de noviembre de 2019 11:53
$comment_id = absint( $_REQUEST['c'] );
switch ( $action ) {
case 'deletecomment':
wp_delete_comment( $comment );
$redir = add_query_arg( array( 'deleted' => '1' ), $redir );
break;
case 'trashcomment':
wp_trash_comment( $comment );
$redir = add_query_arg(
array(
'trashed' => '1',
'ids' => $comment_id,
),
$redir
);
break;
case 'untrashcomment':
wp_untrash_comment( $comment );
$redir = add_query_arg( array( 'untrashed' => '1' ), $redir );
break;
case 'spamcomment':
wp_spam_comment( $comment );
$redir = add_query_arg(
array(
'spammed' => '1',
'ids' => $comment_id,
),
$redir
);
break;
case 'unspamcomment':
wp_unspam_comment( $comment );
$redir = add_query_arg( array( 'unspammed' => '1' ), $redir );
break;
case 'approvecomment':
-5-
C:\wamp64\www\wordpress\wp-admin\comment.php miércoles, 20 de noviembre de 2019 11:53
wp_set_comment_status( $comment, 'approve' );
$redir = add_query_arg( array( 'approved' => 1 ), $redir );
break;
case 'unapprovecomment':
wp_set_comment_status( $comment, 'hold' );
$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
break;
}
wp_redirect( $redir );
die;
case 'editedcomment':
$comment_id = absint( $_POST['comment_ID'] );
$comment_post_id = absint( $_POST['comment_post_ID'] );
edit_comment();
/**
* Filters the URI the user is redirected to after editing a comment in the admin.
*
* @since 2.1.0
*
* @param string $location The URI the user will be redirected to.
* @param int $comment_id The ID of the comment being edited.
*/
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
wp_redirect( $location );
exit();
default:
wp_die( __( 'Unknown action.' ) );
} // end switch
-6-