PageRenderTime 63ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/skeleton_childtheme/functions.php

https://github.com/gellybeans/skeleton_wp
PHP | 896 lines | 472 code | 167 blank | 257 comment | 69 complexity | 8c32b9d5ca37d551e32b2df452ab1c91 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. * Skeleton theme functions and definitions
  4. *
  5. * This theme is largely based on skeleton with some significant modifications
  6. * mainly to template files, but adds additional helper functions to the layout in general.
  7. * Other functions are attached to action and filter hooks in WordPress to change core functionality.
  8. *
  9. * Layout Functions:
  10. *
  11. * st_header // Opening header tag and logo/header text
  12. * st_header_extras // Additional content may be added to the header
  13. * st_navbar // Opening navigation element and WP3 menus
  14. * st_before_content // Opening content wrapper
  15. * st_after_content // Closing content wrapper
  16. * st_before_sidebar // Opening sidebar wrapper
  17. * st_after_sidebar // Closing sidebar wrapper
  18. * st_before_footer // Opening footer wrapper
  19. * st_footer // The footer (includes sidebar-footer.php)
  20. * st_after_footer // The closing footer wrapper
  21. *
  22. * Sets up the theme and provides some helper functions. Some helper functions
  23. * are used in the theme as custom template tags. Others are attached to action and
  24. * filter hooks in WordPress to change core functionality.
  25. *
  26. * The first function, skeleton_setup(), sets up the theme by registering support
  27. * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  28. *
  29. * When using a child theme (see http://codex.wordpress.org/Theme_Development and
  30. * http://codex.wordpress.org/Child_Themes), you can override certain functions
  31. * (those wrapped in a function_exists() call) by defining them first in your child theme's
  32. * functions.php file. The child theme's functions.php file is included before the parent
  33. * theme's file, so the child theme functions would be used.
  34. *
  35. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  36. * to a filter or action hook. The hook can be removed by using remove_action() or
  37. * remove_filter() and you can attach your own function to the hook.
  38. *
  39. * We can remove the parent theme's hook only after it is attached, which means we need to
  40. * wait until setting up the child theme:
  41. *
  42. * <code>
  43. * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  44. * function my_child_theme_setup() {
  45. * // We are providing our own filter for excerpt_length (or using the unfiltered value)
  46. * remove_filter( 'excerpt_length', 'skeleton_excerpt_length' );
  47. * ...
  48. * }
  49. * </code>
  50. *
  51. * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  52. *
  53. * @package WordPress
  54. * @subpackage skeleton
  55. * @since skeleton 0.1
  56. */
  57. /*-----------------------------------------------------------------------------------*/
  58. /* Set Proper Parent/Child theme paths for inclusion
  59. /*-----------------------------------------------------------------------------------*/
  60. @define( 'PARENT_DIR', get_template_directory() );
  61. @define( 'CHILD_DIR', get_stylesheet_directory() );
  62. @define( 'PARENT_URL', get_template_directory_uri() );
  63. @define( 'CHILD_URL', get_stylesheet_directory_uri() );
  64. /*-----------------------------------------------------------------------------------*/
  65. /* Initialize the Options Framework
  66. /* http://wptheming.com/options-framework-theme/
  67. /*-----------------------------------------------------------------------------------*/
  68. if ( !function_exists( 'optionsframework_init' ) ) {
  69. define('OPTIONS_FRAMEWORK_URL', PARENT_URL . '/admin/');
  70. define('OPTIONS_FRAMEWORK_DIRECTORY', PARENT_DIR . '/admin/');
  71. require_once (OPTIONS_FRAMEWORK_DIRECTORY . 'options-framework.php');
  72. }
  73. if ( class_exists( 'jigoshop' ) ) {
  74. require_once (PARENT_DIR . '/jigoshop_functions.php');
  75. }
  76. if ( class_exists( 'bbPress' ) ) {
  77. require_once (PARENT_DIR . '/bbpress_functions.php');
  78. }
  79. require_once (PARENT_DIR . '/shortcodes.php');
  80. /*
  81. * This is an example of how to add custom scripts to the options panel.
  82. * This one shows/hides the an option when a checkbox is clicked.
  83. */
  84. add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts');
  85. if (!function_exists('optionsframework_custom_scripts')) {
  86. function optionsframework_custom_scripts() { ?>
  87. <script type="text/javascript">
  88. jQuery(document).ready(function() {
  89. jQuery('#use_logo_image').click(function() {
  90. jQuery('#section-header_logo,#section-logo_width,#section-logo_height').fadeToggle(400);
  91. });
  92. if (jQuery('#use_logo_image:checked').val() !== undefined) {
  93. jQuery('#section-header_logo,#section-logo_width,#section-logo_height').show();
  94. }
  95. });
  96. </script>
  97. <?php
  98. }
  99. }
  100. // Register Core Stylesheets
  101. // These are necessary for the theme to function as intended
  102. // Supports the 'Better WordPress Minify' plugin to properly minimize styleshsets into one.
  103. // http://wordpress.org/extend/plugins/bwp-minify/
  104. if ( !function_exists( 'st_registerstyles' ) ) {
  105. add_action('get_header', 'st_registerstyles');
  106. function st_registerstyles() {
  107. $theme = wp_get_theme();
  108. $version = $theme['Version'];
  109. $stylesheets = wp_enqueue_style('skeleton', get_bloginfo('template_directory').'/skeleton.css', false, $version, 'screen, projection');
  110. $stylesheets .= wp_enqueue_style('theme', get_bloginfo('stylesheet_directory').'/style.css', 'skeleton', $version, 'screen, projection');
  111. $stylesheets .= wp_enqueue_style('layout', get_bloginfo('template_directory').'/layout.css', 'theme', $version, 'screen, projection');
  112. $stylesheets .= wp_enqueue_style('formalize', get_bloginfo('template_directory').'/formalize.css', 'theme', $version, 'screen, projection');
  113. $stylesheets .= wp_enqueue_style('superfish', get_bloginfo('template_directory').'/superfish.css', 'theme', $version, 'screen, projection');
  114. if ( class_exists( 'jigoshop' ) ) {
  115. $stylesheets .= wp_enqueue_style('jigoshop', get_bloginfo('template_directory').'/jigoshop.css', 'theme', $version, 'screen, projection');
  116. }
  117. echo apply_filters ('child_add_stylesheets',$stylesheets);
  118. }
  119. }
  120. // Build Query vars for dynamic theme option CSS from Options Framework
  121. if ( !function_exists( 'production_stylesheet' )) {
  122. function production_stylesheet($public_query_vars) {
  123. $public_query_vars[] = 'get_styles';
  124. return $public_query_vars;
  125. }
  126. add_filter('query_vars', 'production_stylesheet');
  127. }
  128. if ( !function_exists( 'theme_css' ) ) {
  129. add_action('template_redirect', 'theme_css');
  130. function theme_css(){
  131. $css = get_query_var('get_styles');
  132. if ($css == 'css'){
  133. include_once (PARENT_DIR . '/style.php');
  134. exit; //This stops WP from loading any further
  135. }
  136. }
  137. }
  138. if ( !function_exists( 'st_header_scripts' ) ) {
  139. add_action('init', 'st_header_scripts');
  140. function st_header_scripts() {
  141. $javascripts = wp_enqueue_script('jquery');
  142. $javascripts .= wp_enqueue_script('custom',get_bloginfo('template_url') ."/javascripts/app.js",array('jquery'),'1.2.3',true);
  143. $javascripts .= wp_enqueue_script('superfish',get_bloginfo('template_url') ."/javascripts/superfish.js",array('jquery'),'1.2.3',true);
  144. $javascripts .= wp_enqueue_script('formalize',get_bloginfo('template_url') ."/javascripts/jquery.formalize.min.js",array('jquery'),'1.2.3',true);
  145. echo apply_filters ('child_add_javascripts',$javascripts);
  146. }
  147. }
  148. /** Tell WordPress to run skeleton_setup() when the 'after_setup_theme' hook is run. */
  149. add_action( 'after_setup_theme', 'skeleton_setup' );
  150. if ( ! function_exists( 'skeleton_setup' ) ):
  151. /**
  152. * Sets up theme defaults and registers support for various WordPress features.
  153. *
  154. * Note that this function is hooked into the after_setup_theme hook, which runs
  155. * before the init hook. The init hook is too late for some features, such as indicating
  156. * support post thumbnails.
  157. *
  158. * To override skeleton_setup() in a child theme, add your own skeleton_setup to your child theme's
  159. * functions.php file.
  160. *
  161. * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
  162. * @uses register_nav_menus() To add support for navigation menus.
  163. * @uses add_editor_style() To style the visual editor.
  164. * @uses load_theme_textdomain() For translation/localization support.
  165. * @uses add_custom_image_header() To add support for a custom header.
  166. * @uses register_default_headers() To register the default custom header images provided with the theme.
  167. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  168. *
  169. * @since Skeleton 1.0
  170. */
  171. function skeleton_setup() {
  172. if ( class_exists( 'bbPress' ) ) {
  173. add_theme_support( 'bbpress' );
  174. }
  175. // This theme styles the visual editor with editor-style.css to match the theme style.
  176. add_editor_style();
  177. // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
  178. // add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
  179. // This theme uses post thumbnails
  180. add_theme_support( 'post-thumbnails' );
  181. // Add default posts and comments RSS feed links to head
  182. add_theme_support( 'automatic-feed-links' );
  183. // Register the available menus
  184. register_nav_menus( array(
  185. 'primary' => __( 'Primary Navigation', 'skeleton' ),
  186. ));
  187. // Make theme available for translation
  188. // Translations can be filed in the /languages/ directory
  189. load_theme_textdomain( 'smpl', PARENT_DIR . '/languages' );
  190. $locale = get_locale();
  191. $locale_file = PARENT_DIR . "/languages/$locale.php";
  192. if ( is_readable( $locale_file ) )
  193. require_once( $locale_file );
  194. // No support for text inside the header image.
  195. if ( ! defined( 'NO_HEADER_TEXT' ) )
  196. define( 'NO_HEADER_TEXT', true );
  197. if ( ! defined( 'HEADER_IMAGE_WIDTH') )
  198. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'skeleton_header_image_width',960));
  199. if ( ! defined( 'HEADER_IMAGE_HEIGHT') )
  200. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'skeleton_header_image_height',185 ));
  201. // Add a way for the custom header to be styled in the admin panel that controls
  202. // custom headers. See skeleton_admin_header_style(), below.
  203. add_custom_image_header( '', 'skeleton_admin_header_style' );
  204. // ... and thus ends the changeable header business.
  205. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
  206. register_default_headers( array(
  207. 'berries' => array(
  208. 'url' => '%s/images/headers/berries.jpg',
  209. 'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
  210. /* translators: header image description */
  211. 'description' => __( 'Berries', 'skeleton' )
  212. ),
  213. 'cherryblossom' => array(
  214. 'url' => '%s/images/headers/cherryblossoms.jpg',
  215. 'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
  216. /* translators: header image description */
  217. 'description' => __( 'Cherry Blossoms', 'skeleton' )
  218. ),
  219. 'concave' => array(
  220. 'url' => '%s/images/headers/concave.jpg',
  221. 'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
  222. /* translators: header image description */
  223. 'description' => __( 'Concave', 'skeleton' )
  224. ),
  225. 'fern' => array(
  226. 'url' => '%s/images/headers/fern.jpg',
  227. 'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
  228. /* translators: header image description */
  229. 'description' => __( 'Fern', 'skeleton' )
  230. ),
  231. 'forestfloor' => array(
  232. 'url' => '%s/images/headers/forestfloor.jpg',
  233. 'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
  234. /* translators: header image description */
  235. 'description' => __( 'Forest Floor', 'skeleton' )
  236. ),
  237. 'inkwell' => array(
  238. 'url' => '%s/images/headers/inkwell.jpg',
  239. 'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
  240. /* translators: header image description */
  241. 'description' => __( 'Inkwell', 'skeleton' )
  242. ),
  243. 'path' => array(
  244. 'url' => '%s/images/headers/path.jpg',
  245. 'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
  246. /* translators: header image description */
  247. 'description' => __( 'Path', 'skeleton' )
  248. ),
  249. 'sunset' => array(
  250. 'url' => '%s/images/headers/sunset.jpg',
  251. 'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
  252. /* translators: header image description */
  253. 'description' => __( 'Sunset', 'skeleton' )
  254. )
  255. ) );
  256. }
  257. endif;
  258. /**
  259. * Styles the header image displayed on the Appearance > Header admin panel.
  260. *
  261. * Referenced via add_custom_image_header() in skeleton_setup().
  262. *
  263. * @since Skeleton 1.0
  264. */
  265. if ( !function_exists( 'skeleton_admin_header_style' ) ) :
  266. function skeleton_admin_header_style() {
  267. ?>
  268. <style type="text/css">
  269. /* Shows the same border as on front end */
  270. #headimg {
  271. border-bottom: 100px solid #000;
  272. border-top: 4px solid #000;
  273. }
  274. /* If NO_HEADER_TEXT is false, you would style the text with these selectors:
  275. #headimg #name { }
  276. #headimg #desc { }
  277. */
  278. </style>
  279. <?php
  280. }
  281. endif;
  282. /**
  283. * Sets the post excerpt length to 40 characters.
  284. *
  285. * To override this length in a child theme, remove the filter and add your own
  286. * function tied to the excerpt_length filter hook.
  287. *
  288. * @since Skeleton 1.0
  289. * @return int
  290. */
  291. if ( !function_exists( 'skeleton_excerpt_length' ) ) {
  292. function skeleton_excerpt_length( $length ) {
  293. return 40;
  294. }
  295. add_filter( 'excerpt_length', 'skeleton_excerpt_length' );
  296. }
  297. /**
  298. * Returns a "Continue Reading" link for excerpts
  299. *
  300. * @since Skeleton 1.0
  301. * @return string "Continue Reading" link
  302. */
  303. if ( !function_exists( 'skeleton_continue_reading_link' ) ) {
  304. function skeleton_continue_reading_link() {
  305. return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'skeleton' ) . '</a>';
  306. }
  307. }
  308. /**
  309. * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and skeleton_continue_reading_link().
  310. *
  311. * To override this in a child theme, remove the filter and add your own
  312. * function tied to the excerpt_more filter hook.
  313. *
  314. * @since Skeleton 1.0
  315. * @return string An ellipsis
  316. */
  317. if ( !function_exists( 'skeleton_auto_excerpt_more' ) ) {
  318. function skeleton_auto_excerpt_more( $more ) {
  319. return ' &hellip;' . skeleton_continue_reading_link();
  320. }
  321. add_filter( 'excerpt_more', 'skeleton_auto_excerpt_more' );
  322. }
  323. /**
  324. * Adds a pretty "Continue Reading" link to custom post excerpts.
  325. *
  326. * To override this link in a child theme, remove the filter and add your own
  327. * function tied to the get_the_excerpt filter hook.
  328. *
  329. * @since Skeleton 1.0
  330. * @return string Excerpt with a pretty "Continue Reading" link
  331. */
  332. if ( !function_exists( 'skeleton_custom_excerpt_more' ) ) {
  333. function skeleton_custom_excerpt_more( $output ) {
  334. if ( has_excerpt() && ! is_attachment() ) {
  335. $output .= skeleton_continue_reading_link();
  336. }
  337. return $output;
  338. }
  339. add_filter( 'get_the_excerpt', 'skeleton_custom_excerpt_more' );
  340. }
  341. /**
  342. * Removes inline styles printed when the gallery shortcode is used.
  343. *
  344. * Galleries are styled by the theme in Skeleton's style.css. This is just
  345. * a simple filter call that tells WordPress to not use the default styles.
  346. *
  347. * @since Skeleton 1.2
  348. */
  349. add_filter( 'use_default_gallery_style', '__return_false' );
  350. /**
  351. * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  352. *
  353. * To override st_widgets_init() in a child theme, remove the action hook and add your own
  354. * function tied to the init hook.
  355. *
  356. * @uses register_sidebar
  357. */
  358. //
  359. if ( !function_exists( 'remove_more_jump_link' ) ) {
  360. function remove_more_jump_link($link) {
  361. $offset = strpos($link, '#more-');
  362. if ($offset) {
  363. $end = strpos($link, '"',$offset);
  364. }
  365. if ($end) {
  366. $link = substr_replace($link, '', $offset, $end-$offset);
  367. }
  368. return $link;
  369. }
  370. add_filter('the_content_more_link', 'remove_more_jump_link');
  371. }
  372. if ( !function_exists( 'st_widgets_init' ) ) {
  373. function st_widgets_init() {
  374. // Area 1, located at the top of the sidebar.
  375. register_sidebar( array(
  376. 'name' => __( 'Posts Widget Area', 'skeleton' ),
  377. 'id' => 'primary-widget-area',
  378. 'description' => __( 'Shown only in Blog Posts, Archives, Categories, etc.', 'skeleton' ),
  379. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  380. 'after_widget' => '</li>',
  381. 'before_title' => '<h3 class="widget-title">',
  382. 'after_title' => '</h3>',
  383. ) );
  384. // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
  385. register_sidebar( array(
  386. 'name' => __( 'Pages Widget Area', 'skeleton' ),
  387. 'id' => 'secondary-widget-area',
  388. 'description' => __( 'Shown only in Pages', 'skeleton' ),
  389. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  390. 'after_widget' => '</li>',
  391. 'before_title' => '<h3 class="widget-title">',
  392. 'after_title' => '</h3>',
  393. ) );
  394. // Area 3, located in the footer. Empty by default.
  395. register_sidebar( array(
  396. 'name' => __( 'First Footer Widget Area', 'skeleton' ),
  397. 'id' => 'first-footer-widget-area',
  398. 'description' => __( 'The first footer widget area', 'skeleton' ),
  399. 'before_widget' => '<div class="%1$s">',
  400. 'after_widget' => '</div>',
  401. 'before_title' => '<h3 class="widget-title">',
  402. 'after_title' => '</h3>',
  403. ) );
  404. // Area 4, located in the footer. Empty by default.
  405. register_sidebar( array(
  406. 'name' => __( 'Second Footer Widget Area', 'skeleton' ),
  407. 'id' => 'second-footer-widget-area',
  408. 'description' => __( 'The second footer widget area', 'skeleton' ),
  409. 'before_widget' => '<div class="%1$s">',
  410. 'after_widget' => '</div>',
  411. 'before_title' => '<h3 class="widget-title">',
  412. 'after_title' => '</h3>',
  413. ) );
  414. // Area 5, located in the footer. Empty by default.
  415. register_sidebar( array(
  416. 'name' => __( 'Third Footer Widget Area', 'skeleton' ),
  417. 'id' => 'third-footer-widget-area',
  418. 'description' => __( 'The third footer widget area', 'skeleton' ),
  419. 'before_widget' => '<div class="%1$s">',
  420. 'after_widget' => '</div>',
  421. 'before_title' => '<h3 class="widget-title">',
  422. 'after_title' => '</h3>',
  423. ) );
  424. // Area 6, located in the footer. Empty by default.
  425. register_sidebar( array(
  426. 'name' => __( 'Fourth Footer Widget Area', 'skeleton' ),
  427. 'id' => 'fourth-footer-widget-area',
  428. 'description' => __( 'The fourth footer widget area', 'skeleton' ),
  429. 'before_widget' => '<div class="%1$s">',
  430. 'after_widget' => '</div>',
  431. 'before_title' => '<h3 class="widget-title">',
  432. 'after_title' => '</h3>',
  433. ) );
  434. // Register bbPress sidebar if plugin is installed
  435. if ( class_exists( 'bbPress' ) ) {
  436. register_sidebar( array(
  437. 'name' => __( 'Forum Sidebar', 'skeleton' ),
  438. 'id' => 'bbpress-widget-area',
  439. 'description' => __( 'Sidebar displayed in forum', 'skeleton' ),
  440. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  441. 'after_widget' => '</li>',
  442. 'before_title' => '<h3 class="widget-title">',
  443. 'after_title' => '</h3>',
  444. ) );
  445. }
  446. // Register Jigoshop Cart sidebar if plugin is installed
  447. if ( class_exists( 'jigoshop' ) ) {
  448. register_sidebar( array(
  449. 'name' => __( 'Jigoshop Sidebar', 'skeleton' ),
  450. 'id' => 'shop-widget-area',
  451. 'description' => __( 'Sidebar displayed in Jigoshop pages', 'skeleton' ),
  452. 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  453. 'after_widget' => '</li>',
  454. 'before_title' => '<h3 class="widget-title">',
  455. 'after_title' => '</h3>',
  456. ) );
  457. }
  458. }
  459. /** Register sidebars by running skeleton_widgets_init() on the widgets_init hook. */
  460. add_action( 'widgets_init', 'st_widgets_init' );
  461. }
  462. /** Comment Styles */
  463. if ( ! function_exists( 'st_comments' ) ) :
  464. function st_comments($comment, $args, $depth) {
  465. $GLOBALS['comment'] = $comment; ?>
  466. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  467. <div id="comment-<?php comment_ID(); ?>" class="single-comment clearfix">
  468. <div class="comment-author vcard"> <?php echo get_avatar($comment,$size='64',$default='<path_to_url>' ); ?></div>
  469. <div class="comment-meta commentmetadata">
  470. <?php if ($comment->comment_approved == '0') : ?>
  471. <em><?php _e('Comment is awaiting moderation','smpl');?></em> <br />
  472. <?php endif; ?>
  473. <h6><?php echo __('By','smpl').' '.get_comment_author_link(). ' '. get_comment_date(). ' - ' . get_comment_time(); ?></h6>
  474. <?php comment_text() ?>
  475. <?php edit_comment_link(__('Edit comment','smpl'),' ',''); ?>
  476. <?php comment_reply_link(array_merge( $args, array('reply_text' => __('Reply','smpl'),'depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
  477. </div>
  478. </div>
  479. <!-- </li> -->
  480. <?php }
  481. endif;
  482. if ( ! function_exists( 'skeleton_posted_on' ) ) :
  483. /**
  484. * Prints HTML with meta information for the current post-date/time and author.
  485. *
  486. * @since Skeleton 1.0
  487. */
  488. function skeleton_posted_on() {
  489. printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'skeleton' ),
  490. 'meta-prep meta-prep-author',
  491. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
  492. get_permalink(),
  493. esc_attr( get_the_time() ),
  494. get_the_date()
  495. ),
  496. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  497. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  498. sprintf( esc_attr__( 'View all posts by %s', 'skeleton' ), get_the_author() ),
  499. get_the_author()
  500. )
  501. );
  502. }
  503. endif;
  504. if ( ! function_exists( 'skeleton_posted_in' ) ) :
  505. /**
  506. * Prints HTML with meta information for the current post (category, tags and permalink).
  507. *
  508. * @since Skeleton 1.0
  509. */
  510. function skeleton_posted_in() {
  511. // Retrieves tag list of current post, separated by commas.
  512. $tag_list = get_the_tag_list( '', ', ' );
  513. if ( $tag_list ) {
  514. $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>.', 'skeleton' );
  515. } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  516. $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'skeleton' );
  517. } else {
  518. $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'skeleton' );
  519. }
  520. // Prints the string, replacing the placeholders.
  521. printf(
  522. $posted_in,
  523. get_the_category_list( ', ' ),
  524. $tag_list,
  525. get_permalink(),
  526. the_title_attribute( 'echo=0' )
  527. );
  528. }
  529. endif;
  530. // Header Functions
  531. // Hook to add content before header
  532. if ( !function_exists( 'st_above_header' ) ) {
  533. function st_above_header() {
  534. do_action('st_above_header');
  535. }
  536. } // endif
  537. // Primary Header Function
  538. if ( !function_exists( 'st_header' ) ) {
  539. function st_header() {
  540. do_action('st_header');
  541. }
  542. }
  543. // Opening #header div with flexible grid
  544. if ( !function_exists( 'st_header_open' ) ) {
  545. function st_header_open() {
  546. echo "<div id=\"header\" class=\"sixteen columns\">\n<div class=\"inner\">\n";
  547. }
  548. } // endif
  549. add_action('st_header','st_header_open', 1);
  550. // Hookable theme option field to add add'l content to header
  551. // Child Theme Override: child_header_extras();
  552. if ( !function_exists( 'st_header_extras' ) ) {
  553. function st_header_extras() {
  554. if (of_get_option('header_extra')) {
  555. $extras = "<div class=\"header_extras\">";
  556. $extras .= of_get_option('header_extra');
  557. $extras .= "</div>";
  558. echo apply_filters ('child_header_extras',$extras);
  559. }
  560. }
  561. } // endif
  562. add_action('st_header','st_header_extras', 2);
  563. // Build the logo
  564. // Child Theme Override: child_logo();
  565. if ( !function_exists( 'st_logo' ) ) {
  566. function st_logo() {
  567. // Displays H1 or DIV based on whether we are on the home page or not (SEO)
  568. $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div';
  569. if (of_get_option('use_logo_image')) {
  570. $class="graphic";
  571. } else {
  572. $class="text";
  573. }
  574. // echo of_get_option('header_logo')
  575. $st_logo = '<'.$heading_tag.' id="site-title" class="'.$class.'"><a href="'.esc_url( home_url( '/' ) ).'" title="'.esc_attr( get_bloginfo('name','display')).'">'.get_bloginfo('name').'</a></'.$heading_tag.'>'. "\n";
  576. $st_logo .= '<span class="site-desc '.$class.'">'.get_bloginfo('description').'</span>'. "\n";
  577. echo apply_filters ( 'child_logo' , $st_logo);
  578. }
  579. } // endif
  580. add_action('st_header','st_logo', 3);
  581. if ( !function_exists( 'logostyle' ) ) {
  582. function logostyle() {
  583. if (of_get_option('use_logo_image')) {
  584. echo '<style type="text/css">
  585. #header #site-title.graphic a {background-image: url('.of_get_option('header_logo').');width: '.of_get_option('logo_width').'px;height: '.of_get_option('logo_height').'px;}</style>';
  586. }
  587. }
  588. } //endif
  589. add_action('wp_head', 'logostyle');
  590. if ( !function_exists( 'st_header_close' ) ) {
  591. function st_header_close() {
  592. echo "</div></div><!--/#header-->";
  593. }
  594. } //endif
  595. add_action('st_header','st_header_close', 4);
  596. // Hook to add content after header
  597. if ( !function_exists( 'st_below_header' ) ) {
  598. function st_below_header() {
  599. do_action('st_below_header');
  600. }
  601. } //endif
  602. // End Header Functions
  603. // Navigation (menu)
  604. if ( !function_exists( 'st_navbar' ) ) {
  605. function st_navbar() {
  606. echo '<div id="navigation" class="row sixteen columns">';
  607. wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary'));
  608. echo '</div><!--/#navigation-->';
  609. }
  610. } //endif
  611. // Before Content - st_before_content($columns);
  612. // Child Theme Override: child_before_content();
  613. if ( !function_exists( 'st_before_content' ) ) {
  614. function st_before_content($columns) {
  615. //
  616. // Specify the number of columns in conditional statements
  617. // See http://codex.wordpress.org/Conditional_Tags for a full list
  618. //
  619. // If necessary, you can pass $columns as a variable in your template files:
  620. // st_before_content('six');
  621. //
  622. // Set the default
  623. if (empty($columns)) {
  624. $columns = 'eleven';
  625. } else {
  626. // Check the function for a returned variable
  627. $columns = $columns;
  628. }
  629. // Example of further conditionals:
  630. // (be sure to add the excess of 16 to st_before_sidebar as well)
  631. if (is_page_template('onecolumn-page.php')) {
  632. $columns = 'sixteen';
  633. }
  634. // check to see if bbpress is installed
  635. if ( class_exists( 'bbPress' ) ) {
  636. // force wide on bbPress pages
  637. if (is_bbpress()) {
  638. $columns = 'sixteen';
  639. }
  640. // unless it's the member profile
  641. if (bbp_is_user_home()) {
  642. $columns = 'eleven';
  643. }
  644. } // bbPress
  645. // Apply the markup
  646. echo "<a name=\"top\" id=\"top\"></a>";
  647. echo "<div id=\"content\" class=\"$columns columns\">";
  648. }
  649. }
  650. // After Content
  651. if (! function_exists('st_after_content')) {
  652. function st_after_content() {
  653. echo "\t\t</div><!-- /.columns (#content) -->\n";
  654. }
  655. }
  656. // Before Sidebar - do_action('st_before_sidebar')
  657. // call up the action
  658. if ( !function_exists( 'before_sidebar' ) ) {
  659. function before_sidebar($columns) {
  660. // You can specify the number of columns in conditional statements
  661. // See http://codex.wordpress.org/Conditional_Tags for a full list
  662. //
  663. // If necessary, you can also pass $columns as a variable in your template files:
  664. // do_action('st_before_sidebar','six');
  665. //
  666. if (empty($columns)) {
  667. // Set the default
  668. $columns = 'five';
  669. } else {
  670. // Check the function for a returned variable
  671. $columns = $columns;
  672. }
  673. // Example of further conditionals:
  674. // (be sure to add the excess of 16 to st_before_content as well)
  675. // if (is_page() || is_single()) {
  676. // $columns = 'five';
  677. // } else {
  678. // $columns = 'four';
  679. // }
  680. // Apply the markup
  681. echo '<div id="sidebar" class="'.$columns.' columns" role="complementary">';
  682. }
  683. } //endif
  684. // create our hook
  685. add_action( 'st_before_sidebar', 'before_sidebar');
  686. // After Sidebar
  687. if ( !function_exists( 'after_sidebar' ) ) {
  688. function after_sidebar() {
  689. // Additional Content could be added here
  690. echo '</div><!-- #sidebar -->';
  691. }
  692. } //endif
  693. add_action( 'st_after_sidebar', 'after_sidebar');
  694. // Before Footer
  695. if (!function_exists('st_before_footer')) {
  696. function st_before_footer() {
  697. $footerwidgets = is_active_sidebar('first-footer-widget-area') + is_active_sidebar('second-footer-widget-area') + is_active_sidebar('third-footer-widget-area') + is_active_sidebar('fourth-footer-widget-area');
  698. $class = ($footerwidgets == '0' ? 'noborder' : 'normal');
  699. echo '<div class="clear"></div><div id="footer" class="'.$class.' sixteen columns">';
  700. }
  701. }
  702. if ( !function_exists( 'st_footer' ) ) {
  703. // The Footer
  704. add_action('wp_footer', 'st_footer');
  705. do_action('st_footer');
  706. function st_footer() {
  707. //loads sidebar-footer.php
  708. get_sidebar( 'footer' );
  709. // prints site credits
  710. echo '<div id="credits">';
  711. echo of_get_option('footer_text');
  712. echo '<br /><a class="themeauthor" href="http://www.simplethemes.com" title="Simple WordPress Themes">WordPress Themes</a></div>';
  713. }
  714. }
  715. // After Footer
  716. if (!function_exists('st_after_footer')) {
  717. function st_after_footer() {
  718. echo "</div><!--/#footer-->"."\n";
  719. echo "</div><!--/#wrap.container-->"."\n";
  720. // Google Analytics
  721. if (of_get_option('footer_scripts') <> "" ) {
  722. echo '<script type="text/javascript">'.stripslashes(of_get_option('footer_scripts')).'</script>';
  723. }
  724. }
  725. }
  726. // Enable Shortcodes in excerpts and widgets
  727. add_filter('widget_text', 'do_shortcode');
  728. add_filter( 'the_excerpt', 'do_shortcode');
  729. add_filter('get_the_excerpt', 'do_shortcode');