'', 'default-image' => '', 'wp-head-callback' => '_custom_background_cb', 'admin-head-callback' => '', 'admin-preview-callback' => '' ); add_theme_support('custom-background', $defaults); add_theme_support('automatic-feed-links'); // rss thingy // to add header image support go here: http://themble.com/support/adding-header-background-image-support/ // adding post format support add_theme_support( 'post-formats', // post formats array( 'video', // video ) ); add_theme_support( 'menus' ); // wp menus register_nav_menus( // wp3+ menus array( 'main_nav' => 'The Main Menu', // main nav in header 'footer_links' => 'Footer Links' // secondary nav in footer ) ); } // adding sidebars to Wordpress (these are created in functions.php) add_action( 'widgets_init', 'popster_register_sidebars' ); // adding the bones search form (created in functions.php) add_filter( 'get_search_form', 'popster_wpsearch' ); // removing default styling for gallery style add_filter( 'use_default_gallery_style', '__return_false' ); // Registering main menu function popster_main_nav() { // display the wp3 menu if available wp_nav_menu(array( 'menu' => 'main_nav', /* menu name */ 'theme_location' => 'main_nav', /* where in the theme it's assigned */ 'container_class' => 'col940 clearfix', /* container class */ 'fallback_cb' => 'popster_main_nav_fallback'/*, menu fallback */ ,'depth' => 4 /* maximum depth for the menu */ )); } // Registering menu for footer link function popster_footer_links() { // display the wp3 menu if available wp_nav_menu( array( 'menu' => 'footer_links', /* menu name */ 'theme_location' => 'footer_links', /* where in the theme it's assigned */ 'container_class' => 'footer-links clearfix', /* container class */ 'menu_class' => 'footer-menu', 'fallback_cb' => 'popster_footer_links_fallback', /* menu fallback */ 'depth' => 0 ) ); } // this is the fallback for header menu function popster_main_nav_fallback() { wp_page_menu( 'show_home=Home&menu_class=menu' ); } // this is the fallback for footer menu function popster_footer_links_fallback() { } // remove the p from around imgs (http://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/) add_filter('the_content', 'filter_ptags_on_images'); function filter_ptags_on_images($content){ return preg_replace('/

\s*()?\s*()\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); } /** * Filter TinyMCE Buttons * * Here we are filtering the TinyMCE buttons and adding a button * to it. In this case, we are looking to add a style select * box (button) which is referenced as "styleselect". In this * example we are looking to add the select box to the second * row of the visual editor, as defined by the number 2 in the * mce_buttons_2 hook. */ function themeit_mce_buttons_2( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } add_filter( 'mce_buttons_2', 'themeit_mce_buttons_2' ); /** * Add Style Options * * First we provide available formats for the style format drop down. * This should contain a comma separated list of formats that * will be available in the format drop down list. * * Next, we provide our style options by adding them to an array. * Each option requires at least a "title" value. If only a "title" * is provided, that title will be used as a divider heading in the * styles drop down. This is useful for creating "groups" of options. * * After the title, we set what type of element it is and how it should * be displayed. We can then provide class and style attributes for that * element. The example below shows a variety of options. * * Lastly, we encode the array for use by TinyMCE editor * * {@link http://tinymce.moxiecode.com/examples/example_24.php } */ //add_filter( 'tiny_mce_before_init', 'popster_tiny_mce_before_init' ); function popster_tiny_mce_before_init( $settings ) { $settings['theme_advanced_blockformats'] = 'p,a,div,span,h1,h2,h3,h4,h5,h6,tr,'; $style_formats = array( array( 'title' => 'Two Column', 'block' => 'p', 'classes' => 'one-half' ), array( 'title' => 'Three Column', 'block' => 'p', 'classes' => 'one-third' ), ); $settings['style_formats'] = json_encode( $style_formats ); return $settings; } // Adding an extra css file for used in tiny MCE editor add_action( 'after_setup_theme', 'popster_add_editor_style' ); function popster_add_editor_style() { add_editor_style( 'style-editor.css' ); } add_action('wp_head','popster_sticky_menu_option'); function popster_sticky_menu_option(){ $theme_options = get_theme_mod('popster_options'); if ( isset($theme_options['disable_sticky_menu']) && $theme_options['disable_sticky_menu'] ) { echo ''; }else{ echo ''; } } // Function to exclude categories from recent posts on homepage function popster_exclude_categories( $query ){ $theme_options = get_theme_mod('popster_options'); if ( $query->is_home() && $query->is_main_query() && isset($theme_options['exclude_posts_categories']) && $theme_options['exclude_posts_categories'] ) { //$query->set( 'cat', '-1,-1347' ); $query->query_vars['category__not_in'] = $theme_options['exclude_posts_categories']; } } add_action( 'pre_get_posts', 'popster_exclude_categories' ); /****************** PLUGINS & EXTRA FEATURES **************************/ /* Breadcrumbs function */ function popster_breadcrumb() { if ( !is_front_page() ) { echo '

