max_num_pages > 1) { $output .= ''; } return $output; } /* Output Content Nav -------------------------------------------------*/ function tally_paginate2(){ global $wp_query; $query = $wp_query; $output = null; if ($query->max_num_pages > 1) { $output .= ''; } return $output; } /* Register Widgets -------------------------------------------------*/ function tally_register_sidebar(){ register_sidebar( array( 'name' => __('Primary Sidebar', 'doctors'), 'id' => 'sidebar', 'description' => __('Primary Sidebar Widgets', 'doctors'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => __('Footer Widget #1', 'doctors'), 'id' => 'footer_widget_1', 'description' => __('Footer Widget #1', 'doctors'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => __('Footer Widget #2', 'doctors'), 'id' => 'footer_widget_2', 'description' => __('Footer Widget #2', 'doctors'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => __('Footer Widget #3', 'doctors'), 'id' => 'footer_widget_3', 'description' => __('Footer Widget #3', 'doctors'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => '

', )); register_sidebar( array( 'name' => __('Footer Widget #4', 'doctors'), 'id' => 'footer_widget_4', 'description' => __('Footer Widget #4', 'doctors'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => '

', )); } add_action('widgets_init', 'tally_register_sidebar'); /* Default Theme Option -------------------------------------------------*/ function tally_option_default($option_name){ if(file_exists( tally_file_directory('includes/trunk/'.tally_config('slug').'/'.tally_config('slug').'_mods.php') )){ include( tally_file_directory('includes/trunk/'.tally_config('slug').'/'.tally_config('slug').'_mods.php') ); }else{ include( tally_file_directory('includes/default_mods.php') ); } if(isset($tally_mood[$option_name])){ return $tally_mood[$option_name]; } } /* Theme Option -------------------------------------------------*/ function tally_option($option){ return get_theme_mod($option, tally_option_default($option)); } /* Content Resource Loader -------------------------------------------------*/ function tally_content_resource_loader($file_name, $name, $current_post_id){ $file = tally_file_directory('contents/'.$name.'/'.tally_config($name).'/'.$file_name.'.php'); if(file_exists($file)){ include($file); } } /* Config -------------------------------------------------*/ function tally_config($slug){ $default = array(); $default['dev_mood'] = false; if(file_exists(tally_file_directory('includes/getver.php'))){ include(tally_file_directory('includes/getver.php')); } $config = array_merge($default, $tally_getver); if( $slug != '' ){ if(isset($config[$slug])){ return $config[$slug]; } } } /* Breadcrumb -------------------------------------------------*/ function tally_breadcrumb($separator = " » ") { global $post; echo ''; } /* Show Save Data -------------------------------------------------*/ function tally_get_saved_data(){ $theme_mood = get_theme_mods(); echo ''; } function tally_get_saved_data_all(){ $theme_mood = get_theme_mods(); if(file_exists( tally_file_directory('includes/default_mods.php') )){ include( tally_file_directory('includes/default_mods.php') ); }else{ include( tally_file_directory('includes/default_mods_s.php') ); } $data = array_merge($tally_mood, $theme_mood); echo ''; } /* Create Config Array -------------------------------------------------*/ function tally_create_array_from_option($options){ $output = ''; if(is_array($options )){ $output .= ' $option){ if(is_array($option)){ $output .= "'".$key."' => array(" . "\n"; foreach($option as $key_1 => $option_1){ if(is_array($option_1)){ $output .= "\t" . "array(" . "\n"; foreach($option_1 as $key_2 => $option_2){ if(is_array($option_2)){ $output .= "\t" . "\t" . "array(" . "\n"; foreach($option_2 as $key_3 => $option_3){ $output .= "\t" . "\t" . "\t" . "'".$key_3."' => '".str_replace("'","\'",$option_3)."'," . "\n"; } $output .= "\t" . "\t" . ")," . "\n"; }else{ $output .= "\t" . "\t" . "'".$key_2."' => '".str_replace("'","\'",$option_2)."'," . "\n"; } } $output .= "\t" . ")," . "\n"; }else{ $output .= "\t" . "'".$key_1."' => '".str_replace("'","\'",$option_1)."'," . "\n"; } } $output .= ")," . "\n"; }else{ $output .= "'".$key."' => '".str_replace("'","\'",$option)."'," . "\n"; } } $output .= ');'; } return $output; } /* Home Style Option -------------------------------------------------*/ function tally_home_style_option($section_id, $name){ $section_option = $section_id.$name.'Color'; $main_option = 'tally_color_main_'.$name; if(tally_option($section_option) != ''){ return tally_option($section_option); }else{ return tally_option($main_option); } } /* tally_max_charlength -------------------------------------------------*/ function tally_max_charlength($charlength, $text = null) { if ($text){ $excerpt = $text; }else{ $excerpt = get_the_excerpt(); } $charlength++; if (strlen($excerpt)>$charlength) { $subex = substr($excerpt,0,$charlength-5); $exwords = explode(" ",$subex); $excut = -(strlen($exwords[count($exwords)-1])); if ($excut<0) { return substr($subex,0,$excut); }else{ return $subex; } return '...'; } else { return $excerpt; } } /* Resize image -------------------------------------------------*/ if(!function_exists('tally_image')): function tally_image($url, $width = '', $height = '', $crop = true, $placeholder = true, $align = '', $retina = TALLY_IMAGE_RETINA_SUPPORT){ global $wpdb, $blog_id; $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$url'"; $id = $wpdb->get_var($query); $the_image_name = basename($url); if(($id == true) && function_exists('mr_image_resize') && ($url != NULL)){ return mr_image_resize($url, $width, $height, $crop, $align, $retina); } elseif((file_exists(get_stylesheet_directory().'/images/demo/'.$the_image_name)) && function_exists('mr_image_resize') && ($url != NULL)){ list($or_width, $or_height) = getimagesize(get_template_directory().'/images/demo/'.$the_image_name); if( ($or_width == $width) && ($or_height == $height) ){ return get_template_directory_uri().'/images/demo/'.$the_image_name; }else{ return mr_image_resize(get_template_directory_uri().'/images/demo/'.$the_image_name, $width, $height, $crop, $align, $retina); } } elseif((file_exists(get_template_directory().'/images/demo/'.$the_image_name)) && function_exists('mr_image_resize') && ($url != NULL)){ list($or_width, $or_height) = getimagesize(get_template_directory().'/images/demo/'.$the_image_name); if( ($or_width == $width) && ($or_height == $height) ){ return get_template_directory_uri().'/images/demo/'.$the_image_name; }else{ return mr_image_resize(get_template_directory_uri().'/images/demo/'.$the_image_name, $width, $height, $crop, $align, $retina); } } else{ return 'http://placehold.it/'.$width.'x'.$height; } } endif; /* Get First Media -------------------------------------------------*/ function tally_get_first_embed_media($post_id, $type = 'video', $image = NULL) { $post = get_post($post_id); $content = do_shortcode( apply_filters( 'the_content', $post->post_content ) ); $embeds = get_media_embedded_in_content( $content ); if( !empty($embeds) ) { if($type == 'video'){ foreach( $embeds as $embed ) { if( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) || strpos( $embed, 'iframe' ) ) { return '
'.$embed.'
'; } } }elseif($type == 'audio'){ foreach( $embeds as $embed ) { if( strpos( $embed, 'audio' ) && strpos( $embed, 'wp-audio-shortcode' ) ) { if($image != NULL){ $image = ''.$post->title.''; } return '
'.$image.$embed.'
'; }else{ return '
'.$embed.'
'; } } } } else { //No video embedded found return false; } } /* Warp embed media -------------------------------------------------*/ function add_video_embed_note($html, $url, $attr) { if( strpos( $html, 'video' ) || strpos( $html, 'youtube' ) || strpos( $html, 'vimeo' ) || strpos( $html, 'iframe' ) ) { return '
'.$html.'
'; } else { return $html; } } add_filter('embed_oembed_html', 'add_video_embed_note', 10, 3);