", $feed); $stepTwo = explode("", $stepOne[1]); $tweet = $stepTwo[0]; $tweet = str_replace('<', '<', $tweet); $tweet = str_replace('>', '>', $tweet); return $tweet; } public static function last_tweet($username, $prefix = '', $suffix = '') { $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1"; // Prefix - some text you want displayed before your latest tweet. // (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\") //$prefix = ""; // Suffix - some text you want display after your latest tweet. (Same rules as the prefix.) //$suffix = ""; $twitterFeed = file_get_contents($feed); echo stripslashes($prefix) . self::parse_feed($twitterFeed) . stripslashes($suffix); } /** * * @param strig $username twitter user name */ public static function latest_tweet($username) { include_once(ABSPATH . WPINC . '/class-simplepie.php'); $tweet = fetch_rss("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1"); echo $tweet->items[0]['atom_content']; } public static function extra_contact_info($contactmethods) { unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); $contactmethods['feedburner_page'] = 'Feedburner Url'; $contactmethods['facebook'] = 'Facebook Url'; $contactmethods['facebook_page'] = 'Facebook Fan Page'; $contactmethods['google_plus_url'] = 'Google Plus Url'; $contactmethods['google_page_url'] = 'Google Page Url'; $contactmethods['twitter'] = 'Twitter Url'; $contactmethods['twitter_user'] = 'Twitter Username'; $contactmethods['linkedin'] = 'LinkedIn'; $contactmethods['flickr'] = 'Flickr Username'; $contactmethods['blog'] = 'Blog Url'; $contactmethods['cell'] = 'Mobile Phone'; return $contactmethods; } public static function contact_info() { //http://www.wprecipes.com/how-to-easily-modify-user-contact-info //http://thomasgriffinmedia.com/blog/2010/09/how-to-add-custom-user-contact-info-in-wordpress/ //the_author_meta('facebook', $current_author->ID); add_filter('user_contactmethods', array('cwp_social', 'extra_contact_info')); } /** * * @param string $name -- twitter, facebook, google_plus, linkedin, feedburner_page */ public static function connections($name = null) { $link = false; $theme_admin = (cwp::theme_options('themeadmin') ? cwp::theme_options('themeadmin') : 1); if (isset($name)): $link = the_author_meta($name, $theme_admin); endif; return $link; } /** * * @param type $user_id * @return string feed subscriptions url for verification */ public static function feedburner_subscriptions($user_id = 1) { $feed = get_the_author_meta('feedburner_page', $user_id); //$r = explode('=', $feed); return "http://feedburner.google.com/fb/a/mailverify?uri={$feed}"; } public static function feedburner_url($user_id = 1) { $feed = the_author_meta('feedburner_url', $user_id); $r = explode('=', $feed); return $feed; } public static function google_plusone($content) { $content = $content . '
'; return $content; } public static function google_plusone_script() { wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null); } public static function add_plus_one() { add_action('wp_enqueue_scripts', array('cwp_social', 'google_plusone_script')); add_filter('the_content', array('cwp_social', 'google_plusone')); } public static function plusone() { self::google_plusone_script(); $content = '
'; return $content; } /** * * FB html5 share * @param Array $data - href,faces,width,font * @return type output html/js */ public static function fb_like($data = null) { $faces = isset($data['faces']) ? $data['faces'] : 'true'; $href = isset($data['href']) ? $data['href'] : site_url(); $width = isset($data['width']) ? $data['width'] : '450'; $font = isset($data['font']) ? $data['font'] : 'arial'; ob_start(); ?>
tag. * @param type $app_id * @return html/js */ public static function fb_js($app_id = null) { ob_start(); ?>
ID) ? get_the_title($post->ID) : get_bloginfo('description'); if (!isset($hashtags)) $hashtags = get_bloginfo('hashtags'); ?>
* * * @param string $title * @param string $url - * @param init $post * @param init $width * @param string $colorscheme */ public static function fb_comment($title = "Share your comment with us via Facebook", $url = null, $post = 10, $width = 600, $colorscheme = 'light') { $siteurl = isset($url) ? $url : get_permalink(); add_action('wp_footer', array('cwp_social', 'fb_comment_script')); ob_start(); ?>

timeline_title = $timeline_title; return $this; } public function set_user($user) { $this->user = $user; return $this; } public function set_timeline_widget_id($timeline_widget_id) { $this->timeline_widget_id = $timeline_widget_id; return $this; } public function __construct() { } public static function factory() { return $factory = new cwp_social_twitter(); } public function embed_timelines($user, $timeline_id) { add_action('wp_footer', array($this, 'timelines_js')); ob_start(); ?> timeline_title ?>
tag. * @param type $app_id * @return html/js */ public function fb_script() { $app_id = cwp::theme_options('fbappid'); if ($app_id AND !empty($app_id)): ?>
* @param type $app_id * @param type $title * @param type $width * @param type $post * @param type $colorscheme * @param type $url * @return type */ public function fb_comment($title = "Share your thoughts", $width = 600, $post = 10, $colorscheme = 'light', $url = null) { $siteurl = isset($url) ? $url : get_permalink(); add_action('wp_footer', array($this, 'fb_script')); ob_start(); ?>

ID; $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if ($count == '') { delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count; } public static function setPostViews($postID = Null) { global $post; if ($postID == null) $postID = $post->ID; $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if ($count == '') { $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); } else { $count++; update_post_meta($postID, $count_key, $count); } } public static function breadcrumbs() { /** * http://dimox.net/wordpress-breadcrumbs-without-a-plugin/ */ $delimiter = '»'; $home = 'Home'; // text for the 'Home' link $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb if (!is_home() && !is_front_page() || is_paged()) { echo '
'; global $post; $homeLink = get_bloginfo('url'); echo '' . $home . ' ' . $delimiter . ' '; 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) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' ')); echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after; } elseif (is_day()) { echo '' . get_the_time('Y') . ' ' . $delimiter . ' '; echo '' . get_the_time('F') . ' ' . $delimiter . ' '; echo $before . get_the_time('d') . $after; } elseif (is_month()) { echo '' . get_the_time('Y') . ' ' . $delimiter . ' '; echo $before . get_the_time('F') . $after; } elseif (is_year()) { echo $before . get_the_time('Y') . $after; } elseif (is_single() && !is_attachment()) { if (get_post_type() != 'post') { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '' . $post_type->labels->singular_name . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } else { $cat = get_the_category(); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo $before . get_the_title() . $after; } } elseif (!is_single() && !is_page() && get_post_type() != 'post') { $post_type = get_post_type_object(get_post_type()); echo $before . $post_type->labels->singular_name . $after; } elseif (is_attachment()) { $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo '' . $parent->post_title . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif (is_page() && !$post->post_parent) { echo $before . get_the_title() . $after; } elseif (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) echo $crumb . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif (is_search()) { echo $before . 'Search results for "' . get_search_query() . '"' . $after; } elseif (is_tag()) { echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after; } elseif (is_author()) { global $author; $userdata = get_userdata($author); echo $before . 'Articles posted by ' . $userdata->display_name . $after; } elseif (is_404()) { echo $before . 'Error 404' . $after; } if (get_query_var('paged')) { if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo ' ('; echo __('Page') . ' ' . get_query_var('paged'); if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo ')'; } echo '
'; } } /** * * @global int $paged * @global string $wp_query * @param $pages * @param $range * @link http://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin * @link http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/ */ public static function pagination($wp_query = null) { if (!isset($wp_query)) global $wp_query; //set the paging methods if (is_front_page()): $paged = (get_query_var('page')) ? get_query_var('page') : 1; else : $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; endif; if ($wp_query->max_num_pages > 1) : echo '
'; $big = 999999999; echo paginate_links(array( 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, $paged), 'total' => $wp_query->max_num_pages )); echo '
'; endif; } /** * * @global int $paged * @global string $wp_query * @param $pages * @param $range * @link http://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin * @link http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/ */ public static function pagination_plus($pages = '', $range = 4) { $showitems = ($range * 2) + 1; global $paged; if (empty($paged)) $paged = 1; if ($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if (!$pages) { $pages = 1; } } if (1 != $pages) { echo "
  • Page " . $paged . " of " . $pages . "
  • "; if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) echo "
  • « First
  • "; if ($paged > 1 && $showitems < $pages) echo "
  • ‹ Previous
  • "; for ($i = 1; $i <= $pages; $i++) { if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) { echo ($paged == $i) ? "
  • " . $i . "
  • " : "
  • " . $i . "
  • "; } } if ($paged < $pages && $showitems < $pages) echo "
  • Next ›
  • "; if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) echo "
  • Last »
  • "; echo "
\n"; } } public function add_theme_favicon() { //get_stylesheet_directory_uri(); $file = CWP_URL . '/images/favicon.ico'; if (file_exists(get_stylesheet_directory() . '/images/favicon.ico')): $file = get_stylesheet_directory_uri() . '/images/favicon.ico'; elseif (file_exists(get_template_directory() . '/images/favicon.ico')) : $file = get_template_directory_uri() . '/images/favicon.ico'; endif; echo ''; } public static function favicon() { add_action('wp_head', array('core_functions', 'add_theme_favicon')); add_action('admin_head', array('core_functions', 'add_theme_favicon')); } public static function time_ago($trail_text = 'ago') { $t = human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . $trail_text; return $t; } public static function time_ago_comments() { return $t = human_time_diff(get_comment_time('U'), current_time('timestamp')) . ' ago'; } public static function tweet($data = null, $name = "Tweet") { ob_start() ?> post_excerpt; if ('' == $text) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } $text = strip_shortcodes($text); // optional, recommended $text = strip_tags($text); // use ' $text = strip_tags($text,'

'); ' if you want to keep some tags

$text = substr($text, 0, $length); $excerpt = self::reverse_strrchr($text, '.', 1); if ($excerpt) { echo apply_filters('the_excerpt', $excerpt); } else { echo apply_filters('the_excerpt', $text); } } public static function reverse_strrchr($haystack, $needle, $trail) { return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false; } public static function editor() { add_editor_style('post_css'); } function fb_move_admin_bar() { echo ' '; } // on backend area //add_action( 'admin_head', 'fb_move_admin_bar' ); // on frontend area public static function admin_bar_footer() { add_action('wp_head', array('core_functions', 'fb_move_admin_bar')); } public static function hide_bar_admin() { add_filter('show_admin_bar', '__return_false'); } /** * Add all post format support * @param array $array -default : 'aside', 'gallery', 'video', 'link', 'image', 'quote', 'status' */ public static function all_post_formats($array = array('aside', 'gallery', 'video', 'link', 'image', 'quote', 'status', 'chat')) { add_theme_support('post-formats', $array); } /** * * @param string $theme_name * @param string $option_value */ public function theme_activation($theme_name = null, $option_value = 'yes') { $theme = $theme_name . '_activated'; if (get_option($theme) != $option_value) { update_option($theme, $option_value); } } /** * * @param type $theme_name */ public function theme_deactivation($theme_name = null) { $theme = $theme_name . '_activated'; delete_option($theme); } public static function no_smiley_face() { add_action('wp_head', array('core_functions', '_smiley_face')); } public function _smiley_face() { echo ' '; } public static function jquery($url = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', $version = '1.6.1') { if (!is_admin()) { // comment out the next two lines to load the local copy of jQuery wp_deregister_script('jquery'); wp_register_script('jquery', $url, false, $version); wp_enqueue_script('jquery'); } } public static function inuit_css($style = 'inuit') { $path = CM_URL . '/inuit/css/'; $css = $path . 'inuit.css'; wp_enqueue_style('inuit', $css); $grid = $path . 'grid.inuit.css'; wp_enqueue_style('grid-inuit', $grid, array('inuit')); $dropdown = $path . 'dropdown.inuit.css'; wp_enqueue_style('dropdown-inuit', $dropdown, array('inuit')); } public static function extra_contact_info($contactmethods) { unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); $contactmethods['facebook'] = 'Facebook'; $contactmethods['twitter'] = 'Twitter'; $contactmethods['linkedin'] = 'LinkedIn'; $contactmethods['flickr'] = 'Flickr'; return $contactmethods; } public static function add_contact_info() { //http://www.wprecipes.com/how-to-easily-modify-user-contact-info //http://thomasgriffinmedia.com/blog/2010/09/how-to-add-custom-user-contact-info-in-wordpress/ //the_author_meta('facebook', $current_author->ID); add_filter('user_contactmethods', array('core_functions', 'extra_contact_info')); } }