PageRenderTime 91ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/skeleton/functions.php

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