Mark on WordPress

WordPress puts food on my table.

One-line plugin of the day

with 29 comments

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 \"<script type='text/javascript'>\n<!--\naddLoadEvent(function(){jQuery('.edit-timestamp').click();});\n//-->\n</script>\";"),50);

Written by Mark Jaquith

July 30, 2008 at 12:47 pm

Posted in wordpress

29 Responses

Subscribe to comments with RSS.

  1. Hi Mark
    Where to put this code?

    MuslimBlogger

    July 30, 2008 at 1:49 pm

  2. Great idea!

    marilyn

    July 30, 2008 at 1:58 pm

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

    Haid Dasalami

    July 30, 2008 at 1:59 pm

  4. HAID,

    Try a browser that renders better…looks fine to me…

    klitscher

    July 30, 2008 at 2:21 pm

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

    JJ

    July 30, 2008 at 2:24 pm

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

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

    *scnr*

    Alex

    July 30, 2008 at 2:31 pm

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

    Danny Wachsstock

    July 30, 2008 at 3:59 pm

  8. Returns a syntax error for me.

    Brian Carnell

    July 30, 2008 at 4:02 pm

  9. [...] Mark on WordPress, publicaba un ejemplo de plugin de una sola línea, con el que hacemos que el panel de planificación de publicación aparezca desplegado por [...]

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

    Haid Dasalami

    July 30, 2008 at 6:34 pm

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

    UncleZeiv

    July 30, 2008 at 7:14 pm

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

    Mark Jaquith

    July 30, 2008 at 9:17 pm

  13. And to be clear, this is just the “PHP payload” portion of the plugin. Here it is as a proper plugin.

    Mark Jaquith

    July 30, 2008 at 9:20 pm

  14. Quick question before I try this:

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

    Perry

    July 30, 2008 at 11:03 pm

  15. Thanks but can you tell me why its not working on firefox though i tired with safari and it works well. still I am stumbling it here http://lindsayhogan.stumbleupon.com/ for all my SEO group at stumbleupon

    Lindsay Hogan

    July 31, 2008 at 3:17 am

  16. 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)

    Lee Kelleher

    July 31, 2008 at 4:41 am

  17. @Brian Carnell
    Did ya tried changing the ´ for ‘ quote?

    gOk

    July 31, 2008 at 8:24 am

  18. @Brian Carnell
    ‘ stands for simple quotes… this form mess it all xD~

    gOk

    July 31, 2008 at 8:25 am

  19. [...] Jaquith solves that problem with a one-line plugin that keeps the timestamp field open [...]

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

    djallyn

    July 31, 2008 at 1:49 pm

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

    Network Geek

    July 31, 2008 at 2:32 pm

  22. In PHP 5.3, it would be.

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

    Jacob Santos

    August 1, 2008 at 11:09 am

  23. Wrap it using the sourcecode shortcode:

    http://faq.wordpress.com/2007/09/03/how-do-i-post-source-code/

    Matt

    August 2, 2008 at 12:45 am

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

    klitscher

    August 2, 2008 at 10:19 am

  25. [...] Mark on WordPress, publicaba un ejemplo de plugin de una sola línea, con el que hacemos que el panel de planificación de publicación aparezca desplegado por [...]

  26. Didn’t know about that sourcecode shortcode. Done!

    Might be a good candidate for WordPress core.

    Mark Jaquith

    August 6, 2008 at 12:44 am

  27. 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);

    Austin

    August 6, 2008 at 8:00 am

  28. Returns a syntax error for me.

    serfman

    August 18, 2008 at 5:39 pm

  29. Dimana harus meletakkan kodenya

    salam dari hattp://myrazano.com

    terimakasih

    myrazano

    January 11, 2009 at 12:00 pm


Leave a Reply