Don't like ads? PRO users don't see any ads ;-)
Guest

Themefunction.php

By: a guest on Aug 30th, 2011  |  syntax: None  |  size: 6.27 KB  |  hits: 65  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /**
  3.  * @package WordPress
  4.  * @subpackage Modularity
  5.  */
  6.  
  7. $themecolors = array(
  8.         'bg' => '111111',
  9.         'border' => '111111',
  10.         'text' => 'eeeeee',
  11.         'link' => '428CE7',
  12.         'url' => '428CE7'
  13. );
  14. $content_width = 950; // pixels
  15.  
  16. // Grab the theme options page
  17. require_once ( get_template_directory() . '/theme-options.php' );
  18.  
  19. // Add default posts and comments RSS feed links to head
  20. add_theme_support( 'automatic-feed-links' );
  21.  
  22.  
  23. // Add post thumbnail theme support
  24. add_theme_support( 'post-thumbnails' );
  25. set_post_thumbnail_size( 150, 150, true );
  26.  
  27.  
  28.  
  29.  
  30. // Add a new image size
  31. add_image_size( 'modularity-slideshow', 950, 425, true );
  32.  
  33. // Register nav menu locations
  34. register_nav_menus( array(
  35.         'primary' => __( 'Primary Navigation', 'text_domain' ),
  36. ) );
  37.  
  38. // Get wp_page_menu() lookin' more like wp_nav_menu()
  39. function modularity_page_menu_args( $args ) {
  40.         $args['show_home'] = true;
  41.         $args['menu_class'] = 'main-nav';
  42.         return $args;
  43. }
  44. add_filter( 'wp_page_menu_args', 'modularity_page_menu_args' );
  45.  
  46. // Give Modularity a custom background
  47. add_custom_background();
  48.  
  49. // Allow custom colors to clear the background image
  50. function modularity_custom_background_color() {
  51.         if ( get_background_image() == '' && get_background_color() != '' ) { ?>
  52.                 <style type="text/css">
  53.                 body {
  54.                         background-image: none;
  55.                 }
  56.                 </style>                       
  57.         <?php }
  58. }
  59. add_action( 'wp_head', 'modularity_custom_background_color' );
  60.  
  61. // To use a sidebar, or not to use a sidebar, that is the question. This generates the appropriate class
  62. function modularity_sidebar_class() {
  63.         $options = get_option( 'modularity_theme_options' );
  64.  
  65.         if ( $options['sidebar'] == 1 ) {
  66.                 echo "15 colborder home";
  67.         }
  68.         else {
  69.                 echo "24 last";
  70.         }      
  71. }
  72.  
  73. // The header business begins here:
  74.  
  75. // No CSS, just IMG call
  76. define('HEADER_TEXTCOLOR', '');
  77. define('HEADER_IMAGE', '');
  78. define('HEADER_IMAGE_WIDTH', 950);
  79. define('HEADER_IMAGE_HEIGHT', 200);
  80. define( 'NO_HEADER_TEXT', true );
  81.  
  82. function modularity_admin_header_style() {
  83. ?>
  84. <style type="text/css">
  85. #headimg {
  86.         height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  87.         width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  88. }
  89.  
  90. #headimg h1, #headimg #desc {
  91.         display: none;
  92. }
  93.  
  94. </style>
  95. <?php
  96. }
  97.  
  98. add_custom_image_header( '', 'modularity_admin_header_style' );
  99. // and thus ends the header business
  100.  
  101. // Comments in the Modularity style
  102. function modularity_comment( $comment, $args, $depth ) {
  103.         $GLOBALS['comment'] = $comment;
  104.         switch ( $comment->comment_type ) :
  105.                 case '' :
  106.         ?>
  107.         <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  108.                 <div id="comment-<?php comment_ID(); ?>" class="comment-wrapper">
  109.                         <div class="comment-meta">
  110.                                 <?php echo get_avatar( $comment, 75 ); ?>
  111.                                 <div class="comment-author vcard">
  112.                                         <strong class="fn"><?php comment_author_link(); ?></strong>
  113.                                 </div><!-- .comment-author .vcard -->
  114.                         </div>
  115.                         <div class="comment-entry">
  116.                                 <?php if ( $comment->comment_approved == '0' ) : ?>
  117.                                         <em><?php _e( 'Your comment is awaiting moderation.', 'modularity' ); ?></em>
  118.                                         <br />
  119.                                 <?php endif; ?>
  120.                                 <?php comment_text(); ?>
  121.                                 <p class="post-time">
  122.                                         <?php
  123.                                                 /* translators: 1: date, 2: time */
  124.                                                 printf( __( '%1$s at %2$s', 'modularity' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'modularity' ), ' ' );
  125.                                         ?>
  126.                                         <br />
  127.                                 </p>
  128.                                 <div class="reply">
  129.                                         <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  130.                                 </div><!-- .reply -->                          
  131.                         </div>
  132.         </div><!-- #comment-##  -->
  133.  
  134.         <?php
  135.                         break;
  136.                 case 'pingback'  :
  137.                 case 'trackback' :
  138.         ?>
  139.         <li class="pingback">
  140.                 <p><?php _e( 'Pingback:', 'modularity' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'modularity'), ' ' ); ?></p>
  141.         <?php
  142.                         break;
  143.         endswitch;
  144. }
  145.  
  146. // The Sidebar business
  147. $options = get_option( 'modularity_theme_options' );
  148. if ( $options['sidebar'] == 0 ) {
  149.         $optional_description = __( 'The optional Modularity Lite sidebar is currently deactivated but can be activated from Appearance > Theme Options', 'modularity' );      
  150. } else {
  151.         $optional_description = '';    
  152. }
  153.  
  154. if ( function_exists('register_sidebar') ) {
  155.         register_sidebar(array(
  156.                 'name' => 'Sidebar',
  157.                 'id' => 'sidebar',
  158.                 'description' => $optional_description,
  159.                 'before_widget' => '<div id="%1$s" class="item %2$s">',
  160.                 'after_widget' => '</div>',
  161.                 'before_title' => '<h3 class="sub">',
  162.                 'after_title' => '</h3>',
  163.         ));
  164.  
  165.         register_sidebar(array(
  166.                 'name' => 'Footer 1',
  167.                 'id' => 'footer-1',
  168.                 'before_widget' => '<div id="%1$s" class="item %2$s">',
  169.                 'after_widget' => '</div>',
  170.                 'before_title' => '<h3 class="sub">',
  171.                 'after_title' => '</h3>',
  172.         ));
  173.        
  174.         register_sidebar(array(
  175.                 'name' => 'Footer 2',
  176.                 'id' => 'footer-2',
  177.                 'before_widget' => '<div id="%1$s" class="item %2$s">',
  178.                 'after_widget' => '</div>',
  179.                 'before_title' => '<h3 class="sub">',
  180.                 'after_title' => '</h3>',
  181.         ));
  182.        
  183.         register_sidebar(array(
  184.                 'name' => 'Footer 3',
  185.                 'id' => 'footer-3',
  186.                 'before_widget' => '<div id="%1$s" class="item %2$s">',
  187.                 'after_widget' => '</div>',
  188.                 'before_title' => '<h3 class="sub">',
  189.                 'after_title' => '</h3>'
  190.         ));
  191.  
  192.         register_sidebar(array(
  193.                 'name' => 'Footer 4',
  194.                 'id' => 'footer-4',
  195.                 'before_widget' => '<div id="%1$s" class="item %2$s">',
  196.                 'after_widget' => '</div>',
  197.                 'before_title' => '<h3 class="sub">',
  198.                 'after_title' => '</h3>'
  199.         ));    
  200. }
  201.  
  202. // Load Base Javascripts
  203. if (!is_admin()) add_action( 'init', 'load_base_js' );
  204. function load_base_js( ) {
  205.  
  206.         wp_enqueue_script('jquery');
  207.         //wp_enqueue_script('jquerynav', get_bloginfo('template_directory').'/js/nav.js', array('jquery'));
  208.         wp_enqueue_script('cycle', get_bloginfo('template_directory').'/js/jquery.cycle.js', array('jquery'));
  209.         //wp_enqueue_script('search', get_bloginfo('template_directory').'/js/search.js', array( 'jquery' ) );
  210.  
  211. }
  212.  
  213. // Load Dom Ready Javascripts
  214. function load_dom_ready_js() { ?>
  215.  
  216.         <script type="text/javascript">
  217.         /* <![CDATA[ */
  218.                 jQuery(document).ready(function(){
  219.                         jQuery(function() {
  220.                             jQuery("#slideshow").cycle({
  221.                                 speed: '2500',
  222.                                 timeout: '500',
  223.                                         pause: 1
  224.                             });
  225.                         });
  226.                 });
  227.         /* ]]> */
  228.         </script>
  229.  
  230. <?php }
  231. add_action('wp_head', 'load_dom_ready_js');