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