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

Don't display "Included Total" button if 0 shares and "hide empty counts" is true #44

Closed
billerickson opened this issue May 25, 2018 · 1 comment
Labels
Milestone

Comments

@billerickson
Copy link
Collaborator

We currently display the "Included Total" button whether or not there are any shares. If "Hide Empty Counts" is checked, the 0 is removed but the button itself stays, so it just says "Shares".

screenshot

This makes sense in the context of the other buttons (the FB share button should appear regardless of the share count), but not so with this button.

I think we should remove the "Included Total" button entirely if "hide empty counts" is true and the share count is zero.


Until this is patched and publicly released, you can implement this on your own site by adding the following to your theme's functions.php file or a core functionality plugin.

/**
 * Shared Counts, don't display total if 0 counts
 *
 */
function be_shared_counts_remove_empty_total( $element, $link ) {
	if( 'included_total' == $link['type'] && empty( $link['count'] ) ) {
		$element['wrap_open'] = $element['icon_label'] = $element['icon_count'] = $element['wrap_close'] = '';
	}
	return $element;
}
add_filter( 'shared_counts_output_elements', 'be_shared_counts_remove_empty_total', 10, 2 );
@jaredatch jaredatch added this to the 1.3.0 milestone Jun 7, 2018
@JiveDig
Copy link

JiveDig commented May 13, 2019

Just chiming in to say I tested develop just now and it fixed this issue for me as well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants