Weaver Xtreme API: Filters
Filters Supported by Weaver Xtreme
This article covers the somewhat advanced topic of filters supported by Weaver Xtreme. You must understand basic PHP programming, and should use this information only in a child theme or with the Weaver Xtreme Plus Actions and Filters option.
Weaver Xtreme processes some content through filters. Short descriptions of the filters called by Weaver Xtreme follow. It will likely be most instructive to look at the actual source code to better understand some of these filters.
How to use Weaver Xtreme Filters
The standard way to add filters is to the functions.php file in a Weaver Xtreme child theme. You can also use the Actions and Filters option available with Weaver Xtreme Plus.
Weaver Xtreme will pass the default value shown in each filter description to the filter. The filter then modifies that default value to get the desired output. If there is no default value, then there will be an empty string supplied to the filter.
Note that if a filter is not defined, then the default value is used as the result of the filter.
Wording Filters
These filters allow you to customize wording for various titles and labels. Note that default messages containing a “%s” will have the %s replaced by the appropriate dynamic value provided by WordPress and so your replacement likely should have a “%s” included as well.
weaverx_404_title
apply_filters('weaverx_404_title', __('Sorry, no such page.','weaver-xtreme'))
- Change the 404 page title.
weaverx_daily_archives
apply_filters('weaverx_daily_archives', __( 'Daily Archives: %s','weaver-xtreme'));
- Change the message for Daily Archives
weaverx_monthly_archives
apply_filters('weaverx_monthly_archives', __( 'Monthly Archives: %s','weaver-xtreme'));
- Change message for Monthly Archives
weaverx_yearly_archives
apply_filters('weaverx_yearly_archives', __( 'Yearly Archives: %s','weaver-xtreme'))
- Change message for Yearly Archives
taxonomy_archive_meta
apply_filters( 'taxonomy_archive_meta', '<div class="tax-archive-meta">' . $term_description . '</div>' )
- Used to replace a taxonomy archive page description as returned by WP function term_description(). This is a core WordPress filter, but is included here for information.
weaverx_author_archives
apply_filters('weaverx_author_archives', __( 'Author Archives: %s','weaver-xtreme'))
- Change message for Author Archives
weaverx_category_archives
apply_filters('weaverx_category_archives', __( 'Category Archives: %s','weaver-xtreme'))
- Change the message for Category Archives
category_archive_meta
apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' )
- Used to replace a category archive page description as returned by WP function category_description(). This is a core WordPress filter, but is included here for information.
weaverx_comments_title
echo apply_filters('weaverx_comments_title', __('Comments','weaver-xtreme'))
- Replace comments section title
weaverx_older_comments
apply_filters('weaverx_older_comments',__( '← Older Comments','weaver-xtreme'))
- Replace Older Comments label
weaverx_newer_comments
apply_filters('weaverx_newer_comments',__( 'Newer Comments →','weaver-xtreme'))
- Replace Newer Comments label
weaverx_reply/comment_form
apply_filters('weaverx_leave_reply_form', __( 'Leave a Reply','weaver-xtreme' )),
apply_filters('weaverx_cancel_reply_form',__( 'Cancel Reply','weaver-xtreme' )),
apply_filters('weaverx_post_comment_form',__( 'Post Comment','weaver-xtreme' ))- Change messages for reply/comment form
weaverx_site_title
apply_filters('weaverx_site_title', get_bloginfo( 'name', 'display' ) )
- Replace the default site title
weaverx_tagline
apply_filters('weaverx_tagline', get_bloginfo( 'description' ))
- Replace the default site tagline
weaverx_older_posts, weaverx_newer_posts
apply_filters('weaverx_older_posts','
' . __('Previous Post','weaver-xtreme')) apply_filters('weaverx_newer_posts', __('Next Post','weaver-xtreme') . ' ' );- Change message for older and newer posts navigation
weaverx_more_message
apply_filters('weaverx_more_message',__( 'Search Results for: %s','weaver-xtreme'))
- Replace the search results message.
weaverx_search_results
apply_filters('weaverx_search_results','Continue reading')
- Replace the continue reading message for excerpts
edit_post_link
apply_filters( 'edit_post_link', 'Edit', $post->ID )
- Replace the “Edit” link button for $post->ID – need to include full <a> code and label. This is a core WordPress filter, but is included here for information.
weaverx_leave_reply_blog
apply_filters('weaverx_leave_reply_blog', __( 'Leave a reply','weaver-xtreme'));
apply_filters('weaverx_reply_1', __( '1 Reply','weaver-xtreme'));
apply_filters('weaverx_reply_many', __( '% Replies','weaver-xtreme'));- Replace messages for “Leaver a Reply” message for blog meta info lines
weaverx_breadcrumb_delimiter
apply_filters( 'weaverx_breadcrumb_delimiter', '→' )
- Replace the right arrow delimiter used for breadcrumbs.
- Use ‘weaverx_breadcrumb_delimiter_rtl’ for RTL sites.
- Found in lib-runtime.php
weaverx_breadcrumbs
apply_filters( 'weaverx_breadcrumbs', $full_bc_string, $bc )
- Replace entire breadcrumb. The default includes the wrapping id and classes, while the $bc parameter is just the breadcrumb list.
- Found in lib-runtime.php
weaverx_copyright
apply_filters( 'weaverx_copyright', $default_copyright )
- Allows replacement of default Weaver Xtreme copyright string.
- Found in footer.php
weaverx_poweredby
apply_filters( 'weaverx_poweredby, $default_poweredby )
- Allows replacement of default Weaver Xtreme Powered By string. Should have styling. Default is to wrap with <span id=”site-generator”>…</span>
- Found in footer.php
Image Filters
These filters can be used to change the sizes of images and other items.
weaverx_author_bio_avatar_size
apply_filters( 'weaverx_author_bio_avatar_size', 75 )
- Change the size of the author avatar in the bio
weaverx_attachment_size
apply_filters( 'weaverx_attachment_size', 'large' )
- Change the default size for displaying attachment image
weaverx_fi_after
apply_filters( 'weaverx_fi_after', '' )
- Add content after a regular Featured Image (not header replacement FI). This could be used to add the image caption using the standard theme caption styling, for example:
add_filter('weaverx_fi_after', 'wvrx_fi_after'); function wvrx_fi_after($after) { return $after . '<div class="wp-caption"><p class="wp-caption-text">' . get_post(get_post_thumbnail_id())->post_excerpt . '</p></div>'; }
- Found in lib-content.php
weaverx_fi_link
apply_filters('weaverx_fi_link', $the_fi, $before, $href, $fi_img, $who, $fi_after);
- Generate a custom link for Featured Image. Notated example:
add_filter('weaverx_fi_link', 'wvrx_fi_link', 10, 6); function wvrx_fi_link( $the_fi, $before, $href, $fi_img, $who, $fi_after ) { /* args: $the_fi: the featured link code as generated by Weaver Xtreme $before: HTML added before fi link. When needed, an empty <div> with clear:both $href: The place to link the fi to. Default: the full post if excerpt; otherwise full size image $fi_img: The <img> tag of the image in proper size for page or post view $who: Who is generating the fi: post, page, post_excerpt, post_full $fi_after: code to show after the normal FI link. Only present if wvrx_fi_after filter implemented */ // "no-op" example - return unmodified link return $the_fi; }
- Found in lib-content.php
Advanced Weaver Xtreme Filters
The following filters are intended for more advanced users.
weaverx_posted_on, weaverx_posted_in
apply_filters('weaverx_posted_on',$po, $type)
apply_filters('weaverx_posted_in',$po, $type)
- Replace top and bottom post meta-info line ($po) for blog posts. This filter can be used to replace the entire top or bottom meta information lines. The $type value will usually be empty, but will be ‘single’ for single post view meta info.
weaverx_options
apply_filters('weaverx_options','weaverx_settings_backup')
- This allows a child theme to load an alternate set of settings from the WP options db. The second parameter is the name of the WP option and will be used as the value of get_option(), etc. The valid values can be: weaverx_settings_backup or weaverx_options.
weaverx_replace_widget_area
apply_filters('weaverx_replace_widget_area',$area_name)
- Replace a standard Weaver Xtreme widget area with a different one
weaverx_menu_name
apply_filters('weaverx_menu_name', $weaverx_menu)
- Replace the custom menu with a different one.
weaverx_menu_class
apply_filters('weaverx_menu_class', $class_values, $weaverx_menu)
- Modify menu class – add or delete classes to specific Weaver Xtreme menus
weaverx_menu_logo
apply_filters('weaverx_menu_logo','<span class="custom-logo-on-menu"><img class="custom-logo-on-menu" src="' . $custom_logo_url . '" /></span>', $custom_logo_url);
- This is how the custom logo is added to the primary menu. The url of the custom logo is provided in the 2nd parameter, so you can wrap this however you wish, including adding a link to the site home. (defined in filters.php)