Advertisement
Guest User

MrsDal

a guest
Sep 2nd, 2011
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.90 KB | None | 0 0
  1. <?php
  2. /*----------------------------------------
  3. #
  4. # Theme Name: Brunelleschi
  5. # Theme Author: Kit MacAllister
  6. #
  7. ----------------------------------------*/
  8.  
  9. /*----------------------------------------
  10. #
  11. # BRUNELLESCHI SETUP
  12. #
  13. ----------------------------------------*/
  14.  
  15. /* Run Brunelleschi Theme Setup */
  16. add_action( 'after_setup_theme', 'brunelleschi_setup' );
  17.  
  18. /* brunelleschi setup */
  19. if ( ! function_exists( 'brunelleschi_setup' ) ):
  20. function brunelleschi_setup() {
  21.  
  22. /* Load Theme TextDomain */
  23. load_theme_textdomain( 'brunelleschi', TEMPLATEPATH . '/languages' );
  24. $locale = get_locale();
  25. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  26. if ( is_readable( $locale_file ) ) { require_once( $locale_file ); }
  27.  
  28. /* Add Custom Background */
  29. add_custom_background();
  30.  
  31. /* Add Theme Support for Aside and Gallery */
  32. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
  33.  
  34. /* Add Editor Style */
  35. add_editor_style();
  36.  
  37. /* Add Automatic Feed Links */
  38. add_theme_support( 'automatic-feed-links' );
  39.  
  40. /* Load Theme Textdomain */
  41. load_theme_textdomain( 'brunelleschi', TEMPLATEPATH . '/languages' );
  42.  
  43. /* Register Navigation */
  44. register_nav_menus( array(
  45. 'primary' => __( 'Primary Navigation', 'brunelleschi' ),
  46. ) );
  47.  
  48. /* Default Header Stuff */
  49. if ( ! defined( 'HEADER_TEXTCOLOR' ) ) { define( 'HEADER_TEXTCOLOR', '' ); }
  50. if ( ! defined( 'NO_HEADER_TEXT' ) ) { define( 'NO_HEADER_TEXT', true ); }
  51.  
  52. }
  53. endif;
  54.  
  55. /*----------------------------------------
  56. #
  57. # REGISTER SCRIPTS
  58. #
  59. ----------------------------------------*/
  60.  
  61. /* Updated 6/27/11 */
  62. /* Modernizr */
  63. wp_register_script('modernizr', get_template_directory_uri() . '/js/modernizr-2.0.6.min.js', array(), '2.0.6' );
  64. if( !is_admin() ){ wp_enqueue_script('modernizr'); }
  65.  
  66. /* Contains Media Queries Used by 1140px Grid*/
  67. wp_register_script('respond', get_template_directory_uri() . '/js/respond.js', array());
  68. if( !is_admin() ){ wp_enqueue_script('respond'); }
  69.  
  70. /*----------------------------------------
  71. #
  72. # SETUP FUNCTIONS
  73. #
  74. ----------------------------------------*/
  75.  
  76. /* Title Function */
  77. function brunelleschi_title(){
  78. global $page, $paged;
  79. wp_title( '&raquo;', true, 'right' );
  80. bloginfo( 'name' );
  81. $site_description = get_bloginfo( 'description', 'display' );
  82. if ( $site_description && ( is_home() || is_front_page() ) )
  83. echo " &raquo; $site_description";
  84.  
  85. if ( $paged >= 2 || $page >= 2 )
  86. echo ' &raquo; ' . sprintf( __( 'Page %s', 'brunelleschi' ), max( $paged, $page ) );
  87. }
  88.  
  89. /* Posted In Function */
  90. function brunelleschi_posted_in() {
  91. $tag_list = get_the_tag_list( '', ', ' );
  92. if ( $tag_list ) {
  93. $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'brunelleschi' );
  94. } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  95. $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'brunelleschi' );
  96. } else {
  97. $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'brunelleschi' );
  98. }
  99. printf(
  100. $posted_in,
  101. get_the_category_list( ', ' ),
  102. $tag_list,
  103. get_permalink(),
  104. the_title_attribute( 'echo=0' )
  105. );
  106. }
  107.  
  108. /* Posted On Function */
  109. function brunelleschi_posted_on() {
  110. printf( __('<span class="meta-sep">by</span> %3$s <span class="%1$s">Posted on</span> %2$s', 'brunelleschi' ),
  111. 'meta-prep meta-prep-author',
  112. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
  113. get_permalink(),
  114. esc_attr( get_the_time() ),
  115. get_the_date()
  116. ),
  117. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  118. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  119. sprintf( esc_attr__( 'View all posts by %s', 'brunelleschi' ), get_the_author() ),
  120. get_the_author()
  121. )
  122. );
  123. edit_post_link( __( 'Edit', 'brunelleschi' ), ' <small><span class="edit-link">[', ']</span></small>' );
  124. }
  125.  
  126. /* Theme Comments */
  127. function brunelleschi_comment( $comment, $args, $depth ) {
  128. $GLOBALS['comment'] = $comment;
  129. switch ( $comment->comment_type ) :
  130. case '' :
  131. ?>
  132. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  133. <div id="comment-<?php comment_ID(); ?>">
  134. <div class="comment-author vcard">
  135. <?php echo get_avatar( $comment, 40 ); ?>
  136. <?php printf( __( '%s <span class="says">says:</span>', 'brunelleschi' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  137. </div><!-- .comment-author .vcard -->
  138. <?php if ( $comment->comment_approved == '0' ) : ?>
  139. <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'brunelleschi' ); ?></em>
  140. <br />
  141. <?php endif; ?>
  142.  
  143. <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  144. <?php
  145. printf( __( '%1$s at %2$s', 'brunelleschi' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'brunelleschi' ), ' ' );
  146. ?>
  147. </div><!-- .comment-meta .commentmetadata -->
  148.  
  149. <div class="comment-body"><?php comment_text(); ?></div>
  150.  
  151. <div class="reply">
  152. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  153. </div><!-- .reply -->
  154. </div><!-- #comment-## -->
  155.  
  156. <?php
  157. break;
  158. case 'pingback' :
  159. case 'trackback' :
  160. ?>
  161. <li class="post pingback">
  162. <p><?php _e( 'Pingback:', 'brunelleschi' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'brunelleschi' ), ' ' ); ?></p>
  163. <?php
  164. break;
  165. endswitch;
  166. }
  167.  
  168. /* Remove Recent Comments Style */
  169. function brunelleschi_remove_recent_comments_style() {
  170. add_filter( 'show_recent_comments_widget_style', '__return_false' );
  171. }
  172. add_action( 'widgets_init', 'brunelleschi_remove_recent_comments_style' );
  173.  
  174. /* Remove Gallery CSS */
  175. add_filter( 'use_default_gallery_style', '__return_false' );
  176. function brunelleschi_remove_gallery_css( $css ) {
  177. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  178. }
  179. if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) ) { add_filter( 'gallery_style', 'brunelleschi_remove_gallery_css' ); }
  180.  
  181. /* Custom Excerpt More */
  182. function brunelleschi_custom_excerpt_more( $output ) {
  183. if ( has_excerpt() && ! is_attachment() ) {
  184. $output .= brunelleschi_continue_reading_link();
  185. }
  186. return $output;
  187. }
  188. add_filter( 'get_the_excerpt', 'brunelleschi_custom_excerpt_more' );
  189.  
  190. /* Show the Home Page */
  191. function brunelleschi_page_menu_args( $args ) {
  192. $args['show_home'] = true;
  193. return $args;
  194. }
  195. add_filter( 'wp_page_menu_args', 'brunelleschi_page_menu_args' );
  196.  
  197. /* Excerpt Length */
  198. function brunelleschi_excerpt_length( $length ) {
  199. return 40;
  200. }
  201. add_filter( 'excerpt_length', 'brunelleschi_excerpt_length' );
  202.  
  203. /* Continue Reading Link */
  204. function brunelleschi_continue_reading_link() {
  205. return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'brunelleschi' ) . '</a>';
  206. }
  207.  
  208. /* Auto Excerpt More */
  209. function brunelleschi_auto_excerpt_more( $more ) {
  210. return ' &hellip;' . brunelleschi_continue_reading_link();
  211. }
  212. add_filter( 'excerpt_more', 'brunelleschi_auto_excerpt_more' );
  213.  
  214. /* Admin Header Style */
  215. function brunelleschi_admin_header_style() { ?>
  216. <style type="text/css">
  217. #headerimg {
  218. display: block;
  219. margin: 0 auto;
  220. margin-bottom: 17px;
  221. border-top: 1px solid #aaa;
  222. border-bottom: 1px solid #aaa;
  223. }
  224. </style>
  225. <?php }
  226.  
  227. /*----------------------------------------
  228. #
  229. # Theme Options
  230. #
  231. ----------------------------------------*/
  232.  
  233. /* Load Theme options Page from inc */
  234. require( dirname( __FILE__ ) . '/inc/theme-options.php' );
  235.  
  236. /*----------------------------------------
  237. #
  238. # OPTIONS DEPENDANT FUNCTIONS
  239. #
  240. ----------------------------------------*/
  241. function brunelleschi_option( $string ){
  242. $option = get_option('brunelleschi_options');
  243. if(isset($option[$string]) && $option[$string] !== ''){
  244. return $option[$string];
  245. } else {
  246. return false;
  247. }
  248. }
  249.  
  250. /*----------------------------------------
  251. #
  252. # CUSTOM IMAGE HEADER
  253. #
  254. ----------------------------------------*/
  255.  
  256. /* REQUIRED! -- define content width */
  257. if ( ! brunelleschi_option('content-width') ) { $content_width = 960; }
  258. else { $content_width = brunelleschi_option('content-width'); }
  259.  
  260. /* Disable Based on Settings */
  261. if(brunelleschi_option('use-header-image')) {
  262.  
  263. /* Define Default Header */
  264. if ( ! defined( 'HEADER_IMAGE' ) ) { define( 'HEADER_IMAGE', '%s/images/headers/beach.png' ); }
  265.  
  266. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'brunelleschi_header_image_width', $content_width ) );
  267. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'brunelleschi_header_image_height', 198 ) );
  268.  
  269. register_default_headers( array(
  270. 'beach' => array(
  271. 'url' => '%s/images/headers/beach.png',
  272. 'thumbnail_url' => '%s/images/headers/beach-thumbnail.png',
  273. 'description' => __('Beach', 'brunelleschi')
  274. ),
  275. 'fog' => array(
  276. 'url' => '%s/images/headers/fog.png',
  277. 'thumbnail_url' => '%s/images/headers/fog-thumbnail.png',
  278. 'description' => __('Fog', 'brunelleschi')
  279. ),
  280. 'grass' => array(
  281. 'url' => '%s/images/headers/grass.png',
  282. 'thumbnail_url' => '%s/images/headers/grass-thumbnail.png',
  283. 'description' => __('Grass', 'brunelleschi')
  284. )
  285. ) );
  286.  
  287. /* Add Post Thumbnails */
  288. add_theme_support( 'post-thumbnails' );
  289.  
  290. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  291.  
  292. if ( ! function_exists( 'brunelleschi_admin_header_style' ) ) :
  293.  
  294. /* Backend Header Style */
  295. function brunelleschi_admin_header_style() { ?>
  296. <style type="text/css">
  297. #headerimg {
  298. display: block;
  299. margin: 0 auto;
  300. margin-bottom: 17px;
  301. border-top: 1px solid #aaa;
  302. border-bottom: 1px solid #aaa;
  303. }
  304. </style>
  305. <?php }
  306. endif;
  307. add_custom_image_header( '', 'brunelleschi_admin_header_style' );
  308.  
  309. }
  310.  
  311. /*----------------------------------------
  312. #
  313. # REGISTER WIDGETS AND SIDEBARS
  314. #
  315. ----------------------------------------*/
  316.  
  317. function brunelleschi_widgets_init( ) {
  318. if( brunelleschi_option('sidebar') !== 'none' ){
  319. /* Widget Area 1, located at the top of the sidebar.*/
  320. register_sidebar( array(
  321. 'name' => __( 'Primary Widget Area', 'brunelleschi' ),
  322. 'id' => 'primary-widget-area',
  323. 'description' => __( 'The first widget area', 'brunelleschi' ),
  324. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  325. 'after_widget' => '</li>',
  326. 'before_title' => '<h3 class="widget-title">',
  327. 'after_title' => '</h3>',
  328. ) );
  329.  
  330. /* Widget Area 2, located below the Primary Widget Area in the sidebar. */
  331. register_sidebar( array(
  332. 'name' => __( 'Secondary Widget Area', 'brunelleschi' ),
  333. 'id' => 'secondary-widget-area',
  334. 'description' => __( 'The second widget area', 'brunelleschi' ),
  335. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  336. 'after_widget' => '</li>',
  337. 'before_title' => '<h3 class="widget-title">',
  338. 'after_title' => '</h3>',
  339. ) );
  340. }
  341.  
  342. if( brunelleschi_option('sidebar') === 'both' ){
  343. /* Widget Area 1, located at the top of the second sidebar.*/
  344. register_sidebar( array(
  345. 'name' => __( 'Ternary Widget Area', 'brunelleschi' ),
  346. 'id' => 'ternary-widget-area',
  347. 'description' => __( 'The third widget area', 'brunelleschi' ),
  348. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  349. 'after_widget' => '</li>',
  350. 'before_title' => '<h3 class="widget-title">',
  351. 'after_title' => '</h3>',
  352. ) );
  353.  
  354. /* Widget Area 2, located below the Ternary Widget Area in the sidebar. */
  355. register_sidebar( array(
  356. 'name' => __( 'Quaternary Widget Area', 'brunelleschi' ),
  357. 'id' => 'quaternary-widget-area',
  358. 'description' => __( 'The fourth widget area', 'brunelleschi' ),
  359. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  360. 'after_widget' => '</li>',
  361. 'before_title' => '<h3 class="widget-title">',
  362. 'after_title' => '</h3>',
  363. ) );
  364. }
  365.  
  366. /* Widget Area 3, located in the footer. Empty by default. */
  367. register_sidebar( array(
  368. 'name' => __( 'First Footer Widget Area', 'brunelleschi' ),
  369. 'id' => 'first-footer-widget-area',
  370. 'description' => __( 'The first footer widget area', 'brunelleschi' ),
  371. 'before_widget' => '<li id="%1$s" class="widget-container threecol %2$s">',
  372. 'after_widget' => '</li>',
  373. 'before_title' => '<h3 class="widget-title">',
  374. 'after_title' => '</h3>',
  375. ) );
  376.  
  377. /* Widget Area 4, located in the footer. Empty by default. */
  378. register_sidebar( array(
  379. 'name' => __( 'Second Footer Widget Area', 'brunelleschi' ),
  380. 'id' => 'second-footer-widget-area',
  381. 'description' => __( 'The second footer widget area', 'brunelleschi' ),
  382. 'before_widget' => '<li id="%1$s" class="widget-container threecol %2$s">',
  383. 'after_widget' => '</li>',
  384. 'before_title' => '<h3 class="widget-title">',
  385. 'after_title' => '</h3>',
  386. ) );
  387.  
  388. /* Widget Area 5, located in the footer. Empty by default. */
  389. register_sidebar( array(
  390. 'name' => __( 'Third Footer Widget Area', 'brunelleschi' ),
  391. 'id' => 'third-footer-widget-area',
  392. 'description' => __( 'The third footer widget area', 'brunelleschi' ),
  393. 'before_widget' => '<li id="%1$s" class="widget-container threecol %2$s">',
  394. 'after_widget' => '</li>',
  395. 'before_title' => '<h3 class="widget-title">',
  396. 'after_title' => '</h3>',
  397. ) );
  398.  
  399. /* Area 6, located in the footer. Empty by default. */
  400. register_sidebar( array(
  401. 'name' => __( 'Fourth Footer Widget Area', 'brunelleschi' ),
  402. 'id' => 'fourth-footer-widget-area',
  403. 'description' => __( 'The fourth footer widget area', 'brunelleschi' ),
  404. 'before_widget' => '<li id="%1$s" class="widget-container threecol last %2$s">',
  405. 'after_widget' => '</li>',
  406. 'before_title' => '<h3 class="widget-title">',
  407. 'after_title' => '</h3>',
  408. ) );
  409. }
  410. add_action( 'widgets_init', 'brunelleschi_widgets_init' );
  411.  
  412. /* Brunelleschi Sidebar Function */
  413. function brunelleschi_sidebar_class(){
  414. if(!brunelleschi_option('sidebar-width')){
  415. echo 'threecol last ';
  416. } else {
  417. echo brunelleschi_option('sidebar-width').'col ';
  418. }
  419. if( brunelleschi_option('sidebar') === 'right' || brunelleschi_option('sidebar') === 'both' ){
  420. echo 'last ';
  421. }
  422. }
  423.  
  424. /* Brunelleschi Content Function */
  425. function brunelleschi_content_class(){
  426. if( !brunelleschi_option('sidebar') ) {
  427. echo 'ninecol ';
  428. } elseif( brunelleschi_option('sidebar') === 'none' ) {
  429. echo 'twelvecol last ';
  430. } elseif( brunelleschi_option('sidebar') === 'both'){
  431. switch( brunelleschi_option('sidebar-width') ) {
  432. case 'two':
  433. echo 'eightcol ';
  434. break;
  435. case 'three':
  436. echo 'sixcol ';
  437. break;
  438. case 'four':
  439. echo 'fourcol ';
  440. break;
  441. default:
  442. echo 'sixcol';
  443. break;
  444. }
  445. } else {
  446. switch( brunelleschi_option('sidebar-width') ) {
  447. case 'two':
  448. echo 'tencol ';
  449. break;
  450. case 'three':
  451. echo 'ninecol ';
  452. break;
  453. case 'four':
  454. echo 'eightcol ';
  455. break;
  456. default:
  457. echo 'ninecol';
  458. break;
  459. }
  460. }
  461. if( brunelleschi_option('sidebar') === 'left' ) { echo ' last '; }
  462. }
  463.  
  464. /* HTML5 Image Captions */
  465. add_filter('img_caption_shortcode', 'my_img_caption_shortcode_filter',10,3);
  466.  
  467. function my_img_caption_shortcode_filter($val, $attr, $content = null)
  468. {
  469. extract(shortcode_atts(array(
  470. 'id' => '',
  471. 'align' => '',
  472. 'width' => '',
  473. 'caption' => ''
  474. ), $attr));
  475.  
  476. if ( 1 > (int) $width || empty($caption) )
  477. return $val;
  478.  
  479. $capid = '';
  480. if ( $id ) {
  481. $id = esc_attr($id);
  482. $capid = 'id="figcaption_'. $id . '" ';
  483. $id = 'id="' . $id . '" aria-labelledby="figcaption_' . $id . '" ';
  484. }
  485.  
  486. return '<figure ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: '
  487. . (10 + (int) $width) . 'px">' . do_shortcode( $content ) . '<figcaption ' . $capid
  488. . 'class="wp-caption-text">' . $caption . '</figcaption></figure>';
  489. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement