Wordpress snippets

From Bluefish Wiki
Revision as of 14:38, 7 December 2010 by David Binovec (talk | contribs) (New version)
Jump to: navigation, search

<?xml version="1.0"?> <snippets>

 <branch title="Wordpress">
   <branch title="Sections">
     <leaf type="insert" title="The loop" tooltip="Simple loop skelet"><before><?php if ( have_posts() ) : ?>

<?php while ( have_posts() ) : the_post(); ?>

<?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?>

</before><after/></leaf>

     <leaf type="insert" title="Nested loop" tooltip="Nesting loops means that you are running a second loop before finishing the first one. This can be useful to display a post list with a shortcode for example. "><before><?php $my_query = new WP_Query( array(  => ,  => )); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php the_content(); ?> <?php endwhile; wp_reset_postdata();  ?> </before><after/></leaf>

     <leaf type="insert" title="head section" tooltip="Default universal head section for your template"><before><meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

<meta name="description" content="<?php bloginfo('description'); ?>" /> <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> <script type="text/javascript" src="<?php bloginfo('template_directory')?>/js/jquery.js"></script> <?php wp_head(); ?></before><after/></leaf>

     <leaf type="insert" title="WP 2.9 default loop" tooltip="The loop from WP2.9 default theme"><before><?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <small><?php the_time('j. F. Y') ?> <!-- by <?php the_author() ?> --></small>

<div class="entry"> <?php the_content('Celý článek &raquo;'); ?> </div>

<p class="postmetadata"><?php the_tags('Štítky: ', ', ', '<br />'); ?> Kategorie: <?php the_category(', ') ?> | <?php edit_post_link('Upravit', , ' | '); ?> <?php comments_popup_link('Žádné komentáře &#187;', '1 Komentář &#187;', 'Komentářů: % &#187;'); ?></p> </div>

<?php endwhile; ?>

<div class="navigation"> <div class="alignleft"><?php next_posts_link('&laquo; Další články') ?></div> <div class="alignright"><?php previous_posts_link('Předchozí články &raquo;') ?></div> </div>

<?php else : ?>

<h2 class="center">Nenalezeno</h2> <p class="center">Omlouvám se, ale požadovaný obsah nebyl nalezen.</p> <?php get_search_form(); ?>

<?php endif; ?></before><after/></leaf>

     <leaf type="insert" title="query_posts paged" tooltip="Return posts with the category, but exclude sticky posts completely, and adhere to paging rules"><before><?php

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $sticky=get_option('sticky_posts'); $args=array(

  'cat'=>3,
  'caller_get_posts'=>1,
  'post__not_in' => $sticky,
  'paged'=>$paged,
  );

query_posts($args); ?></before><after/></leaf>

     <leaf type="insert" title="default searchform" tooltip="If you don't have searchform.php in your Theme, WordPress fuction get_search_form() will render its built-in search form. Cornerstone for further customisation of search form"><before><form role="search" method="get" id="searchform" action="<?php bloginfo('url'); ?>">
   <div><label class="screen-reader-text" for="s">Search for:</label>
       <input type="text" value="" name="s" id="s" />
       <input type="submit" id="searchsubmit" value="Search" />
   </div>

</form> </before><after/></leaf>

     <leaf type="insert" title="show thumbnail" tooltip="Shows thumbnail within the loop"><before><?php /*

Do not forget to activate thumbnails in functions.php: add_theme_support( 'post-thumbnails' );

  • /?>

<?php if (function_exists('has_post_thumbnail')) { if ( has_post_thumbnail() ) { ?> <a class="thumbnail" href="<?php the_permalink(); ?>"> <?php the_post_thumbnail( array( 250, 150 ), array( 'class' => 'alignleft') ); ?></a> <?php } } ?></before><after/></leaf>

   <leaf type="insert" title="related posts by tag" tooltip=""><before><?php 

/*

$orig_post = $post; global $post; $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args=array( 'tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'posts_per_page'=>5, // Number of related posts that will be shown. 'caller_get_posts'=>1 ); $my_query = new wp_query( $args ); if( $my_query->have_posts() ) {

echo '<div id="relatedposts"><h3>Related Posts</h3><ul>';

while( $my_query->have_posts() ) { $my_query->the_post(); ?>

<li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div> <div class="relatedcontent"> <h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3> <?php the_time('M j, Y') ?> </div> </li> <? } echo '</ul></div>'; } } $post = $orig_post; wp_reset_query(); ?></before><after/></leaf><leaf type="insert" title="related posts by category" tooltip=""><before><?php /*

$orig_post = $post; global $post; $categories = get_the_category($post->ID); if ($categories) { $category_ids = array(); foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;

$args=array( 'category__in' => $category_ids, 'post__not_in' => array($post->ID), 'posts_per_page'=> 2, // Number of related posts that will be shown. 'caller_get_posts'=>1 );

$my_query = new wp_query( $args ); if( $my_query->have_posts() ) { echo '<div id="related_posts"><h3>Related Posts</h3><ul>'; while( $my_query->have_posts() ) { $my_query->the_post();?>

<li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div> <div class="relatedcontent"> <h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3> <?php the_time('M j, Y') ?> </div> </li> <? } echo '</ul></div>'; } } $post = $orig_post; wp_reset_query(); ?></before><after/></leaf><leaf type="insert" title="display external rss feed" tooltip=""><before><?php /*

include_once(ABSPATH.WPINC.'/feed.php'); $rss = fetch_feed('http://feeds.feedburner.com/wpbeginner'); $maxitems = $rss->get_item_quantity(5); $rss_items = $rss->get_items(0, $maxitems); ?> <ul> <?php if ($maxitems == 0) echo '<li>No items.</li>'; else // Loop through each feed item and display each item as a hyperlink. foreach ( $rss_items as $item ) : ?> <li> <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'> <?php echo $item->get_title(); ?></a> </li> <?php endforeach; ?> </ul></before><after/></leaf><leaf type="insert" title="only certain categories in a menu"><before><ul class="navmenubar"> <?php wp_list_categories('orderby=name&include=7,9,19,16,1,5,17,23'); ?> </ul> </before><after/></leaf><leaf type="insert" title="dropdown categories with js" tooltip=""><before><li id="categories"> <h2><?php _e('Posts by Category'); ?></h2> <form action="<?php bloginfo('url'); ?>/" method="get"> <div> <?php $select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0'); $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); echo $select; ?> <noscript><div><input type="submit" value="View" /></div></noscript> </div></form> </li> </before><after/></leaf><leaf type="insert" title="dropdown categories with submit button"><before><li id="categories"> <h2><?php _e('Categories:'); ?></h2> <form action="<?php bloginfo('url'); ?>" method="get"> <div> <?php wp_dropdown_categories('show_count=1&hierarchical=1'); ?> <input type="submit" name="submit" value="view" /> </div> </form> </li> </before><after/></leaf><leaf type="insert" title="most recent post from a category" tooltip=""><before> <?php /*

   query_posts('showposts=1&cat=3');
   while(have_posts()) : the_post();
   ?>
   <ul>
   <li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
   <ul><li><?php the_content(); ?></li>
   </ul>
   </li>
   </ul>
   <?php endwhile; ?> </before><after/></leaf><leaf type="insert" title="display most recent comment with gravatars" tooltip=""><before>    <?php

/*

   $query = "SELECT * from $wpdb->comments WHERE comment_approved= '1'
   ORDER BY comment_date DESC LIMIT 0 ,5";
   $comments = $wpdb->get_results($query);
   if ($comments) {
   echo '<ul>';
   foreach ($comments as $comment) {
   $url = '<a href="'. get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID .'" title="'.$comment->comment_author .' | '.get_the_title($comment->comment_post_ID).'">';
   echo '<li>';
   echo '<div class="img">';
   echo $url;
   echo get_avatar( $comment->comment_author_email, $img_w);
   echo '</a></div>';
   echo '<div class="txt">Par: ';
   echo $url;
   echo $comment->comment_author;
   echo '</a></div>';
   echo '</li>';
   }
   echo '</ul>';
   }
   ?> </before><after/></leaf><leaf type="insert" title="display most recent tweet" tooltip=""><before>    <?php

/*

   $username = "TwitterUsername"; // Your twitter username.
   $prefix = ""; // Prefix – some text you want displayed before your latest tweet.
   $suffix = ""; // Suffix – some text you want display after your latest tweet.
   $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
   function parse_feed($feed) {
   $stepOne = explode("<content type=\"html\">", $feed);
   $stepTwo = explode("</content>", $stepOne[1]);
   $tweet = $stepTwo[0];
   $tweet = str_replace("&lt;", "<", $tweet);
   $tweet = str_replace("&gt;", ">", $tweet);
   return $tweet;
   }
   $twitterFeed = file_get_contents($feed);
   echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
   ?> </before><after/></leaf><leaf type="insert" title="popular posts by comment count" tooltip=""><before><?php

/*

$pop = $wpdb->get_results("SELECT id, post_title, comment_count FROM {$wpdb->prefix}posts WHERE post_type='post' ORDER BY comment_count DESC LIMIT 10"); ?> <ul> foreach($pop as $post) : ?> <li> <?php echo $post->post_title; ?> </li> <?php endforeach; ?> </ul> </before><after/></leaf><leaf type="insert" title="Most commented posts with thumbnails" tooltip=""><before><?php /*

$popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <?php $justanimage = get_post_meta($post->ID, 'Image', true); if ($justanimage) { ?> <img src="<?php echo get_post_meta($post->ID, "Image", true); ?>" alt="<?php the_title(); ?>" /> <?php } else { ?> <img src="http://an-alternative-image.jpg" alt="" /> <?php } ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php endwhile; ?> </before><after/></leaf><leaf type="insert" title="display parent page title" tooltip=""><before><?php /*

if($post->post_parent) {

   $parent_title = get_the_title($post->post_parent);
   echo $parent_title;

} else {

   wp_title();

} ?> </before><after/></leaf><leaf type="insert" title="detect if post has at least one image" tooltip=""><before><?php /*

$content = $post->post_content; $searchimages = '~<img [^>]* />~';

/*Run preg_match_all to grab all the images and save the results in $pics*/

