Skip to content

Instantly share code, notes, and snippets.

@rfmeier
Last active January 19, 2016 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfmeier/5672503 to your computer and use it in GitHub Desktop.
Save rfmeier/5672503 to your computer and use it in GitHub Desktop.
Create a custom content box with Genesis Framework.
<?php
//* no not include php tags
add_action( 'genesis_after_entry', 'sharedaddy_box_genesis_after_entry', 5 );
/**
* Callback for Genesis Framework 'genesis_after_entry' action.
*
* Create a custom box for sharedaddy links.
*
* Note: Set add_action() priority to accommodate your theme.
* http://codex.wordpress.org/Function_Reference/add_action
*
* @since 0.2
* @author Ryan Meier <rfmeier@gmail.com>
*
* @global $post The current post object within the loop.
* @return none Exit the function.
*/
function sharedaddy_box_genesis_after_entry() {
global $post;
//* if sharing_display() does not exist, return
if ( ! function_exists( 'sharing_display' ) ) {
return;
}
//* get the sharedaddy links html
$sharedaddy_links = sharing_display();
//* if sharing_display() does not return anything, return
if ( empty( $sharedaddy_links ) ) {
return;
}
//* add a filter for future use...
$title = apply_filters( 'sharedaddy_box_title', __( "Like what you're reading? Share it." ), $post );
//* create a template for the sharedaddy box content
$template = '<div class="sharedaddy-box"><h3 class="sharedaddy-box-title">%s</h3>%s</div>';
//* display the sharedaddy links within it's own box
$content = sprintf( $template, esc_html( $title ), $sharedaddy_links );
//* apply a filter for future adjustments
echo apply_filters( 'sharedaddy_box_content', $content, $template, $title, $sharedaddy_links );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment