. * Author Contact: info@backmybook.com * Free Wordpress Theme for Authors URL: http://backmybook.com/free-wordpress-theme-authors * * * @package WordPress * @subpackage Back_My_Book * @since Back My Book 1.0 */ // ========= START LOADING SETTINGS AND CLASSES ========= /** Tell WordPress to run backmybook_setup() when the 'after_setup_theme' hook is run. */ add_action( 'after_setup_theme', 'backmybook_setup' ); define('WP_VERSION', $wp_version); if ( ! function_exists( 'backmybook_setup' ) ): /** * Sets up theme defaults and registers support for various WordPress features. * * @uses add_theme_support() To add support for post thumbnails and automatic feed links. * @uses register_nav_menus() To add support for navigation menus. * @uses set_post_thumbnail_size() To set a custom post thumbnail size. * * @since Back My Book 1.0 */ function backmybook_setup() { // Checks to see if WordPress installation is compatible with theme if (WP_VERSION < 3.0): // disable theme front end if wp < 3.0 function bmb_unsupported_wp_version(){ ?>

Wordpress 3.0'); if (current_user_can('switch_themes') && !is_admin()) echo '
'.__("(Dashboard)","back_my_book").''; ?>

__( 'Primary Navigation', 'backmybook' ), 'footer' => __( 'Footer Navigation', 'backmybook' ) ) ); // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( array( 'default' => array( 'url' => '%s/images/headers/path.png', 'thumbnail_url' => '%s/images/headers/path-thumbnail.png', /* translators: header image description */ 'description' => __( 'Default', 'backmybook' ) ), 'black' => array( 'url' => '%s/images/headers/black.jpg', 'thumbnail_url' => '%s/images/headers/black-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Black', 'backmybook' ) ), 'tile' => array( 'url' => '%s/images/headers/tile.gif', 'thumbnail_url' => '%s/images/headers/tile-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Tile', 'backmybook' ) ), 'books' => array( 'url' => '%s/images/headers/books.jpg', 'thumbnail_url' => '%s/images/headers/books-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Books', 'backmybook' ) ), 'dots' => array( 'url' => '%s/images/headers/dots.gif', 'thumbnail_url' => '%s/images/headers/dots-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Dots', 'backmybook' ) ), 'flowers' => array( 'url' => '%s/images/headers/flowers.jpg', 'thumbnail_url' => '%s/images/headers/flowers-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Flowers', 'backmybook' ) ), 'tile-gray' => array( 'url' => '%s/images/headers/tile-gray.gif', 'thumbnail_url' => '%s/images/headers/tile-gray-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Tile Gray', 'backmybook' ) ), 'tile-orange' => array( 'url' => '%s/images/headers/tile-orange.jpg', 'thumbnail_url' => '%s/images/headers/tile-orange-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Tile Orange', 'backmybook' ) ) ) ); // Sets the defualt colors for theme $bmb_theme_color_defaults = array( 'bmb_text_links' => array('value' => 'B58A00','css' =>'a:link, a:visited, a:hover {color:#'), 'bmb_top_menu' => array('value' =>'59503E','css' =>'#nav,#nav ul ul a {background-color:#'), 'bmb_body_text' => array('value' => '111111','css' =>'body, input, textarea {color:#'), 'bmb_top_menu_hover' => array('value' => 'FFFFFF','css' =>'#nav li:hover > a,#nav ul ul :hover > a {color:#'), 'bmb_top_menu_selected' => array('value' => 'FAF3CF', 'css' =>'#nav ul li.current_page_item > a, #nav ul li.current-menu-ancestor > a, #nav ul li.current-menu-item > a, #nav ul li.current-menu-parent > a {color:#'), 'bmb_top_menu_unselected' => array('value' => 'BAAE8D','css' =>'#nav a {color:#'), 'bmb_author_name' => array('value' => 'FFFFFF','css' =>'.logo a {color:#'), 'bmb_author_description' => array('value' => 'FAF3CF','css' =>'.site-description {color:#'), 'bmb_page_title_h1' => array('value' => 'FFFFFF','css' =>'h1.entry-title {color:#'), 'bmb_page_title_h1_bg' => array('value' => '333333','css' =>'h1.entry-title {background-color:#'), 'bmb_category_title_h1' => array('value' => '333333','css' =>'h1.page-title {background-color:#'), 'bmb_page_title_h2' => array('value' => 'B58A00','css' =>'h2 a:link, h2 a:visited {color:#'), 'bmb_content_titles' => array('value' => 'B58A00','css' =>'.entry-content h1,.entry-content h2, .entry-content h3, .entry-content h4, .entry-content h5, .entry-content h6 {color:#'), 'bmb_footer_text' => array('value' => 'FFFFFF','css' =>'.footer-links li a,.footer-copy {color:#'), 'bmb_footer_bg' => array('value' => '000000','css' =>'#site-info {background-color:#') ); // Now add default colors to database. add_option('bmb_theme_colors', $bmb_theme_color_defaults); $bmb_theme_font = array( 'value' => 'Candara, Verdana, sans-serif', 'css' => 'body { font-family: ', 'key' => 'candara' ); // Now add the default font to database. add_option('bmb_theme_font', $bmb_theme_font); // Make sure the auto generated css file for custom color settings exits if (!file_exists($file = TEMPLATEPATH.'/css/custom-colors.css')) { $fh = fopen($file, 'w'); fwrite($fh,$data); fclose($fh); } endif; } endif; /** * Add custom style sheets and reset file **/ if (!is_admin()) { wp_enqueue_style( 'bmb-reset-fonts-grids', get_stylesheet_directory_uri() . '/css/reset-fonts-grids.css'); wp_enqueue_style( 'bmb-main', get_stylesheet_directory_uri() . '/style.css'); wp_enqueue_style( 'bmb-custom-colors', get_stylesheet_directory_uri() . '/css/custom-colors.css'); } /** * Makes some changes to the tag, by filtering the output of wp_title(). * * If we have a site description and we're viewing the home page or a blog posts * page (when using a static front page), then we will add the site description. * * If we're viewing a search result, then we're going to recreate the title entirely. * We're going to add page numbers to all titles as well, to the middle of a search * result title and the end of all other titles. * * The site title also gets added to all titles. * * @since Back My Book 1.0 * * @param string $title Title generated by wp_title() * @param string $separator The separator passed to wp_title(). Back My Book uses a * vertical bar, "|", as a separator in header.php. * @return string The new title, ready for the <title> tag. * @author WordPress Team */ function backmybook_filter_wp_title( $title, $separator ) { // Don't affect wp_title() calls in feeds. if ( is_feed() ) return $title; // The $paged global variable contains the page number of a listing of posts. // The $page global variable contains the page number of a single post that is paged. // We'll display whichever one applies, if we're not looking at the first page. global $paged, $page; if ( is_search() ) { // If we're a search, let's start over: $title = sprintf( __( 'Search results for %s', 'backmybook' ), '"' . get_search_query() . '"' ); // Add a page number if we're on page 2 or more: if ( $paged >= 2 ) $title .= " $separator " . sprintf( __( 'Page %s', 'backmybook' ), $paged ); // Add the site name to the end: $title .= " $separator " . get_bloginfo( 'name', 'display' ); // We're done. Let's send the new title back to wp_title(): return $title; } // Otherwise, let's start by adding the site name to the end: $title .= get_bloginfo( 'name', 'display' ); // If we have a site description and we're on the home/front page, add the description: $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title .= " $separator " . $site_description; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) $title .= " $separator " . sprintf( __( 'Page %s', 'backmybook' ), max( $paged, $page ) ); // Return the new title to wp_title(): return $title; } add_filter( 'wp_title', 'backmybook_filter_wp_title', 10, 2 ); /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. * * @since Twenty Ten 1.0 * @author WordPress Team */ function backmybook_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'backmybook_page_menu_args' ); /** * Sets the post excerpt length to 40 characters. * * @since Back My Book 1.0 * @return int * @author WordPress Team */ function backmybook_excerpt_length( $length ) { return 40; } add_filter( 'excerpt_length', 'backmybook_excerpt_length' ); /** * Returns a "Continue Reading" link for excerpts * * @since Back My Book 1.0 * @return string "Continue Reading" link * @author Based WordPress Team Twenty Ten theme */ function backmybook_continue_reading_link() { return '</p><div class="read_more"><a href="'. get_permalink() . '">read more</a></div>'; } /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and backmybook_continue_reading_link(). * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. * * @since Back My Book 1.0 * @return string An ellipsis * @author WordPress Team */ function backmybook_auto_excerpt_more( $more ) { return ' …' . backmybook_continue_reading_link(); } add_filter( 'excerpt_more', 'backmybook_auto_excerpt_more' ); /** * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. * * @since Back My Book 1.0 * @return string Excerpt with a pretty "Continue Reading" link * @author WordPress Team */ function backmybook_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= backmybook_continue_reading_link(); } return $output; } add_filter( 'get_the_excerpt', 'backmybook_custom_excerpt_more' ); /** * Register widgetized areas, including sidebars. * * @since Back MyBook 1.0 * @uses register_sidebar */ function backmybook_widgets_init() { // Area 1, located at the top right of the layout. register_sidebar( array( 'name' => __( 'BmB Left Sidebar 1', 'backmybook' ), 'id' => 'primary-widget-area', 'description' => __( 'The primary widget area', 'backmybook' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); // Area 2, located below the Primary Widget Area in the left sidebar. Empty by default. register_sidebar( array( 'name' => __( 'BmB Left Sidebar 2', 'backmybook' ), 'id' => 'secondary-widget-area', 'description' => __( 'The secondary widget area', 'backmybook' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); // Area 3, located at the top right of the layout. Empty by default. register_sidebar( array( 'name' => __( 'BmB Right Sidebar 1', 'backmybook' ), 'id' => 'right-primary-widget-area', 'description' => __( 'Right primary sidebar widget area', 'backmybook' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); // Area 4, located below the primary widget in the right sidebar. Empty by default. register_sidebar( array( 'name' => __( 'BmB Right Sidebar 2', 'backmybook' ), 'id' => 'right-secondary-widget-area', 'description' => __( 'Right sidebar secondary widget area', 'backmybook' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); } /** Register sidebars by running backmybook_widgets_init() on the widgets_init hook. */ add_action( 'widgets_init', 'backmybook_widgets_init' ); // Set sepcial widget to display customized data in sidebars. class List_Content extends WP_Widget { function List_Content() { $widget_options = array('description' => 'This widget displays latest content with thumbnails from a selected category.', 'classname' => 'widget-listing'); parent::WP_Widget(false, 'Back My Book Latest Content', $widget_options); } function form($instance) { // outputs the options form on admin $instance = wp_parse_args((array) $instance, array('title' => __('', 'widget-listing'), 'cat_name' => 'Uncategorized', 'n_posts' => 5)); $title = esc_attr($instance['title']); $cat_name = esc_attr($instance['cat_name']); $n_posts = intval($instance['n_posts']); $categories = &get_categories('type=post&orderby=name&hide_empty=0'); ?> <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'widget-listing'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label> <br/> <label for="<?php echo $this->get_field_id('cat_name'); ?>"><?php _e('Category Name', 'widget-listing'); ?> </label> <select name="<?php echo $this->get_field_name('cat_name'); ?>" id="<?php echo $this->get_field_id('cat_name'); ?>" class="widefat"> <?php if ($categories) { foreach ($categories as $category) { if ($category->cat_name == $cat_name ) { $selected = ' selected'; } else {$selected = '';} echo '<option value="' . $category->cat_name . '"' . $selected . '>' . $category->cat_name . '</option>' . "\n"; } } ?> </select> <br/> <label for="<?php echo $this->get_field_id('n_posts'); ?>"><?php _e('Numer of Posts to Display', 'widget-listing'); ?> <input class="widefat" id="<?php echo $this->get_field_id('n_posts'); ?>" name="<?php echo $this->get_field_name('n_posts'); ?>" type="text" value="<?php echo $n_posts; ?>" /></label> <br/> <?php } function update($new_instance, $old_instance) { // processes widget options to be saved $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['cat_name'] = strip_tags($new_instance['cat_name']); $instance['n_posts'] = intval($new_instance['n_posts']); return $instance; } function widget($args, $instance) { // outputs the content of the widget extract($args, EXTR_SKIP); $title = esc_attr($instance['title']); $cat_name = esc_attr($instance['cat_name']); $n_posts = $instance['n_posts']; echo $before_widget.$before_title.$title.$after_title; bmb_widget_content($cat_name,$n_posts); echo $after_widget; } } register_widget('List_Content'); //EOF Special widget // Set sepcial widget to display featured posts in sidebars. class Feature_Content extends WP_Widget { function Feature_Content() { $widget_options = array('description' => 'This widget displays featured content with thumbnails.', 'classname' => 'widget-listing'); parent::WP_Widget(false, 'Back My Book Featured Content', $widget_options); } function form($instance) { // outputs the options form on admin $instance = wp_parse_args((array) $instance, array('title' => __('', 'widget-listing'), 'cat_name' => 'bmb_widget_feature', 'n_posts' => 5)); $title = esc_attr($instance['title']); $cat_name = esc_attr($instance['cat_name']); $n_posts = intval($instance['n_posts']); ?> <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'widget-listing'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label> <br/> <label for="<?php echo $this->get_field_id('n_posts'); ?>"><?php _e('Numer of Posts to Display', 'widget-listing'); ?> <input class="widefat" id="<?php echo $this->get_field_id('n_posts'); ?>" name="<?php echo $this->get_field_name('n_posts'); ?>" type="text" value="<?php echo $n_posts; ?>" /></label> <input type="hidden" name="<?php echo $this->get_field_name('cat_name'); ?>" value="bmb_widget_feature" /> <br/> <?php } function update($new_instance, $old_instance) { // processes widget options to be saved $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['cat_name'] = strip_tags($new_instance['cat_name']); $instance['n_posts'] = intval($new_instance['n_posts']); return $instance; } function widget($args, $instance) { // outputs the content of the widget extract($args, EXTR_SKIP); $title = esc_attr($instance['title']); $cat_name = esc_attr($instance['cat_name']); $n_posts = $instance['n_posts']; echo $before_widget.$before_title.$title.$after_title; bmb_widget_content($cat_name,$n_posts); echo $after_widget; } } register_widget('Feature_Content'); //EOF Feature posts widget //Adds feature checkbox to admin area function bmb_feature_content() { global $post; $feature = false; if (get_post_meta($post->ID,'bmb_main_feature',true)) { $feature = true; } $feature_widget = false; if (get_post_meta($post->ID,'bmb_widget_feature',true)) { $feature_widget = true; } echo'<input type="hidden" name="bmb_feature_noncename" id="bmb_feature_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />'; ?> <input type="checkbox" id="bmb_main_feature" name="bmb_main_feature" <?php if($feature) echo'checked="checked"'?>> <label for="bmb_main_feature">Feature in home page?</label> <br/><br/> <input type="checkbox" id="bmb_widget_feature" name="bmb_widget_feature" <?php if($feature_widget) echo'checked="checked"'?>> <label for="bmb_widget_feature">Feature in widget?</label> <?php } // Adds checkbox to post page function bmb_create_feature_content() { if (function_exists('add_meta_box') ) { add_meta_box( 'bmb-feature-posts', 'Back My Book Feature Post', 'bmb_feature_content', 'post', 'side', 'high' ); } } function bmb_save_feature_data( $post_id ) { global $post; // Verify if ( !wp_verify_nonce( $_POST['bmb_feature_noncename'], plugin_basename(__FILE__) )) { return $post_id; } if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id )) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id )) return $post_id; } $data = $_POST['bmb_main_feature']; $data_widget = $_POST['bmb_widget_feature']; // Store main feature if (get_post_meta($post_id, 'bmb_main_feature') == "") { add_post_meta($post_id, 'bmb_main_feature', $data, true); } elseif ($data != get_post_meta($post_id, 'bmb_main_feature', true)) { update_post_meta($post_id, 'bmb_main_feature', $data); } elseif ($data == "") { delete_post_meta($post_id, 'bmb_main_feature', get_post_meta($post_id, 'bmb_main_feature', true)); } // Store widget feature if (get_post_meta($post_id, 'bmb_widget_feature') == "") { add_post_meta($post_id, 'bmb_widget_feature', $data_widget, true); } elseif ($data_widget != get_post_meta($post_id, 'bmb_widget_feature', true)) { update_post_meta($post_id, 'bmb_widget_feature', $data_widget); } elseif ($data_widget == "") { delete_post_meta($post_id, 'bmb_widget_feature', get_post_meta($post_id, 'bmb_widget_feature', true)); } } add_action('admin_menu', 'bmb_create_feature_content'); add_action('save_post', 'bmb_save_feature_data'); // Trims excerpt to set number of characters looking for the last word before trimming. function bmb_custom_excerpt($excerpt, $excerpt_max_lenght = 60 ) { $excerpt = substr($excerpt,0,($excerpt_max_lenght-strlen(strrchr(substr($excerpt,0,$excerpt_max_lenght)," ")) )); echo $excerpt .= '... '; return $excerpt; } // Adds options to Appearance tab in admin area // Color theme settings if(is_admin()) require_once(TEMPLATEPATH.'/admin/theme_colors.php'); // Author Photo Profile if(is_admin()) require_once(TEMPLATEPATH.'/admin/profile_photo.php'); // Set up guide pages if(is_admin()) require_once(TEMPLATEPATH.'/admin/guide_setup.php'); // ========= END OF LOADING SETTINGS AND CLASSES ========= // Theme functions /** * Sets template class. Defines class type for body width, column location and column width. * * @since Back My Book 1.0 */ function bmb_template_class($template_class = '') { if(is_page_template( 'onecolumn-page-nosidebar.php' )) { $class = 'yui-t7'; } elseif ($template_class == '') { $class = 'yui-t2'; } else { $class = $template_class; } echo $class; } /** * Set custom header image * * @since Back My Book 1.0 */ function bmb_header_style() { ?> <style type="text/css"> #header { background:transparent url(<?php header_image(); ?>); } </style> <?php } // Now adds the style to the theme head if ( get_header_image() ) add_filter('wp_head','bmb_header_style'); /** * Content feature block. Content displays when a post is checked as "feature" in back end. * * @since Back My Book 1.0 */ function bmb_featured_post( $showposts = 1 ){ global $wpdb; $query = " SELECT wposts.*,wpostmeta.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'bmb_main_feature' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY wposts.post_date DESC LIMIT $showposts "; $posts = $wpdb->get_results($query, OBJECT); $post_count = count($posts); $i=0; if ($post_count > 0 ) { foreach ( $posts as $feature ) : setup_postdata($feature); ?> <div class="feature_panel clearfix"> <?php if ( has_post_thumbnail() ) { ?> <a href="<?php echo get_permalink( $feature->ID ); ?>"><?php the_post_thumbnail();?></a> <?php } ?> <h2><a href="<?php echo get_permalink( $feature->ID ); ?>"><?php echo $feature->post_title;?> </a></h2> <p><?php bmb_custom_excerpt(get_the_excerpt(),'200'); ?> </p> <div class="read_more"><a href="<?php echo get_permalink( $feature->ID ); ?>">read more</a></div> </div> <?php endforeach; } else { echo 'no posts'; } wp_reset_query(); } /** * Displays author profile photo * * @since Back My Book 1.0 */ function bmb_author_photo() { $opt_val = get_option('bmb_author_profile'); if ($opt_val != '' && file_exists(ABSPATH.'wp-content/uploads/'.$opt_val)) { $profile = '/wp-content/uploads/'.$opt_val; } else { $profile = get_bloginfo('template_url').'/images/default_profile.jpg'; } ?> <div class="author_photo"> <img src="<?php echo $profile; ?>" alt="<?php bloginfo('name');?>" /> </div> <?php } /** * Retrieves comments for blogroll * * @since Back My Book 1.0 */ function bmb_get_comments( $post_id = 0 , $shownumber = 2) { global $wpdb, $id; $query = " SELECT comment_content,comment_author,comment_ID,comment_post_ID FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '1' ORDER BY comment_date DESC LIMIT $shownumber "; $comments = $wpdb->get_results($query, OBJECT); $title_max_lenght = 20; $comment_max_lenght = 80; $post_link = get_permalink($comment->comment_post_ID); $comment_link = $post_link ."#comment-$comment->comment_ID"; if(empty($comments)) { echo '<div class="blogroll-comments">'; echo 'There are no comments, <a href="'.$post_link.'#respond">click here</a> be the first one!'; echo '</div>'; } else { foreach ($comments as $comment) { $comment_excerpt = strip_tags($comment->comment_content); // If has links, skip, don't want more links crowding the place if(strpos($comment_excerpt,'http://') > 0) continue; // Sanitize text $comment_excerpt = preg_replace("/\[...\]/","",$comment_excerpt); $comment_excerpt = preg_replace("/^<strong>.+?<\/strong>/","",$comment_excerpt,1); $comment_excerpt = strip_tags(wptexturize($comment_excerpt)); $comment_excerpt = preg_replace("/[\n\t\r]/"," ",$comment_excerpt); // whitespace into 1 blank $comment_excerpt = preg_replace("/\s{2,}/"," ",$comment_excerpt); // whitespace into 1 blank if (strlen($comment_excerpt) >= $comment_max_lenght ) { $comment_excerpt = substr($comment_excerpt,0,($comment_max_lenght-strlen(strrchr(substr($comment_excerpt,0,$comment_max_lenght)," ")) )); $comment_excerpt .= '...'; } $comment_author = $comment->comment_author; if (!$comment_author) { $comment_author = "Anonymous"; } else { if (strlen($comment_author) >= $title_max_lenght ) { $comment_author = substr($comment_author,0,($title_max_lenght-strlen(strrchr(substr($comment_author,0,$title_max_lenght)," ")) )); $comment_author .= '...'; } } echo '<div class="blogroll-comments">'; echo '<strong>'.$comment_author.'</strong> <span>says:</span><br/>'; echo $comment_excerpt.' <a href="'.$comment_link.'">more</a>'; echo '</div>'; } echo '<div class="read_more read_more-comments"><a href="'.$post_link.'#comments">read all</a></div>'; } // endif ?> <?php } /** * Content output for Back My Book custom widget * * @since Back My Book 1.0 */ function bmb_widget_content( $category , $number ) { global $cat; if ($category == 'bmb_widget_feature') { $wp_query = query_posts('showposts='. $number .'&meta_key='.$category); } else { $category = strtolower($category); $id = get_cat_ID( $category); $wp_query = query_posts('showposts='. $number .'&cat='. $id); } $count_posts = count($wp_query); $i=1; if (have_posts()) { while (have_posts()) : the_post(); ?> <div class="listing"> <?php if ( has_post_thumbnail() ) { ?> <?php the_post_thumbnail('widget-thumbnail');?> <?php } ?> <h2 class="entry-title"><a href="<?php the_permalink();?>"><?php the_title();?> </a></h2> <p><?php bmb_custom_excerpt(get_the_excerpt(),'80'); ?><a href="<?php the_permalink();?>">read more</a></p> </div> <?php if ($i == $count_posts && $category != 'bmb_widget_feature') { echo '<p class="read_more"><a href="'.get_category_link($id).'">browse '.$category.'</a></p>'; } $i++; endwhile; } else { ?> <div class="listing"> Sorry, no data. </div> <?php } wp_reset_query(); } /** * Scans post for embedded image within content and returns image path * * @since Back My Book 1.0 */ function bmb_get_img_by_scan( $args = array() ) { preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', get_post_field( 'post_content', $args['post_id'] ), $matches ); /* If there is a match for the image, return its URL. */ if ( isset( $matches ) && $matches[1][0] ) { return $matches[1][0]; } } /** * Custom search form * * @since Back My Book 1.0 */ function bmb_search_from() { $field_value = __('To search, type and hit enter', 'backmybook'); ?> <form method="get" class="search_form" action="<?php bloginfo('home'); ?>/"> <p> <input class="search_input" type="text" value="<?php echo $field_value; ?>" name="s" id="s" onfocus="if (this.value == '<?php echo $field_value; ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $field_value; ?>';}" /> <input type="hidden" id="searchsubmit" value="Search" /> </p> </form> <?php } if ( ! function_exists( 'backmybook_posted_on' ) ) : /** * Prints HTML with meta information for the current post—date/time and author. * * @since Back My Book 1.0 * @author Based WordPress Team Twenty Ten theme */ function backmybook_posted_on() { $commentscount = get_comments_number(); if($commentscount == 1) $commenttext = ' comment'; if($commentscount > 1 || $commentscount == 0) $commenttext = ' comments'; printf( __( '<span class="meta-sep">by</span> %3$s <span class="%1$s">on</span> %2$s %4$s', 'backmybook' ), 'meta-sep meta-prep-author', sprintf( '<span class="entry-date">%3$s</span>', get_permalink(), esc_attr( get_the_time() ), get_the_date() ), sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', get_author_posts_url( get_the_author_meta( 'ID' ) ), sprintf( esc_attr__( 'View all posts by %s', 'backmybook' ), get_the_author() ), get_the_author() ), sprintf( '<span class="post_comments">%3$s</span>', get_permalink(), esc_attr__( 'View all comments', 'backmybook' ), sprintf( esc_attr__( ' - %s', 'backmybook' ), $commentscount.$commenttext ) ) ); } endif; if ( ! function_exists( 'backmybook_posted_in' ) ) : /** * Prints HTML with meta information for the current post (category, tags and permalink). * * @since Back My Book 1.0 * @author Based WordPress Team Twenty Ten theme */ function backmybook_posted_in() { // Retrieves tag list of current post, separated by commas. $tag_list = get_the_tag_list( '', ', ' ); if ( $tag_list ) { $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>.', 'backmybook' ); } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) { $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'backmybook' ); } else { $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'backmybook' ); } // Prints the string, replacing the placeholders. printf( $posted_in, get_the_category_list( ', ' ), $tag_list, get_permalink(), the_title_attribute( 'echo=0' ) ); } endif; if ( ! function_exists( 'backmybook_comment' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since Back My Book 1.0 * @author Based WordPress Team Twenty Ten theme */ function backmybook_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> <div id="comment-<?php comment_ID(); ?>"> <div class="comment-author vcard"> <?php echo get_avatar( $comment, 40 ); ?> <?php printf( __( '%s <span class="says">says:</span>', 'backmybook' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?> </div><!-- .comment-author .vcard --> <?php if ( $comment->comment_approved == '0' ) : ?> <em><?php _e( 'Your comment is awaiting moderation.', 'backmybook' ); ?></em> <br /> <?php endif; ?> <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> <?php /* translators: 1: date, 2: time */ printf( __( '%1$s at %2$s', 'backmybook' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'backmybook' ), ' ' ); ?> </div><!-- .comment-meta .commentmetadata --> <div class="comment-body"><?php comment_text(); ?></div> <div class="reply"> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </div><!-- .reply --> </div><!-- #comment-## --> <?php break; case 'pingback' : case 'trackback' : ?> <li class="post pingback"> <p><?php _e( 'Pingback:', 'backmybook' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'backmybook'), ' ' ); ?></p> <?php break; endswitch; } endif; function twentyten_remove_gallery_css( $css ) { return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css ); } add_filter( 'gallery_style', 'twentyten_remove_gallery_css' ); function bmb_font_list() { $fonts = array( 'arial' => array( 'name' => 'Arial', 'family' => 'Arial, "Helvetica Neue", Helvetica, sans-serif', 'web_safe' => true ), 'arial_black' => array( 'name' => 'Arial Black', 'family' => '"Arial Black", "Arial Bold", Arial, sans-serif', 'web_safe' => true ), 'arial_narrow' => array( 'name' => 'Arial Narrow', 'family' => '"Arial Narrow", Arial, "Helvetica Neue", Helvetica, sans-serif', 'web_safe' => true ), 'courier_new' => array( 'name' => 'Courier New', 'family' => '"Courier New", Courier, Verdana, sans-serif', 'web_safe' => true, 'monospace' => true ), 'georgia' => array( 'name' => 'Georgia', 'family' => 'Georgia, "Times New Roman", Times, serif', 'web_safe' => true ), 'times_new_roman' => array( 'name' => 'Times New Roman', 'family' => '"Times New Roman", Times, Georgia, serif', 'web_safe' => true ), 'trebuchet_ms' => array( 'name' => 'Trebuchet MS', 'family' => '"Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Arial, sans-serif', 'web_safe' => true ), 'verdana' => array( 'name' => 'Verdana', 'family' => 'Verdana, sans-serif', 'web_safe' => true ), 'andale' => array( 'name' => 'Andale Mono', 'family' => '"Andale Mono", Consolas, Monaco, Courier, "Courier New", Verdana, sans-serif', 'web_safe' => false, 'monospace' => true ), 'baskerville' => array( 'name' => 'Baskerville', 'family' => 'Baskerville, "Times New Roman", Times, serif', 'web_safe' => false ), 'bookman_old_style' => array( 'name' => 'Bookman Old Style', 'family' => '"Bookman Old Style", Georgia, "Times New Roman", Times, serif', 'web_safe' => false ), 'calibri' => array( 'name' => 'Calibri', 'family' => 'Calibri, "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif', 'web_safe' => false ), 'cambria' => array( 'name' => 'Cambria', 'family' => 'Cambria, Georgia, "Times New Roman", Times, serif', 'web_safe' => false ), 'candara' => array( 'name' => 'Candara', 'family' => 'Candara, Verdana, sans-serif', 'web_safe' => false ), 'century_gothic' => array( 'name' => 'Century Gothic', 'family' => '"Century Gothic", "Apple Gothic", Verdana, sans-serif', 'web_safe' => false ), 'century_schoolbook' => array( 'name' => 'Century Schoolbook', 'family' => '"Century Schoolbook", Georgia, "Times New Roman", Times, serif', 'web_safe' => false ), 'consolas' => array( 'name' => 'Consolas', 'family' => 'Consolas, "Andale Mono", Monaco, Courier, "Courier New", Verdana, sans-serif', 'web_safe' => false, 'monospace' => true ), 'constantia' => array( 'name' => 'Constantia', 'family' => 'Constantia, Georgia, "Times New Roman", Times, serif', 'web_safe' => false ), 'corbel' => array( 'name' => 'Corbel', 'family' => 'Corbel, "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif', 'web_safe' => false ), 'franklin_gothic' => array( 'name' => 'Franklin Gothic Medium', 'family' => '"Franklin Gothic Medium", Arial, sans-serif', 'web_safe' => false ), 'garamond' => array( 'name' => 'Garamond', 'family' => 'Garamond, "Hoefler Text", "Times New Roman", Times, serif', 'web_safe' => false ), 'gill_sans' => array( 'name' => 'Gill Sans', 'family' => '"Gill Sans MT", "Gill Sans", Calibri, "Trebuchet MS", sans-serif', 'web_safe' => false ), 'helvetica' => array( 'name' => 'Helvetica', 'family' => '"Helvetica Neue", Helvetica, Arial, sans-serif', 'web_safe' => false ), 'hoefler' => array( 'name' => 'Hoefler Text', 'family' => '"Hoefler Text", Garamond, "Times New Roman", Times, sans-serif', 'web_safe' => false ), 'lucida_bright' => array( 'name' => 'Lucida Bright', 'family' => '"Lucida Bright", Cambria, Georgia, "Times New Roman", Times, serif', 'web_safe' => false ), 'lucida_grande' => array( 'name' => 'Lucida Grande', 'family' => '"Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", sans-serif', 'web_safe' => false ), 'palatino' => array( 'name' => 'Palatino', 'family' => '"Palatino Linotype", Palatino, Georgia, "Times New Roman", Times, serif', 'web_safe' => false ), 'rockwell' => array( 'name' => 'Rockwell', 'family' => 'Rockwell, "Arial Black", "Arial Bold", Arial, sans-serif', 'web_safe' => false ), 'tahoma' => array( 'name' => 'Tahoma', 'family' => 'Tahoma, Geneva, Verdana, sans-serif', 'web_safe' => false ) ); return $fonts; } function bmb_find_more_page($content = '') { $number = preg_match_all('#<!--nextpage-->#s', $content,$matches); $number = count($matches[0]); }