This hack adds an “Edit” link next to each entry if you’ve logged in and the cookie still exists on your computer. This is not the ultimate security, since the real security functions are still provided by b2verifauth.php, but it does hide the link from users who are not logged in.
To add this to your WordPress site:
1. Add the following code to your b2template.functions.php in the Post tags section:
/* Hack by Gabriel Serafini to add an "Edit" tag by */
/* each post if you're logged in */
function edit_this(){
global $id, $HTTP_COOKIE_VARS;
if (!empty($HTTP_COOKIE_VARS["wordpressuser"])) {
$output = '- <a href="/blog/wp-admin/wp-post.php?action=edit&post='.$id.'" title="Edit this post">Edit</a>';
echo $output;
}
}
2. Add the following code to your blog index page (usually index.php) where you want your edit tag to live:
<?php edit_this() ?>
I’ve placed mine next to the …posted in Category by Gabriel at … links at the bottom of each post.
The final result is a nice link that lets you instantly edit any post on your site, which is very nice if you tend to like to edit your posts on a regular basis.