what is the earliest point in a wordpress page load where I can detect the post that is being requested? -


what earliest wordpress action post shown can detected reliably ? (either using global $post or detecting wp_query object or other way)

eg. plugin needs detect incoming request plugin on different site, @ moment checks $_post var possible using add_action('plugins_loaded' , callback function uses $post = get_page_by_path($_server['request_uri'],'','post') $post object , uses post data other information used process response gets sent before headers or other standard wp processing happens intention of lessening load on blog receiving request.

is there better way?, know there isn't earlier way because 'plugins_loaded' action gets called right after , well, plugins loaded there more reliable way using get_page_by_path ?

i’d try filter 'the_posts'. find in wp-includes/query.php function get_posts(). passes found posts array reference, can use action.

here plugin use inspect hooks:

<?php /* plugin name: hook check description: inspects hook , prints information footer. version:     1.0 required:    3.1 author:      thomas scholz author uri:  http://toscho.de license:     gpl */ ! defined( 'abspath' ) , exit;  $globals['hook_checks'] = apply_filters(     'hook_check_filter' ,   array ( 'the_posts' ) );  foreach ( $globals['hook_checks'] $hc_hook ) {     add_action( $hc_hook, array( 'hook_check', 'catch_info' ) ); } add_action( 'wp_footer', array( 'hook_check', 'print_info' ) );  class hook_check {     static $info = array ();      public static function catch_info()     {         $args = func_get_args();         self::$info[ current_filter() ] = print_r( $args, true );         return $args[0];     }      public static function print_info()     {         if ( empty ( self::$info ) )         {             return;         }          print '<pre>';         foreach ( self::$info $filter => $catched )         {             print "<b>$filter</b>\n" . htmlspecialchars( $catched );         }         print '</pre>';     } } 

reduced sample output:

array (     [0] => array         (             [0] => stdclass object                 (                     [id] => 112                     [post_content] => entire content …                     [post_title] => awesome title                     [post_excerpt] =>                      [post_status] => publish                 )         ) ) 

this should give information need possible.

oh, , hope see on https://wordpress.stackexchange.com/ such questions. :)


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -