_publish_post_hook

Hook to schedule pings and enclosures when a post is published.

Description

_publish_post_hook( (int) $post_id ); 

Uses XMLRPC_REQUEST and WP_IMPORTING constants.

Parameters (1)

0. $post_id (int)
The ID in the database table of the post being published.

Usage

  1. if ( !function_exists( '_publish_post_hook' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // The ID in the database table of the post being published. 
  5. $post_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _publish_post_hook($post_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function _publish_post_hook( $post_id ) { 
  2. if ( defined( 'XMLRPC_REQUEST' ) ) { 
  3. /** 
  4. * Fires when _publish_post_hook() is called during an XML-RPC request. 
  5. * @since 2.1.0 
  6. * @param int $post_id Post ID. 
  7. */ 
  8.  
  9. if ( defined('WP_IMPORTING') ) 
  10. return; 
  11.  
  12. if ( get_option('default_pingback_flag') ) 
  13. add_post_meta( $post_id, '_pingme', '1' ); 
  14. add_post_meta( $post_id, '_encloseme', '1' ); 
  15.  
  16. wp_schedule_single_event(time(), 'do_pings');