what is the earliest wordpress action where the post that will eventually be shown can be detected reliably ? (either by using global $post or detecting the wp_query object or other way)
eg. my plugin needs to detect an incoming request from another plugin on a different site, at the moment it checks for a $_POST var as early as possible by using add_action('plugins_loaded' and the callback function uses $post = get_page_by_path($_SERVER['REQUEST_URI'],'','post') to get the $post object and then uses the post data to get any other information that is used to process the response which gets sent back before any headers or other standard WP processing happens with the intention of lessening the load on the blog receiving the request.
is there a better way?, I know there isn’t an earlier way because 'plugins_loaded' action gets called right after the , well, plugins get loaded but is there a more reliable way than using get_page_by_path ?
I’d try the filter
'the_posts'. You find it inwp-includes/query.phpfunctionget_posts(). It passes the found posts as a array by reference, so you can use it like an action.Here is a plugin I use to inspect hooks:
Reduced sample Output:
This should give you all information you need as early as possible.
Oh, and I hope to see you on https://wordpress.stackexchange.com/ with such questions. 🙂