* @license GPL * * tekArtist WordPress Theme * Copyright (C) 2007 Stephane Daury * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ if ( function_exists('register_sidebars') ){ register_sidebars(4); if ( function_exists('register_sidebar_widget') ){ register_sidebar_widget('Site Navigation','widget_custom_sitenav'); register_sidebar_widget('Page Navigation','widget_custom_pagenav'); register_sidebar_widget('Author Stamp','widget_custom_author_stamp'); register_sidebar_widget('Search Form','widget_custom_search_form'); register_sidebar_widget('Archives Form','widget_custom_archives_form'); } } function widget_custom_sitenav(){ global $post; $ignoreBase = is_page('base') ? '&exclude='.$post->ID : ''; $top_pages = wp_list_pages('depth=1&title_li=&echo=0'.$ignoreBase); $top_pages = preg_replace('|title="(.*?)"|', 'class="button" id="sidebar\1" title="\1"', $top_pages); $home_url = strtolower(get_bloginfo('url')); $current_url = rtrim(str_replace('index.php','',strtolower($_SERVER['SCRIPT_URI'])),'/'); $temp = explode('/',str_replace($home_url,'',$current_url)); $current_top = $home_url.'/'.$temp[1].'/'; if(strpos($top_pages, 'current_page_item') === false){ $top_pages = str_replace('href="'.$current_top.'" class="button"', 'href="'.$current_top.'" class="button selected"', $top_pages); } else{ $top_pages = preg_replace('|current_page_item(.*?)class="button"|', 'current_page_item\1class="button selected"', $top_pages); } print '

'.__('Site Navigation').'

' . '\n"; } function widget_custom_pagenav(){ global $post; if($post->post_type == 'page') { // get original parent info $parent = get_post($post->post_parent); $i = 2; while(intval($parent->post_parent) != 0){ $top_subpage_post_id = $parent->ID; $parent = get_post($parent->post_parent); $i++; } if($post->post_parent != 0){ $top_subpage = get_post($top_subpage_post_id); $page_nav = wp_list_pages('echo=0&title_li=

'.$top_subpage->post_title.'

&sort_column=menu_order&child_of='.$top_subpage->ID); $page_nav = str_replace('class="pagenav"', 'id="subpagenav" class="widget widget_custom_pagenav"', $page_nav); print $page_nav; } $page_nav = wp_list_pages('echo=0&title_li=

'.$parent->post_title.'

&sort_column=menu_order&depth=1&child_of='.$parent->ID); $page_nav = str_replace('class="pagenav"', 'id="pagenav" class="widget widget_custom_pagenav"', $page_nav); print $page_nav; } } function widget_custom_author_stamp(){ print '
  • Author

    '; include_vcard(); print "\n
  • \n"; } function widget_custom_search_form(){ print '
  • Search

    '; include_search_form(); print "\n
  • \n"; } function widget_custom_archives_form(){ print '
  • Blog archives

    '; include_archives_form(); print "\n
  • \n"; } function sidebar_selector(){ if(is_page()){ page_sidebar(); } else{ blog_sidebar(); } } function blog_sidebar(){ dynamic_sidebar(2); } function page_sidebar(){ global $post; if( (wp_list_pages('echo=0&depth=1&child_of='.$post->ID)) || ($post->post_parent != 0) ){ dynamic_sidebar(3); } } function page_breadcrumb($return=false){ global $post; if ( ($post->post_type == 'page') && (intval($post->post_parent) != 0) ) { $breadcrumb = '» '.$post->post_title; $parent = get_post($post->post_parent); $breadcrumbFormat = '» %s %s'; if($return === true){ $breadcrumb = '» '.$parent->post_title.' '.$breadcrumb; } else{ $breadcrumb = sprintf( $breadcrumbFormat, get_permalink($parent->ID), urlencode($parent->post_title), $parent->post_title, $breadcrumb ); } while(intval($parent->post_parent) != 0){ $parent = get_post($parent->post_parent); if($return === true){ $breadcrumb = '» '.$parent->post_title.' '.$breadcrumb; } else{ $breadcrumb = sprintf( $breadcrumbFormat, get_permalink($parent->ID), urlencode($parent->post_title), $parent->post_title, $breadcrumb ); } } if($return === true){ return ' '.$breadcrumb; } else { print ''; } } } function include_vcard(){ include (TEMPLATEPATH . "/vcard.php"); } function include_search_form(){ include (TEMPLATEPATH . "/search-form.php"); } function include_archives_form(){ include (TEMPLATEPATH . "/archives-form.php"); } function include_social(){ include (TEMPLATEPATH . "/social.php"); } ?>