"; } add_filter( 'the_category', 'popster_add_nofollow_cat' ); function popster_add_nofollow_cat( $text) { $strings = array('rel="category"', 'rel="category tag"', 'rel="whatever may need"'); $text = str_replace('rel="category tag"', "", $text); return $text; } // Show the popular tags ( tags with most posts ), this is shown on the theme under the menu function popster_popular_tags($title){ $tags = get_tags( array( 'orderby' => 'count', 'number'=> 10, 'order'=>'DESC') ); $html = ''; echo $html; } // Related Posts Function (call using popster_related_posts(); ) function popster_related_posts() { global $post; $tags = wp_get_post_tags($post->ID); if($tags) { $tag_arr = ''; foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; } $category = get_the_category($post->ID); $cat_id = $category[0]->cat_ID; $args = array( 'category' => $cat_id, 'numberposts' => 3, /* you can change this to show more */ 'post__not_in' => array($post->ID) ); $related_posts = get_posts($args); if($related_posts) { foreach ($related_posts as $post) : setup_postdata($post); ?>

max_num_pages; /*if ( is_home() ){ $posts_per_page = get_option('posts_per_page'); $total_posts = $wp_query->found_posts; $posts_count_home = ( $theme_options['homepage_recent_posts'] ) ? $theme_options['homepage_recent_posts'] : $posts_per_page; if ( $posts_count_home < $posts_per_page ) $total = ceil (( $total_posts + $posts_per_page - $posts_count_home ) / $posts_per_page ); }*/ if ( $total > 1 ) { if ( !$current_page = get_query_var('paged') ) $current_page = 1; if ( !get_option('permalink_structure' ) ){ $format = '&paged=%#%'; if ( is_home() ) $format = '?paged=%#%'; }else $format = 'page/%#%/'; if ( is_search() ){ $format = '&paged=%#%'; } echo ''; }else{ echo ''; } } // To show the featured posts aka the Slider function popster_featured_posts( $args = 0 ){ global $theme_options; $recent = new WP_Query($args); //$total_post = count( get_posts($args) ); $total_post = $recent->post_count; if ( ! $recent->have_posts() ) return 0; ?> have_posts()) ) return 0; $index_nav = ''; ?>

have_posts()) : $recent->the_post();?>
role="article">

,

' . $i . ''; endwhile;wp_reset_query(); ?>
$value) { $attrs .= " {$attribute}=\"{$value}\""; } $str = ' ' . $str; $str = preg_replace( '`([^"=\'>])((http|https|ftp)://[^\s<]+[^\s<\.)])`i', '$1$2', $str ); $str = substr($str, 1); return $str; } /* * Function relative time * */ function popster_relative_time($time = false, $limit = 86400, $format = 'g:i A M jS') { if (empty($time) || (!is_string($time) && !is_numeric($time))) $time = time(); elseif (is_string($time)) $time = strtotime($time); $now = time(); $relative = ''; if ($time === $now) $relative = __('now', 'popster'); elseif ($time > $now) $relative = __('in the future', 'popster'); else { $diff = $now - $time; /*if ($diff >= $limit) $relative = date($format, $time); else*/if ($diff < 60) { $relative = __('less than one minute ago', 'popster'); } elseif (($minutes = ceil($diff/60)) < 60) { $relative = $minutes.' Minute'.(((int)$minutes === 1) ? '' : 's').' ago'; } elseif ( $diff < (24*60*60) ){ $hours = ceil($diff/3600); $relative = $hours.' Hour'.(((int)$hours === 1) ? '' : 's').' ago'; }elseif ( $diff < (48*60*60) ){ $hours = ceil($diff/3600); $relative = __('1 Day ago', 'popster'); }else{ $relative = ceil($diff / 86400) . ' Days ago'; } } return $relative; } ?>