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. Danny Wachsstock says:

    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)

  3. 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

  4. 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.

  5. Perry says:

    Quick question before I try this:

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

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

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

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

  7. djallyn says:

    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.

  8. 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.

  9. Jacob Santos says:

    In PHP 5.3, it would be.

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

  10. klitscher says:

    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.

  11. 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.