Skip to content

Instantly share code, notes, and snippets.

@vicchi
Created February 25, 2013 09:43
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 vicchi/5028778 to your computer and use it in GitHub Desktop.
Save vicchi/5028778 to your computer and use it in GitHub Desktop.
Example of the WP Biographia WordPress plugin's wp_biographia_link_item filter; appends the current post's title to the Biography Box's mailto link. Copy and paste this code into the bottom of your theme's functions.php.
add_filter ('wp_biographia_link_item', 'filter_link_item', 10, 2);
function filter_link_item ($content, $params) {
// $params = array (
// 'type' => 'link type (icon|text)',
// 'format' => 'link format string',
// 'meta' => 'additional anchor attributes',
// 'title' => 'link title',
// 'url' => 'link URL',
// 'body' => 'link body text',
// 'link-class' => 'link CSS class name',
// 'item-class' => 'link item CSS class name (icons only)'
// );
$url = $params['url'];
if (is_single ()) {
$pos = strpos ($url, 'mailto:');
if ($pos === 0) {
global $post;
$url .= '?subject=' . $post->post_title;
$content = sprintf ($params['format'], $url, $params['meta'], $params['title'], $params['link-class'], $params['body'], $params['item-class']);
}
}
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment