';
$containerAfter = '';
$containerCrumb = '
';
$containerCrumbEnd = '
';
$delimiter = ' » ';
$name = 'Home'; //text for the 'Home' link
$blogname = 'Blog'; //text for the 'Blog' link
$baseLink = '';
$hierarchy = '';
$currentLocation = '';
$currentBefore = '';
$currentAfter = '';
$currentLocationLink = '';
$crumbPagination = '';
global $post;
// Start of Container
echo $containerBefore;
// Start of Breadcrumbs
echo $containerCrumb;
// Output the Base Link
if ( is_front_page() ) {
echo '' . $name . '';
} else {
$home = home_url('/');
$baseLink = '' . $name . '';
echo $baseLink;
}
// If static Page as Front Page, and on Blog Posts Index
if ( is_home() && ( 'page' == get_option( 'show_on_front' ) ) ) {
echo $delimiter . '' . $blogname . '';
}
// If static Page as Front Page, and on Blog, output Blog link
if ( ! is_home() && ! is_page() && ! is_front_page() && ( 'page' == get_option( 'show_on_front' ) ) ) {
$blogpageid = get_option( 'page_for_posts' );
$bloglink = '' . $blogname . '';
echo $delimiter . $bloglink;
}
// Define Category Hierarchy Crumbs for Category Archive
if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0) {
$hierarchy = ( $delimiter . __( 'Category Archive: ', 'basically' ) . get_category_parents( $parentCat, TRUE, $delimiter ) );
} else {
$hierarchy = $delimiter . __( 'Category Archive: ', 'basically' );
}
// Set $currentLocation to the current category
$currentLocation = single_cat_title( '' , FALSE );
}
// Define Crumbs for Day/Year/Month Date-based Archives
elseif ( is_date() ) {
// Define Year/Month Hierarchy Crumbs for Day Archive
if ( is_day() ) {
$date_string = '' . get_the_time('Y') . ' ' . $delimiter . ' ' . '' . get_the_time('F') . ' ';
$date_string .= $delimiter . ' ';
$currentLocation = get_the_time('d');
}
// Define Year Hierarchy Crumb for Month Archive
elseif ( is_month() ) {
$date_string = '' . get_the_time('Y') . ' ';
$date_string .= $delimiter . ' ';
$currentLocation = get_the_time('F');
}
// Set CurrentLocation for Year Archive
elseif ( is_year() ) {
$date_string = '';
$currentLocation = get_the_time('Y');
}
$hierarchy = $delimiter . sprintf( __( 'Posts Published in: %s', 'basically' ), $date_string );
}
// Define Category Hierarchy Crumbs for Single Posts
elseif ( is_single() && !is_attachment() ) {
$cat = get_the_category();
$cat = $cat[0];
$hierarchy = $delimiter . get_category_parents( $cat, TRUE, $delimiter );
// Note: get_the_title() is filtered to output a
// default title if none is specified
$currentLocation = get_the_title();
}
// Define Category and Parent Post Crumbs for Post Attachments
elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat_parents = '';
if ( get_the_category($parent->ID) ) {
$cat = get_the_category($parent->ID);
$cat = $cat[0];
$cat_parents = get_category_parents( $cat, TRUE, $delimiter );
}
$hierarchy = $delimiter . $cat_parents . '' . $parent->post_title . ' ' . $delimiter;
// Note: Titles are forced for attachments; the
// filename will be used if none is specified
$currentLocation = get_the_title();
}
// Define Current Location for Parent Pages
elseif ( ! is_front_page() && is_page() && ! $post->post_parent ) {
$hierarchy = $delimiter;
// Note: get_the_title() is filtered to output a
// default title if none is specified
$currentLocation = get_the_title();
}
// Define Parent Page Hierarchy Crumbs for Child Pages
elseif ( ! is_front_page() && is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '' . get_the_title($page->ID) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) {
$hierarchy = $hierarchy . $delimiter . $crumb;
}
$hierarchy = $hierarchy . $delimiter;
// Note: get_the_title() is filtered to output a
// default title if none is specified
$currentLocation = get_the_title();
}
// Define current location for Search Results page
elseif ( is_search() ) {
$hierarchy = $delimiter . __('Search Results:', 'basically' ) . ' ';
$currentLocation = get_search_query();
}
// Define current location for Tag Archives
elseif ( is_tag() ) {
$hierarchy = $delimiter . __( 'Tag Archive:', 'basically' ) . ' ';
$currentLocation = single_tag_title( '' , FALSE );
}
// Define current location for Author Archives
elseif ( is_author() ) {
$hierarchy = $delimiter . __( 'Posts Written by:', 'basically' ) . ' ';
$currentLocation = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
}
// Define current location for 404 Error page
elseif ( is_404() ) {
$hierarchy = $delimiter . __( 'Error 404:', 'basically' ) . ' ';
$currentLocation = __( 'Page Not Found', 'basically' );
}
// Define current location for Post Format Archives
elseif ( get_post_format() && ! is_home() ) {
$hierarchy = $delimiter . __( 'Post Format Archive:', 'basically' ) . ' ';
$currentLocation = get_post_format_string( get_post_format() ) . 's';
}
// Build the Current Location Link markup
$currentLocationLink = $currentBefore . $currentLocation . $currentAfter;
// Define breadcrumb pagination
// Define pagination for paged Archive pages
if ( get_query_var('paged') && ! function_exists( 'wp_paginate' ) ) {
$crumbPagination = ' (Page ' . get_query_var('paged') . ')';
}
// Define pagination for Paged Posts and Pages
if ( get_query_var('page') ) {
$crumbPagination = ' (Page ' . get_query_var('page') . ') ';
}
// Output the resulting Breadcrumbs
echo $hierarchy; // Output Hierarchy
echo $currentLocationLink; // Output Current Location
echo $crumbPagination; // Output page number, if Post or Page is paginated
echo $containerCrumbEnd; // End of BreadCrumbs
echo $containerAfter; // End of Container
} // end basically_breadcrumbs()
/**
* Custom twitter widget function
*
* Credit:
* Jeffrey Way - https://github.com/JeffreyWay/WordPress-Twitter-Widget
*
* @since basically 2.1.0
*/
class basically_Twitter_Widget extends WP_Widget {
function __construct() {
$params = array(
'description' => __('Display your recent tweets to your readers.', 'basically'),
'name' => __('» basically Twitter Widget', 'basically')
);
// id, name, params
parent::__construct('basically_Twitter_Widget', '', $params);
}
public function form($instance) {
extract($instance);
?>
twitter($tweet_count, $username);
if ( false !== $data && isset($data->tweets) ) {
echo $before_widget;
echo $before_title;
echo $title;
echo $after_title;
echo '- ' . implode('
- ', $data->tweets) . '
'; ?>
username !== $username ||
$tweets->tweet_count !== $tweet_count )
{
return $this->fetch_tweets($tweet_count, $username);
}
return $tweets;
}
private function fetch_tweets($tweet_count, $username)
{
$tweets = wp_remote_get("http://twitter.com/statuses/user_timeline/$username.json");
$tweets = json_decode($tweets['body']);
// An error retrieving from the Twitter API?
if ( isset($tweets->error) ) return false;
$data = new StdClass();
$data->username = $username;
$data->tweet_count = $tweet_count;
foreach($tweets as $tweet) {
if ( $tweet_count-- === 0 ) break;
$data->tweets[] = $this->filter_tweet( $tweet->text );
}
set_transient('recent_tweets_widget', $data, 60 * 5); // five minutes
return $data;
}
private function filter_tweet($tweet)
{
// Username links
$tweet = preg_replace('/(http[^\s]+)/im', '$1', $tweet);
$tweet = preg_replace('/@([^\s]+)/i', '@$1', $tweet);
// URL links
return $tweet;
}
}
?>