<?php

add_image_size( 'archive-thumb', 150, 150,true);

//adding hungarian menu for news
function codex_custom_init_posts_hun() {
  $labels = array(
    'name' => 'Hungarian News',
    'singular_name' => 'Post',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Post',
    'edit_item' => 'Edit Post',
    'new_item' => 'New Post',
    'all_items' => 'All Posts',
    'view_item' => 'View Post',
    'search_items' => 'Search Posts',
    'not_found' =>  'No posts found',
    'not_found_in_trash' => 'No posts found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Hun Posts'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'hirek','with_front' => FALSE),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'has_archive' ),
    'taxonomies' => array( 'categories' )
  ); 

  register_post_type( 'posts-hun', $args );
}
add_action( 'init', 'codex_custom_init_posts_hun', 0);
//adding hungarian menu for news

//adding serbian menu for news
function codex_custom_init_posts_srb() {
  $labels = array(
    'name' => 'Serbian News',
    'singular_name' => 'Post',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Post',
    'edit_item' => 'Edit Post',
    'new_item' => 'New Post',
    'all_items' => 'All Posts',
    'view_item' => 'View Post',
    'search_items' => 'Search Posts',
    'not_found' =>  'No posts found',
    'not_found_in_trash' => 'No posts found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Srb Posts'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'aktualno','with_front' => FALSE),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'has_archive' ),
    'taxonomies' => array( 'categories' )

  ); 

  register_post_type( 'posts-srb', $args );
}
add_action( 'init', 'codex_custom_init_posts_srb', 0);
//end of adding serbian menu for news

//adding english menu for news
function codex_custom_init_posts_eng() {
  $labels = array(
    'name' => 'English News',
    'singular_name' => 'Post',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Post',
    'edit_item' => 'Edit Post',
    'new_item' => 'New Post',
    'all_items' => 'All Posts',
    'view_item' => 'View Post',
    'search_items' => 'Search Posts',
    'not_found' =>  'No posts found',
    'not_found_in_trash' => 'No posts found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Eng Posts'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'news','with_front' => FALSE),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'has_archive' ),
    'taxonomies' => array( 'categories' )
  ); 

  register_post_type( 'posts-eng', $args );
}
add_action( 'init', 'codex_custom_init_posts_eng', 0);
//adding hungarian menu for news

//adding hungarian menu
function codex_custom_init_hun() {
  $labels = array(
    'name' => 'Hungarian Products',
    'singular_name' => 'Product',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Product',
    'edit_item' => 'Edit Product',
    'new_item' => 'New Product',
    'all_items' => 'All Product',
    'view_item' => 'View Product',
    'search_items' => 'Search Product',
    'not_found' =>  'No products found',
    'not_found_in_trash' => 'No products found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Hun Products'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'termekeink','with_front' => FALSE),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'has_archive' ),
    'taxonomies' => array( 'categories' )
  ); 

  register_post_type( 'products-hun', $args );
}
add_action( 'init', 'codex_custom_init_hun', 0);
//end of hungarian menu

//adding serbian menu
function codex_custom_init_srb() {
  $labels = array(
    'name' => 'Serbian Products',
    'singular_name' => 'Product',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Product',
    'edit_item' => 'Edit Product',
    'new_item' => 'New Product',
    'all_items' => 'All Product',
    'view_item' => 'View Product',
    'search_items' => 'Search Product',
    'not_found' =>  'No products found',
    'not_found_in_trash' => 'No products found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Srb Products'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'nasi-proizvodi','with_front' => FALSE),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'has_archive' ),
    'taxonomies' => array( 'categories' )
  ); 

  register_post_type( 'products-srb', $args );
}
add_action( 'init', 'codex_custom_init_srb', 0);
//end of serbian menu

