1. <?php
  2. require_once(TEMPLATEPATH . '/controlpanel.php');
  3. if ( function_exists('register_sidebar') )
  4.     register_sidebar(array(
  5.         'name' => 'Right Column',    
  6.         'before_widget' => '<div id="%1$s" class="widget">',
  7.         'after_widget' => '</div>',
  8.         'before_title' => '<h2 class="sidebartitle">',
  9.         'after_title' => '</h2>',
  10.     ));
  11.  
  12.    
  13.    
  14.     /*  
  15. Original Plugin Name: Limit Posts
  16. Original Plugin URI: http://labitacora.net/comunBlog/limit-post.phps
  17. Usage: the_content_limit($max_charaters, $more_link)
  18. */
  19.  
  20. //thumbnail previews
  21. add_theme_support( 'post-thumbnails' );
  22. set_post_thumbnail_size( 100, 100, true ); // 50 pixels wide by 50 pixels tall, hard crop mode
  23.  
  24. function content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
  25.     $content = get_the_content($more_link_text, $stripteaser, $more_file);
  26.     $content = apply_filters('the_content', $content);
  27.     $content = str_replace(']]>', ']]&gt;', $content);
  28.     $content = strip_tags($content, '<p>');
  29.  
  30.    if (strlen($_GET['p']) > 0) {
  31.         echo "<p>";
  32.         echo $content;
  33.         echo "...";
  34.         echo "&nbsp;<a href='";
  35.         the_permalink();
  36.         echo "'>".$more_link_text."</a>";
  37.         echo "</p>";
  38.    }
  39.    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
  40.         $content = substr($content, 0, $espacio);
  41.         $content = $content;
  42.         echo "<p>";
  43.         echo $content;
  44.         echo "...";
  45.         echo "&nbsp;<a href='";
  46.         the_permalink();
  47.         echo "'>".$more_link_text."</a>";
  48.         echo "</p>";
  49.    }
  50.    else {
  51.         echo "<p>";
  52.         echo $content;
  53.         echo "...";
  54.         echo "&nbsp;<a href='";
  55.         the_permalink();
  56.         echo "'>".$more_link_text."</a>";
  57.         echo "</p>";
  58.    }
  59. }
  60.  
  61. remove_filter('get_the_excerpt', 'wp_trim_excerpt');
  62. add_filter('get_the_excerpt', 'replacement_custom_trim_excerpt');
  63.  
  64. function replacement_wp_trim_excerpt($text) {
  65.     $raw_excerpt = $text;
  66.     if ( '' == $text ) {
  67.         $text = get_the_content('');
  68.  
  69.         $text = strip_shortcodes( $text );
  70.  
  71.         $text = apply_filters('the_content', $text);
  72.         $text = str_replace(']]>', ']]&gt;', $text);
  73.         $text = strip_tags($text);
  74.         $excerpt_length = apply_filters('excerpt_length', 55);
  75.         $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
  76.         $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
  77.         if ( count($words) > $excerpt_length ) {
  78.             array_pop($words);
  79.             $text = implode(' ', $words);
  80.             $text = $text . $excerpt_more;
  81.         } else {
  82.             $text = implode(' ', $words);
  83.         }
  84.     }
  85.     return $text;
  86.     //return apply_filters('replacement_wp_trim_excerpt', $text, $raw_excerpt);
  87. }
  88.  
  89. //this is the function that is actually used for setting excerpt length
  90. function new_excerpt_length($length) {
  91.     return 100;
  92. }
  93. add_filter('excerpt_length', 'new_excerpt_length');
  94.  
  95.  
  96. //replace [...]
  97. function new_excerpt_more($more) {
  98.     return '<i>&nbsp;&nbsp;&nbsp;<a href="' . get_permalink($post->ID) . '">(Continue Reading)</a></i>';
  99. }
  100. add_filter('excerpt_more', 'new_excerpt_more');
  101.  
  102. ?>