A WordPress-centric search engine for devs and theme authors



_publish_post_hook ›

Since2.3.0
Deprecatedn/a
_publish_post_hook ( $post_id )
Access:
  • private
Parameters:
  • (int) $post_id The ID in the database table of the post being published.
    Required: Yes
Defined at:
Codex:

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

Uses XMLRPC_REQUEST and WP_IMPORTING constants.



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' );
	}
	add_post_meta( $post_id, '_encloseme', '1' );

	if ( ! wp_next_scheduled( 'do_pings' ) ) {
		wp_schedule_single_event( time(), 'do_pings' );
	}
}