One-line plugin of the day

Opens the post timestamp editing fields without you having to click the “Edit” link every time. Great for people who are always scheduling their posts.

add_action('admin_head',create_function('$a', "echo \"\n<!--\naddLoadEvent(function(){jQuery('.edit-timestamp').click();});\n//-->\n\";"),50);

29 thoughts on “One-line plugin of the day

  1. I’m aware you’re a premier WP guru, but this is not that helpful, Mark. It doesn’t concern you that the syntax extends through the sidebar, making it hard (but not impossible) to copy (or even read) the line?

    Speaking of plugins, there are plugins to handle this problem that occurs with long HTML fragments, which won’t wrap like text. You may want to look into one of them.

    Regards,

    HAID

  2. I’m using FF 2.0.0.16. The line of code extends way beyond my miserable 1024 by 768 screen.

  3. That’s nothing … all of my plugins are one-liners:

    perl -pe 's|\n||' plugin.php > plugin2.php

    *scnr*

  4. jQuery is smarter than you give it credit for.
    The line:

    if (jQuery(‘.edit-timestamp’)) { jQuery(‘.edit-timestamp’).click(); }

    is redundant; empty jQuery objects don’t throw errors if you use them, they just do nothing. So all you need is:

    jQuery(‘.edit-timestamp’).click();

    (And putting some spaces in may help it wrap away from the sidebar)

  5. klitsch,

    Hadn’t thought of that. I’m just used to presuming everything renders better in FireFox. Turns out, IE7 wraps the text to fit the content area. Who’da thunk it?

    So, by “better browser,” do you mean IE7?

    LOL. That’s a new one.

    Regards,

    HAID

  6. Ouch: I’m just out of a scheduling-intense week and I would have used this a lot… too late now 😉 Thanks anyway for sharing!

  7. Haid,

    I use Safari for my day-to-day browsing (but Firefox for development). Looks fine in Safari. In any case, I inserted manual line breaks to fix it up.

    Danny,

    Nice! jQuery continues to amaze me. I’ve updated to remove that conditional wrapper. That’s good to know.

  8. Quick question before I try this:

    Is it WordPress version dependent? (i.e., 2.5, 2.0.11, etc.?)

  9. Loving the one-line plugin… any more gems?

    Just a thought about the source-code in your post, why not use the [sourcecode] short code?

    (I like the the “copy to clipboard” quick link it has)

  10. There is a problem just clicking the edit time link? I schedule ALL of my posts, and I don’t have any problem just clicking the link.

  11. If you add this to the functions.php file in a theme, will that make this work? Seems like the perfect added functionality to slip quietly into a theme to me.

  12. In PHP 5.3, it would be.

    $javascript = function ($a) { echo ”
    \n\n
    “; };
    add_action(‘admin_head’, $javascript, 50);

  13. Haid,

    Hmm…I was in FF3, so by better browser I definitely didn’t mean IE. I must have caught it after the code was edited. Regardless, it looks nice now.

  14. You may as well let jQuery handle the DOM load event itself, as it makes the code a little shorter.

    add_action('admin_head',create_function('$a', "echo \"jQuery(function(j){j('.edit-timestamp').click();});\";"),50);

Comments are closed.