Flickr Blog This to a WordPress Draft Post
Filed Under Geek, Hacks and Mods, Wordpress | 2009-11-19, 00:10
This is a boring geeky entry, but if you’re looking for this info it might be helpful. I’ve started a new blog (yes, another one) called My Cat Is Broken. It’s a collection of pics and videos of cats being, well broken. Usually it’s our cats. Everyone knows that Flickr is a great place to find cat pics, and I’ve started keeping my eye out for pictures of cats being dumb. When I find one, a quick click of the Blog This button, some title and text and it’s instantly on my site.
But I don’t necessarily want these pics to be published instantly, I’d rather they be saved as drafts for manual publishing later. I found links to an old plugin that’s not even available in the WordPress plugin database called Flickr Blog This To Draft, but the site was down, the plugin unavailable, and I was impatient. I took matters into my own hands.
A quick hack of the xmlrpc.php (in the root directory of my WordPress install) and I was in business. The line to change (as of WordPress 2.8.6) is line 2097 which has the following code:
$post_status = $publish ? ‘publish’ : ‘draft’;
There are multiple ways to change this, but I just commented out that line and hardcoded $post_status to draft.
// $post_status = $publish ? ‘publish’ : ‘draft’;
$post_status = ‘draft’;
The thing to remember here though is that when you upgrade WordPress to the next version for yet another security issue, you’ll have to redo this modification. If you make a copy of your xmlrpc.php file then you can just run a command line diff against the upgraded version after every upgrade. If that’s the only line that changed, copy it back, otherwise jump in manually and re-find that line and fix it. Note though that this means all of your posts will be automatically set to draft. In my case that’s perfectly alright, but you may want to toss some code in there to determine this based on your title or something (i.e. titles that start with “DRAFT” go to drafts, but anything else gets published).
WordPress Inserting Line Breaks In Front of Form Elements
Filed Under Geek, Wordpress | 2009-02-26, 13:37
So I’m working on a form for users to submit data on a WordPress-based site. I want it to look like this:
What I’m getting is this:
Those are screenshots, so here’s a “live” example:
Name:
Email:
Phone #:
Taking a look at the preview page using Firebug, I noticed that it was inserting <br /> in front of each input field. It did this with a select drop-down menu too. What gives? Anyone ever run into this?
Disqus Comment System Added
Filed Under PHP/MySQL, Wordpress | 2008-08-21, 16:01
Comments are both a love and a hate of mine. I love hearing back from people. It’s great to hear suggestions, arguments, opinions, etc. What I hate is the spam from comments and the not so great WordPress comment system. Don’t get me wrong WordPress, I know how much writing a good comment system sucks. I’m looking at doing this for some other sites that I coded from scratch, and let me tell you, I’m not looking forward to it.
So today I finally decided to install the Disqus plugin for WordPress. For those of you that browse a lot of blogs, chances are you’ve run across Disqus on a site. I’ve been wary of using a 3rd party for something as integral to a site as a comment system as I’ve been burned in the past. The latest Disqus plugin allows you to sync comments back to WordPress. This means that if sometime down the road I decided that the Disqus system isn’t for me, then I can switch back to the default WordPress comments without skipping a beat.
The installation of Disqus was almost painless. I downloaded the .zip file, extracted it into the plugins folder and activated the plugin. The configuration screen asked me for my username/password and then found my account and this blog. That was it. Disqus was setup. If this had been a brand new blog, I would have been done. However I wanted to import all my old WordPress comments into Disqus. So under the Advanced Options, I clicked Import. After a second of working it spit out text from all my comments, and an error saying php had run out of memory. I realized that Spam Karma 2 (a now outdated spam plugin) had marked a couple hundred comments as spam that Disqus was attempting to address. I went into Spam Karma, cleaned everything out and then ran an import again with success.
So what’s so great about Disqus? Well it uses a single sign-in across all the blogs that use it, so you won’t ever have to re-register on a new blog that has it installed. It also ties into FriendFeed for those of you that know what FriendFeed is. I hear it has good spam filtering, which I hope is 100% true. And it also integrates Seesmic, the video comment system that I’ve been meaning to get installed on here for awhile. So, leave me a video comment if you can! And the thing that sealed the deal was the ease of installation and the ability to rollback instantly should I hate it. If Disqus lives up to the expectations, I may also look into using it on my other sites since they plan to have an API soon and that would be great for integrating into my existing code. Let me know what you think of the new comment system.
Post to Twitter when you post to your blog
Filed Under Twitter, Wordpress | 2008-02-25, 12:15
I don’t like doing things manually when I can have software do my bidding. Usually I’ll send a twitter when I have a new blog post on here that I think people are interested in. (I recognize not everyone has my RSS feed in their feed reader…yet) But it’s a manual process and an extra step, so I went out and found Alex King’s Twitter Tools plugin. Alex King is a name forever associated in my head with WordPress, primarily for his help in finding themes back in the early days of WP. This plugin is pretty full-featured:
- Archive your Twitter tweets (downloaded every 15 minutes)
- Create a blog post from each of your tweets
- Create a daily digest post of your tweets
- Create a tweet on Twitter whenever you post in your blog, with a link to the blog post
- Post a tweet from your sidebar
- Post a tweet from the WP Admin screens
- Pass your tweets along to another service (via API hook)
I’ve currently got it set up to send to twitter when a post goes live on here. So in theory, when this post went live, it should have shown on my Twitter page.
UPDATE: Looks like Twitter Tools will post any edits to a posts if that blog post has not been twittered yet. Sorry for the twitter flood when I removed the “Uncategorized” category from a couple old posts. I’m going to look into manually adding the “twittered” metadata to all my posts so it doesn’t happen again.
UPDATE 2: Threw together a quick little php script to update the database so old posts aren’t twittered when they’re edited. YMMV, User beware, no warranty, etc. You’ll want to make a backup of your databases, then fill in your username, password, and database_name and then run this either from command line or via the browser.
/*--------code start--------*/ mysql_connect(localhost, "db_username", "db_password"); mysql_select_db("database_name"); $res1 = mysql_query("SELECT * FROM wp_posts p WHERE (p.post_status LIKE \"publish\")"); while ($row = mysql_fetch_array($res1, MYSQL_ASSOC)) { //find out if the TwitterTools metadata has already been written $sql2 = "SELECT * FROM wp_postmeta WHERE (post_id = ".$row['ID'].") && (meta_key LIKE \"aktt_tweeted\") && (meta_value LIKE \"1\")"; print "Post ID: ".$row['ID']."
\n"; if (!mysql_numrows(mysql_query($sql2))) { //metadata not found, let's fake it without twittering $sql = "INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES (".$row['ID'].",\"aktt_tweeted\",1)"; mysql_query($sql); print " -- added metadata to fake it.
\n"; } else { print " -- already been twittered.
\n"; } } /*--------code end--------*/
Image Upload Plugin for WordPress
Filed Under Tools, Websites, Wordpress | 2007-05-14, 01:06
I hate WordPress 2.x’s handling of images. Yes, I said it. In fact this one feature has kept some of my blogs on WordPress 1.x just because I like the plugin I found for uploading images and creating thumbnails all from a web interface, no need to load Photoshop. I just discovered that this plugin has been updated for WordPress 2.x. They just made my day! (Yeah, I noticed, they’ve been compatible since 12/2005, but I never got the memo!) For all your bloggers out there using WordPress 2.x that are frustrated with the image uploading and posting, I highly recommend checking out IImage Browser.
I do not like Internet Explorer
Filed Under Wordpress | 2006-10-18, 12:10
Due to IE not displaying the site correctly, we’ve moved back to a simple layout while we figure out what in the world is wrong. Everything displays exactly how we want it in Firefox, but in IE the side menus were missing, posts wouldn’t show, images wouldn’t low, and the digg buttons wouldn’t display. And then seemingly randomly, without any code changes, different parts of the front page would load. Quite strange and will require some muddling through the code to figure out why IE won’t play nice.
UPDATE: Ok, so it appears that the embedding of a Google Video is what broke things. We pulled it out of a previous post and all is well. I find it odd that Google would give me browser-breaking code. They should know better! Anyways, back to your regularly designed theme. :)