Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*-----------------------------------------------------------------------------------
- Here we have all the custom functions for the theme
- Please be extremely cautious editing this file,
- When things go wrong, they tend to go wrong in a big way.
- You have been warned!
- -----------------------------------------------------------------------------------*/
- /*-----------------------------------------------------------------------------------*/
- /* Exclude pages from search
- /*-----------------------------------------------------------------------------------*/
- function tz_exclude_pages($query) {
- if ($query->is_search) {
- $query->set('post_type', 'post');
- }
- return $query;
- }
- add_filter('pre_get_posts','tz_exclude_pages');
- /*-----------------------------------------------------------------------------------*/
- /* Register WP3.0+ Menus
- /*-----------------------------------------------------------------------------------*/
- function register_menu() {
- register_nav_menu('primary-menu', __('Primary Menu'));
- }
- add_action('init', 'register_menu');
- /*-----------------------------------------------------------------------------------*/
- /* Load Translation Text Domain
- /*-----------------------------------------------------------------------------------*/
- load_theme_textdomain ('framework');
- /*-----------------------------------------------------------------------------------*/
- /* Set Max Content Width (use in conjuction with ".entry-content img" css)
- /*-----------------------------------------------------------------------------------*/
- if ( ! isset( $content_width ) ) $content_width = 600;
- /*-----------------------------------------------------------------------------------*/
- /* Register Sidebars
- /*-----------------------------------------------------------------------------------*/
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'name' => 'Main Sidebar',
- 'before_widget' => '<div id="%1$s" class="widget %2$s clearfix">',
- 'after_widget' => '</div><div class="seperator clearfix"><span class="line"></span></div>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ));
- register_sidebar(array(
- 'name' => 'Page Sidebar',
- 'before_widget' => '<div id="%1$s" class="widget %2$s clearfix">',
- 'after_widget' => '</div><div class="seperator clearfix"><span class="line"></span></div>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ));
- register_sidebar(array(
- 'name' => 'Portfolio Sidebar',
- 'before_widget' => '<div id="%1$s" class="widget %2$s clearfix">',
- 'after_widget' => '</div><div class="seperator clearfix"><span class="line"></span></div>',
- 'before_title' => '<h3 class="widget-title">',
- 'after_title' => '</h3>',
- ));
- }
- /*-----------------------------------------------------------------------------------*/
- /* Post Formats
- /*-----------------------------------------------------------------------------------*/
- $formats = array(
- 'aside',
- 'gallery',
- 'link',
- 'image',
- 'quote',
- 'audio',
- 'video');
- add_theme_support( 'post-formats', $formats );
- add_post_type_support( 'post', 'post-formats' );
- /*-----------------------------------------------------------------------------------*/
- /* Configure WP2.9+ Thumbnails
- /*-----------------------------------------------------------------------------------*/
- if ( function_exists( 'add_theme_support' ) ) {
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 50, 50, true ); // Normal post thumbnails
- add_image_size( 'thumbnail-portfolio', 220, 160, true ); // Portfolio thumbnails
- add_image_size( 'image-thumb', 500, '', true ); // Image format thumbnails
- add_image_size( 'gallery-thumb', 500, '', true ); // Gallery format thumbnails
- }
- /*-----------------------------------------------------------------------------------*/
- /* Change Default Excerpt Length
- /*-----------------------------------------------------------------------------------*/
- function tz_excerpt_length($length) {
- return 16; }
- add_filter('excerpt_length', 'tz_excerpt_length');
- /*-----------------------------------------------------------------------------------*/
- /* Configure Excerpt String
- /*-----------------------------------------------------------------------------------*/
- function tz_excerpt_more($excerpt) {
- return str_replace('[...]', '...', $excerpt); }
- add_filter('wp_trim_excerpt', 'tz_excerpt_more');
- /*-----------------------------------------------------------------------------------*/
- /* Register and load common JS
- /*-----------------------------------------------------------------------------------*/
- function tz_enqueue_scripts() {
- // register our scripts
- wp_register_script('superfish', get_template_directory_uri() . '/js/superfish.js', 'jquery');
- wp_register_script('validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', 'jquery');
- wp_register_script('easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', 'jquery');
- wp_register_script('tz_custom', get_template_directory_uri() . '/js/jquery.custom.js', 'jquery', '1.0', TRUE);
- wp_register_script('fancybox', get_template_directory_uri().'/js/jquery.fancybox-1.3.4.pack.js', 'jquery');
- wp_register_script('slidesjs', get_template_directory_uri().'/js/slides.min.jquery.js', 'jquery');
- wp_register_script('jPlayer', get_template_directory_uri().'/js/jquery.jplayer.min.js', 'jquery');
- // register our stylesheets
- wp_register_style( 'fancybox', get_template_directory_uri() . '/css/fancybox/jquery.fancybox-1.3.4.css' );
- // enqueue our scripts
- wp_enqueue_script('jquery');
- wp_enqueue_script('jquery-ui-core');
- wp_enqueue_script('jquery-ui-tabs');
- wp_enqueue_script('jquery-ui-accordion');
- wp_enqueue_script('jPlayer');
- wp_enqueue_script('slidesjs');
- wp_enqueue_script('fancybox');
- wp_enqueue_script('easing');
- wp_enqueue_script('superfish');
- wp_enqueue_script('tz_custom');
- if( is_page_template('template-contact.php') ) { wp_enqueue_script('validation'); }
- if( is_singular() ) { wp_enqueue_script( 'comment-reply' ); }
- // enqueue our stylesheets
- wp_enqueue_style( 'fancybox' );
- }
- add_action('wp_enqueue_scripts', 'tz_enqueue_scripts');
- /*-----------------------------------------------------------------------------------*/
- /* Register and load admin javascript
- /*-----------------------------------------------------------------------------------*/
- function tz_admin_js($hook) {
- if ($hook == 'post.php' || $hook == 'post-new.php') {
- wp_register_script('tz-admin', get_template_directory_uri() . '/js/jquery.custom.admin.js', 'jquery');
- wp_enqueue_script('tz-admin');
- }
- }
- add_action('admin_enqueue_scripts','tz_admin_js',10,1);
- /*-----------------------------------------------------------------------------------*/
- /* Add Browser Detection Body Class
- /*-----------------------------------------------------------------------------------*/
- add_filter('body_class','tz_browser_body_class');
- function tz_browser_body_class($classes) {
- global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
- if($is_lynx) $classes[] = 'lynx';
- elseif($is_gecko) $classes[] = 'gecko';
- elseif($is_opera) $classes[] = 'opera';
- elseif($is_NS4) $classes[] = 'ns4';
- elseif($is_safari) $classes[] = 'safari';
- elseif($is_chrome) $classes[] = 'chrome';
- elseif($is_IE) $classes[] = 'ie';
- else $classes[] = 'unknown';
- if($is_iphone) $classes[] = 'iphone';
- return $classes;
- }
- /*-----------------------------------------------------------------------------------*/
- /* Comment Styling
- /*-----------------------------------------------------------------------------------*/
- function tz_comment($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
- <div id="comment-<?php comment_ID(); ?>" class="comment-height">
- <div class="comment-meta commentmetadata">
- <span class="author">
- <?php echo get_comment_author_link(); ?>
- <span><a href="<?php comment_link() ?>" title="<?php _e('Permalink to this comment', 'framework'); ?>">#</a></span>
- </span>
- <div class="comment-reply-wrap clearfix">
- <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
- </div>
- </div>
- <div class="comment-body clearfix">
- <?php if ($comment->comment_approved == '0') : ?>
- <em class="moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
- <?php endif; ?>
- <?php comment_text() ?>
- </div>
- </div>
- <?php
- }
- /*-----------------------------------------------------------------------------------*/
- /* Seperated Pings Styling
- /*-----------------------------------------------------------------------------------*/
- function tz_list_pings($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?>
- <?php }
- /*-----------------------------------------------------------------------------------*/
- /* Custom Login Logo Support
- /*-----------------------------------------------------------------------------------*/
- function tz_custom_login_logo() {
- echo '<style type="text/css">
- h1 a { background-image:url('.get_template_directory_uri().'/images/custom-login-logo.png) !important; background-size: auto auto !important; }
- </style>';
- }
- function tz_wp_login_url() {
- return home_url();
- }
- function tz_wp_login_title() {
- return get_option('blogname');
- }
- add_action('login_head', 'tz_custom_login_logo');
- add_filter('login_headerurl', 'tz_wp_login_url');
- add_filter('login_headertitle', 'tz_wp_login_title');
- /*-----------------------------------------------------------------------------------*/
- /* Force Insert to Post button
- /*-----------------------------------------------------------------------------------*/
- add_filter( 'get_media_item_args', 'tz_force_send' );
- function tz_force_send($args){
- $args['send'] = true;
- return $args;
- }
- /*-----------------------------------------------------------------------------------*/
- /* Load Widgets & Shortcodes
- /*-----------------------------------------------------------------------------------*/
- // Add the Latest Tweets Custom Widget
- include("functions/widget-tweets.php");
- // Add the Flickr Photos Custom Widget
- include("functions/widget-flickr.php");
- // Add the Custom Video Widget
- include("functions/widget-video.php");
- // Add the Theme Shortcodes
- include("functions/theme-shortcodes.php");
- // Add the post meta
- include("functions/theme-postmeta.php");
- // Add the post types
- include("functions/theme-posttypes.php");
- // Add the portfolio meta
- include("functions/theme-portfoliometa.php");
- // Add the page meta
- include("functions/theme-pagemeta.php");
- /*-----------------------------------------------------------------------------------*/
- /* Filters that allow shortcodes in Text Widgets
- /*-----------------------------------------------------------------------------------*/
- add_filter('widget_text', 'shortcode_unautop');
- add_filter('widget_text', 'do_shortcode');
- /*-----------------------------------------------------------------------------------*/
- /* Load Theme Options
- /*-----------------------------------------------------------------------------------*/
- define('TZ_FILEPATH', TEMPLATEPATH);
- define('TZ_DIRECTORY', get_template_directory_uri());
- require_once (TZ_FILEPATH . '/admin/admin-functions.php');
- require_once (TZ_FILEPATH . '/admin/admin-interface.php');
- require_once (TZ_FILEPATH . '/functions/theme-options.php');
- require_once (TZ_FILEPATH . '/functions/theme-functions.php');
- require_once (TZ_FILEPATH . '/tinymce/tinymce.loader.php');
- //* Enqueue Headroom
- add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
- function sk_enqueue_scripts() {
- if ( wp_is_mobile() )
- return;
- wp_enqueue_style( 'animations', get_stylesheet_directory_uri() . '/css/animations.min.css' );
- wp_enqueue_script( 'headroom', get_stylesheet_directory_uri() . '/js/headroom.min.js', '', '', true );
- wp_enqueue_script( 'jquery-headroom', get_stylesheet_directory_uri() . '/js/jQuery.headroom.min.js', array( 'jquery' ), '1.0.0', true );
- wp_enqueue_script( 'headroom-init', get_stylesheet_directory_uri() . '/js/headroom-init.js', array( 'jquery-headroom' ), '1.0.0', true );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement