Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* This calls our options page in the Admin */
- require_once( STYLESHEETPATH . '/options.php');
- // This changes the excerpt length, change 40 to whatever you want
- function change_excerpt_length(){
- function new_excerpt_length($length) {
- return 40;
- }
- add_filter('excerpt_length', 'new_excerpt_length');
- }
- add_action( 'after_setup_theme', 'change_excerpt_length' );
- // change continue reading link, change the "Read More" line to whatever you like
- class Twentyten_Child_Text_Wrangler {
- function reading_more($translation, $text, $domain) {
- $translations = &get_translations_for_domain( $domain );
- if ( $text == 'Continue reading <span class="meta-nav">→</span>' ) {
- return $translations->translate( '<span class="read-more">Read More <span class="meta-nav">»</span></span>' );
- }
- return $translation;
- }
- }
- add_filter('gettext', array('Twentyten_Child_Text_Wrangler', 'reading_more'), 10, 4);
- function new_excerpt_more($more) {
- return 'Can you hear me now?';
- }
- add_filter('excerpt_more', 'new_excerpt_more');
- // add search box to navigation menu must be using menu system, comment out to disable
- add_filter('wp_nav_menu_items','add_search_box', 10, 2);
- function add_search_box($items, $args) {
- ob_start();
- get_search_form();
- $searchform = ob_get_contents();
- ob_end_clean();
- $items .= '<div class="menuadd"><li>' . $searchform . '</li></div>';
- return $items;
- }
- // We add post thumbnail function to our theme here
- //If you change the image dimensions, I'd recomend using ajax rebuild thumbnails to fix your images
- add_action( 'after_setup_theme', 'ttinfo_setup' );
- function ttinfo_setup() {
- //This sets the dimensions for the thumbnails displayed on the homepage for the excerpts with thumbnail layout
- add_image_size( 'home-post-thumbnail', 120, 120, true );
- // This is the size the grid layout page uses
- add_image_size( 'grid-medium-thumbnail', 310, 120, true );
- }
- // Add your own favicon.ico to your child theme folder and it will be shown
- function add_theme_favicon() {
- echo '<link rel="shortcut icon" href="' . get_bloginfo('stylesheet_directory') . '/favicon.ico" >';
- }
- add_action('wp_head', 'add_theme_favicon');
- /* This adds a widget area above the content for adsense or whatever You can check style.css on how to style it */
- /** Tell WordPress to run child_theme_setup() when the 'after_setup_theme' hook is run.*/
- add_action( 'after_setup_theme', 'child_theme_setup' );
- /** This function will hold our new calls and over-rides */
- if ( !function_exists( 'child_theme_setup' ) ):
- function child_theme_setup() {
- /** Add our Extra Widgetized Areas */
- function child_widgets_init() {
- // Load our Widget Area Names and ID's into an Array
- $widgets = array (
- array(
- "name" => "Content Ads Widget",
- "id" => "content-top-widget-area")
- );
- /* Loop through the array and add our Widgetised areas */
- foreach ($widgets as $widget) {
- register_sidebar( array(
- 'name' => __( $widget['name'], 'twentyten' ),
- 'id' => $widget['id'],
- 'description' => __( $widget['name'] .' Area', 'twentyten' ),
- '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 twentyten_widgets_init() on the widgets_init hook. */
- add_action( 'widgets_init', 'child_widgets_init' );
- }
- endif;
- define('HEADER_IMAGE', get_bloginfo('stylesheet_directory') . '/images/winter.jpg'); /* set our own default header image */
- function ttoptions_setup(){
- /* This adds our own default headers. Change "twentyten-options" to the name of your theme throughout,
- change "dock.jpg, dock, docks etc" to the name of your images for each section, code from Aaron Jorbin's introduction to Thirty Ten*/
- $ttoptions_dir = get_bloginfo('stylesheet_directory');
- register_default_headers( array (
- 'docks' => array (
- 'url' => "$ttoptions_dir/images/dock.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/dock_thumb.jpg",
- 'description' => __( 'Dock', 'twentyten-options' )
- ),
- 'cottage' => array (
- 'url' => "$ttoptions_dir/images/cabin.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/cabin_thumb.jpg",
- 'description' => __( 'Cabin', 'twentyten-options' )
- ),
- 'cat' => array (
- 'url' => "$ttoptions_dir/images/cat.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/cat_thumb.jpg",
- 'description' => __( 'Cat', 'twentyten-options' )
- ),
- 'castle' => array (
- 'url' => "$ttoptions_dir/images/castle.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/castle_thumb.jpg",
- 'description' => __( 'Castle', 'twentyten-options' )
- ),
- 'fishing' => array (
- 'url' => "$ttoptions_dir/images/fishing.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/fishing_thumb.jpg",
- 'description' => __( 'Fishing', 'twentyten-options' )
- ),
- 'lake' => array (
- 'url' => "$ttoptions_dir/images/lake.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/lake_thumb.jpg",
- 'description' => __( 'Lake', 'twentyten-options' )
- ),
- 'highway' => array (
- 'url' => "$ttoptions_dir/images/highway.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/highway_thumb.jpg",
- 'description' => __( 'Highway', 'twentyten-options' )
- ),
- 'winter' => array (
- 'url' => "$ttoptions_dir/images/winter.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/winter_thumb.jpg",
- 'description' => __( 'Winter', 'twentyten-options' )
- ),
- 'sunset-red' => array (
- 'url' => "$ttoptions_dir/images/tree.jpg",
- 'thumbnail_url' => "$ttoptions_dir/images/tree_thumb.jpg",
- 'description' => __( 'Red Sunset', 'twentyten-options' )
- )
- ));
- }
- /* This removes the default headers so we can use our own */
- function ttoptions_remove_twenty_ten_headers(){
- unregister_default_headers( array(
- 'berries',
- 'cherryblossom',
- 'concave',
- 'fern',
- 'forestfloor',
- 'inkwell',
- 'path' ,
- 'sunset')
- );
- }
- add_action( 'after_setup_theme', 'ttoptions_remove_twenty_ten_headers', 11 );
- add_action( 'after_setup_theme', 'ttoptions_setup' );
- /* This enables more functions in the Wysiwyg html post editor */
- function enable_more_buttons($buttons) {
- $buttons[] = 'hr';
- $buttons[] = 'sub';
- $buttons[] = 'sup';
- $buttons[] = 'fontselect';
- $buttons[] = 'fontsizeselect';
- $buttons[] = 'cleanup';
- $buttons[] = 'styleselect';
- return $buttons;
- }
- add_filter("mce_buttons_3", "enable_more_buttons");
- /* Slider config code mostly from Speaky theme */
- if ( ! function_exists( 'ttoptions_slider' ) ) :
- /* Change the number of featured images the slider will display here,
- you can also change the name of the category it pulls the images from in the line below*/
- function ttoptions_slider($category = 'Featured', $postcount = 10){
- ?>
- <?php
- $q = new WP_Query("category_name=$category&showposts=$postcount");
- //Start slider loop
- if( get_category_by_slug($category)->category_count > 0 && $q->have_posts() ) :?>
- <div id="slider">
- <?php
- while($q->have_posts()) : $q->the_post() && has_post_thumbnail($post->ID);?>
- <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
- <div class="nivo-caption2"><p><?php the_title(); ?></p></div>
- <?php the_post_thumbnail();?>
- </a>
- <?php endwhile; //End slider loop ?>
- </div><!--/slider-->
- <?php else: ?>
- <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
- <?php endif; ?>
- </div><!-- #featured-image -->
- <?php
- //Reset Query
- wp_reset_query();
- ?>
- <?php }
- endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement