Advertisement
Guest User

Untitled

a guest
Oct 13th, 2013
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 26.94 KB | None | 0 0
  1. <?php
  2. /*-----------------------------------------------------------------------------------*/
  3. /*  Do not remove these lines, sky will fall on your head.
  4. /*-----------------------------------------------------------------------------------*/
  5. require_once( dirname( __FILE__ ) . '/theme-options.php' );
  6. include("functions/tinymce/tinymce.php");
  7. if ( ! isset( $content_width ) ) $content_width = 1060;
  8.  
  9. /*-----------------------------------------------------------------------------------*/
  10. /*  Load Translation Text Domain
  11. /*-----------------------------------------------------------------------------------*/
  12. load_theme_textdomain( 'mythemeshop', get_template_directory().'/lang' );
  13. if ( function_exists('add_theme_support') ) add_theme_support('automatic-feed-links');
  14.  
  15. /*-----------------------------------------------------------------------------------*/
  16. /*  Post Thumbnail Support
  17. /*-----------------------------------------------------------------------------------*/
  18. if ( function_exists( 'add_theme_support' ) ) {
  19.     add_theme_support( 'post-thumbnails' );
  20.     set_post_thumbnail_size( 223, 137, true );
  21.     add_image_size( 'featured', 223, 137, true ); //featured
  22.     add_image_size( 'related', 50, 42, true ); //related
  23.     add_image_size( 'widgetthumb', 50, 42, true ); //widget
  24.     add_image_size( 'slider', 634, 304, true ); //slider
  25. }
  26.  
  27. /*-----------------------------------------------------------------------------------*/
  28. /*  Custom Menu Support
  29. /*-----------------------------------------------------------------------------------*/
  30. add_theme_support( 'menus' );
  31. if ( function_exists( 'register_nav_menus' ) ) {
  32.     register_nav_menus(
  33.         array(
  34.           'primary-menu' => 'Primary Menu'
  35.         )
  36.     );
  37. }
  38.  
  39. /*-----------------------------------------------------------------------------------*/
  40. /*  Javascsript
  41. /*-----------------------------------------------------------------------------------*/
  42. function mts_add_scripts() {
  43.     $mts_options = get_option('THEMENAME');
  44.  
  45.     wp_enqueue_script('jquery');
  46.  
  47.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  48.         wp_enqueue_script( 'comment-reply' );
  49.     }
  50.    
  51.     //Slider
  52.     if($mts_options['mts_featured_slider'] == '1' && !is_singular()) {
  53.         wp_register_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js');
  54.         wp_enqueue_script ('flexslider');
  55.     }  
  56.  
  57.     global $is_IE;
  58.     if ($is_IE) {
  59.         wp_register_script ('html5shim', "http://html5shim.googlecode.com/svn/trunk/html5.js");
  60.         wp_enqueue_script ('html5shim');
  61.     }
  62. }
  63. add_action('wp_enqueue_scripts','mts_add_scripts');
  64.    
  65. function mts_load_footer_scripts() {  
  66.     $mts_options = get_option('THEMENAME');
  67.    
  68.     // Site wide js
  69.     wp_register_script('modernizr', get_template_directory_uri() . '/js/modernizr.min.js', true);
  70.     wp_enqueue_script ('modernizr');
  71.    
  72.     wp_register_script('customscript', get_template_directory_uri() . '/js/customscript.js', true);
  73.     wp_enqueue_script ('customscript');
  74.    
  75.     //Lightbox
  76.     if($mts_options['mts_lightbox'] == '1') {
  77.         wp_register_script('prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', true);
  78.         wp_enqueue_script('prettyPhoto');
  79.     }
  80.    
  81.     //Sticky Nav
  82.     if($mts_options['mts_sticky_nav'] == '1') {
  83.         wp_register_script('StickyNav', get_template_directory_uri() . '/js/sticky.js', true);
  84.         wp_enqueue_script('StickyNav');;
  85.     }
  86. }  
  87. add_action('wp_footer', 'mts_load_footer_scripts');  
  88.  
  89. /*-----------------------------------------------------------------------------------*/
  90. /* Enqueue CSS
  91. /*-----------------------------------------------------------------------------------*/
  92. function mts_enqueue_css() {
  93.     $mts_options = get_option('THEMENAME');
  94.  
  95.     //slider
  96.     if($mts_options['mts_featured_slider'] == '1' && !is_singular()) {
  97.         wp_register_style('flexslider', get_template_directory_uri() . '/css/flexslider.css', 'style');
  98.         wp_enqueue_style('flexslider');
  99.     }
  100.    
  101.     //lightbox
  102.     if($mts_options['mts_lightbox'] == '1') {
  103.         wp_register_style('prettyPhoto', get_template_directory_uri() . '/css/prettyPhoto.css', 'style');
  104.         wp_enqueue_style('prettyPhoto');
  105.     }
  106.    
  107.     //Font Awesome
  108.     wp_register_style('fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css', 'style');
  109.     wp_enqueue_style('fontawesome');
  110.     global $is_IE;
  111.     if ($is_IE) {
  112.        wp_register_style('ie7-fontawesome', get_template_directory_uri() . '/css/font-awesome-ie7.min.css', 'style');
  113.        wp_enqueue_style('ie7-fontawesome');
  114.     }
  115.    
  116.     wp_enqueue_style('stylesheet', get_template_directory_uri() . '/style.css', 'style');
  117.    
  118.     //Responsive
  119.     if($mts_options['mts_responsive'] == '1') {
  120.         wp_enqueue_style('responsive', get_stylesheet_directory_uri() . '/css/responsive.css', 'style');
  121.     }
  122.    
  123.     if ($mts_options['mts_bg_pattern_upload'] != '') {
  124.         $mts_bg = $mts_options['mts_bg_pattern_upload'];
  125.     } else {
  126.         if($mts_options['mts_bg_pattern'] != '') {
  127.             $mts_bg = get_template_directory_uri().'/images/'.$mts_options['mts_bg_pattern'].'.png';
  128.         }
  129.     }
  130.     $mts_sclayout = '';
  131.     $mts_shareit_left = '';
  132.     $mts_shareit_right = '';
  133.     $mts_author = '';
  134.     $mts_header_section = '';
  135.     if ($mts_options['mts_layout'] == 'sclayout') {
  136.         $mts_sclayout = '.article { float: right;}
  137.         .sidebar.c-4-12 { float: left; padding-right: 0; }';
  138.         if($mts_options['mts_floating_social'] == '1') {
  139.             $mts_shareit_right = '.shareit { margin: 0 760px 0; border-left: 0; }';
  140.         }
  141.     }
  142.     if ($mts_options['mts_header_section2'] == '0') {
  143.         $mts_header_section = '.logo-wrap, .widget-header { display: none; }
  144.         #navigation { border-top: 0; }
  145.         #header { min-height: 47px; }';
  146.     }
  147.     if($mts_options['mts_floating_social'] == '1') {
  148.         $mts_shareit_left = '.shareit { top: 282px; left: auto; z-index: 0; margin: 0 0 0 -123px; width: 90px; position: fixed; overflow: hidden; padding: 5px; border:none; border-right: 0;}
  149.         .share-item {margin: 2px;}';
  150.     }
  151.     if($mts_options['mts_author_comment'] == '1') {
  152.         $mts_author = '.bypostauthor {padding: 3%!important; background: #FAFAFA; width: 94%!important;}
  153.         .bypostauthor:after { content: "'.__('Author','mythemeshop').'"; position: absolute; right: -1px; top: -1px; padding: 1px 10px; background: #818181; color: #FFF; }';
  154.     }
  155.     $custom_css = "
  156.         body {background-color:{$mts_options['mts_bg_color']}; }
  157.         body {background-image: url({$mts_bg});}
  158.         .postauthor h5, .copyrights a, .single_post a, .textwidget a, #logo a, .pnavigation2 a, .sidebar.c-4-12 a:hover, .copyrights a:hover, footer .widget li a:hover, .sidebar.c-4-12 a:hover, .related-posts a:hover, .reply a, .title a:hover, .post-info a:hover,.comm, #tabber .inside li a:hover, .readMore a:hover, .fn a, a, a:hover { color:{$mts_options['mts_color_scheme']}; }   
  159.         #commentform input#submit, .mts-subscribe input[type='submit'], #move-to-top:hover, #searchform .icon-search, #navigation ul .current-menu-item a, #navigation ul li:hover, .pagination a, #tabber ul.tabs li a.selected, .tagcloud a:hover, #navigation ul .sfHover a, .woocommerce a.button, .woocommerce-page a.button, .woocommerce button.button, .woocommerce-page button.button, .woocommerce input.button, .woocommerce-page input.button, .woocommerce #respond input#submit, .woocommerce-page #respond input#submit, .woocommerce #content input.button, .woocommerce-page #content input.button, .woocommerce nav.woocommerce-pagination ul li a, .woocommerce-page nav.woocommerce-pagination ul li a, .woocommerce #content nav.woocommerce-pagination ul li a, .woocommerce-page #content nav.woocommerce-pagination ul li a, .woocommerce .bypostauthor:after { background-color:{$mts_options['mts_color_scheme']}; color: #fff!important; }
  160.         .flex-control-thumbs .flex-active{ border-top:3px solid {$mts_options['mts_color_scheme']};}
  161.         {$mts_sclayout}
  162.         {$mts_shareit_left}
  163.         {$mts_shareit_right}
  164.         {$mts_author}
  165.         {$mts_header_section}
  166.         {$mts_options['mts_custom_css']}
  167.             ";
  168.     wp_add_inline_style( 'stylesheet', $custom_css );
  169. }
  170. add_action('wp_enqueue_scripts', 'mts_enqueue_css', 99);
  171.  
  172. /*-----------------------------------------------------------------------------------*/
  173. /*  Enable Widgetized sidebar and Footer
  174. /*-----------------------------------------------------------------------------------*/
  175. if ( function_exists('register_sidebar') )
  176.     register_sidebar(array(
  177.         'name'=>'Sidebar',
  178.         'description'   => __( 'Appears on homepage, posts and pages', 'mythemeshop' ),
  179.         'before_widget' => '<li id="%1$s" class="widget widget-sidebar %2$s">',
  180.         'after_widget' => '</li>',
  181.         'before_title' => '<div class="widget-wrap"><h3>',
  182.         'after_title' => '</h3></div>',
  183.     ));
  184.     register_sidebar(array(
  185.         'name' => 'Header Ad',
  186.         'description'   => __( 'Appears in Header', 'mythemeshop' ),
  187.         'id' => 'widget-header' ,
  188.         'before_widget' => '<div class="widget-header">',
  189.         'after_widget' => '</div>',
  190.         'before_title' => '',
  191.         'after_title' => ''
  192.     ));
  193.     register_sidebar(array(
  194.         'name' => 'Left Footer',
  195.         'description'   => __( 'Appears in left side of footer.', 'mythemeshop' ),
  196.         'id' => 'footer-1',
  197.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  198.         'after_widget' => '</div>',
  199.         'before_title' => '<div class="widget-wrap"><h3 class="widget-title">',
  200.         'after_title' => '</h3></div>',
  201.     ));
  202.     register_sidebar(array(
  203.         'name' => 'Center Footer',
  204.         'description'   => __( 'Appears in center of footer.', 'mythemeshop' ),
  205.         'id' => 'footer-2',
  206.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  207.         'after_widget' => '</div>',
  208.         'before_title' => '<div class="widget-wrap"><h3 class="widget-title">',
  209.         'after_title' => '</h3></div>',
  210.     ));
  211.     register_sidebar(array(
  212.         'name' => 'Right Footer',
  213.         'description'   => __( 'Appears in right side of footer.', 'mythemeshop' ),
  214.         'id' => 'footer-3',
  215.         'before_widget' => '<div id="%1$s" class="widget %2$s">',
  216.         'after_widget' => '</div>',
  217.         'before_title' => '<div class="widget-wrap"><h3 class="widget-title">',
  218.         'after_title' => '</h3></div>',
  219.     ));
  220.  
  221. /*-----------------------------------------------------------------------------------*/
  222. /*  Load Widgets & Shortcodes
  223. /*-----------------------------------------------------------------------------------*/
  224. // Add the 125x125 Ad Block Custom Widget
  225. include("functions/widget-ad125.php");
  226.  
  227. // Add the 300x250 Ad Block Custom Widget
  228. include("functions/widget-ad300.php");
  229.  
  230. // Add the 728x90 Ad Block Custom Widget
  231. include("functions/widget-ad728.php");
  232.  
  233. // Add the Tabbed Custom Widget
  234. include("functions/widget-tabs.php");
  235.  
  236. // Add the Latest Tweets Custom Widget
  237. include("functions/widget-tweets.php");
  238.  
  239. // Add the Theme Shortcodes
  240. include("functions/theme-shortcodes.php");
  241.  
  242. // Add Recent Posts Widget
  243. include("functions/widget-recentposts.php");
  244.  
  245. // Add Related Posts Widget
  246. include("functions/widget-relatedposts.php");
  247.  
  248. // Add Popular Posts Widget
  249. include("functions/widget-popular.php");
  250.  
  251. // Add Facebook Like box Widget
  252. include("functions/widget-fblikebox.php");
  253.  
  254. // Add Google Plus box Widget
  255. include("functions/widget-googleplus.php");
  256.  
  257. // Add Subscribe Widget
  258. include("functions/widget-subscribe.php");
  259.  
  260. // Add Social Profile Widget
  261. include("functions/widget-social.php");
  262.  
  263. // Add Category Posts Widget
  264. include("functions/widget-catposts.php");
  265.  
  266. // Add Welcome message
  267. include("functions/welcome-message.php");
  268.  
  269. // Theme Functions
  270. include("functions/theme-actions.php");
  271.  
  272. /*-----------------------------------------------------------------------------------*/
  273. /*  Filters customize wp_title
  274. /*-----------------------------------------------------------------------------------*/
  275. function mts_wp_title( $title, $sep ) {
  276.     global $paged, $page;
  277.  
  278.     if ( is_feed() )
  279.         return $title;
  280.  
  281.     // Add the site name.
  282.     $title .= get_bloginfo( 'name' );
  283.  
  284.     // Add the site description for the home/front page.
  285.     $site_description = get_bloginfo( 'description', 'display' );
  286.     if ( $site_description && ( is_home() || is_front_page() ) )
  287.         $title = "$title $sep $site_description";
  288.  
  289.     // Add a page number if necessary.
  290.     if ( $paged >= 2 || $page >= 2 )
  291.         $title = "$title $sep " . sprintf( __( 'Page %s', 'mythemeshop' ), max( $paged, $page ) );
  292.  
  293.     return $title;
  294. }
  295. add_filter( 'wp_title', 'mts_wp_title', 10, 2 );
  296.  
  297. /*-----------------------------------------------------------------------------------*/
  298. /*  Filters that allow shortcodes in Text Widgets
  299. /*-----------------------------------------------------------------------------------*/
  300. add_filter('widget_text', 'shortcode_unautop');
  301. add_filter('widget_text', 'do_shortcode');
  302. add_filter('the_content_rss', 'do_shortcode');
  303.  
  304. /*-----------------------------------------------------------------------------------*/
  305. /*  Custom Comments template
  306. /*-----------------------------------------------------------------------------------*/
  307. function mts_comments($comment, $args, $depth) {
  308.     $GLOBALS['comment'] = $comment; ?>
  309.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  310.         <div id="comment-<?php comment_ID(); ?>" style="position:relative;">
  311.             <div class="comment-author vcard">
  312.                 <?php echo get_avatar( $comment->comment_author_email, 50 ); ?>
  313.                 <?php printf(__('<span class="fn">%s</span>', 'mythemeshop'), get_comment_author_link()) ?>
  314.                 <?php $mts_options = get_option('THEMENAME'); if($mts_options['mts_comment_date'] == '1') { ?>
  315.                     <span class="ago"><?php echo human_time_diff( get_comment_time('U'), current_time('. timestamp') ) . ' ago'; ?></span>
  316.                 <?php } ?>
  317.                 <span class="comment-meta">
  318.                     <?php edit_comment_link(__('(Edit)', 'mythemeshop'),'  ','') ?>
  319.                 </span>
  320.             </div>
  321.             <?php if ($comment->comment_approved == '0') : ?>
  322.                 <em><?php _e('Your comment is awaiting moderation.', 'mythemeshop') ?></em>
  323.                 <br />
  324.             <?php endif; ?>
  325.             <div class="commentmetadata">
  326.             <?php comment_text() ?>
  327.             <div class="reply">
  328.                 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  329.             </div>
  330.             </div>
  331.         </div>
  332.     </li>
  333. <?php }
  334.  
  335. /*-----------------------------------------------------------------------------------*/
  336. /*  excerpt
  337. /*-----------------------------------------------------------------------------------*/
  338. function mts_excerpt($limit) {
  339.   $excerpt = explode(' ', get_the_excerpt(), $limit);
  340.   if (count($excerpt)>=$limit) {
  341.     array_pop($excerpt);
  342.     $excerpt = implode(" ",$excerpt);
  343.   } else {
  344.     $excerpt = implode(" ",$excerpt);
  345.   }
  346.   $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
  347.   return $excerpt;
  348. }
  349.  
  350. /*-----------------------------------------------------------------------------------*/
  351. /* nofollow to next/previous links
  352. /*-----------------------------------------------------------------------------------*/
  353. function mts_pagination_add_nofollow($content) {
  354.     return 'rel="nofollow"';
  355. }
  356. add_filter('next_posts_link_attributes', 'mts_pagination_add_nofollow' );
  357. add_filter('previous_posts_link_attributes', 'mts_pagination_add_nofollow' );
  358.  
  359. /*-----------------------------------------------------------------------------------*/
  360. /* Nofollow to category links
  361. /*-----------------------------------------------------------------------------------*/
  362. add_filter( 'the_category', 'mts_add_nofollow_cat' );
  363. function mts_add_nofollow_cat( $text ) {
  364. $text = str_replace('rel="category tag"', 'rel="nofollow"', $text); return $text;
  365. }
  366.  
  367. /*-----------------------------------------------------------------------------------*/
  368. /* nofollow post author link
  369. /*-----------------------------------------------------------------------------------*/
  370. add_filter('the_author_posts_link', 'mts_nofollow_the_author_posts_link');
  371. function mts_nofollow_the_author_posts_link ($link) {
  372. return str_replace('<a href=', '<a rel="nofollow" href=',$link);
  373. }
  374.  
  375. /*-----------------------------------------------------------------------------------*/
  376. /* nofollow to reply links
  377. /*-----------------------------------------------------------------------------------*/
  378. function mts_add_nofollow_to_reply_link( $link ) {
  379. return str_replace( '")\'>', '")\' rel=\'nofollow\'>', $link );
  380. }
  381. add_filter( 'comment_reply_link', 'mts_add_nofollow_to_reply_link' );
  382.  
  383. /*-----------------------------------------------------------------------------------*/
  384. /* removes the WordPress version from your header for security
  385. /*-----------------------------------------------------------------------------------*/
  386. function wb_remove_version() {
  387.     return '<!--Theme by MyThemeShop.com-->';
  388. }
  389. add_filter('the_generator', 'wb_remove_version');
  390.    
  391. /*-----------------------------------------------------------------------------------*/
  392. /* Removes Trackbacks from the comment count
  393. /*-----------------------------------------------------------------------------------*/
  394. add_filter('get_comments_number', 'mts_comment_count', 0);
  395. function mts_comment_count( $count ) {
  396.     if ( ! is_admin() ) {
  397.         global $id;
  398.         $comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
  399.         return count($comments_by_type['comment']);
  400.     } else {
  401.         return $count;
  402.     }
  403. }
  404.  
  405. /*-----------------------------------------------------------------------------------*/
  406. /* adds a class to the post if there is a thumbnail
  407. /*-----------------------------------------------------------------------------------*/
  408. function has_thumb_class($classes) {
  409.     global $post;
  410.     if( has_post_thumbnail($post->ID) ) { $classes[] = 'has_thumb'; }
  411.         return $classes;
  412. }
  413. add_filter('post_class', 'has_thumb_class');
  414.  
  415. /*-----------------------------------------------------------------------------------*/
  416. /* Breadcrumb
  417. /*-----------------------------------------------------------------------------------*/
  418. function mts_the_breadcrumb() {
  419.     echo '<a href="';
  420.     echo home_url();
  421.     echo '" rel="nofollow"><i class="icon-home"></i>&nbsp;'.__('Home','mythemeshop');
  422.     echo "</a>";
  423.     if (is_category() || is_single()) {
  424.         echo "&nbsp;/&nbsp;";
  425.         the_category(' &bull; ');
  426.             if (is_single()) {
  427.                 echo "&nbsp;/&nbsp;";
  428.                 the_title();
  429.             }
  430.     } elseif (is_page()) {
  431.         echo "&nbsp;/&nbsp;";
  432.         echo the_title();
  433.     } elseif (is_search()) {
  434.         echo "&nbsp;/&nbsp;".__('Search Results for','mythemeshop')."... ";
  435.         echo '"<em>';
  436.         echo the_search_query();
  437.         echo '</em>"';
  438.     }
  439. }
  440.  
  441. /*-----------------------------------------------------------------------------------*/
  442. /* Pagination
  443. /*-----------------------------------------------------------------------------------*/
  444. function mts_pagination($pages = '', $range = 3) {
  445.     $showitems = ($range * 3)+1;
  446.     global $paged; if(empty($paged)) $paged = 1;
  447.     if($pages == '') {
  448.         global $wp_query; $pages = $wp_query->max_num_pages;
  449.         if(!$pages){ $pages = 1; }
  450.     }
  451.     if(1 != $pages) {
  452.         echo "<div class='pagination'><ul>";
  453.         if($paged > 2 && $paged > $range+1 && $showitems < $pages)
  454.             echo "<li><a rel='nofollow' href='".get_pagenum_link(1)."'>&laquo; ".__('First','mythemeshop')."</a></li>";
  455.         if($paged > 1 && $showitems < $pages)
  456.             echo "<li><a rel='nofollow' href='".get_pagenum_link($paged - 1)."' class='inactive'>&lsaquo; ".__('Previous','mythemeshop')."</a></li>";
  457.         for ($i=1; $i <= $pages; $i++){
  458.             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
  459.                 echo ($paged == $i)? "<li class='current'><span class='currenttext'>".$i."</span></li>":"<li><a rel='nofollow' href='".get_pagenum_link($i)."' class='inactive'>".$i."</a></li>";
  460.             }
  461.         }
  462.         if ($paged < $pages && $showitems < $pages)
  463.             echo "<li><a rel='nofollow' href='".get_pagenum_link($paged + 1)."' class='inactive'>".__('Next','mythemeshop')." &rsaquo;</a></li>";
  464.         if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages)
  465.             echo "<a rel='nofollow' class='inactive' href='".get_pagenum_link($pages)."'>".__('Last','mythemeshop')." &raquo;</a>";
  466.             echo "</ul></div>";
  467.     }
  468. }
  469.  
  470. /*-----------------------------------------------------------------------------------*/
  471. /* Redirect feed to feedburner
  472. /*-----------------------------------------------------------------------------------*/
  473. $mts_options = get_option('THEMENAME');
  474. if ( isset($mts_options['mts_feedburner']) != '') {
  475. function mts_rss_feed_redirect() {
  476.     $mts_options = get_option('THEMENAME');
  477.     global $feed;
  478.     $new_feed = $mts_options['mts_feedburner'];
  479.     if (!is_feed()) {
  480.             return;
  481.     }
  482.     if (preg_match('/feedburner/i', $_SERVER['HTTP_USER_AGENT'])){
  483.             return;
  484.     }
  485.     if ($feed != 'comments-rss2') {
  486.             if (function_exists('status_header')) status_header( 302 );
  487.             header("Location:" . $new_feed);
  488.             header("HTTP/1.1 302 Temporary Redirect");
  489.             exit();
  490.     }
  491. }
  492. add_action('template_redirect', 'mts_rss_feed_redirect');
  493. }
  494.  
  495. $mts_options = get_option('THEMENAME');
  496. if ( $mts_options['mts_admin_style'] == '1') {
  497. function mts_admin_css() {
  498.     wp_enqueue_style( 'mts_admin_css', get_template_directory_uri() . '/css/admin.css' );
  499. }
  500. add_action('admin_print_styles', 'mts_admin_css' );
  501. function mts_remove_footer_admin () {
  502.     echo "Thank you for creating with <a href=\"http://wordpress.org/\">WordPress</a>. Dashboard Customization by <a href=\"http://mythemeshop.com/\">MyThemeShop</a>.";
  503. }
  504. add_filter('admin_footer_text', 'mts_remove_footer_admin');
  505. }
  506.  
  507. /*-----------------------------------------------------------------------------------*/
  508. /* Single Post Pagination
  509. /*-----------------------------------------------------------------------------------*/
  510. function mts_wp_link_pages_args_prevnext_add($args)
  511. {
  512.     global $page, $numpages, $more, $pagenow;
  513.     if (!$args['next_or_number'] == 'next_and_number')
  514.         return $args;
  515.     $args['next_or_number'] = 'number';
  516.     if (!$more)
  517.         return $args;
  518.     if($page-1)
  519.         $args['before'] .= _wp_link_page($page-1)
  520.         . $args['link_before']. $args['previouspagelink'] . $args['link_after'] . '</a>'
  521.     ;
  522.     if ($page<$numpages)
  523.    
  524.         $args['after'] = _wp_link_page($page+1)
  525.         . $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'
  526.         . $args['after']
  527.     ;
  528.     return $args;
  529. }
  530. add_filter('wp_link_pages_args', 'mts_wp_link_pages_args_prevnext_add');
  531.  
  532. /*-----------------------------------------------------------------------------------*/
  533. /* WooCommerce
  534. /*-----------------------------------------------------------------------------------*/
  535. if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
  536. add_theme_support('woocommerce');
  537.  
  538. //WooCommerce
  539. function mts_woo_enqueue_css() {
  540.     wp_enqueue_style('woocommerce', get_template_directory_uri() . '/css/woocommerce2.css', 'style');
  541. }
  542. add_action('wp_enqueue_scripts', 'mts_woo_enqueue_css', 100);
  543.  
  544. // Register Shop and Single Product Sidebar
  545. register_sidebar(array(
  546.     'name' => 'Shop Page Sidebar',
  547.     'description'   => __( 'Appears on Shop main page and product archive pages.', 'mythemeshop' ),
  548.     'id' => 'shop-sidebar',
  549.     'before_widget' => '<li id="%1$s" class="widget widget-sidebar %2$s">',
  550.     'after_widget' => '</li>',
  551.     'before_title' => '<div class="widget-wrap"><h3>',
  552.     'after_title' => '</h3></div>',
  553. ));
  554. register_sidebar(array(
  555.     'name' => 'Single Product Sidebar',
  556.     'description'   => __( 'Appears on single product pages.', 'mythemeshop' ),
  557.     'id' => 'product-sidebar',
  558.     'before_widget' => '<li id="%1$s" class="widget widget-sidebar %2$s">',
  559.     'after_widget' => '</li>',
  560.     'before_title' => '<div class="widget-wrap"><h3>',
  561.     'after_title' => '</h3></div>',
  562. ));
  563.  
  564. // Change number or products per row to 3
  565. add_filter('loop_shop_columns', 'loop_columns');
  566. if (!function_exists('loop_columns')) {
  567.     function loop_columns() {
  568.         return 3; // 3 products per row
  569.     }
  570. }
  571.  
  572. // Redefine woocommerce_output_related_products()
  573. function woocommerce_output_related_products() {
  574. woocommerce_related_products(3,1); // Display 3 products in rows of 1
  575. }
  576.  
  577. /*** Hook in on activation */
  578. global $pagenow;
  579. if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action( 'init', 'mythemeshop_woocommerce_image_dimensions', 1 );
  580.  
  581. /*** Define image sizes */
  582. function mythemeshop_woocommerce_image_dimensions() {
  583.     $catalog = array(
  584.         'width'     => '228',   // px
  585.         'height'    => '312',   // px
  586.         'crop'      => 1        // true
  587.     );
  588.     $single = array(
  589.         'width'     => '440',   // px
  590.         'height'    => '600',   // px
  591.         'crop'      => 1        // true
  592.     );
  593.     $thumbnail = array(
  594.         'width'     => '75',    // px
  595.         'height'    => '100',   // px
  596.         'crop'      => 0        // false
  597.     );
  598.     // Image sizes
  599.     update_option( 'shop_catalog_image_size', $catalog );       // Product category thumbs
  600.     update_option( 'shop_single_image_size', $single );         // Single product image
  601.     update_option( 'shop_thumbnail_image_size', $thumbnail );   // Image gallery thumbs
  602. }
  603.  
  604. add_filter ( 'woocommerce_product_thumbnails_columns', 'mts_thumb_cols' );
  605.  function mts_thumb_cols() {
  606.      return 4; // .last class applied to every 4th thumbnail
  607.  }
  608. }
  609. /*------------[ Cart ]-------------*/
  610. if ( ! function_exists( 'mts_cart' ) ) {
  611.     function mts_cart() {
  612.     global $mts_options;
  613. if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
  614. ?>
  615. <div class="mts-cart">
  616.     <?php global $woocommerce; ?>
  617.     <span>
  618.         <i class="icon-user"></i>
  619.         <?php if ( is_user_logged_in() ) { ?>
  620.             <a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','mythemeshop'); ?>"><?php _e('My Account','mythemeshop'); ?></a>
  621.         <?php }
  622.         else { ?>
  623.             <a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','mythemeshop'); ?>"><?php _e('Login ','mythemeshop'); ?></a>
  624.         <?php } ?>
  625.     </span>
  626.     <span>
  627.         <i class="icon-shopping-cart"></i> <a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'mythemeshop'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'mythemeshop'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
  628.     </span>
  629. </div>
  630. <?php } }
  631. }
  632.  
  633. /*-----------------------------------------------------------------------------------*/
  634. /* add <!-- next-page --> button to tinymce
  635. /*-----------------------------------------------------------------------------------*/
  636. add_filter('mce_buttons','wysiwyg_editor');
  637. function wysiwyg_editor($mce_buttons) {
  638.    $pos = array_search('wp_more',$mce_buttons,true);
  639.    if ($pos !== false) {
  640.        $tmp_buttons = array_slice($mce_buttons, 0, $pos+1);
  641.        $tmp_buttons[] = 'wp_page';
  642.        $mce_buttons = array_merge($tmp_buttons, array_slice($mce_buttons, $pos+1));
  643.    }
  644.    return $mce_buttons;
  645. }
  646.  
  647. /*-----------------------------------------------------------------------------------*/
  648. /*  Custom Gravatar Support
  649. /*-----------------------------------------------------------------------------------*/
  650. if( !function_exists( 'mts_custom_gravatar' ) ) {
  651.     function mts_custom_gravatar( $avatar_defaults ) {
  652.         $mts_avatar = get_bloginfo('template_directory') . '/images/gravatar.png';
  653.         $avatar_defaults[$mts_avatar] = 'Custom Gravatar (/images/gravatar.png)';
  654.         return $avatar_defaults;
  655.     }
  656.     add_filter( 'avatar_defaults', 'mts_custom_gravatar' );
  657. }
  658.  
  659. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement