PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/fayre/functions.php

https://bitbucket.org/cevenson/photosites-themes
PHP | 682 lines | 348 code | 57 blank | 277 comment | 39 complexity | 4d38c9f25b596f99964ef7b231394748 MD5 | raw file
  1. <?php
  2. /**
  3. * Boilerplate functions and definitions
  4. *
  5. * Sets up the theme and provides some helper functions. Some helper functions
  6. * are used in the theme as custom template tags. Others are attached to action and
  7. * filter hooks in WordPress to change core functionality.
  8. *
  9. * The first function, boilerplate_setup(), sets up the theme by registering support
  10. * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  11. *
  12. * When using a child theme (see http://codex.wordpress.org/Theme_Development and
  13. * http://codex.wordpress.org/Child_Themes), you can override certain functions
  14. * (those wrapped in a function_exists() call) by defining them first in your child theme's
  15. * functions.php file. The child theme's functions.php file is included before the parent
  16. * theme's file, so the child theme functions would be used.
  17. *
  18. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  19. * to a filter or action hook. The hook can be removed by using remove_action() or
  20. * remove_filter() and you can attach your own function to the hook.
  21. *
  22. * We can remove the parent theme's hook only after it is attached, which means we need to
  23. * wait until setting up the child theme:
  24. *
  25. * <code>
  26. * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  27. * function my_child_theme_setup() {
  28. * // We are providing our own filter for excerpt_length (or using the unfiltered value)
  29. * remove_filter( 'excerpt_length', 'boilerplate_excerpt_length' );
  30. * ...
  31. * }
  32. * </code>
  33. *
  34. * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  35. *
  36. * @package WordPress
  37. * @subpackage Boilerplate
  38. * @since Boilerplate 1.0
  39. */
  40. /**
  41. * Set the content width based on the theme's design and stylesheet.
  42. *
  43. * Used to set the width of images and content. Should be equal to the width the theme
  44. * is designed for, generally via the style.css stylesheet.
  45. */
  46. if ( ! isset( $content_width ) )
  47. $content_width = 640;
  48. /** Tell WordPress to run boilerplate_setup() when the 'after_setup_theme' hook is run. */
  49. add_action( 'after_setup_theme', 'boilerplate_setup' );
  50. if ( ! function_exists( 'boilerplate_setup' ) ):
  51. /**
  52. * Sets up theme defaults and registers support for various WordPress features.
  53. *
  54. * Note that this function is hooked into the after_setup_theme hook, which runs
  55. * before the init hook. The init hook is too late for some features, such as indicating
  56. * support post thumbnails.
  57. *
  58. * To override boilerplate_setup() in a child theme, add your own boilerplate_setup to your child theme's
  59. * functions.php file.
  60. *
  61. * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
  62. * @uses register_nav_menus() To add support for navigation menus.
  63. * @uses () To add support for a custom background.
  64. * @uses add_editor_style() To style the visual editor.
  65. * @uses load_theme_textdomain() For translation/localization support.
  66. * @uses add_custom_image_header() To add support for a custom header.
  67. * @uses register_default_headers() To register the default custom header images provided with the theme.
  68. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  69. *
  70. * @since Twenty Ten 1.0
  71. */
  72. function boilerplate_setup() {
  73. // This theme styles the visual editor with editor-style.css to match the theme style.
  74. add_editor_style();
  75. // Uncomment if you choose to use post thumbnails; add the_post_thumbnail() wherever thumbnail should appear
  76. add_theme_support( 'post-thumbnails' );
  77. // Add default posts and comments RSS feed links to head
  78. add_theme_support( 'automatic-feed-links' );
  79. // Make theme available for translation
  80. // Translations can be filed in the /languages/ directory
  81. load_theme_textdomain( 'boilerplate', TEMPLATEPATH . '/languages' );
  82. $locale = get_locale();
  83. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  84. if ( is_readable( $locale_file ) )
  85. require_once( $locale_file );
  86. // This theme uses wp_nav_menu() in one location.
  87. register_nav_menus( array(
  88. 'primary' => __( 'Primary Navigation', 'boilerplate' ),
  89. ) );
  90. // This theme allows users to set a custom background
  91. add_custom_background();
  92. // Add support for custom backgrounds.
  93. add_theme_support( 'custom-background', array(
  94. // Let WordPress know what our default background color is.
  95. // This is dependent on our current color scheme.
  96. 'default-color' => $default_background_color,
  97. ) );
  98. // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
  99. add_theme_support( 'post-thumbnails' );
  100. // Add support for custom headers.
  101. $custom_header_support = array(
  102. // The default header text color.
  103. 'default-text-color' => '000',
  104. // The height and width of our custom header.
  105. 'width' => apply_filters( 'twentyeleven_header_image_width', 230 ),
  106. 'height' => apply_filters( 'twentyeleven_header_image_height', 120 ),
  107. // Support flexible heights.
  108. 'flex-height' => true,
  109. // Random image rotation by default.
  110. 'random-default' => true,
  111. // Callback for styling the header.
  112. 'wp-head-callback' => 'twentyeleven_header_style',
  113. // Callback for styling the header preview in the admin.
  114. 'admin-head-callback' => 'twentyeleven_admin_header_style',
  115. // Callback used to display the header preview in the admin.
  116. 'admin-preview-callback' => 'twentyeleven_admin_header_image',
  117. );
  118. add_theme_support( 'custom-header', $custom_header_support );
  119. if ( ! function_exists( 'get_custom_header' ) ) {
  120. // This is all for compatibility with versions of WordPress prior to 3.4.
  121. define( 'HEADER_TEXTCOLOR', $custom_header_support['default-text-color'] );
  122. define( 'HEADER_IMAGE', '' );
  123. define( 'HEADER_IMAGE_WIDTH', $custom_header_support['width'] );
  124. define( 'HEADER_IMAGE_HEIGHT', $custom_header_support['height'] );
  125. add_custom_image_header( $custom_header_support['wp-head-callback'], $custom_header_support['admin-head-callback'], $custom_header_support['admin-preview-callback'] );
  126. add_custom_background();
  127. }
  128. // We'll be using post thumbnails for custom header images on posts and pages.
  129. // We want them to be the size of the header image that we just defined
  130. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  131. set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true );
  132. // Add Twenty Eleven's custom image sizes.
  133. // Used for large feature (header) images.
  134. add_image_size( 'large-feature', $custom_header_support['width'], $custom_header_support['height'], true );
  135. // Used for featured posts if a large-feature doesn't exist.
  136. add_image_size( 'small-feature', 500, 300 );
  137. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  138. }
  139. endif; // twentyeleven_setup
  140. if ( ! function_exists( 'twentyeleven_header_style' ) ) :
  141. /**
  142. * Styles the header image and text displayed on the blog
  143. *
  144. * @since Twenty Eleven 1.0
  145. */
  146. function twentyeleven_header_style() {
  147. $text_color = get_header_textcolor();
  148. // If no custom options for text are set, let's bail.
  149. if ( $text_color == HEADER_TEXTCOLOR )
  150. return;
  151. // If we get this far, we have custom styles. Let's do this.
  152. ?>
  153. <style type="text/css">
  154. <?php
  155. // Has the text been hidden?
  156. if ( 'blank' == $text_color ) :
  157. ?>
  158. #site-title,
  159. #site-description {
  160. position: absolute !important;
  161. clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  162. clip: rect(1px, 1px, 1px, 1px);
  163. }
  164. <?php
  165. // If the user has set a custom color for the text use that
  166. else :
  167. ?>
  168. #site-title a,
  169. #site-description {
  170. color: #<?php echo $text_color; ?> !important;
  171. }
  172. <?php endif; ?>
  173. </style>
  174. <?php
  175. }
  176. endif; // twentyeleven_header_style
  177. if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) :
  178. /**
  179. * Styles the header image displayed on the Appearance > Header admin panel.
  180. *
  181. * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
  182. *
  183. * @since Twenty Eleven 1.0
  184. */
  185. function twentyeleven_admin_header_style() {
  186. ?>
  187. <style type="text/css">
  188. .appearance_page_custom-header #headimg {
  189. border: none;
  190. }
  191. #headimg h1,
  192. #desc {
  193. font-family: 'montserratbold', Helvetica, Arial, sans-serif;
  194. }
  195. #headimg h1 {
  196. margin: 0;
  197. }
  198. #headimg h1 a {
  199. font-family: 'montserratbold', Helvetica, Arial, sans-serif;
  200. font-size: 32px;
  201. line-height: 36px;
  202. text-decoration: none;
  203. }
  204. #desc {
  205. font-size: 14px;
  206. line-height: 23px;
  207. padding: 0 0 3em;
  208. }
  209. <?php
  210. // If the user has set a custom color for the text use that
  211. if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
  212. ?>
  213. #site-title a,
  214. #site-description {
  215. color: #<?php echo get_header_textcolor(); ?>;
  216. }
  217. <?php endif; ?>
  218. #headimg img {
  219. max-width: 320px;
  220. height: auto;
  221. width: 100%;
  222. }
  223. </style>
  224. <?php
  225. }
  226. endif; // twentyeleven_admin_header_style
  227. if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) :
  228. /**
  229. * Custom header image markup displayed on the Appearance > Header admin panel.
  230. *
  231. * Referenced via add_theme_support('custom-header') in twentyeleven_setup().
  232. *
  233. * @since Twenty Eleven 1.0
  234. */
  235. function twentyeleven_admin_header_image() { ?>
  236. <div id="headimg">
  237. <?php
  238. $color = get_header_textcolor();
  239. $image = get_header_image();
  240. if ( $color && $color != 'blank' )
  241. $style = ' style="color:#' . $color . '"';
  242. else
  243. $style = ' style="display:none"';
  244. ?>
  245. <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
  246. <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
  247. <?php if ( $image ) : ?>
  248. <img src="<?php echo esc_url( $image ); ?>" alt="" />
  249. <?php endif; ?>
  250. </div>
  251. <?php }
  252. endif; // twentyeleven_admin_header_image
  253. /**
  254. * Makes some changes to the <title> tag, by filtering the output of wp_title().
  255. *
  256. * If we have a site description and we're viewing the home page or a blog posts
  257. * page (when using a static front page), then we will add the site description.
  258. *
  259. * If we're viewing a search result, then we're going to recreate the title entirely.
  260. * We're going to add page numbers to all titles as well, to the middle of a search
  261. * result title and the end of all other titles.
  262. *
  263. * The site title also gets added to all titles.
  264. *
  265. * @since Twenty Ten 1.0
  266. *
  267. * @param string $title Title generated by wp_title()
  268. * @param string $separator The separator passed to wp_title(). Twenty Ten uses a
  269. * vertical bar, "|", as a separator in header.php.
  270. * @return string The new title, ready for the <title> tag.
  271. */
  272. function boilerplate_filter_wp_title( $title, $separator ) {
  273. // Don't affect wp_title() calls in feeds.
  274. if ( is_feed() )
  275. return $title;
  276. // The $paged global variable contains the page number of a listing of posts.
  277. // The $page global variable contains the page number of a single post that is paged.
  278. // We'll display whichever one applies, if we're not looking at the first page.
  279. global $paged, $page;
  280. if ( is_search() ) {
  281. // If we're a search, let's start over:
  282. $title = sprintf( __( 'Search results for %s', 'boilerplate' ), '"' . get_search_query() . '"' );
  283. // Add a page number if we're on page 2 or more:
  284. if ( $paged >= 2 )
  285. $title .= " $separator " . sprintf( __( 'Page %s', 'boilerplate' ), $paged );
  286. // Add the site name to the end:
  287. $title .= " $separator " . get_bloginfo( 'name', 'display' );
  288. // We're done. Let's send the new title back to wp_title():
  289. return $title;
  290. }
  291. // Otherwise, let's start by adding the site name to the end:
  292. $title .= get_bloginfo( 'name', 'display' );
  293. // If we have a site description and we're on the home/front page, add the description:
  294. $site_description = get_bloginfo( 'description', 'display' );
  295. if ( $site_description && ( is_home() || is_front_page() ) )
  296. $title .= " $separator " . $site_description;
  297. // Add a page number if necessary:
  298. if ( $paged >= 2 || $page >= 2 )
  299. $title .= " $separator " . sprintf( __( 'Page %s', 'boilerplate' ), max( $paged, $page ) );
  300. // Return the new title to wp_title():
  301. return $title;
  302. }
  303. add_filter( 'wp_title', 'boilerplate_filter_wp_title', 10, 2 );
  304. /**
  305. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  306. *
  307. * To override this in a child theme, remove the filter and optionally add
  308. * your own function tied to the wp_page_menu_args filter hook.
  309. *
  310. * @since Twenty Ten 1.0
  311. */
  312. function boilerplate_page_menu_args( $args ) {
  313. $args['show_home'] = true;
  314. return $args;
  315. }
  316. add_filter( 'wp_page_menu_args', 'boilerplate_page_menu_args' );
  317. /**
  318. * Sets the post excerpt length to 40 characters.
  319. *
  320. * To override this length in a child theme, remove the filter and add your own
  321. * function tied to the excerpt_length filter hook.
  322. *
  323. * @since Twenty Ten 1.0
  324. * @return int
  325. */
  326. function boilerplate_excerpt_length( $length ) {
  327. return 40;
  328. }
  329. add_filter( 'excerpt_length', 'boilerplate_excerpt_length' );
  330. /**
  331. * Returns a "Continue Reading" link for excerpts
  332. *
  333. * @since Twenty Ten 1.0
  334. * @return string "Continue Reading" link
  335. */
  336. function boilerplate_continue_reading_link() {
  337. return ' <a class="read-more" href="'. get_permalink() . '">' . __( 'Read More', 'boilerplate' ) . '</a>';
  338. }
  339. /**
  340. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and boilerplate_continue_reading_link().
  341. *
  342. * To override this in a child theme, remove the filter and add your own
  343. * function tied to the excerpt_more filter hook.
  344. *
  345. * @since Twenty Ten 1.0
  346. * @return string An ellipsis
  347. */
  348. function boilerplate_auto_excerpt_more( $more ) {
  349. return ' &hellip;' . boilerplate_continue_reading_link();
  350. }
  351. add_filter( 'excerpt_more', 'boilerplate_auto_excerpt_more' );
  352. /**
  353. * Adds a pretty "Continue Reading" link to custom post excerpts.
  354. *
  355. * To override this link in a child theme, remove the filter and add your own
  356. * function tied to the get_the_excerpt filter hook.
  357. *
  358. * @since Twenty Ten 1.0
  359. * @return string Excerpt with a pretty "Continue Reading" link
  360. */
  361. function boilerplate_custom_excerpt_more( $output ) {
  362. if ( has_excerpt() && ! is_attachment() ) {
  363. $output .= boilerplate_continue_reading_link();
  364. }
  365. return $output;
  366. }
  367. add_filter( 'get_the_excerpt', 'boilerplate_custom_excerpt_more' );
  368. /**
  369. * Remove inline styles printed when the gallery shortcode is used.
  370. *
  371. * Galleries are styled by the theme in Twenty Ten's style.css.
  372. *
  373. * @since Twenty Ten 1.0
  374. * @return string The gallery style filter, with the styles themselves removed.
  375. */
  376. function boilerplate_remove_gallery_css( $css ) {
  377. return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  378. }
  379. add_filter( 'gallery_style', 'boilerplate_remove_gallery_css' );
  380. if ( ! function_exists( 'boilerplate_comment' ) ) :
  381. /**
  382. * Template for comments and pingbacks.
  383. *
  384. * To override this walker in a child theme without modifying the comments template
  385. * simply create your own boilerplate_comment(), and that function will be used instead.
  386. *
  387. * Used as a callback by wp_list_comments() for displaying the comments.
  388. *
  389. * @since Twenty Ten 1.0
  390. */
  391. function boilerplate_comment( $comment, $args, $depth ) {
  392. $GLOBALS['comment'] = $comment;
  393. switch ( $comment->comment_type ) :
  394. case '' :
  395. ?>
  396. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  397. <article id="comment-<?php comment_ID(); ?>">
  398. <div class="comment-author vcard">
  399. <?php echo get_avatar( $comment, 40 ); ?>
  400. <?php printf( __( '%s <span class="says">says:</span>', 'boilerplate' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  401. </div><!-- .comment-author .vcard -->
  402. <?php if ( $comment->comment_approved == '0' ) : ?>
  403. <em><?php _e( 'Your comment is awaiting moderation.', 'boilerplate' ); ?></em>
  404. <br />
  405. <?php endif; ?>
  406. <footer class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  407. <?php
  408. /* translators: 1: date, 2: time */
  409. printf( __( '%1$s at %2$s', 'boilerplate' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'boilerplate' ), ' ' );
  410. ?>
  411. </footer><!-- .comment-meta .commentmetadata -->
  412. <div class="comment-body"><?php comment_text(); ?></div>
  413. <div class="reply btn btn-small">
  414. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  415. </div><!-- .reply -->
  416. </article><!-- #comment-## -->
  417. <?php
  418. break;
  419. case 'pingback' :
  420. case 'trackback' :
  421. ?>
  422. <li class="post pingback">
  423. <p><?php _e( 'Pingback:', 'boilerplate' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'boilerplate'), ' ' ); ?></p>
  424. <?php
  425. break;
  426. endswitch;
  427. }
  428. endif;
  429. /**
  430. * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  431. *
  432. * To override boilerplate_widgets_init() in a child theme, remove the action hook and add your own
  433. * function tied to the init hook.
  434. *
  435. * @since Twenty Ten 1.0
  436. * @uses register_sidebar
  437. */
  438. function boilerplate_widgets_init() {
  439. // Area 1, located at the top of the sidebar.
  440. register_sidebar( array(
  441. 'name' => __( 'Primary Widget Area', 'boilerplate' ),
  442. 'id' => 'primary-widget-area',
  443. 'description' => __( 'The primary widget area', 'boilerplate' ),
  444. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  445. 'after_widget' => '</li>',
  446. 'before_title' => '<h3 class="widget-title">',
  447. 'after_title' => '</h3>',
  448. ) );
  449. // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
  450. register_sidebar( array(
  451. 'name' => __( 'Secondary Widget Area', 'boilerplate' ),
  452. 'id' => 'secondary-widget-area',
  453. 'description' => __( 'The secondary widget area', 'boilerplate' ),
  454. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  455. 'after_widget' => '</li>',
  456. 'before_title' => '<h3 class="widget-title">',
  457. 'after_title' => '</h3>',
  458. ) );
  459. // Area 3, located in the footer. Empty by default.
  460. register_sidebar( array(
  461. 'name' => __( 'First Footer Widget Area', 'boilerplate' ),
  462. 'id' => 'first-footer-widget-area',
  463. 'description' => __( 'The first footer widget area', 'boilerplate' ),
  464. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  465. 'after_widget' => '</li>',
  466. 'before_title' => '<h3 class="widget-title">',
  467. 'after_title' => '</h3>',
  468. ) );
  469. // Area 4, located in the footer. Empty by default.
  470. register_sidebar( array(
  471. 'name' => __( 'Second Footer Widget Area', 'boilerplate' ),
  472. 'id' => 'second-footer-widget-area',
  473. 'description' => __( 'The second footer widget area', 'boilerplate' ),
  474. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  475. 'after_widget' => '</li>',
  476. 'before_title' => '<h3 class="widget-title">',
  477. 'after_title' => '</h3>',
  478. ) );
  479. // Area 5, located in the footer. Empty by default.
  480. register_sidebar( array(
  481. 'name' => __( 'Third Footer Widget Area', 'boilerplate' ),
  482. 'id' => 'third-footer-widget-area',
  483. 'description' => __( 'The third footer widget area', 'boilerplate' ),
  484. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  485. 'after_widget' => '</li>',
  486. 'before_title' => '<h3 class="widget-title">',
  487. 'after_title' => '</h3>',
  488. ) );
  489. // Area 6, located in the footer. Empty by default.
  490. register_sidebar( array(
  491. 'name' => __( 'Fourth Footer Widget Area', 'boilerplate' ),
  492. 'id' => 'fourth-footer-widget-area',
  493. 'description' => __( 'The fourth footer widget area', 'boilerplate' ),
  494. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  495. 'after_widget' => '</li>',
  496. 'before_title' => '<h3 class="widget-title">',
  497. 'after_title' => '</h3>',
  498. ) );
  499. }
  500. /** Register sidebars by running boilerplate_widgets_init() on the widgets_init hook. */
  501. add_action( 'widgets_init', 'boilerplate_widgets_init' );
  502. /**
  503. * Removes the default styles that are packaged with the Recent Comments widget.
  504. *
  505. * To override this in a child theme, remove the filter and optionally add your own
  506. * function tied to the widgets_init action hook.
  507. *
  508. * @since Twenty Ten 1.0
  509. */
  510. function boilerplate_remove_recent_comments_style() {
  511. global $wp_widget_factory;
  512. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  513. }
  514. add_action( 'widgets_init', 'boilerplate_remove_recent_comments_style' );
  515. if ( ! function_exists( 'boilerplate_posted_on' ) ) :
  516. /**
  517. * Prints HTML with meta information for the current post—date/time and author.
  518. *
  519. * @since Twenty Ten 1.0
  520. */
  521. function boilerplate_posted_on() {
  522. // BP: slight modification to Twenty Ten function, converting single permalink to multi-archival link
  523. // Y = 2012
  524. // F = September
  525. // m = 01–12
  526. // j = 1–31
  527. // d = 01–31
  528. printf( __( '<span class="entry-date icon-calendar-3">%2$s %3$s %4$s</span>', 'boilerplate' ),
  529. // %1$s = container class
  530. 'meta-prep meta-prep-author',
  531. // %2$s = month: /yyyy/mm/
  532. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
  533. home_url() . '/' . get_the_date( 'Y' ) . '/' . get_the_date( 'm' ) . '/',
  534. esc_attr( 'View Archives for ' . get_the_date( 'F' ) . ' ' . get_the_date( 'Y' ) ),
  535. get_the_date( 'F' )
  536. ),
  537. // %3$s = day: /yyyy/mm/dd/
  538. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
  539. home_url() . '/' . get_the_date( 'Y' ) . '/' . get_the_date( 'm' ) . '/' . get_the_date( 'd' ) . '/',
  540. esc_attr( 'View Archives for ' . get_the_date( 'F' ) . ' ' . get_the_date( 'j' ) . ' ' . get_the_date( 'Y' ) ),
  541. get_the_date( 'j' )
  542. ),
  543. // %4$s = year: /yyyy/
  544. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
  545. home_url() . '/' . get_the_date( 'Y' ) . '/',
  546. esc_attr( 'View Archives for ' . get_the_date( 'Y' ) ),
  547. get_the_date( 'Y' )
  548. ),
  549. // %5$s = author vcard
  550. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  551. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  552. sprintf( esc_attr__( 'View all posts by %s', 'boilerplate' ), get_the_author() ),
  553. get_the_author()
  554. )
  555. );
  556. }
  557. endif;
  558. if ( ! function_exists( 'boilerplate_posted_in' ) ) :
  559. /**
  560. * Prints HTML with meta information for the current post (category, tags and permalink).
  561. *
  562. * @since Twenty Ten 1.0
  563. */
  564. function boilerplate_posted_in() {
  565. // Retrieves tag list of current post, separated by commas.
  566. $tag_list = get_the_tag_list( '', ', ' );
  567. if ( $tag_list ) {
  568. $posted_in = __( '<span class="icon-folder-2">%1$s </span> <span class="icon-tags">%2$s</span>. <span class="icon-bookmark-1"><a href="%3$s" title="Permalink to %4$s" rel="bookmark"> permalink</a></span>.', 'boilerplate' );
  569. } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  570. $posted_in = __( '<span class="icon-folder-2">%1$s </span> <span class="icon-bookmark-1"><a href="%3$s" title="Permalink to %4$s" rel="bookmark"> permalink</a></span>.', 'boilerplate' );
  571. } else {
  572. $posted_in = __( '<span class="icon-bookmark-1"><a href="%3$s" title="Permalink to %4$s" rel="bookmark"> permalink</a></span>.', 'boilerplate' );
  573. }
  574. // Prints the string, replacing the placeholders.
  575. printf(
  576. $posted_in,
  577. get_the_category_list( ', ' ),
  578. $tag_list,
  579. get_permalink(),
  580. the_title_attribute( 'echo=0' )
  581. );
  582. }
  583. endif;
  584. /* Begin Boilerplate */
  585. // Add Admin
  586. require_once(TEMPLATEPATH . '/boilerplate-admin/admin-menu.php');
  587. // remove version info from head and feeds (http://digwp.com/2009/07/remove-wordpress-version-number/)
  588. function boilerplate_complete_version_removal() {
  589. return '';
  590. }
  591. add_filter('the_generator', 'boilerplate_complete_version_removal');
  592. /* End Boilerplate */
  593. // change Search Form input type from "text" to "search" and add placeholder text
  594. function boilerplate_search_form ( $form ) {
  595. $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
  596. <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
  597. <input type="search" placeholder="Search for..." value="' . get_search_query() . '" name="s" id="s" />
  598. <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
  599. </div>
  600. </form>';
  601. return $form;
  602. }
  603. add_filter( 'get_search_form', 'boilerplate_search_form' );
  604. // added per WP upload process request
  605. if ( function_exists( 'add_theme_support' ) ) {
  606. add_theme_support( 'post-thumbnails' );
  607. }
  608. // Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu
  609. function add_menuclass($ulclass) {
  610. return preg_replace('/<ul>/', '<ul class="nav">', $ulclass, 1);
  611. }
  612. add_filter('wp_page_menu','add_menuclass');
  613. if (!is_admin()) {
  614. // jQuery (optional loading via Google CDN)
  615. wp_deregister_script('jquery');
  616. wp_register_script('jquery', ('http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js'), false);
  617. wp_enqueue_script('jquery');
  618. // Flexslider JS
  619. wp_register_script('flexslider', '/wp-content/themes/fayre/js/jquery.flexslider.js', null, 2, false);
  620. wp_enqueue_script('flexslider');
  621. // Flexslider CSS
  622. wp_register_style( 'flexslider', '/wp-content/themes/fayre/css/flexslider.css', null, null, null);
  623. wp_enqueue_style('flexslider');
  624. }?>
  625. <?php if ( function_exists( 'ngg_images_results' ) ) ngg_images_results(); ?>