Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //sidebars
- include(get_template_directory().'/functions/rt_ud_sidebars.php');
- //custom post types - taxonomies
- include(get_template_directory().'/functions/rt_custom_posts.php');
- rt_theme_custom_posts(); //call custom post types
- //admin panel options
- if(is_admin()):
- include(get_template_directory().'/rttheme_options/includes.php');
- endif;
- if(!is_admin()):
- //vt resize
- include(get_template_directory().'/rttheme_options/plugins/vt_resize.php');
- //breadcrumb function
- include(get_template_directory().'/functions/rt_breadcrumb.php');
- //shortcodes
- include(get_template_directory().'/functions/rt_shortcodes.php');
- //comments
- include(get_template_directory().'/functions/rt_comments.php');
- endif;
- if ( ! isset( $content_width ) ) $content_width = 680;
- // Load text domain
- load_theme_textdomain('rt_theme', get_template_directory().'/languages' );
- // Automatic Feed Links
- add_theme_support( 'automatic-feed-links' );
- /*
- *
- * Loading Theme Scripts
- *
- */
- function rt_theme_load_scripts(){
- global $tabbed_page;
- $template_directory = get_template_directory_uri();
- if (!is_admin()) {//load theme scripts
- wp_deregister_script( 'jquery' );
- wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js' , false, '');
- wp_enqueue_script('jquery-easing', $template_directory . '/js/jquery.easing.1.3.js', array('jquery') );
- wp_enqueue_script('jquery-cycle', $template_directory . '/js/jquery.cycle.all.min.js', array('jquery') );
- wp_enqueue_script('jquery-validate', $template_directory . '/js/jquery.validate.js', array('jquery') );
- wp_enqueue_script('jquery-prettyphoto', $template_directory . '/js/jquery.prettyPhoto.js', array('jquery') );
- if(!get_option('rttheme_disable_cufon')){//if cufon is active
- wp_enqueue_script('cufon', $template_directory . '/js/cufon.js', array('jquery') );
- wp_enqueue_script('aller-cufon-fonts', $template_directory . '/js/vegur_font.js', array('jquery') );
- }
- wp_enqueue_script('tools', $template_directory . '/js/jquery.tools.min.js', array('jquery') );
- wp_enqueue_script('rt-theme-scripts', $template_directory . '/js/script.js', array('jquery') );
- wp_enqueue_script('jquery-form');
- }
- }
- add_action('init', 'rt_theme_load_scripts');
- /*
- Theme color selection
- */
- if (get_option('rttheme_style')){
- $which_theme=get_option('rttheme_style');
- }else{
- $which_theme="1";
- }
- /*
- Post Thumbnails Support
- */
- add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts
- /*
- WP 3.0 custom menu
- */
- add_action( 'init', 'rt_theme_navigations' );
- function rt_theme_navigations() {
- register_nav_menu( 'rt-theme-left-navigation', __( 'RT Theme Left Navigation' ) );
- register_nav_menu( 'rt-theme-top-navigation', __( 'RT Theme Top Navigation' ) );
- register_nav_menu( 'rt-theme-footer-navigation', __( 'RT Theme Footer Navigation' ) );
- }
- wp_create_nav_menu( 'RT Theme Left Navigation Menu', array( 'slug' => 'rt-theme-left-menu' ) );
- wp_create_nav_menu( 'RT Theme Top Navigation Menu', array( 'slug' => 'rt-theme-top-menu' ) );
- wp_create_nav_menu( 'RT Theme Footer Navigation Menu', array( 'slug' => 'rt-theme-footer-menu') );
- /*
- Flush old re-write rules
- note : this function can be removed after develop period - Tolga Can
- */
- function rt_flush_rewrite_rules()
- {
- global $wp_rewrite;
- $wp_rewrite->flush_rules();
- }
- add_action('admin_init', 'rt_flush_rewrite_rules');
- /*
- Pagination
- */
- function get_pagination($range = 7){
- global $paged, $wp_query;
- if ( !isset( $max_page ) ) {
- $max_page = $wp_query->max_num_pages;
- }
- if($max_page > 1){
- if(!$paged){
- $paged = 1;
- }
- if ($paged > 1){
- echo "<li class=\"arrow\">";
- previous_posts_link('«');
- echo "</li>\n";
- }
- if($max_page > $range){
- if($paged < $range){
- for($i = 1; $i <= ($range + 1); $i++){
- echo "<li";
- if($i==$paged) echo " class='active'";
- echo "><a href='" . get_pagenum_link($i) ."'>$i</a>";
- echo "</li>\n";
- }
- }
- elseif($paged >= ($max_page - ceil(($range/2)))){
- for($i = $max_page - $range; $i <= $max_page; $i++){
- echo "<li";
- if($i==$paged) echo " class='active'";
- echo "><a href='" . get_pagenum_link($i) ."'>$i</a>";
- echo "</li>\n";
- }
- }
- elseif($paged >= $range && $paged < ($max_page - ceil(($range/2)))){
- for($i = ($paged - ceil($range/2)); $i <= ($paged + ceil(($range/2))); $i++){
- echo "<li";
- if($i==$paged) echo " class='active'";
- echo "><a href='" . get_pagenum_link($i) ."'>$i</a>";
- echo "</li>\n";
- }
- }
- }
- else{
- for($i = 1; $i <= $max_page; $i++){
- echo "<li";
- if($i==$paged) echo " class=\"active\" ";
- echo "><a href='" . get_pagenum_link($i) ."'>$i</a>";
- echo "</li>\n";
- }
- }
- if ($paged != $max_page){
- echo "<li class=\"arrow\">";
- next_posts_link('»');
- echo "</li>\n";
- }
- }
- }
- /*
- add a class to active product and portolio links
- */
- function rt_nav($link_page,$link_cat){
- global $current_page_link,$current_cat_link;
- $current_page_link=$link_page;
- $current_cat_link=$link_cat;
- //page
- function add_class_page($output) {
- global $current_page_link,$current_cat_link;
- $bul=str_replace('/','\\/','"><a href="'.$current_page_link.'">');
- $bul=str_replace('?','\\?',$bul);
- $degistir=' current-menu-item"><a href="'.$current_page_link.'">';
- return preg_replace('/'.$bul.'/', $degistir, $output, 20);
- }
- //term in page
- function add_class_cat2($output) {
- global $current_page_link,$current_cat_link;
- $bul=str_replace('/','\\/','"><a href="'.$current_cat_link.'">');
- $bul=str_replace('?','\\?',$bul);
- $degistir=' current-menu-item"><a href="'.$current_cat_link.'">';
- return preg_replace('/'.$bul.'/', $degistir, $output, 20);
- }
- //call the left menu
- if ( has_nav_menu( 'rt-theme-left-navigation' ) ){
- $menuVars = array(
- 'menu_id' => 'menu',
- 'echo' => false,
- 'container_id' => 'dropdown_menu',
- 'theme_location' => 'rt-theme-left-navigation'
- );
- }else{
- $menuVars = array(
- 'menu' => 'RT Theme Left Navigation Menu',
- 'menu_id' => 'menu',
- 'echo' => false,
- 'container_id' => 'dropdown_menu',
- 'theme_location' => 'rt-theme-left-navigation'
- );
- }
- if($link_page && $link_cat){
- $dd = add_filter('wp_nav_menu', 'add_class_page');
- $dd = add_filter('wp_nav_menu', 'add_class_cat2');
- }
- echo wp_nav_menu($menuVars);
- }
- /*
- get the post thumbnail url
- */
- function get_post_thumbnail() {
- $files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
- if($files) :
- $keys = array_reverse(array_keys($files));
- $j=0;
- $num = $keys[$j];
- $image=wp_get_attachment_image($num, 'large', false);
- $imagepieces = explode('"', $image);
- $imagepath = $imagepieces[1];
- $url=wp_get_attachment_thumb_url($num);
- return $url;
- endif;
- }
- //installing RT-THEME WIDGETS
- require_once(get_template_directory() . '/rttheme_options/widgets/rt-theme-box-widget.php');
- require_once(get_template_directory() . '/rttheme_options/widgets/rt-theme-slider-widget.php');
- require_once(get_template_directory() . '/rttheme_options/widgets/rt-theme-news-widget.php');
- #
- # WPML match post id
- #
- function wpml_post_id($id){
- if(function_exists('icl_object_id')) {
- return icl_object_id($id,'post',false);
- } else {
- return $id;
- }
- }
- #
- # WPML match page id
- #
- function wpml_page_id($id){
- if(function_exists('icl_object_id')) {
- return icl_object_id($id,'page',true);
- } else {
- return $id;
- }
- }
- #
- # WPML match categories
- #
- function wpml_lang_object_ids($ids_array, $type) {
- if(function_exists('icl_object_id')) {
- $res = array();
- if(!empty($ids_array) && is_array($ids_array)){
- foreach ($ids_array as $id) {
- $xlat = icl_object_id($id,$type,false);
- if(!is_null($xlat)) $res[] = $xlat;
- }
- }
- return $res;
- } else {
- return $ids_array;
- }
- }
- #
- # gets orginal paths of images when multi site mode active
- #
- function find_image_org_path($image) {
- if(is_multisite()){
- global $blog_id;
- if (isset($blog_id) && $blog_id > 0) {
- if(strpos($image,get_bloginfo('wpurl'))!==false){//image is local
- $the_image_path = get_current_site(1)->path.str_replace(get_blog_option($blog_id,'fileupload_url'),get_blog_option($blog_id,'upload_path'),$image);
- }else{
- $the_image_path = $image;
- }
- }else{
- $the_image_path = $image;
- }
- }else{
- $the_image_path = $image;
- }
- return $the_image_path;
- }
- #
- # returns a post ID from a url
- #
- function rt_get_attachment_id_from_src ($image_src) {
- global $wpdb;
- $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'";
- $id = $wpdb->get_var($query);
- return $id;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement