Wanted: Excerpt Exacter

Published 16 years, 4 months past

So after I once again published a post without filling in the excerpt, thus forcing me to go back to fill it in later, I tweeted in a fit of pique:

I need a WordPress plugin that won’t let me publish a post until I’ve filled in the excerpt field. Anyone got one?

To which I got a whole lot of responses saying, in effect, “Oooo!  Good idea!  I need that too!  Let me know when you find one!”  Some of them came from people running fairly high-profile blogs.  The need clearly exists.  A couple of responses were of the “I could do that!” variety, so I thought I’d post here so as to describe how I think it ought to work from the user’s perspective, and then we can hash things out in comments and someone can code it up and make everyone happy.

So really what I want is, when I push the “Publish” button in WordPress, the plugin checks to see if there’s an excerpt.  If not, one of two things happens:

  1. The plugin throws up a warning dialog telling me that I’m about to post without an excerpt (again).  If I say “Okay”, it goes ahead with publishing.  If I say “Cancel”, it returns me right back to where I was, which is the “Write Post” page, with all the data intact and unaltered.

  2. The plugin returns me to the “Write Post” page with all data intact and unaltered, and puts an error box at the top of the page telling me I forgot to write an excerpt (again) and that it won’t let me publish until I fix the problem.

One or the other.  I think I like #1 a little better, but I’d be good either way.  I’m open to other approaches as well, but I don’t think the plugin should rely on JavaScript, as that means leaving out people who don’t enable JavaScript or post from JS-incapable devices.

I would do this myself, but I’m a little wary of the “return to the page with all data intact and unaltered” bit, which I would imagine is pretty easy to mess up.  Thus I’m putting it up here as a semi-Lazyweb post so that someone else, someone with more experience with WordPress and plugin authoring, can do it right and quickly.

Okay, who’s on it?


Comments (19)

  1. Ooo…I think that could be done. #1 would definitely be easier than #2.

    I do love a challenge though :)

  2. I’m on it. Nothing like a small plugin challenge to keep the mind energized.

    Will report back when I have a working prototype. Shouldn’t be too long. :)

  3. Eric, I can hand this off to a guy at work — and willingly so because Jim (our fearless leader) wants every post to have an excerpt before it gets posted. I’d jump on it myself except I’m pretty jammed up right now.

    As I twitted back to you this afternoon, I’d have it check (on-click) to see if you had included an excerpt. If not, the best way to return you to the editing page would be to first save the post as a Draft and take you back to the post edit page. Else, you could publish it anyway.

    You could build into the admin page an option for the “post anyway” or “never post without” choice and therefore have it both ways.

    It would be a simple test to look for the presence of the_excerpt() and run from there.

    Personally, I’d make it look cool by using a jQuery lightbox-style dialog box with one of the pre-installed jQuery plugins in the WP Admin area, but that’s just me playing with the eye candy… ;-)

  4. Pingback ::

    Wanted: Excerpt Exacter

  5. WP 2.5 admin uses jquery right? I bet you could just insert a little script that gives you a confirmation box if the excerpt field is empty.

  6. Okay. Version 1.0 is ready.
    http://hamstu.com/uploads/NeverForgetcerpt.zip

    Some notes
    So yeah, it’s called Never Forgetcerpt, haha, maybe a little lame but hey, who cares. It works as far as I can tell, only tested in WordPress 2.5, and it uses jQuery, so with older WP installs probably won’t work so well, i.e. at all. See the readme.txt for more info.

    *glances at footer* — Whoah, Eric, are you really using WP 1.5? Hmm, probably isn’t going to work for you. You gotta upgrade man!

    Anyway, it’s GNU licensed, anyone feel free to take it and do what you like with it. I hope it’s useful to some.

    Cheers,
    Hamish

  7. I use this “hack”, use it in loop:
    <?php if ( ($post->post_excerpt != '') && (!is_single()) ) {the_excerpt(); }
    else the_content('Прочтём до конца?',strip_teaser);?>

  8. wow, the plug-in is already available even before I get to leave a comment… Good job Hamish!

  9. I have a related problem: The automated excerpt would be fine, if it included pictures, and included the first paragraph rather than first X characters.

    90% of the time the above approach would be what I intended, the other 10% would still be closer, but I would edit it slightly.

  10. “Whoah, Eric, are you really using WP 1.5?”

    The source says it’s the latest, so I’d assume the footer is just content.

  11. Very cool, Hamish! Thank you! There’s one thing about it that worries me, which is that it doesn’t save anything. So if I accidentally close my browser window because I see a little pop-up I want to dismiss and my muscle memory kicks out a command-W, I’ll lose whatever changes I made right before hitting “Publish”. 95% of the time, that won’t happen, but the other 5% will be really annoying. Is there any way to modify things so that a save-draft operation is fired right before putting up the warning box?

    Oh, and I’m on the latest version; I just hadn’t updated my footer. Thanks for reminding me to get it fixed.

  12. This seems to be solved already, but Ecto (not a plugin) also optionally gives warnings if you try to post without an excerpt, category, and/or (maybe?) tags.

  13. Hey, thanks a lot Eric! I’m glad you like it.

    I’ve now updated the plugin to autosave when you click either Save or Publish. Same address: http://hamstu.com/uploads/NeverForgetcerpt.zip

    Also, I’m glad to hear you’re not actually using WordPress 1.5. You had me worried there for a minute!

  14. So awesome, Hamish. You rock.

    Now, what do you think of extending your excellent work into a more complex plugin called (for example) “Forget-Meta-Not” which lets the user set preferences to warn them if they’ve forgotten any of excerpt, categories, or tags? (Inspired by both my further thinking and Adam mentioning what Ecto does.)

  15. Great idea. I know I’ve forgotten categories, tags, etc. before as well, so that would be quite useful.

    I’ll see what I can do.

  16. Pingback ::

    NeverForgetcerpt Plugin :: WPLover

    […] begins from CSS godfather Eric Meyer’s tweet a few days ago, which then turns into a blog post: NeverForgetcerpt, a plugin that will warn you if you’re posting an article without creating […]

  17. Pingback ::

    The manual Excerpt in WordPress. What, why, how, tips and plugins - op111.net

    […] Wanted: Excerpt Exacter […]

  18. Hi there :)

    Sounds like just what I need! however, the link is dead… can anyone please point me in the direction of this plugin?

    Thanks

    /Doug

  19. Pingback ::

    WordPress plugin: Admin Anti-forget Alarm » Tiago Madeira

    […] to fix some stuff before publishing something, and it looks like this is a useful feature for other people as well. There is even a Require Thumbnail plugin in the WordPress Plugin Directory that seems to […]

Add Your Thoughts

Meyerweb dot com reserves the right to edit or remove any comment, especially when abusive or irrelevant to the topic at hand.

HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <em> <i> <q cite=""> <s> <strong> <pre class=""> <kbd>


if you’re satisfied with it.

Comment Preview