• Resolved lexhair

    (@lexhair)


    Andrew…I wrote my own little plugin to tweet a post with the YOURLS shortlink. My plugin fires on the “draft”to”publish” action hook in wp_transition_post_status().

    I was digging through your code to determine when it creates a shortlink on a post going from Draft to Publish status because my tweets did not have the YOURLS shortlink included.

    Correct me if I’m wrong but it seems like for posts not going from future to publish, your plugin creates the YOURLS shortlink for draft posts going to published posts on the “save_post” hook. As I understand how WordPress posts, the “save_post” hook is fired after the “transition_post_status” hook. Since my plugin hooks into “draft_to_publish” hook, (which seemed logical to me), the YOURLS shortlink isn’t ready yet.

    My workaround was to change my plugin to the “wp_insert_post” hook which fires after “save_post”. However, when I do this and to prevent firing tweets when I update my post, I eliminated the ability for the function to fire when future posts transition to publish. So I added another hook for another function to fire on the “future_to_publish” hook which modifies the arguments I send to the original function. Your plugin uses the transition_post_status hook which fires before “future_to_publish” so the YOURLS shortlink should be ready when my function fires.

    My workaround is fine but required quite a bit of research looking at thee core’s sequence of firing do_action() events. If you would include a do_action() hook after your plugin creates a new shortlink and pass the $post object, I could have hooked into your plugin and not worried about the core works to that level of detail.

    Thanks for a great plugin.
    John
    NYC USA

    https://www.ads-software.com/plugins/yourls-link-creator/

Viewing 16 replies (of 16 total)
  • Thread Starter lexhair

    (@lexhair)

    I keep forgetting about mod plugins. No worries. Simple enough to pull the object when I need it. Thanks again!!!

Viewing 16 replies (of 16 total)
  • The topic ‘YOURLS hooks’ is closed to new replies.