Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter doffer

    (@doffer)

    Guess I misunderstood you, because something got wrong… I’m getting this error: Parse error: parse error, unexpected T_STRING in /usr/home/web/wno14743/blog/wp-content/plugins/teb-word-count.php on line 27

    <?php
    /*
    Plugin Name: Word Count
    Plugin URI: https://www.jonas.rabbe.com/archives/2005/05/06/word-count-plugin-for-wordpress/
    Description: This plugin counts the number of words and images per post.
    Version: 1.0
    Author: Jonas Rabbe
    Author URI: https://www.jonas.rabbe.com/
    */

    // This just echoes the chosen line, we'll position it later
    function teb_word_count($display = true) {
    global $wpdb, $id;
    $post = $wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id");

    $post_content = apply_filters('the_content', $post);
    $words = trim(strip_tags($post_content));
    if( $words == '' ) {
    $wordcount = 0;
    } else {
    $words = explode(' ', $words);
    $wordcount = count($words);
    }
    $ret_words = number_format($wordcount) . ' ' . ($wordcount == 1 ? 'ord' : 'ord');

    $imagecount = preg_match_all('/<img/', $post_content, $images);
    $imagecount -=preg_match_all('/<img[^>]+(?=(class='wp-smiley'))/s', $post_content, $images);
    $ret_images = number_format($imagecount) . ' ' . ($imagecount == 1 ? 'bilde' : 'bilder');

    $text = $ret_words . ($imagecount > 0 ? ' og ' . $ret_images : '');

    if( !$display ) {
    return $text;
    }

    echo $text;
    }
    ?>

    Thread Starter doffer

    (@doffer)

    The regex is just messy to me, but the only thing I need is to exclude is the smiley directory… If someone could just add a line to make it work, I would be very happy, since I’m no hacker/coder my self ??

Viewing 2 replies - 1 through 2 (of 2 total)