• I posted this earlier, but as anonymous, so I think it might have been lost in the shuffle.
    I’m writing a plugin that hooks on the “publish_post” action, which is supposed to be passed in the post ID. I wrote it, and registered it, but when I tested it, the post ID was not being passed in. The argument coming in was blank. After some debugging, I realized that there is by default already a function registered for “publish_post”, called “generic_ping”. “generic_ping” was getting the post ID passed in, but by the time my function was called, post ID was blank. Strange?
    So I took a look at the heart of the plugin system. It all boils down to this loop:
    foreach($functions as $function) {
    $string = $function($string);
    }

    There’s some other code that sorts the functions by priority and arranges them into that array. Then the foreach simply iterates through all the functions and calls them, with the appropriate piece of information passed in. But $string = $function($string) appears to imply that it is the plugged in function’s responsibility to pass the piece of information back out, so other plugins called later can also use it. “generic_ping” does not! It takes the post ID, but returns nothing. So any other plugin called after “generic_ping” won’t get the post ID.
    I worked around this problem by using a priority to register my plugin to be called before “generic_ping”, and by making sure that I return the post ID so that other plugins can get at it.
    So, am I right about all this? Can somebody confirm my understanding of the plugin system, and this bug in “generic_ping”?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Bug? In default “generic_ping” action for “publ’ is closed to new replies.