preg_match_all( $searchimages, $content, $pics );

// Check to see if we have at least 1 image $iNumberOfPics = count($pics[0]);

if ( $iNumberOfPics > 0 ) {

    // Your post have one or more images.

}

?> </before><after/></leaf><leaf type="insert" title="admin only" tooltip="http://wptricks.net/how-to-display-content-for-admin-only/"><before><?php global $user_ID; if( $user_ID ) : ?> <?php if( current_user_can('level_10') ) : ?> <!-- only for admins --> <?php endif; ?> <?php endif; ?></before><after/></leaf></branch>

   <branch title="Template tags">
     <branch title="Modified template tags"><leaf type="insert" title="Date: today, yesterday or date" tooltip="Shows today for today's posts, yesterday for yesterday's posts or date for other posts"><before><?php if (get_the_time('F jS, Y') == date('F jS, Y')){echo "Today";}elseif(get_the_time('F jS, Y') == date('F jS, Y', time()-86400)){echo "Yesterday";}else{the_time('F jS, Y');};  ?></before><after/></leaf><leaf type="insert" title="add  facebook like"><before><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></before><after/></leaf><leaf type="insert" title="display date as time ago" tooltip=""><before><?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?> </before><after/></leaf><leaf type="insert" title="template url"><before><?php bloginfo('template_url'); ?></before><after/></leaf></branch><leaf type="insert" title="HP link">
       <before><?php echo get_option('home'); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="wp_nav_menu()">
       <before> <?php $args = array( 
 'container'       => 'div', 
 'container_class' => 'horizontal-menu', 
 'container_id'    => 'topmenu', 
 'menu_class'      => 'dropdown', 
 'echo'            => true,
 'fallback_cb'     => 'wp_page_menu',
 'depth'           => 0,
 'theme_location'  => 'primary' );

?> <?php wp_nav_menu($args); ?> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="wp_footer()">
       <before><?php wp_footer(); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="wp_head()">
       <before><?php wp_head(); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="get_sidebar()" tooltip="insert 'slug' to call sidebar-slug.php">
       <before><?php get_sidebar(); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="get custom fields">
       <before><?php echo get_post_meta($post->ID, 'Custom field key', true); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="include exact template file">
       <before><?php include (TEMPLATEPATH . '/sidebar.php'); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="get_footer()">
       <before><?php get_footer(); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="get_header()">
       <before><?php get_header(); ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="comments_template()">
       <before><?php comments_template(); ?></before>
       <after/>
     </leaf>
   <leaf type="insert" title="dynamic sidebar"><before><?php // insert dynamic sidebar name or id instead of $index (default = 1)

if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($index) ) : ?> <!-- place your content for the case the dynamic sidebar was not found --> <?php endif; ?></before><after/></leaf><leaf type="insert" title="Archive title"><before><?php if ( is_category() ) { single_cat_title(); } if ( is_tag() ) { single_tag_title(); } if ( is_author() ) { echo "Články autora"; } if ( is_day()) { Články ze dne the_time('F jS, Y'); }

	  	if ( is_month() ) { Články z the_time('F, Y'); }
	  	if (is_year()) { Články z roku the_time('Y'); }      
     ?></before><after/></leaf></branch>
   <branch title="Functions.php">
     <leaf type="insert" title="limit_posts_per_archive_page()">
       <before>function limit_posts_per_archive_page() {

if ( is_category() ) $limit = 10; elseif ( is_search() ) $limit = 10; else $limit = get_option('posts_per_page'); set_query_var('posts_per_archive_page', $limit); } add_filter('pre_get_posts', 'limit_posts_per_archive_page');

