_publish_post_hook( int $post_id )
- Since
- 2.3.0
- Source
wp-includes/post.php:7997
Hook to schedule pings and enclosures when a post is published.
Description
Uses XMLRPC_REQUEST and WP_IMPORTING constants.
Parameters
$post_idint- The ID of the post being published.
Hooks fired · 1
One hook fires while _publish_post_hook() runs, in this order:
- do_action( xmlrpc_publish_post )actionline 8006 (+9 into the body)
Fires when _publish_post_hook() is called during an XML-RPC request.
Uses · 6
- do_action()Calls the callback functions that have been added to an action hook.
- get_option()Retrieves an option value based on an option name.
- add_post_meta()Adds a meta field to the given post.
- get_to_ping()Retrieves URLs that need to be pinged.
- wp_next_scheduled()Retrieves the timestamp of the next scheduled event for the given hook.
- wp_schedule_single_event()Schedules an event to run only once.
Source
function _publish_post_hook( $post_id ) { if ( defined( 'XMLRPC_REQUEST' ) ) { /** * Fires when _publish_post_hook() is called during an XML-RPC request. * * @since 2.1.0 * * @param int $post_id Post ID. */ do_action( 'xmlrpc_publish_post', $post_id ); } if ( defined( 'WP_IMPORTING' ) ) { return; } if ( get_option( 'default_pingback_flag' ) ) { add_post_meta( $post_id, '_pingme', '1', true ); } add_post_meta( $post_id, '_encloseme', '1', true ); $to_ping = get_to_ping( $post_id ); if ( ! empty( $to_ping ) ) { add_post_meta( $post_id, '_trackbackme', '1' ); } if ( ! wp_next_scheduled( 'do_pings' ) ) { wp_schedule_single_event( time(), 'do_pings' ); }}History
Introduced in 2.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.