Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(TEMPLATEPATH . '/controlpanel.php');
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Right Column',
- 'before_widget' => '<div id="%1$s" class="widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h2 class="sidebartitle">',
- 'after_title' => '</h2>',
- ));
- /*
- Original Plugin Name: Limit Posts
- Original Plugin URI: http://labitacora.net/comunBlog/limit-post.phps
- Usage: the_content_limit($max_charaters, $more_link)
- */
- //thumbnail previews
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 100, 100, true ); // 50 pixels wide by 50 pixels tall, hard crop mode
- function content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
- $content = get_the_content($more_link_text, $stripteaser, $more_file);
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- $content = strip_tags($content, '<p>');
- if (strlen($_GET['p']) > 0) {
- echo "<p>";
- echo $content;
- echo "...";
- echo " <a href='";
- the_permalink();
- echo "'>".$more_link_text."</a>";
- echo "</p>";
- }
- else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
- $content = substr($content, 0, $espacio);
- $content = $content;
- echo "<p>";
- echo $content;
- echo "...";
- echo " <a href='";
- the_permalink();
- echo "'>".$more_link_text."</a>";
- echo "</p>";
- }
- else {
- echo "<p>";
- echo $content;
- echo "...";
- echo " <a href='";
- the_permalink();
- echo "'>".$more_link_text."</a>";
- echo "</p>";
- }
- }
- remove_filter('get_the_excerpt', 'wp_trim_excerpt');
- add_filter('get_the_excerpt', 'replacement_custom_trim_excerpt');
- function replacement_wp_trim_excerpt($text) {
- $raw_excerpt = $text;
- if ( '' == $text ) {
- $text = get_the_content('');
- $text = strip_shortcodes( $text );
- $text = apply_filters('the_content', $text);
- $text = str_replace(']]>', ']]>', $text);
- $text = strip_tags($text);
- $excerpt_length = apply_filters('excerpt_length', 55);
- $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
- $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
- if ( count($words) > $excerpt_length ) {
- array_pop($words);
- $text = implode(' ', $words);
- $text = $text . $excerpt_more;
- } else {
- $text = implode(' ', $words);
- }
- }
- return $text;
- //return apply_filters('replacement_wp_trim_excerpt', $text, $raw_excerpt);
- }
- //this is the function that is actually used for setting excerpt length
- function new_excerpt_length($length) {
- return 100;
- }
- add_filter('excerpt_length', 'new_excerpt_length');
- //replace [...]
- function new_excerpt_more($more) {
- return '<i> <a href="' . get_permalink($post->ID) . '">(Continue Reading)</a></i>';
- }
- add_filter('excerpt_more', 'new_excerpt_more');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement