WordPress.org

Ready to get started?Download WordPress

Forums

codergurl's hacks (46 posts)

  1. Laughinglizard
    Member
    Posted 10 years ago #

    Added your hacks to my list, including those of Jon, Mike and others. If anyone else has significant hacks for WP, please send me a link or simply logon and blog away at http://dinki.mine.nu/word/
    I figure when these hacks get put into their right place, my site will be a good starting point. :-)

  2. otaku42
    Member
    Posted 10 years ago #

    @Codergurl: you should consider to run the upgrade-script for 0.73 in order to get rid of the "[Unknown column 'comment_approved' in 'where clause']" messages that currently show up in your test-blog.

  3. Kathie
    Member
    Posted 10 years ago #

    The link to the auto commenter is dead for me.

  4. codergurl
    Member
    Posted 10 years ago #

    *blush* None of the links were working because I typed in the wrong directory. Try clicking on the link again.

  5. Kathie
    Member
    Posted 10 years ago #

    Oh works fine now :) Thank yoooou. I installed the commenter one. I just have one question... How can I get the links from the LAST post? I know you have to put 1 instead of 0 BUUUUT when I do that I also get the old comments in my comments site (the pop-up you know... where you comment on the recent post)?
    I would try it myself but Im not too familiar with php *blushes*

  6. codergurl
    Member
    Posted 10 years ago #

    Fixed.
    Change:
    $id = ($show) ? ($id - 1) : $id;
    To:
    $cid = ($show) ? ($id - 1) : $id;
    Change:
    WHERE comment_post_ID='$id'
    To:
    WHERE comment_post_ID='$cid'

  7. Kathie
    Member
    Posted 10 years ago #

    Awesome!!! Oh my god love you :D

  8. Kathie
    Member
    Posted 10 years ago #

    This is weird... I just posted a new entry and now it does the same like before... I had 4 comments, but they arent showing up. Instead it says that I havent had any comments so far :( Oh well.

  9. Kathie
    Member
    Posted 10 years ago #

    Nervmind. I thing whats wrong with it... Do you know how I change the 'number' of the post? Like my last post was number 46 but the most recent 49. How can I make it 47?

  10. codergurl
    Member
    Posted 10 years ago #

    oh, i thought about that last night after i made the last post. this wasn't such a good idea after all. i think it's time to go back to doing it the manual way. i'll try to get it done tomorrow. ;)

  11. Anonymous
    Unregistered
    Posted 10 years ago #

    I had issues with the getstats function, it didn't appear to be complete because it wasn't returning any values. I've hacked it into working shape and document it here :-
    function get_stats($what) {
    global $wpdb;
    switch($what) {
    case 'users':
    global $tableusers;
    $request = $wpdb->get_var("SELECT COUNT(*) FROM $tableusers WHERE user_level > 0");
    break;
    case 'posts':
    global $tableposts;
    $request = $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_status <> 'draft'");
    break;
    case 'comments':
    global $tablecomments;
    $request = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments");
    break;
    }
    echo $request;
    }

  12. Kathie
    Member
    Posted 10 years ago #

    Is it possible to put a target="_blank" in the comments hack? I tried and didnt work for me :|

  13. debwire
    Member
    Posted 10 years ago #

    I'm a wordpress and php newbie. For the above hacks, what files do we modify to insert the code or are we treating each hack as its own .php page (e.g., stats.php) and then calling that page from somewhere? Please put in layman's terms. Thanks.

  14. Cena
    Member
    Posted 10 years ago #

    Deb, looks like if you read the source, the instructions for placement are in the code.

  15. Anonymous
    Unregistered
    Posted 10 years ago #

    A slightly easier way to post the date since would be to just do the years if greater than months if greater than weeks,....ect... I have posted the code for my hack here (www.chrisandabigail.com).

  16. Anonymous
    Unregistered
    Posted 10 years ago #

    wow, this is cool.. i must try this asap :-)

  17. southerngal
    Member
    Posted 10 years ago #

    No one has a clue?

  18. davidchait
    Member
    Posted 10 years ago #

    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

  19. southerngal
    Member
    Posted 10 years ago #

    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;
    }
    }
    ?>

  20. southerngal
    Member
    Posted 10 years ago #

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

  21. seraph
    Member
    Posted 10 years ago #

    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!

  22. Laughinglizard
    Member
    Posted 10 years ago #

    :-P Sorry Seraph...here let me mess it up one more time for you!

  23. tcervo
    Member
    Posted 10 years ago #

    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: http://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

  24. TechGnome
    Moderator
    Posted 10 years ago #

    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

  25. tcervo
    Member
    Posted 10 years ago #

    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.

  26. Anonymous
    Unregistered
    Posted 10 years ago #

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

  27. macewan
    Member
    Posted 10 years ago #

  28. ludvig87
    Member
    Posted 10 years ago #

    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???

  29. ludvig87
    Member
    Posted 10 years ago #

    I am talking about the previous comments hack.

  30. asphodel
    Member
    Posted 10 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.