/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, icons, and column width.
*/
//The Widgetization Code (sidebar, under adsense)
if ( function_exists('register_sidebar') ) {
register_sidebar(array('name'=>'Right Sidebar','before_widget' => '
','after_widget' => '
','before_title' => '','after_title' => '
',)); }
//Define the wp_content DIR for backward compatibility
if (!defined('WP_CONTENT_URL'))
define('WP_CONTENT_URL', get_option('site_url').'/wp-content');
if (!defined('WP_CONTENT_DIR'))
define('WP_CONTENT_DIR', ABSPATH.'/wp-content');
//Define the content width for images
$max_width = 323;
$GLOBALS['content_width'] = 323;
///////////////////////////////
//Include modularized lib files
///////////////////////////////
//Custom Breadcrumb plugin
include(TEMPLATEPATH."/lib/breadcrumb.php");
//Default Custom Field code
include(TEMPLATEPATH."/lib/custom-fields.php");
//Legacy Code (for backward compatibility)
if(!function_exists('wp_page_menu')) { //if pre-2.7
include(TEMPLATEPATH."/legacy/legacy.php"); }
//wp_page_menu argument filter
add_filter('wp_page_menu_args','skyye_page_menu_args');
function skyye_page_menu_args($args) {
$exclude = get_skyye_option('exclude_pages');
$show_home = (!in_array('home',(array)$exclude)) ? 1 : 0;
$exclude_pages = implode(',',(array)$exclude);
$args = array('show_home' => $show_home,
'title_li' => '', 'sort_column' => 'post_title',
'menu_class' => 'menu', 'echo' => true,
'exclude' => $exclude_pages);
return $args;
}
//A function to include files throughout the theme
//It checks to see if the file exists first, so as to avoid error messages.
function get_template_file($filename) {
if (file_exists(TEMPLATEPATH."/$filename"))
include(TEMPLATEPATH."/$filename");
}
//A function to RETURN the content
//of a theme option, defined as an argument.
function get_skyye_option($option) {
global $wp_theme_options;
$option = $wp_theme_options[$option];
$option = (!is_array($option)) ? stripslashes($option) : $option;
if(!$option) return FALSE;
return $option;
}
//A function to ECHO the content
//of a theme option, defined as an argument.
function skyye_option($option) {
echo get_skyye_option($option);
}
//A simple function to get data stored in a custom field
function get_custom_field($field) {
global $post;
$custom_field = get_post_meta($post->ID, $field, true);
echo $custom_field;
}
//A function to get custom field image attachment...
//if there is none, use default image
function image_attachment($field, $width, $height) {
global $post;
$custom_field = get_post_meta($post->ID, $field, true);
//default fallback URL and PATH
$default_img = get_bloginfo('template_url').'/images/'.$field.'.png';
$default_img_path = TEMPLATEPATH.'/images/'.$field.'.png';
if($custom_field) { //if the user set a custom field
echo '
';
}
elseif (file_exists($default_img_path)) { //if the fallback image exists
echo '
';
}
else { //if fallback image does not exist, use a grey block div
echo '';
}
}
function new_excerpt_more($excerpt) {
return str_replace('[...]', '...', $excerpt);
}
add_filter('wp_trim_excerpt', 'new_excerpt_more');
$catty = "";
function wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
global $request, $posts_per_page, $wpdb, $paged;
if(empty($prelabel)) {
$prelabel = '';
}
if(empty($nxtlabel)) {
$nxtlabel = '';
}
$half_pages_to_show = round($pages_to_show/2);
if (!is_single()) {
if(!is_category()) {
preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);
} else {
preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
}
$fromwhere = $matches[1];
$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
$max_page = ceil($numposts /$posts_per_page);
if(empty($paged)) {
$paged = 1;
}
if($max_page > 1 || $always_show) {
echo "$before $after";
}
}
}
?>