/wp-content/themes/strappress/includes/functions.php
PHP | 480 lines | 317 code | 64 blank | 99 comment | 37 complexity | 414b3ec83070868ddc5c99a6d54d0246 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-3.0, LGPL-2.1
- <?php
- /**
- * Theme's Functions and Definitions
- *
- *
- * @file functions.php
- * @package StrapPress
- * @author Brad Williams
- * @copyright 2011 - 2012 Brag Interactive
- * @license license.txt
- * @version Release: 2.3.0
- * @filesource wp-content/themes/responsive/includes/functions.php
- * @link http://codex.wordpress.org/Theme_Development#Functions_File
- * @since available since Release 1.0
- */
- ?>
- <?php
- /**
- * Fire up the engines boys and girls let's start theme setup.
- */
- add_action('after_setup_theme', 'responsive_setup');
- if (!function_exists('responsive_setup')):
- function responsive_setup() {
- global $content_width;
- /**
- * Global content width.
- */
- if (!isset($content_width))
- $content_width = 550;
- /**
- * Responsive is now available for translations.
- * Add your files into /languages/ directory.
- * @see http://codex.wordpress.org/Function_Reference/load_theme_textdomain
- */
- load_theme_textdomain('responsive', get_template_directory().'/languages');
- $locale = get_locale();
- $locale_file = get_template_directory().'/languages/$locale.php';
- if (is_readable( $locale_file))
- require_once( $locale_file);
-
- /**
- * Add callback for custom TinyMCE editor stylesheets. (editor-style.css)
- * @see http://codex.wordpress.org/Function_Reference/add_editor_style
- */
- add_editor_style();
- /**
- * This feature enables post and comment RSS feed links to head.
- * @see http://codex.wordpress.org/Function_Reference/add_theme_support#Feed_Links
- */
- add_theme_support('automatic-feed-links');
- /**
- * This feature enables post-thumbnail support for a theme.
- * @see http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
- */
- add_theme_support('post-thumbnails');
- add_image_size( 'port-thumb', 250, 200 );
- add_image_size( 'port-full', 600, 400 );
- add_image_size( 'portfolio-two-column', 562, 380, true ); // portfolio column image
- add_image_size( 'portfolio-three-column', 362, 300, true ); // portfolio 3 column image
- add_image_size( 'portfolio-four-column', 262, 200, true ); // portfolio 4 column image
- $options = get_option('responsive_theme_options');
-
- register_nav_menus(array(
- 'footer-menu' => __('Footer Menu', 'responsive')
- )
- );
- }
- endif;
- /**
- * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
- */
- function responsive_page_menu_args( $args ) {
- $args['show_home'] = true;
- return $args;
- }
- add_filter( 'wp_page_menu_args', 'responsive_page_menu_args' );
- /**
- * Remove div from wp_page_menu() and replace with ul.
- */
- function responsive_wp_page_menu ($page_markup) {
- preg_match('/^<div class=\"([a-z0-9-_]+)\">/i', $page_markup, $matches);
- $divclass = $matches[1];
- $replace = array('<div class="'.$divclass.'">', '</div>');
- $new_markup = str_replace($replace, '', $page_markup);
- $new_markup = preg_replace('/^<ul>/i', '<ul class="'.$divclass.'">', $new_markup);
- return $new_markup; }
- add_filter('wp_page_menu', 'responsive_wp_page_menu');
- /**
- * Filter 'get_comments_number'
- *
- * Filter 'get_comments_number' to display correct
- * number of comments (count only comments, not
- * trackbacks/pingbacks)
- *
- * Courtesy of Chip Bennett
- */
- function responsive_comment_count( $count ) {
- if ( ! is_admin() ) {
- global $id;
- $comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
- return count($comments_by_type['comment']);
- } else {
- return $count;
- }
- }
- add_filter('get_comments_number', 'responsive_comment_count', 0);
- /**
- * wp_list_comments() Pings Callback
- *
- * wp_list_comments() Callback function for
- * Pings (Trackbacks/Pingbacks)
- */
- function responsive_comment_list_pings( $comment ) {
- $GLOBALS['comment'] = $comment;
- ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><?php echo comment_author_link(); ?></li>
- <?php }
- /**
- * Sets the post excerpt length to 40 characters.
- * Next few lines are adopted from Coraline
- */
- function responsive_excerpt_length($length) {
- return 40;
- }
- add_filter('excerpt_length', 'responsive_excerpt_length');
- /**
- * Returns a "Read more" link for excerpts
- */
- function responsive_read_more() {
- return ' <a href="' . get_permalink() . '">' . __('<div class="read-more">Read more ›</div><!-- end of .read-more -->', 'responsive') . '</a>';
- }
- /**
- * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and responsive_read_more_link().
- */
- function responsive_auto_excerpt_more($more) {
- return '<span class="ellipsis">…</span>' . responsive_read_more();
- }
- add_filter('excerpt_more', 'responsive_auto_excerpt_more');
- /**
- * Adds a pretty "Read more" link to custom post excerpts.
- */
- function responsive_custom_excerpt_more($output) {
- if (has_excerpt() && !is_attachment()) {
- $output .= responsive_read_more();
- }
- return $output;
- }
- add_filter('get_the_excerpt', 'responsive_custom_excerpt_more');
- /**
- * This function removes inline styles set by WordPress gallery.
- */
- function responsive_remove_gallery_css($css) {
- return preg_replace("#<style type='text/css'>(.*?)</style>#s", '', $css);
- }
- add_filter('gallery_style', 'responsive_remove_gallery_css');
- /**
- * This function removes default styles set by WordPress recent comments widget.
- */
- function responsive_remove_recent_comments_style() {
- global $wp_widget_factory;
- remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
- }
- add_action( 'widgets_init', 'responsive_remove_recent_comments_style' );
- /**
- * Breadcrumb Lists
- * Allows visitors to quickly navigate back to a previous section or the root page.
- *
- * Courtesy of Dimox
- *
- * bbPress compatibility patch by Dan Smith
- */
- function responsive_breadcrumb_lists() {
- $chevron = '<span class="divider">/</span>';
- $name = __('Home','responsive'); //text for the 'Home' link
- $currentBefore = '<li class="current">';
- $currentAfter = '</li>';
- echo '<ul class="breadcrumb">';
- global $post;
- $home = home_url();
- echo '<li><a href="' . $home . '">' . $name . '</a>' . $chevron . '</li>';
- if (is_category()) {
- global $wp_query;
- $cat_obj = $wp_query->get_queried_object();
- $thisCat = $cat_obj->term_id;
- $thisCat = get_category($thisCat);
- $parentCat = get_category($thisCat->parent);
- if ($thisCat->parent != 0)
- echo(get_category_parents($parentCat, TRUE, ' ' . $chevron . ' '));
- echo $currentBefore . 'Archive by category '';
- single_cat_title();
- echo ''' . $currentAfter;
- } elseif (is_day()) {
- echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $chevron . '</li> ';
- echo '<li><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $chevron . '</li> ';
- echo $currentBefore . get_the_time('d') . $currentAfter;
- } elseif (is_month()) {
- echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $chevron . '</li> ';
- echo $currentBefore . get_the_time('F') . $currentAfter;
- } elseif (is_year()) {
- echo $currentBefore . get_the_time('Y') . $currentAfter;
- } elseif (is_single()) {
- $pid = $post->ID;
- $pdata = get_the_category($pid);
- $adata = get_post($pid);
- if(!empty($pdata)){
- echo '<li>' .get_category_parents($pdata[0]->cat_ID, TRUE, ' ' . $chevron . ' '). '</li> ';
- echo $currentBefore;
- }
- echo $adata->post_title;
- echo $currentAfter;
- } elseif (is_page() && !$post->post_parent) {
- echo $currentBefore;
- the_title();
- echo $currentAfter;
- } elseif (is_page() && $post->post_parent) {
- $parent_id = $post->post_parent;
- $breadcrumb_lists = array();
- while ($parent_id) {
- $page = get_page($parent_id);
- $breadcrumb_lists[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>';
- $parent_id = $page->post_parent;
- }
- $breadcrumb_lists = array_reverse($breadcrumb_lists);
- foreach ($breadcrumb_lists as $crumb)
- echo $crumb . ' ' . $chevron . ' ';
- echo $currentBefore;
- the_title();
- echo $currentAfter;
- } elseif (is_search()) {
- echo $currentBefore . __('Search results for '','responsive') . get_search_query() . __(''','responsive') . $currentAfter;
- } elseif (is_tag()) {
- echo $currentBefore . __('Posts tagged '','responsive');
- single_tag_title();
- echo ''' . $currentAfter;
- } elseif (is_author()) {
- global $author;
- $userdata = get_userdata($author);
- echo $currentBefore . __('Articles posted by ','responsive') . $userdata->display_name . $currentAfter;
- } elseif (is_404()) {
- echo $currentBefore . __('Error 404','responsive') . $currentAfter;
- }
- if (get_query_var('paged')) {
- if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
- echo ' (';
- echo __('Page','responsive') . ' ' . get_query_var('paged');
- if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
- echo ')';
- }
- echo '</ul>';
- }
- /**
- * A safe way of adding javascripts to a WordPress generated page.
- */
- if (!is_admin())
- add_action('wp_enqueue_scripts', 'responsive_js');
- if (!function_exists('responsive_js')) {
- function responsive_js() {
- // JS at the bottom for fast page loading.
- // except for Modernizr which enables HTML5 elements & feature detects.
- wp_enqueue_script('modernizr', get_template_directory_uri() . '/js/responsive-modernizr.js', array('jquery'), '2.5.3', false);
- wp_enqueue_script('responsive-scripts', get_template_directory_uri() . '/js/responsive-scripts.js', array('jquery'), '1.1.0', true);
- wp_enqueue_script('responsive-plugins', get_template_directory_uri() . '/js/responsive-plugins.js', array('jquery'), '1.1.0', true);
- wp_enqueue_script('colorbox', get_template_directory_uri() . '/js/jquery.colorbox-min.js', array('jquery'), '1.3.19', true);
- }
- }
- /**
- * A comment reply.
- */
- function responsive_enqueue_comment_reply() {
- if ( is_singular() && comments_open() && get_option('thread_comments')) {
- wp_enqueue_script('comment-reply');
- }
- }
- add_action( 'wp_enqueue_scripts', 'responsive_enqueue_comment_reply' );
-
- /**
- * Where the post has no post title, but must still display a link to the single-page post view.
- */
- add_filter('the_title', 'responsive_title');
- function responsive_title($title) {
- if ($title == '') {
- return __('Untitled','responsive');
- } else {
- return $title;
- }
- }
- /**
- * WordPress Widgets start right here.
- */
- function responsive_widgets_init() {
- register_sidebar(array(
- 'name' => __('Main Sidebar', 'responsive'),
- 'description' => __('Area One - sidebar.php', 'responsive'),
- 'id' => 'main-sidebar',
- 'before_title' => '<div class="widget-title">',
- 'after_title' => '</div>',
- 'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Home Page Right Sidebar', 'responsive'),
- 'description' => __('Area One/2 - sidebar-home-right.php', 'responsive'),
- 'id' => 'sidebar-home-right',
- 'before_title' => '<div class="widget-title">',
- 'after_title' => '</div>',
- 'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Right Sidebar', 'responsive'),
- 'description' => __('Area Two - sidebar-right.php', 'responsive'),
- 'id' => 'right-sidebar',
- 'before_title' => '<div class="widget-title">',
- 'after_title' => '</div>',
- 'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
- 'after_widget' => '</div>'
- ));
-
- register_sidebar(array(
- 'name' => __('Left Sidebar', 'responsive'),
- 'description' => __('Area Three - sidebar-left.php', 'responsive'),
- 'id' => 'left-sidebar',
- 'before_title' => '<div class="widget-title">',
- 'after_title' => '</div>',
- 'before_widget' => '<div id="%1$s" class="widget-wrapper-left %2$s">',
- 'after_widget' => '</div>'
- ));
-
- register_sidebar(array(
- 'name' => __('Left Sidebar Half Page', 'responsive'),
- 'description' => __('Area Four - sidebar-left-half.php', 'responsive'),
- 'id' => 'left-sidebar-half',
- 'before_title' => '<div class="widget-title">',
- 'after_title' => '</div>',
- 'before_widget' => '<div id="%1$s" class="widget-wrapper-left %2$s">',
- 'after_widget' => '</div>'
- ));
-
- register_sidebar(array(
- 'name' => __('Right Sidebar Half Page', 'responsive'),
- 'description' => __('Area Five - sidebar-right-half.php', 'responsive'),
- 'id' => 'right-sidebar-half',
- 'before_title' => '<div class="widget-title">',
- 'after_title' => '</div>',
- 'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Home Widget 1', 'responsive'),
- 'description' => __('Area Six - sidebar-home.php', 'responsive'),
- 'id' => 'home-widget-1',
- 'before_title' => '<div id="widget-title-one" class="widget-title-home"><h3>',
- 'after_title' => '</h3></div>',
- 'before_widget' => '<div id="%1$s" class="%2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Home Widget 2', 'responsive'),
- 'description' => __('Area Seven - sidebar-home.php', 'responsive'),
- 'id' => 'home-widget-2',
- 'before_title' => '<div id="widget-title-two" class="widget-title-home"><h3>',
- 'after_title' => '</h3></div>',
- 'before_widget' => '<div id="%1$s" class="%2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Home Widget 3', 'responsive'),
- 'description' => __('Area Eight - sidebar-home.php', 'responsive'),
- 'id' => 'home-widget-3',
- 'before_title' => '<div id="widget-title-three" class="widget-title-home"><h3>',
- 'after_title' => '</h3></div>',
- 'before_widget' => '<div id="%1$s" class="%2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Home Widget Site Map', 'responsive'),
- 'description' => __('Area Eight - sidebar-home.php', 'responsive'),
- 'id' => 'home-site-map',
- 'before_title' => '<div id="widget-title-three" class="widget-title-home"><h4>',
- 'after_title' => '</h4></div>',
- 'before_widget' => '<div id="%1$s" class="span3 %2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Contact', 'responsive'),
- 'description' => __('Area Nine - contact.php', 'responsive'),
- 'id' => 'contact-widget',
- 'before_title' => '<div id="widget-title-three" class="widget-contact"><h3>',
- 'after_title' => '</h3></div>',
- 'before_widget' => '<div id="%1$s" class="%2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Membership Option Silver', 'responsive'),
- 'description' => __('Area Ten - sidebar-membership.php', 'responsive'),
- 'id' => 'membership-option-silver',
- 'before_title' => '<div id="widget-title-one" class="widget-title-home"><h3>',
- 'after_title' => '</h3></div>',
- 'before_widget' => '<div id="%1$s" class="%2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Membership Option Gold', 'responsive'),
- 'description' => __('Area Eleven - sidebar-membership.php', 'responsive'),
- 'id' => 'membership-option-gold',
- 'before_title' => '<div id="widget-title-one" class="widget-title-home"><h3>',
- 'after_title' => '</h3></div>',
- 'before_widget' => '<div id="%1$s" class="%2$s">',
- 'after_widget' => '</div>'
- ));
- register_sidebar(array(
- 'name' => __('Membership Option Platinum', 'responsive'),
- 'description' => __('Area Twelve - sidebar-membership.php', 'responsive'),
- 'id' => 'membership-option-platinum',
- 'before_title' => '<div id="widget-title-one" class="widget-title-home"><h3>',
- 'after_title' => '</h3></div>',
- 'before_widget' => '<div id="%1$s" class="%2$s">',
- 'after_widget' => '</div>'
- ));
- }
-
- add_action('widgets_init', 'responsive_widgets_init');
- ?>