Shared Counts – Change label for total field

When using the “Included Total” field with the Icons style, the output looks something like this:

With the following code, you can change it to “Shares” for multiple shares, or “Share” if there’s only one share, like this:

<?php
/**
* Shared Counts - Change "Total" to "Shares"
* @author Bill Erickson
* @see https://www.billerickson.net/code/shared-counts-change-label-for-total-field
*/
function ea_shared_counts_change_total_label( $link ) {
$classes = explode( ' ', $link[ 'class' ] );
if( 'included_total' == $link[ 'type' ] && in_array( 'style-icon', $classes ) ) {
$link[ 'label' ] = _n( 'Share', 'Shares', $link[ 'count' ] );
}
return $link;
}
add_filter( 'shared_counts_link', 'ea_shared_counts_change_total_label' );
view raw functions.php hosted with ❤ by GitHub

Shared Counts