Posts filed under ‘wp hacks’
upgraded to wordpress 2.3
December 22nd, 2007
I’ve upgraded to wordpress 2.3 mainly to use their new sidebar widget feature. I thought it will be overly cool to not have to rewrite the sidebar.php for every theme. However, I’d like to have different sidebars for different views. Like the sidebar for my index page would look different than the sidebar for my single post. I haven’t yet figured out how to create additional sidebar for a theme. Do you know how to do it? Please share if you do. Thanks! N/M I figured out. It’s talked about here.
Consider the Ultimate Tag Warrior 3 plugin
If you are like me and use the UTW plugin, you might notice wordpress 2.3 now has its own native tags support. After the upgrade, I notice the old tags are not converted. I thought there must be already a way to convert them. Fortunately for us, wordpress 2.3 has also a built in way to convert your tags from the UTW plugin. Just go to your wordpress admin and look under Manage > Import. You will see the UTW import option.
disable wordpress smiley for a certain post/page
February 2nd, 2006
okie, i thought someone has figured it out by now. but when i asked on the wordpress board, i got no response. so i digged around and figured a hack for it.
i noticed sometimes esp. on some pages, the smiley conversion does a poor job and converts the wrong text into smilies. it really mars my content. personally i want to be able to just turn the smiley off for a certain post or page.
the best way i can think of to do it is via a hack.
open your wp-includes/functions-formatting.php file, try find the function (possibly line 576):
function convert_smilies($text) {
then under it, replace:
global $wp_smiliessearch, $wp_smiliesreplace; $output = ''; if (get_settings('use_smilies')) {
with:
global $wp_smiliessearch, $wp_smiliesreplace, $post; $output = ''; $smileykey = get_post_meta($post->ID, "disable_smiley", TRUE); if (get_settings('use_smilies') && $smileykey != 'true') {
that’s all i needed to do.
now next time you write a new post/post, simply create a custom field with the key disable_smiley and value true to disable smiley conversion for just that post/page. isn’t that neat?
dodos threaded comments for wp 2.0
January 31st, 2006
as you see, i’ve reinstalled dodos threaded comments hack for wp 2.0. feel free to test it out here.
i’ve released the new version here. i can not provide much support due to my busy schedule. however for the next few days, if you try it and find obvious errors in the steps, i will take a look.
good luck!
moving pure-essence.net
January 29th, 2006
moving pe is a big project. right now i’m only 30% of the way there. it was a pain moving all the database due to their sizes but i finally finished it.
i’m taking my time to check out all the wonderful new features & looks that comes with
wp 2.0. while browsing for potential plugins, i found these quite interesting:
fight comment spam plugin (wordpress hashcash)
- i probably will not install this right a way. the fact it uses ajax concerns me. nonetheless this is one of the best comment spamming projects i’ve seen out there. i will keep my eyes on it. during the move, when i was reviewing my comments data, i had to manually delete around 2mb of comments spam that somehow got logged into my table. most of them remind me a lot of
header injection
. so i added a few lines of codes to my post file to hopefully help reduce spams.
// to prevent header injection
if (eregi("\r",$_POST['email']) || eregi("\n",$_POST['email'])) { exit; }
// names must be alpha only
if(eregi("[^a-zA-Z]+", $_POST['author'])) die("Name must not contain characters other than a-z.");
the second part enforces user to enter only alphabetical inputs for the commenter name.
the awesome flickr & wordpress plugin
- now this looks extremely interesting. i will probably install it. i spent a lot of time writing a php gallery script but it might be hard integrating it with wordpress. i love the flexibility of flickr. i think it is a much better choice.
old hacks need to be upgraded
February 16th, 2005
a lot of old plugins or hacks for wp 1.2 is no longer working for wp 1.5
here are the ones i encountered and how i fixed them. they might not be the most ideal fixes but they worked for me.
(more…)
dodos threaded comments for wp 1.5
February 16th, 2005
OMG what a pain! yes i’ve already upgraded my domain to wp 1.5 and i spent the past 5 hours writing how to add the threaded comments back for v1.5. it’s easy for myself to add it back; i just kept my old index.php and my old wp-comments.php. if you want to do that, DO IT. if you do that, you can just add the following two functions to your wp-includes/comment-functions.php
GRAB the old dodos_thread() function for your old wp-includes/functions.php and move it to the new wp-includes/functions.php
add dodo’s modified wp_notify_postauthor() to wp-includes/comment-functions.php
otherwise download my guide here – again it took me five hours to write and figure out coz they freaking changed A LOT of code @_@ arg i will never do it again next time they release a new version.
you can test my threaded comments feature on a refresh install of wp 1.5 here
threaded comments notification
January 23rd, 2005
ok i guess when i wrote up my threaded comments hack, i did not include the feature where the comment author who you are replying to will get notified by email. hrm it’s just an update in your functions.php under wp-includes.
here’s my code. you can replace your old wp_notify_postauthor function with it.
like always. BACK UP before you overwrite anything.
small bug fix – spotted by ecila
the reply notification does not include the commenter’s email address so i added it in now.
more for the ultimate comment idea
January 19th, 2005
in addtion to the previous post, i wrote a piece of code where you can add above
$wpdb->query("INSERT INTO $tablecomments
in your wp-comments-post.php to have it delete unapproved comments that’s ___ days old
//// Auto delete unapprove comments if the comment is ___ days old
$how_old_comment = 10; // 10 days
$current_time = time();
$comment_date = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_approved='0'");
$comment_time = mysql2date('U', $comment_date) + $how_old_comment * 24 * 3600;
if($comment_time < $current_time) { // delete the comment
$wpdb->query("DELETE FROM $tablecomments WHERE comment_approved='0' AND comment_date='$comment_date'");
} //// End delete unapprove comments if the comment is ___ days old
i haven’t thoroughly tested this code. if you have problems, let me know.
also here’s a script you can run to get rid of blank and/or invalid email addresses in your comments table. get the code here, paste it to a text file. modify the $default_email variable and name it dodos_update_blank_emails.php. then upload the script to your wp root directory and run it. do it at your own risk. i have tested it on my own site and it worked for me.
the ultimate comment idea
January 18th, 2005
i really like skippy’s self comment moderation plugin.
The basic idea is that if the user supplies a valid email address, and they check that email account, then the commenter is most likely not a spammer.
altho not foolproof, i like it better than asking people entering a certain code. plus this way it does not only fight spam, it also fights flamers. because from my personal experience, most flamers are too chicken **** to leave their real email addresses. this way i don’t need to waste my time to read their worthless comments.
i think it’s kinda annoying to ask your regular commenters repeatedly moderate their own comments. so i added a little modification where your script tests if the commenter’s email already exists in the database or not. if it does, it will be automatically approved, otherwise an email with an approval link is sent to the user.
i also thought of the idea to apply skippy’s filter only after a post is certain days old.
you are welcome to use either or both.
How to use my trick:
1. install skippy’s plugin. modify your $seed variable. activate it. upload moderation.php to your wp root directory.
2. make sure in your wp control panel, under options -> discussion “An administrator must approve the comment (regardless of any matches below)” is UNCHECKED.
3. open wp-comments-post.php and find the line:
$wpdb->query("INSERT INTO $tablecomments
if you wish to use auto unapprove comments after the post is __ many days old. add above
//// Auto unapprove comments if a post is ___ days old $how_old = 7; // 7 days $current_time = time(); $post_date = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE ID='$comment_post_ID'"); $post_time = mysql2date('U', $post_date) + $how_old * 24 * 3600; if($post_time < $current_time && $approved == 1) { $approved = 0; } //// End unapprove comments if a post is ___ days old
if you wish to use auto unapprove comments if the commenter’s email addy is new. add above
//// Auto unapprove comments if the commenter's email is not recognized from the database $comment_author_email_exist = $wpdb->get_var("SELECT comment_author_email FROM $tablecomments WHERE comment_author_email='$email' AND comment_approved='1' LIMIT 1"); if(empty($comment_author_email_exist) && $approved == 1) { $approved = 0; } //// End unapprove comments if the commenter's email is not recognized from the database
you like my new code button?
August 17th, 2004
updated
- old comments are deleted because i have improved my script. so far i haven’t seen any errors. feel free to test more
check out my new code button in the comments field.. it actually replaces my other “better handle <code>” hack – test it out in the comments area by click on the “code” button
and let me know how you like it. if it’s worthwhile to release it as a hack.