//adding english menu
function codex_custom_init_eng() {
  $labels = array(
    'name' => 'English Products',
    'singular_name' => 'Product',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New Product',
    'edit_item' => 'Edit Product',
    'new_item' => 'New Product',
    'all_items' => 'All Product',
    'view_item' => 'View Product',
    'search_items' => 'Search Product',
    'not_found' =>  'No products found',
    'not_found_in_trash' => 'No products found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Eng Products'
  );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'our-products','with_front' => FALSE),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'has_archive' ),
    'taxonomies' => array( 'categories' )
  ); 

  register_post_type( 'products-eng', $args );
}
add_action( 'init', 'codex_custom_init_eng', 0);
//end of english menu

//adding category support to hungarian posts
function my_taxonomies_posts_hun() {
$labels = array(
	'name'              => _x( 'Post Categories', 'taxonomy general name' ),
	'singular_name'     => _x( 'Post Category', 'taxonomy singular name' ),
	'search_items'      => __( 'Search Post Categories' ),
	'all_items'         => __( 'All Post Categories' ),
	'parent_item'       => __( 'Parent Post Category' ),
	'parent_item_colon' => __( 'Parent Post Category:' ),
	'edit_item'         => __( 'Edit Post Category' ), 
	'update_item'       => __( 'Update Post Category' ),
	'add_new_item'      => __( 'Add New Post Category' ),
	'new_item_name'     => __( 'New Post Category' ),
	'menu_name'         => __( 'Categories' ),
);
$args = array(
	'labels' => $labels,
	'hierarchical' => true,
);
register_taxonomy( 'fokategoriak', 'posts-hun', $args );
}
add_action( 'init', 'my_taxonomies_posts_hun', 0 );

//adding category support to serbian posts
function my_taxonomies_posts_srb() {
$labels = array(
	'name'              => _x( 'Post Categories', 'taxonomy general name' ),
	'singular_name'     => _x( 'Post Category', 'taxonomy singular name' ),
	'search_items'      => __( 'Search Post Categories' ),
	'all_items'         => __( 'All Post Categories' ),
	'parent_item'       => __( 'Parent Post Category' ),
	'parent_item_colon' => __( 'Parent Post Category:' ),
	'edit_item'         => __( 'Edit Post Category' ), 
	'update_item'       => __( 'Update Post Category' ),
	'add_new_item'      => __( 'Add New Post Category' ),
	'new_item_name'     => __( 'New Post Category' ),
	'menu_name'         => __( 'Categories' ),
);
$args = array(
	'labels' => $labels,
	'hierarchical' => true,
);
register_taxonomy( 'glavne-kategorije', 'posts-srb', $args );
}
add_action( 'init', 'my_taxonomies_posts_srb', 0 );

//adding category support to english posts
function my_taxonomies_posts_eng() {
$labels = array(
	'name'              => _x( 'Post Categories', 'taxonomy general name' ),
	'singular_name'     => _x( 'Post Category', 'taxonomy singular name' ),
	'search_items'      => __( 'Search Post Categories' ),
	'all_items'         => __( 'All Post Categories' ),
	'parent_item'       => __( 'Parent Post Category' ),
	'parent_item_colon' => __( 'Parent Post Category:' ),
	'edit_item'         => __( 'Edit Post Category' ), 
	'update_item'       => __( 'Update Post Category' ),
	'add_new_item'      => __( 'Add New Post Category' ),
	'new_item_name'     => __( 'New Post Category' ),
	'menu_name'         => __( 'Categories' ),
);
$args = array(
	'labels' => $labels,
	'hierarchical' => true,
);
register_taxonomy( 'main-categories', 'posts-eng', $args );
}
add_action( 'init', 'my_taxonomies_posts_eng', 0 );

//adding category support to serbian products
function my_taxonomies_products_srb() {
$labels = array(
	'name'              => _x( 'Post Categories', 'taxonomy general name' ),
	'singular_name'     => _x( 'Post Category', 'taxonomy singular name' ),
	'search_items'      => __( 'Search Post Categories' ),
	'all_items'         => __( 'All Post Categories' ),
	'parent_item'       => __( 'Parent Post Category' ),
	'parent_item_colon' => __( 'Parent Post Category:' ),
	'edit_item'         => __( 'Edit Post Category' ), 
	'update_item'       => __( 'Update Post Category' ),
	'add_new_item'      => __( 'Add New Post Category' ),
	'new_item_name'     => __( 'New Post Category' ),
	'menu_name'         => __( 'Categories' ),
);
$args = array(
	'labels' => $labels,
	'hierarchical' => true,
);
register_taxonomy( 'kategorije-proizvoda', 'products-srb', $args );

}
add_action( 'init', 'my_taxonomies_products_srb', 0 );

