-
-
Save billerickson/4250ac6942e7da6365e29950a52b224f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Include Shared Counts in Display Posts Shortcode | |
* | |
* @author Bill Erickson | |
* @see https://www.billerickson.net/code/shared-counts-display-posts-shortcode/ | |
*/ | |
function be_shared_counts_dps( $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text ) { | |
// Check for include_shared_counts="true" | |
if( ! ( isset( $original_atts['include_shared_counts'] ) && filter_var( $original_atts['include_shared_counts'], FILTER_VALIDATE_BOOLEAN ) ) | |
return $output; | |
// Make sure Shared Counts is active | |
if( ! function_exists( 'shared_counts' ) ) | |
return $output; | |
$style = !empty( $original_atts['shared_counts_style'] ) ? esc_attr( $original_atts['shared_counts_style'] ) : false; | |
$share = shared_counts()->front->display( $location = 'dps', $echo = false, $style ); | |
$output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $share . $image . $title . $date . $author . $category_display_text . $excerpt . $content . '</' . $inner_wrapper . '>'; | |
return $output; | |
} | |
add_action( 'display_posts_shortcode_output', 'be_shared_counts_dps', 10, 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment