2014年2月26日 星期三

WordPress-控制台dashboard的修改

控制台dashboard顯示項目的修改
以WordPress 3.81為範例
\wordpress\wp-admin\includes\dashboard.php
這裡主要是把迴響功能全部關閉,讓它不會在控制台中顯示出來

#206~220 以下全刪 (此處是"概況" 可以顯示連到迴響的link)
    // Comments
    $num_comm = wp_count_comments();
    if ( $num_comm && $num_comm->total_comments ) {
        $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->total_comments ), number_format_i18n( $num_comm->total_comments ) );
        ?>
        <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
        <?php
        if ( $num_comm->moderated ) {
            /* translators: Number of comments in moderation */
            $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) );
            ?>
            <li class="comment-mod-count"><a href="edit-comments.php?comment_status=moderated"><?php echo $text; ?></a></li>
            <?php
        }
    }


#484~518 以下全刪 (也可以不刪)
<div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
            <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>

            <?php echo get_avatar( $comment, 50, 'mystery' ); ?>

            <div class="dashboard-comment-wrap">
            <h4 class="comment-meta">
                <?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__( 'From %1$s on %2$s%3$s' ),
                    '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?>
            </h4>

            <?php
            else :
                switch ( $comment->comment_type ) :
                case 'pingback' :
                    $type = __( 'Pingback' );
                    break;
                case 'trackback' :
                    $type = __( 'Trackback' );
                    break;
                default :
                    $type = ucwords( $comment->comment_type );
                endswitch;
                $type = esc_html( $type );
            ?>
            <div class="dashboard-comment-wrap">
            <?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
            <h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link." ".$comment_link ); ?></h4>
            <p class="comment-author"><?php comment_author_link(); ?></p>

            <?php endif; // comment_type ?>
            <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
            <p class="row-actions"><?php echo $actions_string; ?></p>
            </div>
        </div>

#548~555 以下全刪除 (其實若刪除這段, 就不用刪#484~518)
    $recent_comments = wp_dashboard_recent_comments();

    if ( !$future_posts && !$recent_posts && !$recent_comments ) {
        echo '<div class="no-activity">';
        echo '<p class="smiley"></p>';
        echo '<p>' . __( 'No activity yet!' ) . '</p>';
        echo '</div>';
    }