//adding category support to serbian products
function my_taxonomies_products_hun() {
$labels = array(
	'name'              => _x( 'Post Categories', 'taxonomy general name' ),
	'singular_name'     => _x( 'Post Category', 'taxonomy singular name' ),
	'search_items'      => __( 'Search Post Categories' ),
	'all_items'         => __( 'All Post Categories' ),
	'parent_item'       => __( 'Parent Post Category' ),
	'parent_item_colon' => __( 'Parent Post Category:' ),
	'edit_item'         => __( 'Edit Post Category' ), 
	'update_item'       => __( 'Update Post Category' ),
	'add_new_item'      => __( 'Add New Post Category' ),
	'new_item_name'     => __( 'New Post Category' ),
	'menu_name'         => __( 'Categories' ),
);
$args = array(
	'labels' => $labels,
	'hierarchical' => true,
);

register_taxonomy( 'termek-kategoriak', 'products-hun', $args );
}
add_action( 'init', 'my_taxonomies_products_hun', 0 );

//adding category support to english products
function my_taxonomies_products_eng() {
$labels = array(
	'name'              => _x( 'Post Categories', 'taxonomy general name' ),
	'singular_name'     => _x( 'Post Category', 'taxonomy singular name' ),
	'search_items'      => __( 'Search Post Categories' ),
	'all_items'         => __( 'All Post Categories' ),
	'parent_item'       => __( 'Parent Post Category' ),
	'parent_item_colon' => __( 'Parent Post Category:' ),
	'edit_item'         => __( 'Edit Post Category' ), 
	'update_item'       => __( 'Update Post Category' ),
	'add_new_item'      => __( 'Add New Post Category' ),
	'new_item_name'     => __( 'New Post Category' ),
	'menu_name'         => __( 'Categories' ),
);
$args = array(
	'labels' => $labels,
	'hierarchical' => true,
);

register_taxonomy( 'product-categories', 'products-eng', $args );
}
add_action( 'init', 'my_taxonomies_products_eng', 0 );




function php_execute($html){
if(strpos($html,"<"."?php")!==false){
ob_start();
eval("?".">".$html);
$html=ob_get_contents();
ob_end_clean();
}
return $html;
}
add_filter('widget_text','php_execute',100);

// Localization
load_theme_textdomain('cp', TEMPLATEPATH.'/lang/');


// load admin menu
require_once ( TEMPLATEPATH . '/admin/admin-menu.php');


// Register Sidebar
if ( function_exists('register_sidebar') ) 
{
   register_sidebar(array(
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div><!-- #END widgetcontent --></div><!-- #END widget --><div class="clear"></div>',
		'before_title' => '<h2 class="widgettitle">',
		'after_title' => '</h2><div class="widgetcontent">',
   ));
}

// Register Sponsors Sidebar
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Sponsor Sidebar',
'id' => 'sponsor-sidebar',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div><!-- #END widgetcontent --></div><!-- #END widget --><div class="clear"></div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2><div class="widgetcontent">',
));
}



// remove nofollow attribute
function remove_nofollow($string) 
{
	$string = str_ireplace(' rel="nofollow"', '', $string);
	return $string;
}
add_filter('the_content', 'remove_nofollow');
add_filter('comment_text', 'remove_nofollow');


// the new search widget
function cp_search_widget() 
{
	?>
	<div class="widget">
		<h2 class="widgettitle"><?php _e('Search', 'cp'); ?></h2>
		<div class="widgetcontent">
			<div class="widgetsearchform"><?php include(TEMPLATEPATH.'/searchform.php');?></div>
		</div>
	</div>
	<div class="clear"></div>
	<?php
}
register_sidebar_widget('CP Search', 'cp_search_widget');


