WP Biographia supports multiple filters, which are described in more detail below. The plugin's filters allow you to:

  • change the default set of installation settings and options at plugin activation time
  • modify and/or enhance the set of contact information fields the plugin adds to the author's profile
  • modify and/or enhance the contact links that are added to the Biography Box by the plugin
  • modify the position of the Biography Box to before or after the post content returned by the_content() and/or the_excerpt()
  • hide the display of the Biography Box entirely under user-defined circumstances
  • modify and/or enhance the Biography Box that is produced by the [wp_scs][wp_biographia][/wp_scs] shortcode
  • modify and/or enhance the format and content of the contact links that are added to the Biography Box by the plugin
  • modify and/or enhance the Biography Box that is produced for an RSS feed
  • modify and/or enhance the entirety of the Biography Box

wp_biographia_default_settings

Applied to the default set of plugin settings and options. Note that this filter is called once, upon plugin activation, when there are no WP Biographia settings/options existing in the database.

Example: Add the date and time that the plugin was first activated
[php] add_filter ('wp_biographia_default_settings', 'add_activation_timestamp'); function add_activation_timestamp ($options) { // options = array (option name => option value) $options['plugin_activation_timestamp'] = date (DATE_ATOM); return $options; } [/php]

wp_biographia_contact_info

Applied to the default set of contact information fields that are added to an author's profile by the plugin. Note that in order to add and display a new contact link to the Biography Box, the contact link must be added to the value returned by the wp_biographia_link_items filter as well as the value returned by this filter.

Example: Add Pinterest as a supported contact information field
[php] add_filter ('wp_biographia_contact_info', 'add_pinterest_support'); function add_pinterest_support ($contacts) { // contacts = array (field => array (field => field-name, contactmethod => description)) $contacts['pinterest'] = array ( 'field' => 'pinterest', 'contactmethod' => __('Pinterest') ); return $contacts; } [/php]

wp_biographia_link_items

Applied to the default set of contact links that are added to the Biography Box by the plugin. Note that in order to add and display a new contact link, the contact information field must be added to the value returned by the wp_biographia_contact_info filter as well as the value returned by this filter. Note that $icon_dir_url will by default contain the URL of the images directory within the plugin directory, which will look something like /wp-content/plugins/wp-biographia/images/ (the trailing slash is important). If an alternate icon directory has been specified in the plugin's settings and options, then $icon_dir_url will contain this alternate, configured, directory URL. If the icon you want to add for a new contact link doesn't reside in the directory URL mentioned previously, you'll need to set $icon_dir_url to point to your own custom location.

Example: Add Pinterest as a supported contact link in the Biography Box
[php] add_filter ('wp_biographia_link_items', 'add_pinterest_link', 10, 2); function add_pinterest_link ($links, $icon_dir_url) { // links = array (field => array (link_title => title, link_text => text, link_icon => URL) $links['pinterest'] = array ( 'link_title' => __('Pinterest'), 'link_text' => __('Pinterest'), 'link_icon' => $icon_dir_url . 'pinterest.png' ); return $links; } [/php]

wp_biographia_pattern

Applied to the format string used to position the Biography Box before the post content or after the post content that is returned by the_content() and/or the_excerpt().

Example: Insert a header between post content and Biography Box
[php] add_filter ('wp_biographia_pattern', 'insert_biography_header'); function insert_biography_header ($pattern) { return '%1$s<p class="biography-header">About The Author</p>%2$s'; } [/php]

wp_biographia_pre

Allows display of the Biography Box to be hidden under user-defined circumstances. This only affects the display of the Biography Box that is configured via the plugin's admin screen or via the shortcode in configured mode.

Example: Suppress the Biography Box
[php] add_filter ('wp_biographia_pre', 'suppress_biography_box'); function suppress_biography_box ($flag) { return true; } [/php]

wp_biographia_shortcode

Applied to the current instance of the Biography Box that is produced via the [wp_scs][wp_biographia][/wp_scs] shortcode.

Example: Apply shortcode specific CSS to the Biography Box
[php] add_filter ('wp_biographia_links', 'add_shortcode_css', 10, 2); function add_shortcode_css ($content, $params) { // params = array (mode => shortcode-mode, author => author-id, prefix => prefix-string, name => name-option) return '<div class="custom-shortcode-css">' . $content . '</div>'; } [/php]

wp_biographia_content_title

Applied to the title of the Biography Box.

Example: Override the name prefix for all uses of the Biography Box
[php] add_filter ('wp_biographia_content_title', 'override_name_prefix', 10, 3); function override_name_prefix ($content, $name_prefix, $formatted_name) { return 'This is ' . $formatted_name; } [/php]

wp_biographia_links

Applied to the formatted set of contact links for the current instance of the Biography Box

Example: Replace the default text link separator character (the pipe symbol "|") with a dash ("-").
[php] add_filter ('wp_biographia_links', 'replace_link_separator', 10, 3); function replace_link_separator ($content, $links, $params) { // links = array (link-item) // params = array (glue => separator-string, class => link-item-css-class-name, // prefix => links-prefix-html, postfix => links-postfix-html) return str_replace ($params['glue'], ' - ', $content); } [/php]
Example: Wrap the formatted content links in an additional HTML div
[php] add_filter ('wp_biographia_links', 'wrap_links', 10, 3); function wrap_links ($content, $links, $params) { // links = array (link-item) // params = array (glue => separator-string, class => link-item-css-class-name, // prefix => links-prefix-html, postfix => links-postfix-html) $new_prefix = '<div class="custom-link-class">' . $params['prefix']; $new_postfix = $params['postfix'] . '</div>'; return $new_prefix . implode ($params['glue'], $links) . $new_postfix; } [/php]

wp_biographia_link_item

Applied to each active contact link, in the order in which they are processed by the plugin.

Example: Force all links that point to the current site to open in a new window
[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)' // ); $site_url = site_url (); $pos = strpos ($params['url'], $site_url); if ($pos !== false) { $params['meta'] = 'target="_blank"'; } if ($params['type'] === 'icon') { $content = sprintf ($params['format'], $params['url'], $params['meta'], $params['title'], $params['link-class'], $params['body'], $params['item-class']); } else { $content = sprintf ($params['format'], $params['url'], $params['meta'], $params['title'], $params['link-class'], $params['body']); } return $content; } [/php]

wp_biographia_feed

Applied to the current instance of the Biography Box that is produced via the site's RSS feed.

Example: Apply RSS feed specific CSS to the Biography Box
[php] add_filter ('wp_biographia_feed', 'add_feed_css'); function add_feed_css ($content) { return '<div class="custom-feed-css">' . $content . '</div>'; } [/php]

wp_biographia_biography_box

Applied to the entire content of the current instance of the Biography Box.

Example: Remove all WP Biographia CSS classes commencing wp-biographia- and replace them with custom CSS classes that adhere to the plugin's CSS class naming convention.
[php] add_filter ('wp_biographia_biography_box', 'replace_css_classes', 10, 2); function replace_css_classes ($biography, $items) { $new_content = array (); foreach ($items as $item) { $new_content[] = str_replace ('wp-biographia-', 'custom-', $item); } return implode ('', $new_content); } [/php]