'; } return $str; } } // prints out a list of the current page's children or siblings in a widget div function asfp_subpages_nav($args=null) { parse_str($args,$arg); // link_heading if (isset($arg['depth'])) $depth = $arg['depth']; else $depth = 2; if (isset($arg['echo'])) $echo = $arg['echo']; else $echo = true; if (isset($arg['widget_class'])) $widget_class = $arg['widget_class']; else $widget_class = true; global $post; if (is_page() && !is_404() && !is_search() && !is_front_page()) { // If CHILD_OF is not NULL, then this page has a parent // Therefore, list siblings i.e. subpages of this page's parent if ($post->post_parent) $thelist = wp_list_pages('echo=0&title_li=&depth='.$depth.'&sort_column=menu_order&child_of='.asfp_get_ancestor()); // If CHILD_OF is zero, this is a top level page, so list subpages only. else $thelist = wp_list_pages('echo=0&title_li=&depth=2&sort_column=menu_order&child_of='.$post->ID); if (!empty($thelist)) { if ($post->post_parent) { $sectitle = get_the_title(asfp_get_ancestor()); $securl = get_permalink(asfp_get_ancestor()); } else { $sectitle = get_the_title($post->ID); $securl = get_permalink($post->ID); } $out = ''; $out .= '
'; if ($echo) echo $out; else return $out; } } } /* * asfp_get_latest_tweet() * gets the most recent tweet from user's timeline * @param string username * @returns string */ function asfp_get_latest_tweet($username) { $path = 'http://twitter.com/statuses/user_timeline/'.$username.'.json?count=1'; $path = 'https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name='.$username.'&count=1'; $jason = file_get_contents($path); $arr = json_decode($jason); $object = get_object_vars($arr[0]); return make_clickable($object['text']); } /* * USED BY THE FUNCTIONS ABOVE * * * * * * * * * * * * * * * * * * * * * * * * * * */ // returns the page id of the parent, grandparent, or great-grandparent of the current page function asfp_get_ancestor() { global $post; if ($post->post_parent) { $ancestor = get_posts('post_type=page&include='.$post->post_parent); if ($ancestor[0]->post_parent) { $ancestor2 = get_posts('post_type=page&include='.$ancestor[0]->post_parent); if ($ancestor2[0]->post_parent) return $ancestor2[0]->post_parent; else return $ancestor[0]->post_parent; } else return $post->post_parent; } else return false; } /* * NOT TEMPLATE FUNCTIONS * * * * * * * * * * * * * * * * * * * * * * * * * * * */ // Used by document types feature function asfp_doctypes_regex($text) { $types = get_option('asfp_doctypes_list'); $types = preg_replace('/,[ ]*/i','|',$types); // add the class to links $text = preg_replace('/href=([\'|"][[a-z0-9]|[\.\-\_]]*)\.('.$types.')([\'|"])/i','href=\\1.\\2\\3 class="link \\2"',$text); // remove the class from links followed directly by an image tag $text = preg_replace('/(]+)class="link [^"]+"([^>]*>)