// unregister the standard search widget
function cp_unregister_widgets() 
{
	unregister_widget('WP_Widget_Search');         
}
add_action('widgets_init', 'cp_unregister_widgets');  



// Add support for post thumbnails -- only WP 2.9+
if ( function_exists('add_theme_support') ) 
{
	add_theme_support('post-thumbnails');
	set_post_thumbnail_size(150,150);
}


// new comment function
function cp_comment_author_link() 
{
	$comment_author_link = get_comment_author_link();
	if ( ereg(']* class=[^>]+>', $comment_author_link) ) 
	{
		$comment_author_link = ereg_replace('(]* class=[\'"]?)', '\\1url ' , $comment_author_link );
	} 
	else 
	{
		$comment_author_link = ereg_replace('(<a )/', '\\1class="url "' , $comment_author_link );
	}
    echo $comment_author_link;
}


function cp_comment_author_avatar() 
{
	$email = get_comment_author_email();
	$avatar = str_replace("class='avatar", "class='photo avatar", get_avatar("$email", "42" ) );
	echo $avatar;
}


function cp_comments( $comment, $args, $depth ) 
{

	$GLOBALS['comment'] = $comment; ?>
                 
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
		
		<a name="comment-<?php comment_ID() ?>"></a>
		
		<div class="comment-meta">
      
			<span class="name"><?php cp_comment_author_avatar(); ?></span>

			<?php if ( (get_comment_type() == "comment") ) { cp_comment_author_link(); } ?>
			<?php if ( (get_comment_type() == "pingback") or (get_comment_type() == "trackback") ) { ?><?php cp_comment_author_link(); ?><br /><?php } ?>
      	
			<?php if ( (get_comment_type() == "comment") or (get_comment_type() == "pingback") or (get_comment_type() == "trackback") ) { ?>
           		
				<span class="comment-date"> <?php _e('on', 'cp'); ?> <?php echo get_comment_date( __('F jS, Y', 'cp') ); ?> <?php _e('at', 'cp'); ?> <?php echo get_comment_time(); ?></span>
				<span class="edit"><?php edit_comment_link( __('Edit', 'cp'), '', '' ); ?></span>
				<span class="permalink"><a class="comment-permalink" href="<?php echo get_comment_link(); ?>" title="<?php _e('Direct link to this comment', 'cp'); ?>">#</a></span>
           		
			<?php } ?>
	     
		</div>
    	
		<div class="comment-entry" id="comment-<?php comment_ID(); ?>">
			
			<?php comment_text() ?>

			<?php if ( $comment->comment_approved == '0') { ?> <p class='comment-unapproved'><?php _e('Your comment is awaiting moderation.', 'cp'); ?></p> <?php } ?>
			
			<div class="comment-reply">

				<?php comment_reply_link( array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']) ) ) ?>

			</div>
			
		</div>

		<div class="clear"></div>   

	<?php 
} 

/* ------------------------ */
/*  define some shortcodes  */
/*  used in footer text     */
/* ------------------------ */

function cp_shortcode_copyright()
{
	return sprintf('&copy; %1$s <a href="%2$s" title="%3$s">%3$s</a> ', date('Y'), get_bloginfo('url'), get_bloginfo('name') );
}

function cp_shortcode_wordpress()
{
	return sprintf('%1$s <a href="http://wordpress.org" title="Wordpress">Wordpress</a> ', __('Powered by', 'cp') );
}

function cp_shortcode_credit()
{
	return sprintf('%1$s <a target="_blank" href="http://cproell.de/" title="Christian Proell">CP-Themes</a> ', __('Theme by', 'cp') );
}

add_shortcode ('copyright', 'cp_shortcode_copyright'); 
add_shortcode ('wordpress', 'cp_shortcode_wordpress');
add_shortcode ('credit', 'cp_shortcode_credit');


?>