?></before>

       <after/>
     </leaf>
     <leaf type="insert" title="register_sidebar">
       <before>if ( function_exists('register_sidebar') ) {

register_sidebar(array('name'=>'my_sidebar', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2>', 'after_title' => '</h2>', )); }</before>

       <after/>
     </leaf>
     <leaf type="insert" title="custom comments style">
       <before>function mytheme_comment($comment, $args, $depth) {
  $GLOBALS['comment'] = $comment; ?>
  <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
    <div id="comment-<?php comment_ID(); ?>">
     <div class="comment-author vcard">
        <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
        <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
     </div>
     <?php if ($comment->comment_approved == '0') : ?>
        <em><?php _e('Your comment is awaiting moderation.') ?></em>
        <br />
     <?php endif; ?>
     <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ',) ?></div>
     <?php comment_text() ?>
     <div class="reply">
        <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
     </div>
    </div>

<?php

       }

</before>

       <after/>
     </leaf>
     <leaf type="insert" title="is_cat_list_empty()"><before>function is_cat_list_empty($content){

$pos1 = strpos($content, '<li>' .__( "No categories" ). '</li>'); if($pos1 === false){ return false; }else{ return true; } }</before><after/></leaf>

     <leaf type="insert" title="don't show "No categories"">
       <before>function bm_dont_display_it($content) {
 if (!empty($content)) {
   $content = str_ireplace('<li>' .__( "No categories" ). '</li>', "", $content);
 }
 return $content;

} add_filter('wp_list_categories','bm_dont_display_it');</before>

       <after/>
     </leaf>
     <leaf type="insert" title="getCurrentCatID()">
       <before>function getCurrentCatID(){
 global $wp_query;
 if(is_category() || is_single()){

$cat_ID = get_query_var('cat');

 }
 return $cat_ID;
}</before>
       <after/>
     </leaf>
     <leaf type="insert" title="new_excerpt_length()">
       <before>function new_excerpt_length($length) {

return 30; } add_filter('excerpt_length', 'new_excerpt_length');</before>

       <after/>
     </leaf>
     <leaf type="insert" title="new_excerpt_more()">
       <before>function new_excerpt_more($excerpt) {

$excerpt = str_replace('[...]', '...', $excerpt); return preg_replace('/<img[^>]*>/Ui', , $excerpt); } add_filter('wp_trim_excerpt', 'new_excerpt_more');</before>

       <after/>
     </leaf>
     <leaf type="insert" title="dimbox_breadcrumbs()" tooltip="breadcrumbs without a plugin"><before>/*

function dimox_breadcrumbs() {

 $delimiter = '&raquo;';
 $name = 'Home'; //text for the 'Home' link
 $currentBefore = '<span class="current">';
 $currentAfter = '</span>';

 if ( !is_home() && !is_front_page() || is_paged() ) {

   echo '<div id="crumbs">';

   global $post;
   $home = get_bloginfo('url');
   echo '<a href="' . $home . '">' . $name . '</a> ' . $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 $currentBefore . 'Archive by category &#39;';
     single_cat_title();
     echo '&#39;' . $currentAfter;

   } elseif ( is_day() ) {
     echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
     echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
     echo $currentBefore . get_the_time('d') . $currentAfter;

   } elseif ( is_month() ) {
     echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
     echo $currentBefore . get_the_time('F') . $currentAfter;

   } elseif ( is_year() ) {
     echo $currentBefore . get_the_time('Y') . $currentAfter;

   } elseif ( is_single() && !is_attachment() ) {
     $cat = get_the_category(); $cat = $cat[0];
     echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
     echo $currentBefore;
     the_title();
     echo $currentAfter;

   } 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 '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
     echo $currentBefore;
     the_title();
     echo $currentAfter;

   } elseif ( is_page() && !$post->post_parent ) {
     echo $currentBefore;
     the_title();
     echo $currentAfter;

   } elseif ( is_page() && $post->post_parent ) {
     $parent_id  = $post->post_parent;
     $breadcrumbs = array();
     while ($parent_id) {
       $page = get_page($parent_id);
       $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
       $parent_id  = $page->post_parent;
     }
     $breadcrumbs = array_reverse($breadcrumbs);
     foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
     echo $currentBefore;
     the_title();
     echo $currentAfter;

   } elseif ( is_search() ) {
     echo $currentBefore . 'Search results for &#39;' . get_search_query() . '&#39;' . $currentAfter;

   } elseif ( is_tag() ) {
     echo $currentBefore . 'Posts tagged &#39;';
     single_tag_title();
     echo '&#39;' . $currentAfter;

   } elseif ( is_author() ) {
      global $author;
     $userdata = get_userdata($author);
     echo $currentBefore . 'Articles posted by ' . $userdata->display_name . $currentAfter;

   } elseif ( is_404() ) {
     echo $currentBefore . 'Error 404' . $currentAfter;
   }

   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 '</div>';

 }

}</before><after/></leaf>

     <leaf type="insert" title="addHomeMenuLink" tooltip="Adds home page link to wp_nav_menu"><before>// http://www.divisionbyzero.co.uk/2010/08/02/how-to-add-a-home-link-to-a-wordpress-3-nav-menu/

function addHomeMenuLink($menuItems, $args) { if('primary' == $args->theme_location) { if ( is_front_page() ) $class = 'class="current_page_item"'; else $class = ;

$homeMenuItem = '<li ' . $class . '>' . $args->before . '<a href="' . home_url( '/' ) . '" title="Home">' . $args->link_before . 'Úvod' . $args->link_after . '</a>' . $args->after . '</li>';

$menuItems = $homeMenuItem . $menuItems; }

return $menuItems; }

add_filter( 'wp_nav_menu_items', 'addHomeMenuLink', 10, 2 );</before><after/></leaf>

     <leaf type="insert" title="addHomePageMenuLink()" tooltip="Adds home page link to wp_page_menu()"><before>// http://www.divisionbyzero.co.uk/2010/08/02/how-to-add-a-home-link-to-a-wordpress-3-nav-menu/

function addHomePageMenuLink($args) { $page=get_page_by_title("Příspěvky");

   $args = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '<span>', 'link_after' => '</span>', 'show_home' => 'Úvod', 'exclude' => $page->ID);
   return $args;

} add_filter('wp_page_menu_args','addHomePageMenuLink');</before><after/></leaf>

     <leaf type="insert" title="register_my_menu()">
       <before>add_action( 'init', 'register_my_menu' );

function register_my_menu() { register_nav_menu( 'my_menu', "My menu description" ); }</before>

       <after/>
     </leaf>
     <leaf type="insert" title="activate thumbnails">
       <before>add_theme_support( 'post-thumbnails' );</before>
       <after/>
     </leaf>
     <leaf type="insert" title="my_search_form()"><before>function my_search_form( $form ) {
   $form = '<form role="search" method="get" id="searchform" action="'.get_bloginfo('url').'" >
   <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
   <input type="text" value="' . get_search_query() . '" name="s" id="s" />
   <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
   </div>
   </form>';
   return $form;

}

add_filter( 'get_search_form', 'my_search_form' ); </before><after/></leaf>

   <leaf type="insert" title="rss thumbnails" tooltip=""><before>// http://www.daveredfern.com/blog/getting-the-most-from-wordpress-post-thumbnail/

function rss_post_thumbnail($content) {

 	global $post;
  	if(has_post_thumbnail($post->ID)) {
  	    	$content = '<p>' . get_the_post_thumbnail($post->ID) .
  	    	   	   '</p>' . get_the_content();
  	}
  	return $content;

} add_filter('the_excerpt_rss', 'rss_post_thumbnail'); add_filter('the_content_feed', 'rss_post_thumbnail');</before><after/></leaf><leaf type="insert" title="disable search" tooltip=""><before>// http://wpengineer.com/1042/disable-wordpress-search/

   function fb_filter_query( $query, $error = true ) {
   if ( is_search() ) {
   $query->is_search = false;
   $query->query_vars[s] = false;
   $query->query[s] = false;
   // to error
   if ( $error == true )
   $query->is_404 = true;
   }
   }
   add_action( 'parse_query', 'fb_filter_query' );
   add_filter( 'get_search_form', create_function( '$a', "return null;" ) );</before><after/></leaf><leaf type="insert" title="disable rss feed" tooltip=""><before>// http://wpengineer.com/287/disable-wordpress-feed/

function fb_disable_feed() { wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') ); }

add_action('do_feed', 'fb_disable_feed', 1); add_action('do_feed_rdf', 'fb_disable_feed', 1); add_action('do_feed_rss', 'fb_disable_feed', 1); add_action('do_feed_rss2', 'fb_disable_feed', 1); add_action('do_feed_atom', 'fb_disable_feed', 1);</before><after/></leaf><leaf type="insert" title="disable html code in comments" tooltip=""><before>// http://www.theblog.ca/literal-comments // This will occur when the comment is posted

function plc_comment_post( $incoming_comment ) {

// convert everything in a comment to display literally $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);

// the one exception is single quotes, which cannot be #039; because WordPress marks it as spam $incoming_comment['comment_content'] = str_replace( "'", '&apos;', $incoming_comment['comment_content'] ); return( $incoming_comment ); }

// This will occur before a comment is displayed function plc_comment_display( $comment_to_display ) {

// Put the single quotes back in $comment_to_display = str_replace( '&apos;', "'", $comment_to_display );

return $comment_to_display;</before><after/></leaf><leaf type="insert" title="remove no follow from posts" tooltip=""><before>// http://digwp.com/2010/02/remove-nofollow-attributes-from-post-content/ function remove_nofollow($string) { $string = str_ireplace(' rel="nofollow"', , $string); return $string; } add_filter('the_content', 'remove_nofollow'); </before><after/></leaf><leaf type="insert" title="excerpt length depending on a category" tooltip=""><before>// http://www.daveredfern.com/ add_filter('excerpt_length', 'my_excerpt_length'); function my_excerpt_length($length) {

   if(in_category(14)) {
       return 13;
   } else {
       return 60;
   }

} </before><after/></leaf><leaf type="insert" title="Automaticly output the content into two columns" tooltip=""><before>/* http://www.kriesi.at/archives/wordpress-display-content-in-multiple-columns

You can use these basic css styles for formating:

.content_right, .content_left{

   float:left;
   width:45%;

}

.content_left{

   padding-right:5%;

}


  • /

function my_multi_col($content){ $columns = explode('<h2>', $content);

$i = 0;

foreach ($columns as $column){ if (($i % 2) == 0){ $return .= '<div class="content_left">' . "\n"; if ($i > 1){ $return .= "<h2>"; } else{ $return .= '<div class="content_right">' . "\n <h2>"; } $return .= $column; $return .= '</p></div>'; $i++; }

if(isset($columns[1])){ $content = wpautop($return); }else{ $content = wpautop($content); } echo $content; } } add_filter('the_content', 'my_multi_col'); </before><after/></leaf><leaf type="insert" title="remove [...] from the excerpt" tooltip=""><before>// http://www.wprecipes.com/how-to-remove-the-from-the-excerpt function trim_excerpt($text) {

 return rtrim($text,'[...]');

} add_filter('get_the_excerpt', 'trim_excerpt');</before><after/></leaf><leaf type="insert" title="get top most parent of a page"><before>// http://wpengineer.com/921/pages-subpages-is-parent/ function get_topmost_parent($post_id){ $parent_id = get_post($post_id)->post_parent; if($parent_id == 0){ return $post_id; }else{ return get_topmost_parent($parent_id); } }</before><after/></leaf><leaf type="insert" title="is page or subpage of" tooltip=""><before>// http://wpengineer.com/921/pages-subpages-is-parent/ // check ID post and child-post function has_parent( $post, $post_id ) { if ($post->ID == $post_id) return true; elseif ($post->post_parent == 0) return false; else return has_parent( get_post($post->post_parent), $post_id ); }</before><after/></leaf><leaf type="insert" title="No post images on home page" tooltip=""><before>// http://www.wprecipes.com/how-to-prevent-post-images-from-being-displayed-on-homepage

add_filter('the_content','wpi_image_content_filter',11);

function wpi_image_content_filter($content){

   if (is_home() || is_front_page()){
     $content = preg_replace("/<img[^>]+\>/i", "", $content);
   }
   return $content;

}</before><after/></leaf><leaf type="insert" title="Add home page link to menu from admininstration"><before>// http://www.wpbeginner.com/wp-themes/how-to-show-home-page-link-in-wordpress-3-0-menu/ function home_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'home_page_menu_args' );</before><after/></leaf><leaf type="insert" title="get_page_by_slug();" tooltip="retriev page object from given slug - url name"><before>/**

* Retrieve a page given its url name.
*
* @since 2.1.0
* @uses $wpdb
*
* @param string $page_title Page url name
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
* @param string $post_type Optional. Post type. Default page.
* @return mixed
*/

function get_page_by_slug($page_title, $output = OBJECT, $post_type = 'page' ) { global $wpdb; $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type= %s", $page_title, $post_type ) ); if ( $page ) return get_page($page, $output);

return null; }</before><after/></leaf></branch>

   <branch title="Plugin calls">
     <leaf type="insert" title="wp_pagenavi()">
       <before><?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?></before>
       <after/>
     </leaf>
     <leaf type="insert" title="the_content_limit()">
       <before><?php the_content_limit(200, "Celý článek"); ?></before>
       <after/>
     </leaf>
   </branch>
   <branch title="wp29 default theme">
     <leaf type="insert" title="single.php">
       <before><?php

get_header(); ?>

<div id="content" class="widecolumn" role="main">

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div class="navigation"> <div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div> <div class="alignright"><?php next_post_link('%link &raquo;') ?></div> </div>

<div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2>

<div class="entry"> <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>

<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> <?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>

<p class="postmetadata alt"> <small> This entry was posted <?php /* This is commented, because it requires a little adjusting sometimes. You'll need to download this plugin, and follow the instructions: http://binarybonsai.com/wordpress/time-since/ */ /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?> on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?> and is filed under <?php the_category(', ') ?>. You can follow any responses to this entry through the <?php post_comments_feed_link('RSS 2.0'); ?> feed.

<?php if ( comments_open() && pings_open() ) { // Both Comments and Pings are open ?> You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(); ?>" rel="trackback">trackback</a> from your own site.

<?php } elseif ( !comments_open() && pings_open() ) { // Only Pings are Open ?> Responses are currently closed, but you can <a href="<?php trackback_url(); ?> " rel="trackback">trackback</a> from your own site.

<?php } elseif ( comments_open() && !pings_open() ) { // Comments are open, Pings are not ?> You can skip to the end and leave a response. Pinging is currently not allowed.

<?php } elseif ( !comments_open() && !pings_open() ) { // Neither Comments, nor Pings are open ?> Both comments and pings are currently closed.

<?php } edit_post_link('Edit this entry',,'.'); ?>

</small> </p>

</div> </div>

<?php comments_template(); ?>

<?php endwhile; else: ?>

<p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>

</div>

<?php get_footer(); ?> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="header.php">
       <before><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

<head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

<?php wp_head(); ?> </head> <body> <div id="page">


<div id="header" role="banner"> <div id="headerimg"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="description"><?php bloginfo('description'); ?></div> </div> </div> <hr /> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="index.php">
       <before><?php get_header(); ?>

<div id="content" class="narrowcolumn" role="main">

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

<div class="entry"> <?php the_content('Read the rest of this entry &raquo;'); ?> </div>

<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', , ' | '); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> </div>

<?php endwhile; ?>

<div class="navigation"> <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div> </div>

<?php else : ?>

<h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?>

<?php endif; ?>

</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="page.php">
       <before><?php get_header(); ?>

<div id="content" class="narrowcolumn" role="main">

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <div class="entry"> <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>

<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

</div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>

<?php comments_template(); ?>

</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="footer.php">
       <before><hr />

<div id="footer" role="contentinfo"> <!-- If you'd like to support WordPress, having the "powered by" link somewhere on your blog is the best way; it's our only promotion or advertising. --> <p> <?php bloginfo('name'); ?> is proudly powered by <a href="http://wordpress.org/">WordPress</a> <br /><a href="<?php bloginfo('rss2_url'); ?>">Entries (RSS)</a> and <a href="<?php bloginfo('comments_rss2_url'); ?>">Comments (RSS)</a>. <!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. --> </p> </div> </div> <?php wp_footer(); ?> </body> </html> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="comments.php">
       <before><?php

// Do not delete these lines if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!');

if ( post_password_required() ) { ?> <p class="nocomments">Tento příspěvek je chráněn heslem. Pro zobrazení komentářu zadejte, prosím, heslo.</p> <?php return; } ?>

<!-- You can start editing here. -->

<?php if ( have_comments() ) : ?> <h3 id="comments"><?php comments_number('Žádné komentáře', 'Jeden komentář', 'Komentářů: %' );?> pro &#8220;<?php the_title(); ?>&#8221;</h3>

<div class="navigation"> <div class="alignleft"><?php previous_comments_link() ?></div> <div class="alignright"><?php next_comments_link() ?></div> </div>

<ol class="commentlist"> <?php wp_list_comments(); ?> </ol>

<div class="navigation"> <div class="alignleft"><?php previous_comments_link() ?></div> <div class="alignright"><?php next_comments_link() ?></div> </div>

<?php else : // this is displayed if there are no comments so far ?>

<?php if ( comments_open() ) : ?> <!-- If comments are open, but there are no comments. -->

<?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Přidávání komentářů je uzavřeno.</p>

<?php endif; ?> <?php endif; ?>


<?php if ( comments_open() ) : ?>

<div id="respond">

<h3><?php comment_form_title( 'Přidat komentář', 'Reagovat na %s' ); ?></h3>

<div class="cancel-comment-reply"> <small><?php cancel_comment_reply_link(); ?></small> </div>

<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?> <p>Musíte být <a href="<?php echo wp_login_url( get_permalink() ); ?>">přihlášen</a> aby bylo možné přidat komentář.</p> <?php else : ?>

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

<?php if ( is_user_logged_in() ) : ?>

<p>Přihlášen jako <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Odhlásit se &raquo;</a></p>

<?php else : ?>

<p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> /> <label for="author"><small>Jméno <?php if ($req) echo "(povinný)"; ?></small></label></p>

<p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> /> <label for="email"><small>Email (nebude zobrazen) <?php if ($req) echo "(povinný)"; ?></small></label></p> <!-- <p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" /> <label for="url"><small>WWW</small></label></p> --> <?php endif; ?>

<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->

<p><textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea></p> <?php do_action('comment_form', $post->ID); ?> <p><input name="submit" type="submit" id="submit" tabindex="5" value="Přidat komentář" /> <?php comment_id_fields(); ?> </p>


</form>

<?php endif; // If registration required and not logged in ?> </div>

<?php endif; // if you delete this the sky will fall on your head ?> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="archive.php">
       <before><?php get_header(); ?>

<div id="content" class="narrowcolumn" role="main">

<?php if (have_posts()) : ?>

	  <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
	  <?php /* If this is a category archive */ if (is_category()) { ?>

<h2 class="pagetitle">Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2>

	  <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>

<h2 class="pagetitle">Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h2>

	  <?php /* If this is a daily archive */ } elseif (is_day()) { ?>

<h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>

	  <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>

<h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>

	  <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>

<h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2> <?php /* If this is an author archive */ } elseif (is_author()) { ?> <h2 class="pagetitle">Author Archive</h2>

	  <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>

<h2 class="pagetitle">Blog Archives</h2>

	  <?php } ?>


<div class="navigation"> <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div> </div>

<?php while (have_posts()) : the_post(); ?> <div <?php post_class() ?>> <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> <small><?php the_time('l, F jS, Y') ?></small>

<div class="entry"> <?php the_content() ?> </div>

<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', , ' | '); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>

</div>

<?php endwhile; ?>

<div class="navigation"> <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div> </div> <?php else :

if ( is_category() ) { // If this is a category archive printf("<h2 class='center'>Sorry, but there aren't any posts in the %s category yet.</h2>", single_cat_title(,false)); } else if ( is_date() ) { // If this is a date archive echo("<h2>Sorry, but there aren't any posts with this date.</h2>"); } else if ( is_author() ) { // If this is a category archive $userdata = get_userdatabylogin(get_query_var('author_name')); printf("<h2 class='center'>Sorry, but there aren't any posts by %s yet.</h2>", $userdata->display_name); } else { echo("<h2 class='center'>No posts found.</h2>"); } get_search_form();

endif; ?>

</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?> </before>

       <after/>
     </leaf>
     <leaf type="insert" title="sidebar.php">
       <before>	<div id="sidebar" role="complementary">

<ul> <?php /* Widgetized sidebar, if you have the plugin installed. */ if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> <li> <?php get_search_form(); ?> </li>

<!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it. <li><h2>Author</h2> <p>A little something about you, the author. Nothing lengthy, just an overview.</p> </li> -->

<?php if ( is_404() || is_category() || is_day() || is_month() || is_year() || is_search() || is_paged() ) { ?> <li>

<?php /* If this is a 404 page */ if (is_404()) { ?> <?php /* If this is a category archive */ } elseif (is_category()) { ?> <p>You are currently browsing the archives for the <?php single_cat_title(); ?> category.</p>

<?php /* If this is a daily archive */ } elseif (is_day()) { ?> <p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a> blog archives for the day <?php the_time('l, F jS, Y'); ?>.</p>

<?php /* If this is a monthly archive */ } elseif (is_month()) { ?> <p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a> blog archives for <?php the_time('F, Y'); ?>.</p>

<?php /* If this is a yearly archive */ } elseif (is_year()) { ?> <p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a> blog archives for the year <?php the_time('Y'); ?>.</p>

<?php /* If this is a search result */ } elseif (is_search()) { ?> <p>You have searched the <a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a> blog archives for <strong>'<?php the_search_query(); ?>'</strong>. If you are unable to find anything in these search results, you can try one of these links.</p>

<?php /* If this set is paginated */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> <p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a> blog archives.</p>

<?php } ?>

</li> <?php }?> </ul> <ul role="navigation"> <?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?>

<li><h2>Archives</h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> </li>

<?php wp_list_categories('show_count=1&title_li=<h2>Categories</h2>'); ?> </ul> <ul> <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?> <?php wp_list_bookmarks(); ?>

<li><h2>Meta</h2> <ul> <?php wp_register(); ?> <li><?php wp_loginout(); ?></li> <li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li> <li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li> <li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li> <?php wp_meta(); ?> </ul> </li> <?php } ?>

<?php endif; ?> </ul> </div>

</before>

       <after/>
     </leaf>
     <leaf type="insert" title="functions.php">
       <before>if ( function_exists('register_sidebar') ) {

register_sidebar(array('name'=>'my_sidebar', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2>', 'after_title' => '</h2>', )); }</before>

       <after/>
     </leaf>
     <leaf type="insert" title="style.css">
       <before>/*

Theme Name: WordPress Default Theme URI: http://wordpress.org/ Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>. Version: 1.6 Author: Michael Heilemann Author URI: http://binarybonsai.com/ Tags: blue, custom header, fixed width, two columns, widgets

Kubrick v1.5 http://binarybonsai.com/kubrick/

This theme was designed and built by Michael Heilemann, whose blog you will find at http://binarybonsai.com/

The CSS, XHTML and design is released under GPL: http://www.opensource.org/licenses/gpl-license.php

  • /


/* Begin Typography & Colors */ body { font-size: 62.5%; /* Resets 1em to 10px */ font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; background: #d5d6d7 url('images/kubrickbgcolor.jpg'); color: #333; text-align: center; }

  1. page {

background-color: white; border: 1px solid #959596; text-align: left; }

  1. header {

background: #73a0c5 url('images/kubrickheader.jpg') no-repeat bottom center; }

  1. headerimg {

margin: 7px 9px 0; height: 192px; width: 740px; }

  1. content {

font-size: 1.2em; }

.widecolumn .entry p { font-size: 1.05em; }

.narrowcolumn .entry, .widecolumn .entry { line-height: 1.4em; }

.widecolumn { line-height: 1.6em; }

.narrowcolumn .postmetadata { text-align: center; }

.thread-alt { background-color: #f8f8f8; } .thread-even { background-color: white; } .depth-1 { border: 1px solid #ddd; }

.even, .alt {

border-left: 1px solid #ddd; }

  1. footer {

background: #e7e7e7 url('images/kubrickfooter.jpg') no-repeat top; border: none; }

small { font-family: Arial, Helvetica, Sans-Serif; font-size: 0.9em; line-height: 1.5em; }

h1, h2, h3 { font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif; font-weight: bold; }

h1 { font-size: 4em; text-align: center; }

  1. headerimg .description {

font-size: 1.2em; text-align: center; }

h2 { font-size: 1.6em; }

h2.pagetitle { font-size: 1.6em; }

  1. sidebar h2 {

font-family: 'Lucida Grande', Verdana, Sans-Serif; font-size: 1.2em; }

h3 { font-size: 1.3em; }

h1, h1 a, h1 a:hover, h1 a:visited, #headerimg .description { text-decoration: none; color: white; }

h2, h2 a, h2 a:visited, h3, h3 a, h3 a:visited { color: #333; }

h2, h2 a, h2 a:hover, h2 a:visited, h3, h3 a, h3 a:hover, h3 a:visited, #sidebar h2, #wp-calendar caption, cite { text-decoration: none; }

.entry p a:visited { color: #b85b5a; }

.sticky { background: #f7f7f7; padding: 0 10px 10px; } .sticky h2 { padding-top: 10px; }

.commentlist li, #commentform input, #commentform textarea { font: 0.9em 'Lucida Grande', Verdana, Arial, Sans-Serif; } .commentlist li ul li { font-size: 1em; }

.commentlist li { font-weight: bold; }

.commentlist li .avatar { float: right; border: 1px solid #eee; padding: 2px; background: #fff; }

.commentlist cite, .commentlist cite a { font-weight: bold; font-style: normal; font-size: 1.1em; }

.commentlist p { font-weight: normal; line-height: 1.5em; text-transform: none; }

  1. commentform p {

font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; }

.commentmetadata { font-weight: normal; }

  1. sidebar {

font: 1em 'Lucida Grande', Verdana, Arial, Sans-Serif; }

small, #sidebar ul ul li, #sidebar ul ol li, .nocomments, .postmetadata, blockquote, strike { color: #777; }

code { font: 1.1em 'Courier New', Courier, Fixed; }

acronym, abbr, span.caps { font-size: 0.9em; letter-spacing: .07em; }

a, h2 a:hover, h3 a:hover { color: #06c; text-decoration: none; }

a:hover { color: #147; text-decoration: underline; }

  1. wp-calendar #prev a, #wp-calendar #next a {

font-size: 9pt; }

  1. wp-calendar a {

text-decoration: none; }

  1. wp-calendar caption {

font: bold 1.3em 'Lucida Grande', Verdana, Arial, Sans-Serif; text-align: center; }

  1. wp-calendar th {

font-style: normal; text-transform: capitalize; } /* End Typography & Colors */


/* Begin Structure */ body { margin: 0 0 20px 0; padding: 0; }

  1. page {

background-color: white; margin: 20px auto; padding: 0; width: 760px; border: 1px solid #959596; }

  1. header {

background-color: #73a0c5; margin: 0 0 0 1px; padding: 0; height: 200px; width: 758px; }

  1. headerimg {

margin: 0; height: 200px; width: 100%; }

.narrowcolumn { float: left; padding: 0 0 20px 45px; margin: 0px 0 0; width: 450px; }

.widecolumn { padding: 10px 0 20px 0; margin: 5px 0 0 150px; width: 450px; }

.post { margin: 0 0 40px; text-align: justify; }

.post hr { display: block; }

.widecolumn .post { margin: 0; }

.narrowcolumn .postmetadata { padding-top: 5px; }

.widecolumn .postmetadata { margin: 30px 0; }

.widecolumn .smallattachment { text-align: center; float: left; width: 128px; margin: 5px 5px 5px 0px; }

.widecolumn .attachment { text-align: center; margin: 5px 0px; }

.postmetadata { clear: both; }

.clear { clear: both; }

  1. footer {

padding: 0; margin: 0 auto; width: 760px; clear: both; }

  1. footer p {

margin: 0; padding: 20px 0; text-align: center; } /* End Structure */


/* Begin Headers */ h1 { padding-top: 70px; margin: 0; }

h2 { margin: 30px 0 0; }

h2.pagetitle { margin-top: 30px; text-align: center; }

  1. sidebar h2 {

margin: 5px 0 0; padding: 0; }

h3 { padding: 0; margin: 30px 0 0; }

h3.comments { padding: 0; margin: 40px auto 20px ; } /* End Headers */


/* Begin Images */ p img { padding: 0; max-width: 100%; }

/* Using 'class="alignright"' on an image will (who would've thought?!) align the image to the right. And using 'class="centered', will of course center the image. This is much better than using align="center", being much more futureproof (and valid) */

img.centered { display: block; margin-left: auto; margin-right: auto; }

img.alignright { padding: 4px; margin: 0 0 2px 7px; display: inline; }

img.alignleft { padding: 4px; margin: 0 7px 2px 0; display: inline; }

.alignright { float: right; }

.alignleft { float: left; } /* End Images */


/* Begin Lists

Special stylized non-IE bullets Do not work in Internet Explorer, which merely default to normal bullets. */

html>body .entry ul { margin-left: 0px; padding: 0 0 0 30px; list-style: none; padding-left: 10px; text-indent: -10px; }

html>body .entry li { margin: 7px 0 8px 10px; }

.entry ul li:before, #sidebar ul ul li:before { content: "\00BB \0020"; }

.entry ol { padding: 0 0 0 35px; margin: 0; }

.entry ol li { margin: 0; padding: 0; }

.postmetadata ul, .postmetadata li { display: inline; list-style-type: none; list-style-image: none; }

  1. sidebar ul, #sidebar ul ol {

margin: 0; padding: 0; }

  1. sidebar ul li {

list-style-type: none; list-style-image: none; margin-bottom: 15px; }

  1. sidebar ul p, #sidebar ul select {

margin: 5px 0 8px; }

  1. sidebar ul ul, #sidebar ul ol {

margin: 5px 0 0 10px; }

  1. sidebar ul ul ul, #sidebar ul ol {

margin: 0 0 0 10px; }

ol li, #sidebar ul ol li { list-style: decimal outside; }

  1. sidebar ul ul li, #sidebar ul ol li {

margin: 3px 0 0; padding: 0; } /* End Entry Lists */


/* Begin Form Elements */

  1. searchform {

margin: 10px auto; padding: 5px 3px; text-align: center; }

  1. sidebar #searchform #s {

width: 108px; padding: 2px; }

  1. sidebar #searchsubmit {

padding: 1px; }

.entry form { /* This is mainly for password protected posts, makes them look better. */ text-align:center; }

select { width: 130px; }

  1. commentform input {

width: 170px; padding: 2px; margin: 5px 5px 1px 0; }

  1. commentform {

margin: 5px 10px 0 0; }

  1. commentform textarea {

width: 100%; padding: 2px; }

  1. respond:after {

content: "."; display: block; height: 0; clear: both; visibility: hidden; }

  1. commentform #submit {

margin: 0 0 5px auto; float: right; } /* End Form Elements */


/* Begin Comments*/ .alt { margin: 0; padding: 10px; }

.commentlist { padding: 0; text-align: justify; }

.commentlist li { margin: 15px 0 10px; padding: 5px 5px 10px 10px; list-style: none;

} .commentlist li ul li { margin-right: -5px; margin-left: 10px; }

.commentlist p { margin: 10px 5px 10px 0; } .children { padding: 0; }

  1. commentform p {

margin: 5px 0; }

.nocomments { text-align: center; margin: 0; padding: 0; }

.commentmetadata { margin: 0; display: block; } /* End Comments */


/* Begin Sidebar */

  1. sidebar

{ padding: 20px 0 10px 0; margin-left: 545px; width: 190px; }

  1. sidebar form {

margin: 0; } /* End Sidebar */


/* Begin Calendar */

  1. wp-calendar {

empty-cells: show; margin: 10px auto 0; width: 155px; }

  1. wp-calendar #next a {

padding-right: 10px; text-align: right; }

  1. wp-calendar #prev a {

padding-left: 10px; text-align: left; }

  1. wp-calendar a {

display: block; }

  1. wp-calendar caption {

text-align: center; width: 100%; }

  1. wp-calendar td {

padding: 3px 0; text-align: center; }

  1. wp-calendar td.pad:hover { /* Doesn't work in IE */

background-color: #fff; } /* End Calendar */


/* Begin Various Tags & Classes */ acronym, abbr, span.caps { cursor: help; }

acronym, abbr { border-bottom: 1px dashed #999; }

blockquote { margin: 15px 30px 0 10px; padding-left: 20px; border-left: 5px solid #ddd; }

blockquote cite { margin: 5px 0 0; display: block; }

.center { text-align: center; }

.hidden { display: none; }

.screen-reader-text {

    position: absolute;
    left: -1000em;

}

hr { display: none; }

a img { border: none; }

.navigation { display: block; text-align: center; margin-top: 10px; margin-bottom: 60px; } /* End Various Tags & Classes*/


/* Captions */ .aligncenter, div.aligncenter { display: block; margin-left: auto; margin-right: auto; }

.wp-caption { border: 1px solid #ddd; text-align: center; background-color: #f3f3f3; padding-top: 4px; margin: 10px; -moz-border-radius: 3px; -khtml-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; }

.wp-caption img { margin: 0; padding: 0; border: 0 none; }

.wp-caption p.wp-caption-text { font-size: 11px; line-height: 17px; padding: 0 4px 5px; margin: 0; } /* End captions */


/* "Daisy, Daisy, give me your answer do. I'm half crazy all for the love of you. It won't be a stylish marriage, I can't afford a carriage. But you'll look sweet upon the seat of a bicycle built for two." */ </before>

       <after/>
     </leaf>
   </branch>
   <branch title="style.css">
     <leaf type="insert" title="WP generated classes" tooltip="should be in every template's style.css"><before>/* WP generated classes */

.aligncenter, div.aligncenter { display: block; margin-left: auto; margin-right: auto; } .alignleft { float: left; } .alignright { float: right; } .wp-caption { background-color: #f3f3f3; border: 1px solid #ddd; -khtml-border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; /* optional rounded corners for browsers that support it */ margin: 10px; padding-top: 4px; text-align: center; } .wp-caption img { border: 0 none; margin: 0; padding: 0; } .wp-caption p.wp-caption-text { font-size: 11px; line-height: 17px; margin: 0; padding: 0 4px 5px; } /* /WP generated classes */</before><after/></leaf>

     <leaf type="insert" title="theme description" tooltip="From this piece of code, the wordpress generates theme info in admin area">
       <before>/*

Theme Name: WordPress Default Theme URI: http://wordpress.org/ Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>. Version: 1.6 Author: Michael Heilemann Author URI: http://binarybonsai.com/ Tags: blue, custom header, fixed width, two columns, widgets

The CSS and XHTML is released under GPL: http://www.opensource.org/licenses/gpl-license.php

  • /</before>
       <after/>
     </leaf>
   </branch>
 <branch title="simple tricks"><leaf type="insert" title="get current cat without a function"><before>$currentCat = get_category(get_query_var('cat'),false);

$currentCatId = $currentCat->cat_ID;</before><after/></leaf></branch>

 <branch title="WordPress GUI for functions"><branch title="Build WP custom menu"><leaf type="insert" title="1) Code for functions.php" tooltip="Insert this code into your function.php file (if you dont have one, create a new file with functions.php name and place it in your template directory)"><before>if ( function_exists( 'register_nav_menu' ) ) {

register_nav_menu( '%0', '%1' ); } </before><after/><param name="Nav menu location identifier (no white spaces - use dashes instead)"/><param name="Description for your new nav menu"/></leaf><leaf type="insert" title="2) Code for the place, where you want to display menu" tooltip="Place in a file, where you want to display menu. Eg.: head.php"><before><?php wp_nav_menu('theme_location=%0&menu=%1&menu_class=%2&menu_id=%3&link_before=%4&link_after=%5&depth=%6&echo=%7&container=%8&container_id=%9&'); ?></before><after/><param name="Location name coresponding to one defined in functions.php"/><param name="Or id of menu which you want to display (will override location parametr)"/><param name="Class asigned to a menu ul tag"/><param name="ID assigned to a menu ul tag"/><param name="Text or element before link text inside link tag ( eg. span )"/><param name="Text or element after link text inside link tag ( eg. span )"/><param name="Depth of link hierarchy ( 0 for all)"/><param name="Display menu or return it as variable (1 for display, 0 for return as variable)"/><param name="Containter wrapping menu ul (default div)"/><param name="Containter ID"/></leaf></branch><branch title="Build dynamic sidebar for widgets"><leaf type="insert" title="1) Code for functions.php" tooltip="Insert this code into your function.php file (if you dont have one, create a new file with functions.php name and place it in your template directory)"><before><?php // this piece of code should be placed in functions.php file. If you dont have one // create new file called functions.php in you template directory ?> <?php $args = array( 'name' => '%0', 'id' => '%1', 'description'=> '%2', 'before_widget' => '%3', 'after_widget' => '%4', 'before_title' => '%5', 'after_title' => '%6' ); ?>

</before><after/><param name="Name of a sidebar (will be displayed in widget administration)"/><param name="ID of widget (default value: sidebar-$i will place a unique id for sidebar)"/><param name="Description of a sidebar"/><param name="HTML element before each widget (eg. <li>)"/><param name="HTML element after each widget (eg. </li> )"/><param name="HTML element before title text (eg. <h2> )"/><param name="HTML element after title text (eg. <h2> )"/></leaf><leaf type="insert" title="2) Code for sidebar-your-name.php file" tooltip="You must create a separate sidebar-your-name.php file and put this code inside. Choose your custom name instead your-name (without white spaces - replace them with hyphens)"><before><?php //this code should be placed in a new file called somewhat //like this: sidebar-your-name.php where the "sidebar-" part is obligatory ?> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('%0') ) : ?> //Here you can place a content for a case you do not have widgets asigned to this sidebar <?php endif; ?></before><after/><param name="Name of your sidebar declared in the functions.php file"/></leaf><leaf type="insert" title="3) Code for the place, where you want to insert your sidebar" tooltip="This will call your sidebar-your-name.php and display it's content"><before><?php get_sidebar('%0'); ?> </before><after/><param name="Name of your sidebar file created in step 2 - only the part after sidebar- and before .php (eg. your-name will call file sidebar-your-name.php file)"/></leaf></branch>

 <leaf type="insert" title="list categories"><before><?php wp_list_categories(array(

'show_option_all'=>, 'orderby'=>'%0', 'order'=>'ASC', 'show_last_update'=>0, 'style'=>'list', 'show_count'=>%1, 'hide_empty'=>%2, 'use_desc_for_title'=>1, 'child_of'=>%3, 'feed'=>, 'feed_type'=>, 'feed_image'=>, 'exclude'=>%4, 'exclude_tree'=>%5, 'include'=>, 'hierarchical'=>true, 'number'=>NULL, 'title_li'=>'%6', // defaults to: __( 'Categories' ) 'echo'=>%8, 'depth'=>%7, 'current_category'=>0, 'pad_counts'=>0, 'taxonomy'=>'category', 'walker'=>'Walker_Category'));?></before><after/><param name="Order by (id, name, slug, count)"/><param name="Show category posts count (1 - show, 0 - dont show)"/><param name="Hide categories with no posts? ( 1 - hide, 0 - show empty cats)"/><param name="Display only children of category ( category ID or leave empty)"/><param name="Exclude category/ies from the list (category id, category id, ... ,category id or leave empty)"/><param name="Exclude category and it's subcategories (category_id, ... , category_id or leave empty)"/><param name="Title of outer list item ( leave empty if no title or write you own title)"/><param name="How many levels to be included ( 0 - all cats, -1 - all cats in flat, 1 - only top level cats, n - number o levels)"/><param name="Show the result or keep in variable? ( 1 show, 0 in variable)"/></leaf><leaf type="insert" title="Theme name and description for style.css file" tooltip="Put this piece of code into your style.css file in your template directory. If you do not have one, create a new style.css file and place this piece of code at the top of this file. If you have your styles in a diferent file (design.css etc.) rename it to a style.css and again, place this piece of code at the top of that file.">

   <before>/*

Theme Name: %0 Theme URI: %1 Description: %2 Version: %3 Author: %4 Author URI: %5 Tags: %6

  • /</before>
   <after/>
   <param name="Theme name"/>
   <param name="Theme homepage"/>
   <param name="Theme description"/>
   <param name="Theme version"/>
   <param name="Name of the author"/>
   <param name="Homepage of author"/>
   <param name="Tags (separet multiple tags with comma)"/>
 </leaf>

<leaf type="insert" title="Get custom field value and diplay it"><before><?php echo get_post_meta(%0, '%1', true); ?></before><after/><param name="Post id ($post->ID for currently displayed post)"/><param name="Custom field name"/></leaf>

<leaf type="insert" title="Insert plugin function in safety way" tooltip="If you are using plugins and their functions, you should allways wrapt it with conditional check based on function_exists()"><before><?php if ( function_exists('%0') : ?> <?php %0(%1);  ?> <?php endif; ?></before><after/><param name="Function name provided by plugin"/><param name="Parameters of the function (including quotes, commas etc.)"/></leaf><leaf type="insert" title="Insert plugin function in safety way with fallback function" tooltip="If you are using plugins and their functions, you should allways wrapt it with conditional check based on function_exists(). This snippet also provides fallback function"><before><?php if ( function_exists('%0') : ?> <?php %0(%1);  ?> <?php else : ?> <?php %2(%3); ?> <?php endif; ?></before><after/><param name="Function name provided by plugin"/><param name="Parameters of the function (including quotes, commas etc.)"/><param name="Fallback function name"/><param name="Parameters of the fallback function (including quotes, commas etc.)"/></leaf><leaf type="insert" title="the_content('more link text')"><before><?php the_content('%0'); ?></before><after/><param name="More link text (default: (more...) )"/></leaf><leaf type="insert" title="the_tags"><before><?php the_tags('%0', '%1', '%2'); ?></before><after/><param name="Text to display before the actual tags are displayed. Defaults to Tags: "/><param name="Text or character to display between each tag link. The default is a comma (,) between each tag"/><param name="Text to display after the last tag. The default is to display nothing"/></leaf><leaf type="insert" title="list pages"><before><?php wp_list_pages( array(

   'depth' => %0,
   'show_date' => ,
   'date_format' => get_option('date_format'),
   'child_of' => %1,
   'exclude' => %2,
   'include' => %3,
   'title_li' => '%4',
   'echo' => %5,
   'authors' => '%6',
   'sort_column' => '%7',
   'link_before' => %8,
   'link_after' => %9,
   'walker' =>  ) ); ?></before><after/><param name="Depth (0 - all nested levels, -1 all levels in flat, 1 - top pages only, n - number of levels"/><param name="Only pages which are child of (page id)"/><param name="Exclude pages (pages ids separateb by comma)"/><param name="include only listed pages (separated by comma)"/><param name="Title displayed before the list ( leave empty for no title )"/><param name="Display the list (1) or save it to variable (0)"/><param name="Only pages by author (comma separated list of authors id)"/><param name="Sort by (menu_order, post_title, ID, post_author, post_name, post_date, post_modified)"/><param name="text or html that precedes the link text inside <a> tag"/><param name="text or html that follows the link text inside <a> tag"/></leaf></branch>

</branch> </snippets>