jaredatch/EA-Share-Count

How to add a custom class to the container of the buttons!?

Closed this issue · 2 comments

I've seen the enhancement that billerickson did which is located in this post:
#75

enhancement link: https://github.com/jaredatch/EA-Share-Count/blob/master/includes/class-front.php#L256

but he didn't give steps for a newbi so plz could you plz explain how to add a custom class for a Nob to the wrapper of buttons?

Best regards

By default the wrapping element has a class of ea-share-count-wrap, and whatever location it is (ex: before_content).

If you're using ea_share()->front->display( $location, $echo, $style ) to display buttons in a custom location (ex: sidebar), then use the location parameter to specify whatever additional class you want.

ea_share()->front->display( 'social-sidebar', true, 'slim' );

If you just want to change 'ea-share-count-wrap' to something else but leave the rest of the markup untouched (ex: keep using a div, and ensure each location retains its location-based class), then you could do a string replace:

/**
 * Change share count wrapper 
 *
 */
function be_change_share_count_wrapper( $output, $location ) {
	return str_replace( 'ea-share-count-wrap', 'social-wrapper', $output );
}
add_filter( 'ea_share_count_display_wrap_format', 'be_change_share_count_wrapper', 10, 2 );

If you wanted to completely change the markup (ex: use an aside for the wrapper) then you would completely replace the current output in that filter with whatever you want. You'll want to follow the format already used in there, with %1$s representing the social links and %2$s representing the location-specific class. Example:

/**
 * Change share count markup 
 *
 */
function be_change_share_count_wrapper_markup( $output, $location ) {
	return '<aside class="ea-share-count-wrap %2$s">%1$s</aside>';
}
add_filter( 'ea_share_count_display_wrap_format', 'be_change_share_count_wrapper_markup', 10, 2 );

maaan thank you so much