<?php 

if (function_exists('add_post_type_support')) add_post_type_support( 'page', 'excerpt' );
add_theme_support( 'automatic-feed-links' );

if ( ! function_exists( 'concept_blog_options_stored_in_one_row' ) ){
	function concept_blog_options_stored_in_one_row(){
		global $concept_blog_store_options_in_one_row;
		
		return isset( $concept_blog_store_options_in_one_row ) ? (bool) $concept_blog_store_options_in_one_row : false; 
	}
}

if ( ! function_exists( 'concept_blog_get_theme_option' ) ){
	function concept_blog_get_theme_option( $option_name, $default_value = '' ){
		global $concept_blog_theme_options, $shortname;

		if ( concept_blog_options_stored_in_one_row() ){
			$concept_blog_theme_options_name = $shortname;
			
			if ( ! isset( $concept_blog_theme_options ) ) $concept_blog_theme_options = get_option( $concept_blog_theme_options_name );
			$option_value = isset ( $concept_blog_theme_options[$option_name] ) ? $concept_blog_theme_options[$option_name] : false;
		} else {
			$option_value = get_option( $option_name );
		}
		
		if ( !$option_value && '' != $default_value ) $option_value = $default_value;
		
		return $option_value;
	}
}

if ( ! function_exists( 'concept_blog_update_theme_option' ) ){
	function concept_blog_update_theme_option( $option_name, $new_value ){
		global $concept_blog_theme_options, $shortname;
		
		if ( concept_blog_options_stored_in_one_row() ){
			$concept_blog_theme_options_name =  $shortname;
			
			if ( ! isset( $concept_blog_theme_options ) ) $concept_blog_theme_options = get_option( $concept_blog_theme_options_name );
			$concept_blog_theme_options[$option_name] = $new_value;
			
			$option_name = $concept_blog_theme_options_name;
			$new_value = $concept_blog_theme_options;
		}
		
		update_option( $option_name, $new_value );
	}
}

if ( ! function_exists( 'concept_blog_delete_theme_option' ) ){
	function concept_blog_delete_theme_option( $option_name ){
		global $concept_blog_theme_options, $concept_blog_shortname;
		
		if ( concept_blog_options_stored_in_one_row() ){
			$concept_blog_theme_options_name =  $concept_blog_shortname;
			
			if ( ! isset( $concept_blog_theme_options ) ) $concept_blog_theme_options = get_option( $concept_blog_theme_options_name );
			
			unset( $concept_blog_theme_options[$option_name] );
			update_option( $concept_blog_theme_options_name, $concept_blog_theme_options );
		} else {
			delete_option( $option_name );
		}
	}
}

if ( ! function_exists( 'concept_blog_in_subcat' ) ){
	function concept_blog_in_subcat($blogcat,$current_cat='') {
		$in_subcategory = false;
		
		if (cat_is_ancestor_of($blogcat,$current_cat) || $blogcat == $current_cat) $in_subcategory = true;
			
		return $in_subcategory;
	}
}

/*** GETS PAGE NAME BY IT'S ID ***/
if ( ! function_exists( 'concept_blog_get_pagename' ) ){
	function concept_blog_get_pagename( $page_id )
	{
		$page_object = get_page( $page_id );
		
		return apply_filters( 'the_title', $page_object->post_title, $page_id );
	}
}

/*** GETS CATEGORY NAME BY IT'S ID ***/
if ( ! function_exists( 'concept_blog_get_categname' ) ){
	function concept_blog_get_categname( $cat_id )
	{
		return get_cat_name( $cat_id );
	}
}

/*** GETS CATEGORY ID BY IT'S NAME ***/
if ( ! function_exists( 'concept_blog_get_catId' ) ){
	function concept_blog_get_catId($cat_name)
	{
		$cat_name_id = get_cat_ID( html_entity_decode( $cat_name, ENT_QUOTES ) );
		return $cat_name_id;
	}
}

/*** GETS PAGE ID BY IT'S NAME ***/
if ( ! function_exists( 'concept_blog_get_pageId' ) ){
	function concept_blog_get_pageId( $page_name )
	{
		global $wpdb;
		
		if ( is_numeric( $page_name ) ) return $page_name;
		
		$page_name = html_entity_decode( $page_name, ENT_QUOTES );
		$page = get_page_by_title( $page_name );

		return $page->ID;
	}
}
?>