Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.69 KB | None | 0 0
  1. <?php  
  2.  
  3. /* This calls our options page in the Admin */
  4. require_once( STYLESHEETPATH . '/options.php');
  5.  
  6. // This changes the excerpt length, change 40 to whatever you want
  7. function change_excerpt_length(){
  8.    function new_excerpt_length($length) {
  9.     return 40;
  10.    }
  11.    add_filter('excerpt_length', 'new_excerpt_length');
  12. }
  13. add_action( 'after_setup_theme', 'change_excerpt_length' );
  14.  
  15.  
  16. // change continue reading link, change the "Read More" line to whatever you like
  17. class Twentyten_Child_Text_Wrangler {
  18. function reading_more($translation, $text, $domain) {
  19.   $translations = &get_translations_for_domain( $domain );
  20.   if ( $text == 'Continue reading <span class="meta-nav">&rarr;</span>' ) {
  21.    return $translations->translate( '<span class="read-more">Read More <span class="meta-nav">&raquo;</span></span>' );
  22.   }
  23.   return $translation;
  24.  }
  25. }
  26. add_filter('gettext', array('Twentyten_Child_Text_Wrangler', 'reading_more'), 10, 4);
  27.  
  28. function new_excerpt_more($more) {
  29.     return 'Can you hear me now?';
  30. }
  31. add_filter('excerpt_more', 'new_excerpt_more');
  32.  
  33. // add search box to navigation menu must be using menu system, comment out to disable
  34. add_filter('wp_nav_menu_items','add_search_box', 10, 2);
  35. function add_search_box($items, $args) {
  36.  
  37.         ob_start();
  38.         get_search_form();
  39.         $searchform = ob_get_contents();
  40.         ob_end_clean();
  41.  
  42.         $items .= '<div class="menuadd"><li>' . $searchform . '</li></div>';
  43.  
  44.     return $items;
  45. }
  46. // We add post thumbnail function to our theme here
  47. //If you change the image dimensions, I'd recomend using ajax rebuild thumbnails to fix your images
  48. add_action( 'after_setup_theme', 'ttinfo_setup' );
  49. function ttinfo_setup() {
  50. //This sets the dimensions for the thumbnails displayed on the homepage for the excerpts with thumbnail layout
  51. add_image_size( 'home-post-thumbnail', 120, 120, true );
  52. // This is the size the grid layout page uses
  53. add_image_size( 'grid-medium-thumbnail', 310, 120, true );
  54. }
  55. // Add your own favicon.ico to your child theme folder and it will be shown
  56. function add_theme_favicon() {
  57. echo '<link rel="shortcut icon" href="' . get_bloginfo('stylesheet_directory') . '/favicon.ico" >';
  58. }
  59. add_action('wp_head', 'add_theme_favicon');
  60.  
  61. /* This adds a widget area above the content for adsense or whatever You can check style.css on how to style it */
  62. /** Tell WordPress to run child_theme_setup() when the 'after_setup_theme' hook is run.*/
  63. add_action( 'after_setup_theme', 'child_theme_setup' );
  64.  
  65. /** This function will hold our new calls and over-rides */
  66. if ( !function_exists( 'child_theme_setup' ) ):
  67. function child_theme_setup() {
  68.    
  69.     /** Add our Extra Widgetized Areas */
  70.     function child_widgets_init() {
  71.        
  72.         // Load our Widget Area Names and ID's into an Array
  73.         $widgets = array (
  74.    
  75.             array(  
  76.                 "name" => "Content Ads Widget",
  77.                 "id" => "content-top-widget-area")
  78.             );
  79.        
  80.        
  81.         /* Loop through the array and add our Widgetised areas */      
  82.         foreach ($widgets as $widget) {
  83.             register_sidebar( array(
  84.                 'name' => __( $widget['name'], 'twentyten' ),
  85.                 'id' => $widget['id'],
  86.                 'description' => __( $widget['name'] .' Area', 'twentyten' ),
  87.                 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  88.                 'after_widget' => '</li>',
  89.                 'before_title' => '<h3 class="widget-title">',
  90.                 'after_title' => '</h3>',
  91.             ) );
  92.         }
  93.  
  94.     }
  95.     /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
  96.     add_action( 'widgets_init', 'child_widgets_init' );
  97.     }
  98. endif;
  99.  
  100. define('HEADER_IMAGE', get_bloginfo('stylesheet_directory') . '/images/winter.jpg'); /* set our own default header image */
  101.  
  102. function ttoptions_setup(){
  103.  
  104. /* This adds our own default headers. Change "twentyten-options" to the name of your theme throughout,
  105.  change "dock.jpg, dock, docks etc" to the name of your images for each section, code from Aaron Jorbin's introduction to Thirty Ten*/
  106.     $ttoptions_dir =    get_bloginfo('stylesheet_directory');
  107.     register_default_headers( array (
  108.         'docks' => array (
  109.             'url' => "$ttoptions_dir/images/dock.jpg",
  110.             'thumbnail_url' => "$ttoptions_dir/images/dock_thumb.jpg",
  111.             'description' => __( 'Dock', 'twentyten-options' )
  112.         ),
  113.         'cottage' => array (
  114.             'url' => "$ttoptions_dir/images/cabin.jpg",
  115.             'thumbnail_url' => "$ttoptions_dir/images/cabin_thumb.jpg",
  116.             'description' => __( 'Cabin', 'twentyten-options' )
  117.                 ),
  118.         'cat' => array (
  119.             'url' => "$ttoptions_dir/images/cat.jpg",
  120.             'thumbnail_url' => "$ttoptions_dir/images/cat_thumb.jpg",
  121.             'description' => __( 'Cat', 'twentyten-options' )
  122.                 ),
  123.         'castle' => array (
  124.             'url' => "$ttoptions_dir/images/castle.jpg",
  125.             'thumbnail_url' => "$ttoptions_dir/images/castle_thumb.jpg",
  126.             'description' => __( 'Castle', 'twentyten-options' )
  127.                 ),
  128.         'fishing' => array (
  129.             'url' => "$ttoptions_dir/images/fishing.jpg",
  130.             'thumbnail_url' => "$ttoptions_dir/images/fishing_thumb.jpg",
  131.             'description' => __( 'Fishing', 'twentyten-options' )
  132.                         ),
  133.         'lake' => array (
  134.             'url' => "$ttoptions_dir/images/lake.jpg",
  135.             'thumbnail_url' => "$ttoptions_dir/images/lake_thumb.jpg",
  136.             'description' => __( 'Lake', 'twentyten-options' )
  137.                         ),
  138.         'highway' => array (
  139.             'url' => "$ttoptions_dir/images/highway.jpg",
  140.             'thumbnail_url' => "$ttoptions_dir/images/highway_thumb.jpg",
  141.             'description' => __( 'Highway', 'twentyten-options' )
  142.                                 ),
  143.         'winter' => array (
  144.             'url' => "$ttoptions_dir/images/winter.jpg",
  145.             'thumbnail_url' => "$ttoptions_dir/images/winter_thumb.jpg",
  146.             'description' => __( 'Winter', 'twentyten-options' )
  147.         ),
  148.         'sunset-red' => array (
  149.             'url' => "$ttoptions_dir/images/tree.jpg",
  150.             'thumbnail_url' => "$ttoptions_dir/images/tree_thumb.jpg",
  151.             'description' => __( 'Red Sunset', 'twentyten-options' )
  152.         )
  153.  
  154.     ));
  155.  
  156. }
  157. /* This removes the default headers so we can use our own */
  158. function ttoptions_remove_twenty_ten_headers(){
  159.     unregister_default_headers( array(
  160.         'berries',
  161.         'cherryblossom',
  162.         'concave',
  163.         'fern',
  164.         'forestfloor',
  165.         'inkwell',
  166.         'path' ,
  167.         'sunset')
  168.     );
  169. }
  170.  
  171. add_action( 'after_setup_theme', 'ttoptions_remove_twenty_ten_headers', 11 );
  172. add_action( 'after_setup_theme', 'ttoptions_setup' );
  173.  
  174. /* This enables more functions in the Wysiwyg html post editor */
  175. function enable_more_buttons($buttons) {
  176.   $buttons[] = 'hr';
  177.   $buttons[] = 'sub';
  178.   $buttons[] = 'sup';
  179.   $buttons[] = 'fontselect';
  180.   $buttons[] = 'fontsizeselect';
  181.   $buttons[] = 'cleanup';
  182.   $buttons[] = 'styleselect';
  183.   return $buttons;
  184. }
  185. add_filter("mce_buttons_3", "enable_more_buttons");
  186.  
  187. /* Slider config code mostly from Speaky theme */
  188. if ( ! function_exists( 'ttoptions_slider' ) ) :
  189. /* Change the number of featured images the slider will display here,
  190.    you can also change the name of the category it pulls the images from in the line below*/
  191. function ttoptions_slider($category = 'Featured', $postcount = 10){
  192. ?>
  193.         <?php
  194.         $q = new WP_Query("category_name=$category&showposts=$postcount");  
  195.         //Start slider loop
  196.         if( get_category_by_slug($category)->category_count > 0 && $q->have_posts() ) :?>
  197.         <div id="slider">
  198.          <?php
  199.         while($q->have_posts()) : $q->the_post() && has_post_thumbnail($post->ID);?>
  200.            
  201.             <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
  202.             <div class="nivo-caption2"><p><?php the_title(); ?></p></div>
  203.                 <?php the_post_thumbnail();?>  
  204.             </a>
  205.         <?php endwhile; //End slider loop  ?>
  206.             </div><!--/slider-->
  207.             <?php else: ?>             
  208.                 <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />    
  209.         <?php endif; ?>
  210.         </div><!-- #featured-image -->     
  211.         <?php
  212.         //Reset Query
  213.         wp_reset_query();
  214.         ?>     
  215. <?php }
  216. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement