Advertisement
Guest User

Untitled

a guest
Mar 26th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.87 KB | None | 0 0
  1. <?php
  2.  
  3. /* ==  WARNING! DO NOT EDIT THIS FILE! (PLEASE)  ==============================
  4. *
  5. *     If you know what you're doing and would like to add your own custom
  6. *     functions to this theme, DO NOT EDIT THIS FILE. Instead, use the
  7. *     custom-functions.php file to define custom functions. Adding your
  8. *     custom functions there will make it much easier to upgrade to a newer
  9. *     version of this theme without losing any of your customizations.
  10. *
  11. * ============================================================================*/
  12.  
  13.  
  14. /* ==  Start Engine ==============================*/
  15.  
  16. require_once(TEMPLATEPATH . '/engine/engine.php');
  17.  
  18.  
  19. /* ==  Thumbnails  ==============================*/
  20.  
  21. if ( function_exists( 'add_theme_support' ) ) {
  22.     set_post_thumbnail_size( 60, 60, true ); // Normal post thumbnails
  23. }
  24.  
  25.  
  26. /* ==  Set Max Content Width  ==============================*/
  27.  
  28. if ( ! isset( $content_width ) ) $content_width = 580;
  29.  
  30.  
  31. /* ==  Register Menus  ==============================*/
  32.  
  33. function dt_register_menu() {
  34.  
  35.     register_nav_menu('primary-menu-left', __('Primary Menu Left', 'engine'));
  36.     register_nav_menu('primary-menu-right', __('Primary Menu Right', 'engine'));
  37.     register_nav_menu('secondary-menu', __('Secondary Menu', 'engine'));
  38.     register_nav_menu('footer-menu', __('Footer Menu', 'engine'));
  39.     register_nav_menu('mobile-menu', __('Mobile Menu', 'engine'));
  40.  
  41. }
  42.  
  43. add_action('init', 'dt_register_menu');
  44.  
  45.  
  46. /* ==  Script Enqueues  ==============================*/
  47.  
  48. function dt_theme_script_enqueues() {
  49.  
  50.     if (!is_admin()) {
  51.  
  52.         if(!is_single()) {
  53.             wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js', 'jquery');
  54.             wp_enqueue_script('isotope');
  55.         }
  56.  
  57.         if(!is_page()) {
  58.             wp_register_script('slidesjs', get_template_directory_uri() . '/js/slides.min.jquery.js', 'jquery');
  59.             wp_enqueue_script('slidesjs');
  60.         }
  61.  
  62.         wp_register_script('colorbox', get_template_directory_uri() . '/js/jquery.colorbox.js', 'jquery');
  63.         wp_enqueue_script('colorbox');
  64.        
  65.         wp_register_script('fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', 'jquery');
  66.         wp_enqueue_script('fitvids');
  67.        
  68.         wp_register_script('imagesLoaded', get_template_directory_uri() . '/js/jquery.imagesloaded.js', 'jquery');
  69.         wp_enqueue_script('imagesLoaded');
  70.        
  71.         if(has_nav_menu('mobile-menu')) {
  72.             wp_register_script('mobileMenu', get_template_directory_uri() . '/js/jquery.mobileMenu.js', 'jquery');
  73.             wp_enqueue_script('mobileMenu');
  74.         }
  75.        
  76.         if(is_front_page() && get_option('dt_slider') != 'false') {
  77.             wp_enqueue_script('camera', get_template_directory_uri() . '/js/camera.min.js', 'jquery');
  78.         }
  79.  
  80.     }
  81.  
  82. }
  83.  
  84. add_action('wp_print_scripts', 'dt_theme_script_enqueues');
  85.  
  86.  
  87. /* ==  Style Enqueues  ==============================*/
  88.  
  89. function dt_theme_style_enqueues() {
  90.  
  91.        wp_register_style('colorbox', get_template_directory_uri() . '/js/colorbox/colorbox.css');
  92.        wp_enqueue_style( 'colorbox');
  93.        
  94.        wp_enqueue_style( 'dt-mobile', get_template_directory_uri() . '/mobile.css');
  95.        
  96.        if(is_front_page() || is_home()) {
  97.             wp_enqueue_style('camera', get_template_directory_uri() . '/camera.css');
  98.         }
  99.    
  100. }
  101.  
  102. add_action('wp_print_styles', 'dt_theme_style_enqueues');
  103.  
  104.  
  105. /* ==  Sidebars  ==============================*/
  106.  
  107. if ( function_exists('register_sidebar') ) {
  108.  
  109.     register_sidebar(array(
  110.         'name' => __('Homepage Intro', 'engine'),
  111.         'id' => 'home_intro',
  112.         'description' => __('Widget area displayed on the homepage below the slider.', 'engine'),
  113.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  114.         'after_widget' => '</div></div>',
  115.         'before_title' => '<h3 class="widget-title">',
  116.         'after_title' => '</h3>',
  117.     ));
  118.    
  119.     register_sidebar(array(
  120.         'name' => __('Homepage Sidebar', 'engine'),
  121.         'id' => 'home_sidebar',
  122.         'description' => __('Sidebar widget area only displayed on the homepage.', 'engine'),
  123.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  124.         'after_widget' => '</div></div>',
  125.         'before_title' => '<h3 class="widget-title">',
  126.         'after_title' => '</h3>',
  127.     ));
  128.    
  129.     register_sidebar(array(
  130.         'name' => __('Blog Sidebar', 'engine'),
  131.         'id' => 'blog_sidebar',
  132.         'description' => __('Sidebar widget area only displayed on archives and single posts.', 'engine'),
  133.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  134.         'after_widget' => '</div></div>',
  135.         'before_title' => '<h3 class="widget-title">',
  136.         'after_title' => '</h3>',
  137.     ));
  138.  
  139.     register_sidebar(array(
  140.         'name' => __('Page Sidebar', 'engine'),
  141.         'id' => 'page_sidebar',
  142.         'description' => __('Sidebar widget area only displayed on pages.', 'engine'),
  143.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  144.         'after_widget' => '</div></div>',
  145.         'before_title' => '<h3 class="widget-title">',
  146.         'after_title' => '</h3>',
  147.     ));
  148.    
  149.     register_sidebar(array(
  150.         'name' => __('Global Sidebar', 'engine'),
  151.         'id' => 'global_sidebar',
  152.         'description' => __('Default sidebar widget area. Displayed on all posts, pages, archives, etc. excluding the homepage.', 'engine'),
  153.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  154.         'after_widget' => '</div></div>',
  155.         'before_title' => '<h3 class="widget-title">',
  156.         'after_title' => '</h3>',
  157.     ));
  158.    
  159.     register_sidebar(array(
  160.         'name' => __('Footer 1', 'engine'),
  161.         'id' => 'footer_1',
  162.         'description' => __('Footer widget area.', 'engine'),
  163.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  164.         'after_widget' => '</div></div>',
  165.         'before_title' => '<h3 class="widget-title">',
  166.         'after_title' => '</h3>',
  167.     ));
  168.    
  169.     register_sidebar(array(
  170.         'name' => __('Footer 2', 'engine'),
  171.         'id' => 'footer_2',
  172.         'description' => __('Footer widget area.', 'engine'),
  173.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  174.         'after_widget' => '</div></div>',
  175.         'before_title' => '<h3 class="widget-title">',
  176.         'after_title' => '</h3>',
  177.     ));
  178.    
  179.     register_sidebar(array(
  180.         'name' => __('Footer 3', 'engine'),
  181.         'id' => 'footer_3',
  182.         'description' => __('Footer widget area.', 'engine'),
  183.         'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside cf">',
  184.         'after_widget' => '</div></div>',
  185.         'before_title' => '<h3 class="widget-title">',
  186.         'after_title' => '</h3>',
  187.     ));
  188.  
  189. }
  190.  
  191.  
  192. /* ==  Custom Post Types  ==============================
  193. *
  194. *      dt_register_post_type($name, $slug, $supports, $exclude_from_search)
  195. *
  196. *      STRING       required    $name
  197. *      STRING       required    $slug
  198. *      ARRAY        optional    $supports
  199. *      BOOLEAN      optional    $exclude_from_search
  200. *
  201. *      If you decide to change the slug, remember to re-save your permalinks
  202. *      in Settings > Permalinks
  203. *
  204. * ============================================================================*/
  205.  
  206. $supports = array('title', 'editor', 'thumbnail', 'custom-fields', 'excerpt', 'comments', 'groups', 'post-formats');
  207.  
  208. dt_register_post_type(__('Showcase', 'engine'), 'showcase', $supports);
  209.  
  210.  
  211. $supports = array('title', 'thumbnail', 'custom-fields', 'excerpt');
  212.  
  213. dt_register_post_type(__('Slides', 'engine'), 'slides', $supports);
  214.  
  215.  
  216. /* ==  Custom Taxonomies  ==============================
  217. *
  218. *      dt_register_taxonomy($name, $slug, $posttype, $hierarchical)
  219. *
  220. *      STRING       required    $name
  221. *      STRING       required    $slug
  222. *      STRING       required    $posttype
  223. *      ARRAY        optional    $hierarchical
  224. *
  225. *      If you decide to change the slug, remember to re-save your permalinks
  226. *      in Settings > Permalinks
  227. *
  228. * ============================================================================*/
  229.  
  230. dt_register_taxonomy(__('Groups', 'engine'), 'group', 'showcase', true);
  231.  
  232.  
  233. /* ==  Post Formats  ==============================*/
  234.  
  235. add_theme_support( 'post-formats', array( 'image', 'gallery', 'video' ) );
  236. add_post_type_support( 'showcase', 'post-formats' );
  237.  
  238.  
  239. /* ==  Widgets  ==============================*/
  240.  
  241. $widgets = array(
  242.     'better-search',
  243.     'twitter-tweets',
  244.     'flickr-photos'
  245. );
  246.  
  247. dt_include_widgets($widgets);
  248.  
  249.  
  250. /* ==  Colour Scheme  ==============================*/
  251.  
  252. function dt_colour_css() {
  253.  
  254.     $colour = get_option('dt_color');
  255.  
  256.     if($colour == '') {
  257.         $colour = '#99cc00';
  258.     }
  259.  
  260.     ?>
  261.  
  262.     <style type="text/css">
  263.        
  264.         a,
  265.         a:hover,
  266.         #site-title a:hover,
  267.         #secondary-menu ul li.current-menu-item ul a:hover,
  268.         #secondary-menu ul ul a:hover,
  269.         .commentlist .comment-meta a:hover,
  270.         #comments label span,
  271.         .item .post-title a:hover,
  272.         #sidebar a:hover,
  273.         #sidebar .DT_Twitter a:hover,
  274.         #secondary-menu ul li.current-menu-item a,
  275.         #secondary-menu ul li.current-menu-item a:hover { color: <?php echo $colour; ?>; }
  276.  
  277.  
  278.         #filter li.active,
  279.         #comments #submit,
  280.         .featured .featured-details a.read-more,
  281.         .featured .camera_prev:hover,
  282.         .featured .camera_next:hover,
  283.         .featured .camera_commands:hover,
  284.         #slide-controls a:hover,
  285.         #load-more:hover,
  286.         .widget .tagcloud a:hover,
  287.         .DT_Flickr .flickr_badge_image img:hover { background-color: <?php echo $colour; ?>; }
  288.  
  289.     </style>
  290.  
  291.     <?php
  292.  
  293. }
  294.  
  295. add_action('wp_head', 'dt_colour_css');
  296.  
  297.  
  298.  
  299. /* ==  Overlay Icon  ==============================*/
  300.  
  301. function dt_overlay_icon() {
  302.  
  303.     $format = get_post_format();
  304.  
  305.     $has_format = false;
  306.     $link = '#';
  307.     $thumbnail_id = get_post_thumbnail_id(get_the_ID());
  308.     $thumb_src = wp_get_attachment_image_src( $thumbnail_id, array( '9999','9999' ), false, '' );
  309.     $thumb_src = $thumb_src[0];
  310.    
  311.     $custom = get_post_meta(get_the_ID(), 'dt_custom_thumbnail', true);
  312.     if( $custom != '') $thumb_src = $custom;
  313.  
  314.     if($format == 'image') {
  315.  
  316.         $link = wp_get_attachment_image_src( $thumbnail_id, array( '9999','9999' ), false, '' );
  317.         $link = $link[0];
  318.        
  319.         if( $custom != '') $link = $custom;
  320.        
  321.         $has_format = true;
  322.  
  323.     } elseif($format == 'gallery') {
  324.  
  325.         $link = $thumb_src;
  326.         $has_format = true;
  327.  
  328.     } elseif($format == 'video') {
  329.  
  330.         global $wp_embed;
  331.         $video_url = htmlspecialchars(get_post_meta(get_the_ID(), 'dt_video', true));
  332.         $video_embed = $wp_embed->run_shortcode('[embed]'.$video_url.'[/embed]');
  333.  
  334.         $link = '#video-'.get_the_ID();
  335.  
  336.         $has_format = true;
  337.     }
  338.  
  339.     if($has_format) : ?>
  340.    
  341.         <?php
  342.        
  343.         if( $format == 'gallery') $format = __('gallery', 'engine');
  344.         if( $format == 'image') $format = __('image', 'engine');
  345.         if( $format == 'video') $format = __('video', 'engine');
  346.        
  347.         ?>
  348.        
  349.         <a data-gallery="group-<?php the_ID(); ?>" class="colorbox-<?php echo $format; ?>" href="<?php echo $link; ?>"><?php _e('View', 'engine'); ?> <?php echo ucfirst($format); ?></a>&nbsp;&nbsp;/&nbsp;&nbsp;
  350.        
  351.         <?php
  352.         if($format == 'video'):
  353.         ?>
  354.  
  355.         <span class="dt-video-embed">
  356.             <span id="video-<?php the_ID(); ?>"><?php echo $video_embed; ?></span>
  357.         </span>
  358.        
  359.         <?php
  360.         endif;
  361.  
  362.         if($format == 'gallery') {
  363.  
  364.             $args = array(
  365.                 'orderby'        => 'menu_order',
  366.                 'post_type'      => 'attachment',
  367.                 'post_parent'    => get_the_ID(),
  368.                 'post_mime_type' => 'image',
  369.                 'post_status'    => null,
  370.                 'posts_per_page'    => -1,
  371.             );
  372.  
  373.             $attachments = get_posts($args);
  374.  
  375.             if ($attachments) :
  376.                
  377.                 foreach ($attachments as $attachment) :
  378.                    
  379.                     $link = wp_get_attachment_image_src( $attachment->ID, array( '9999','9999' ), false, '' );
  380.                     $link = $link[0];
  381.  
  382.                     if($thumb_src != $link) :
  383.                     ?>
  384.  
  385.                         <a class="colorbox-<?php echo $format; ?> hidden" data-gallery="group-<?php the_ID(); ?>" href="<?php echo $link; ?>"></a>
  386.  
  387.                     <?php
  388.                     endif;
  389.  
  390.                 endforeach;
  391.  
  392.             endif;
  393.  
  394.         }
  395.  
  396.     endif;
  397.    
  398.     ?>
  399.     <a href="<?php the_permalink(); ?>"><?php _e('Read Post', 'engine'); ?></a>
  400.     <?php
  401.  
  402. }
  403.  
  404.  
  405. /* ==  Add rel to gallery links  ==============================*/
  406.  
  407. add_filter('wp_get_attachment_link', 'add_gallery_id_rel');
  408. function add_gallery_id_rel($link) {
  409.     global $post;
  410.     return str_replace('<a href', '<a rel="gallery-'. $post->ID .'" href', $link);
  411. }
  412.  
  413.  
  414. /* ==  Footer Code  ==============================*/
  415.  
  416. function dt_analytics(){
  417.     $output = get_option('dt_google_analytics');
  418.     if ( $output <> "" )
  419.         echo stripslashes($output) . "\n";
  420. }
  421.  
  422. add_action('wp_footer','dt_analytics');
  423.  
  424.  
  425. /* ==  Comment Styling  ==============================*/
  426.  
  427. function dt_comment($comment, $args, $depth) {
  428.  
  429.     $isByAuthor = false;
  430.  
  431.     if($comment->comment_author_email == get_the_author_meta('email')) {
  432.         $isByAuthor = true;
  433.     }
  434.  
  435.     $GLOBALS['comment'] = $comment; ?>
  436.  
  437.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  438.  
  439.         <!--BEGIN #comment-id-->
  440.         <div id="comment-<?php comment_ID(); ?>" class="clearfix">
  441.  
  442.             <?php echo get_avatar($comment,$size='46'); ?>
  443.  
  444.             <!--BEGIN .comment-meta-->
  445.             <div class="comment-meta">
  446.                 <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php echo human_time_diff( get_comment_time('U'), current_time('timestamp') ) . ' '.  __('ago', 'engine'); ?>
  447.                 &middot;
  448.                 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  449.             <!--END .comment-meta-->
  450.             </div>
  451.  
  452.             <!--BEGIN .comment-author-->
  453.             <div class="comment-author">
  454.                 <?php echo get_comment_author_link(); ?> <?php _e('said…', 'engine'); ?>
  455.             <!--END .comment-author-->
  456.             </div>
  457.  
  458.             <?php if ($comment->comment_approved == '0') : ?>
  459.             <em class="moderation"><?php _e('Your comment is awaiting moderation.', 'engine'); ?></em>
  460.             <?php endif; ?>
  461.  
  462.             <!--BEGIN .comment-body-->
  463.             <div class="comment-body">
  464.                 <?php comment_text() ?>
  465.             <!--END .comment-body-->
  466.             </div>
  467.  
  468.         <!--END #comment-id-->
  469.         </div>
  470.  
  471. <?php
  472. }
  473.  
  474.  
  475. /* ==  List categories for the groups  ==============================*/
  476.  
  477. class Group_Walker extends Walker_Category {
  478.    function start_el(&$output, $category, $depth = 0, $args = array(), $current_object_id = 0) {
  479.       extract($args);
  480.       $cat_name = esc_attr( $category->name);
  481.       $cat_name = apply_filters( 'list_cats', $cat_name, $category );
  482.       $link = '<a href="#" data-filter=".term-'.$category->term_id.'" ';
  483.       if ( $use_desc_for_title == 0 || empty($category->description) )
  484.          $link .= 'title="' . sprintf(__( 'View all items filed under %s', 'engine' ), $cat_name) . '"';
  485.       else
  486.          $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
  487.       $link .= '>';
  488.       // $link .= $cat_name . '</a>';
  489.       $link .= $cat_name;
  490.       if(!empty($category->description)) {
  491.         // $link .= ' <span>'.$category->description.'</span>';
  492.       }
  493.       $link .= '</a>';
  494.       if ( (! empty($feed_image)) || (! empty($feed)) ) {
  495.          $link .= ' ';
  496.          if ( empty($feed_image) )
  497.             $link .= '(';
  498.          $link .= '<a href="' . get_category_feed_link($category->term_id, $feed_type) . '"';
  499.          if ( empty($feed) )
  500.             $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s', 'engine' ), $cat_name ) . '"';
  501.          else {
  502.             $title = ' title="' . $feed . '"';
  503.             $alt = ' alt="' . $feed . '"';
  504.             $name = $feed;
  505.             $link .= $title;
  506.          }
  507.          $link .= '>';
  508.          if ( empty($feed_image) )
  509.             $link .= $name;
  510.          else
  511.             $link .= "<img src='$feed_image'$alt$title" . ' />';
  512.          $link .= '</a>';
  513.          if ( empty($feed_image) )
  514.             $link .= ')';
  515.       }
  516.       if ( isset($show_count) && $show_count )
  517.          $link .= ' (' . intval($category->count) . ')';
  518.       if ( isset($show_date) && $show_date ) {
  519.          $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
  520.       }
  521.       if ( isset($current_category) && $current_category )
  522.          $_current_category = get_category( $current_category );
  523.       if ( 'list' == $args['style'] ) {
  524.           $output .= '<li class="segment-'.rand(2, 99).'"';
  525.           $class = 'cat-item cat-item-'.$category->term_id;
  526.           if ( isset($current_category) && $current_category && ($category->term_id == $current_category) )
  527.              $class .=  ' current-cat';
  528.           elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) )
  529.              $class .=  ' current-cat-parent';
  530.           $output .=  '';
  531.           $output .= ">$link\n";
  532.        } else {
  533.           $output .= "\t$link<br />\n";
  534.        }
  535.    }
  536. }
  537.  
  538.  
  539. /* ==  Get related posts by taxonomy  ==============================*/
  540.  
  541. function dt_get_posts_related_by_taxonomy($post_id, $taxonomy, $notin, $args=array()) {
  542.   $query = new WP_Query();
  543.   $terms = wp_get_object_terms($post_id, $taxonomy);
  544.   if (count($terms)) {
  545.     // Assumes only one term for per post in this taxonomy
  546.     $post_ids = get_objects_in_term($terms[0]->term_id,$taxonomy);
  547.     $post = get_post($post_id);
  548.     $args = wp_parse_args($args,array(
  549.       'post_type' => $post->post_type, // The assumes the post types match
  550.       //'post__in' => $post_ids,
  551.       'post__not_in' => array($notin),
  552.       'taxonomy' => $taxonomy,
  553.       'term' => $terms[0]->slug,
  554.       'posts_per_page' => get_option('dt_related_number')
  555.     ));
  556.     $query = new WP_Query($args);
  557.   }
  558.   return $query;
  559. }
  560.  
  561. function add_nofollow_cat( $text ) {
  562.  
  563.     $valid_tag = 'rel="tag"';
  564.     $text = str_replace('rel="category tag"', $valid_tag, $text);
  565.     return $text;
  566. }
  567. add_filter( 'the_category', 'add_nofollow_cat' );
  568.  
  569.  
  570. /* ==  Sidebar Class  ==============================*/
  571.  
  572. add_filter('body_class','dt_sidebar_classes');
  573.  
  574. function dt_sidebar_classes($classes) {
  575.  
  576.     if(is_home() && dt_is_sidebar_active('home_sidebar')) {
  577.         $classes[] = 'sidebar-on';
  578.  
  579.     } elseif(!is_home() && (dt_is_sidebar_active('blog_sidebar') || dt_is_sidebar_active('global_sidebar')) ) {
  580.         $classes[] = 'sidebar-on';
  581.  
  582.     }
  583.  
  584.     return $classes;
  585.  
  586. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement