Viewing 15 replies - 16 through 30 (of 46 total)
  • wow, this is cool.. i must try this asap ??

    No one has a clue?

    A faster-executing incarnation of the date-blog hack (since I’m an optimizing-coder by day…) would be something like:

    function the_date_since($before = '', $after = ' back', $echo = 1)
    {
    global $post;
    $output = $before;
    $seconds = abs(time() - strtotime($post->post_date));
    $minutes = floor($seconds/60);
    $hours = floor($minutes/60);
    $days = floor($hours/24);
    $weeks = floor($days/7);
    $months = floor($days/30); // 30 is decent, better than weeks/4...
    $years = floor($days/365); // good enough.
    if ($years > 0)
    $output .= "over ".$years." year".($years>1?'s':'');
    elseif ($months > 0)
    $output .= $months." month".($months>1?'s':'');
    elseif ($weeks > 0)
    $output .= $weeks." week".($weeks>1?'s':'');
    elseif ($days > 0)
    $output .= $days." day".($days>1?'s':'');
    elseif ($hours > 0)
    $output .= $hours." hour".($hours>1?'s':'');
    elseif ($minutes > 0)
    $output .= $minutes." minute".($minutes>1?'s':'');
    else
    $output .= "just posted";
    $output .= $after;
    if ($echo) echo $output;
    else return $output;
    }

    What did I tweak?
    – progressive divisions (since divides are expensive ops).
    – progressive if/elseif (like chrisandabigail used) for only touching the single case to output.
    – inlined compares to decide whether to tack a ‘s’ if more than one of current time unit.
    Enjoy!
    =d

    I finally figured out what to include where.
    But, I still have a few questions.
    It will not show all the commentors for the last post or the current post, just a limit of 3 if I put a 1 in the php include or 1 if I put in a 0. *scratching my head at this as that doesn’t make any sense and I have no idea how to go about fixing it.*
    The code is below. Where can a strip_post tag go? I have a few commentors with \\\ or /// showing.
    <?php
    function comment_plugger($show = 0, $limit = 0, $sep = ‘, ‘, $none = ‘ none’) {
    global $wpdb, $tablecomments, $id;
    $cid = ($show) ? ($id – 1) : $id;
    $request = “SELECT DISTINCT comment_author_url, comment_author FROM $tablecomments”;
    $request .= ” WHERE comment_post_ID=’$cid’ AND comment_author <> ” AND comment_author_url <> ””;
    $request .= ‘ ORDER BY comment_author ASC’;
    $request .= ($limit > 0) ? “LIMIT $limit” : ”;
    $commentors = $wpdb->get_results($request);
    if ($commentors) {
    $output = ”;
    foreach ($commentors as $commentor) {
    if (!empty($commentor->comment_author_url)) {
    $output[] = ‘comment_author_url.'” title=”‘.$commentor->comment_author.'”>’.$commentor->comment_author.'<⁄a>’;
    }
    }
    }
    if (is_array($output)) {
    echo implode($sep, $output);
    } else {
    echo $none;
    }
    }
    ?>

    Is there a way to show the blog stats and the last few comments, unless it’s a passworded entry?

    HEH! IE is lame. It can’t parse the CSS here properly: LaughingLizards nick is so long that it messes the columns …
    Anyways, I love that archives hack!

    ?? Sorry Seraph…here let me mess it up one more time for you!

    I’ve implemented the Nicer Archives hack on my site (thanks for posting it), but I modified it so it would validate. Check it out here: https://www.tcervo.com/archives.php
    The modifications I made were pretty straightforward:
    * I gave all the select statements id’s, so that I could associate a label. (This was for Section 508 validation.)
    * In the archive_link() function, I changed the echo statement to read:
    echo “$siteurl/$blogfilename?p=&post->ID&c=1”;
    (I changed ampersand’s to & because the XHTML validator was throwing an error.)
    * I wrapped the form elements in an unordered list. At first I used div’s, but it was easier to style the select statements inline using li’s.
    That’s it! It now validates for XHTML 1.0, CSS, and Section 508.
    -Tony

    here’s my contribution of the the_date_since function:
    <code.
    <?php
    function the_date_since($before = ”, $after = ‘ago’, $echo = 1) {
    global $post;
    $output = $before;
    $seconds = abs(time() – strtotime($post->post_date));
    $minutes = floor($seconds/60);
    $seconds -= $minutes * 60;
    $hours = floor($minutes/60);
    $minutes -= $hours * 60;
    $days = floor($hours/24);
    $hours -= $days * 24;
    $weeks = floor($days/7);
    $days -= $weeks * 7;
    $months = floor($days/30); // 30 is decent, better than weeks/4…
    $weeks -= $months * 30;
    $years = floor($days/365); // good enough.
    if ($years > 0)
    $output .= “over “.$years.” year”.($years>1?’s, ‘:’, ‘);
    if ($months > 0)
    $output .= ($weeks>1?”:’and’).$months.” month”.($months>1?’s, ‘:’, ‘);
    if ($weeks > 0)
    $output .= ($days>1?”:’and’).$weeks.” week”.($weeks>1?’s, ‘:’, ‘);
    if ($days > 0)
    $output .= ($hours>1?”:’and’).$days.” day”.($days>1?’s, ‘:’, ‘);
    if ($hours > 0)
    $output .= ($minutes>1?”:’and’).$hours.” hour”.($hours>1?’s, ‘:’, ‘);
    if ($minutes > 0)
    $output .= ($seconds>1?”:’and’).$minutes.” minute”.($minutes>1?’s, ‘:’, ‘);
    if ($seconds > 0)
    $output .= ‘and ‘.$seconds.” second”.($seconds>1?’s ‘:’ ‘);
    /*else
    $output .= “just posted”;
    */
    $output .= $after;
    if ($echo) echo $output;
    else return $output;
    }
    ?>

    it’s a combination of codegirl’s and david’s codes.
    What does it do:
    1) it will display years, months, days, hours, minutes and seconds….
    2) it leaves out where the unit is 0
    3) Includes david’s progressive division
    4) Is smart enough to add an “and” before the last unit – ie, 4 Days, 3 hours, 25 minutes, and 12 seconds
    TG

    I really shouldn’t post when I’m a) tired, b) hungry, or c) both.
    Anyway, one of the changes I made to the Nicer Archives hack, so that it would validate, was typed incorrectly. Here’s the correct code:
    echo “$siteurl/$blogfilename?p=$post->ID&c=1”;
    Sheesh…I’m dangerous with a keyboard.

    How would I open the links for people who commented in a new window? (target=”_BLANK”) I don’t know php that well.. yet ^_^

    Ive added the code in my index file, but the comments dont show up.
    Ive copied the code and insert it as I should, but what am I doing wrong???

    I am talking about the previous comments hack.

    For the Get Blog Stats hack, where do I put it if b2functions is no longer in the 1.0 version?

Viewing 15 replies - 16 through 30 (of 46 total)
  • The topic ‘codergurl’s hacks’ is closed to new replies.