Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dashicons css classes for icons in At a Glance #2499

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from
34 changes: 4 additions & 30 deletions src/wp-admin/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
.welcome-panel .welcome-icon:before,
#dashboard_right_now li a:before,
#dashboard_right_now li span:before,
#dashboard_right_now .search-engines-info:before {
#dashboard_right_now .search-engines-info a:before {
color: #646970;
font: normal 20px/1 dashicons;
speak: never;
Expand Down Expand Up @@ -410,38 +410,12 @@
#dashboard_right_now .search-engines-info:before,
#dashboard_right_now li a:before,
#dashboard_right_now li > span:before { /* get only the first level span to exclude screen-reader-text in mu-storage */
content: "\f159"; /* generic icon for items added by CPTs ? */
padding: 0 5px 0 0;
}

#dashboard_right_now .page-count a:before,
#dashboard_right_now .page-count span:before {
content: "\f105";
}

#dashboard_right_now .post-count a:before,
#dashboard_right_now .post-count span:before {
content: "\f109";
}

#dashboard_right_now .comment-count a:before {
content: "\f101";
}

#dashboard_right_now .comment-mod-count a:before {
content: "\f125";
}

#dashboard_right_now .storage-count a:before {
content: "\f104";
}

#dashboard_right_now .storage-count.warning a:before {
content: "\f153";
}

#dashboard_right_now .search-engines-info:before {
content: "\f348";
#dashboard_right_now li a:not(.dashicons-before):before,
#dashboard_right_now li > span:not(.dashicons-before):before { /* get only the first level span to exclude screen-reader-text in mu-storage */
content: "\f159"; /* generic icon for items added by CPTs ? */
}

/* Dashboard WordPress events */
Expand Down
33 changes: 20 additions & 13 deletions src/wp-admin/includes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,12 @@ function wp_dashboard_right_now() {

$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
$icon_class = 'dashicons-before dashicons-admin-' . $post_type;

if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
printf( '<li class="%1$s-count"><a class="%3$s" href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text, esc_attr( $icon_class ) );
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
printf( '<li class="%1$s-count"><span class="%3$s">%2$s</span></li>', $post_type, $text, esc_attr( $icon_class ) );
}
}
}
Expand All @@ -334,15 +335,15 @@ function wp_dashboard_right_now() {
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
<li class="comment-count">
<a href="edit-comments.php"><?php echo $text; ?></a>
<a class="dashicons-before dashicons-admin-comments" href="edit-comments.php"><?php echo $text; ?></a>
</li>
<?php
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
/* translators: %s: Number of comments. */
$text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count<?php echo ! $num_comm->moderated ? ' hidden' : ''; ?>">
<a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a>
<a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text dashicons-before dashicons-format-chat"><?php echo $text; ?></a>
</li>
<?php
}
Expand Down Expand Up @@ -400,8 +401,9 @@ function wp_dashboard_right_now() {
$content = apply_filters( 'privacy_on_link_text', __( 'Search engines discouraged' ) );

$title_attr = '' === $title ? '' : " title='$title'";
$icon_class = 'dashicons-before dashicons-info';

echo "<p class='search-engines-info'><a href='options-reading.php'$title_attr>$content</a></p>";
echo '<p class="search-engines-info"><a href="options-reading.php"' . $title_attr . ' class="' . esc_attr( $icon_class ) . '">' . $content . '</a></p>';
}
?>
</div>
Expand Down Expand Up @@ -1652,9 +1654,11 @@ function wp_dashboard_quota() {
$percentused = ( $used / $quota ) * 100;
}

$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$icon_class = ( $percentused >= 70 ) ? ' dashicons-dismiss' : 'dashicons-admin-media';
$icon_class .= ' dashicons-before';
$used = round( $used, 2 );
$percentused = number_format( $percentused );

?>
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
Expand All @@ -1668,27 +1672,30 @@ function wp_dashboard_quota() {
number_format_i18n( $quota )
);
printf(
'<a href="%1$s">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
'<a href="%1$s" class="%4$s">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
/* translators: Hidden accessibility text. */
__( 'Manage Uploads' )
__( 'Manage Uploads' ),
esc_attr( $icon_class )
);
?>
</li><li class="storage-count <?php echo $used_class; ?>">
<?php
$text = sprintf(
$icon_class .= ' musublink';
$text = sprintf(
/* translators: 1: Number of megabytes, 2: Percentage. */
__( '%1$s MB (%2$s%%) Space Used' ),
number_format_i18n( $used, 2 ),
$percentused
);
printf(
'<a href="%1$s" class="musublink">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
'<a href="%1$s" class="%4$s">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
esc_url( admin_url( 'upload.php' ) ),
$text,
/* translators: Hidden accessibility text. */
__( 'Manage Uploads' )
__( 'Manage Uploads' ),
esc_attr( $icon_class )
);
?>
</li>
Expand Down
Loading