_publish_post_hook

The timeline below displays how wordpress function _publish_post_hook has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.9

/**
 * Hook to schedule pings and enclosures when a post is published.
 *
 * Uses XMLRPC_REQUEST and WP_IMPORTING constants.
 *
 * @since 2.3.0
 * @access private
 *
 * @param int $post_id The ID of the post being published.
 */
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');
    }
}

WordPress Version: 5.3

/**
 * Hook to schedule pings and enclosures when a post is published.
 *
 * Uses XMLRPC_REQUEST and WP_IMPORTING constants.
 *
 * @since 2.3.0
 * @access private
 *
 * @param int $post_id The ID in the database table of the post being published.
 */
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');
    }
}

WordPress Version: 4.8

/**
 * Hook to schedule pings and enclosures when a post is published.
 *
 * Uses XMLRPC_REQUEST and WP_IMPORTING constants.
 *
 * @since 2.3.0
 * @access private
 *
 * @param int $post_id The ID in the database table of the post being published.
 */
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');
    }
}

WordPress Version: 4.0

/**
 * Hook to schedule pings and enclosures when a post is published.
 *
 * Uses XMLRPC_REQUEST and WP_IMPORTING constants.
 *
 * @since 2.3.0
 * @access private
 *
 * @param int $post_id The ID in the database table of the post being published.
 */
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');
    wp_schedule_single_event(time(), 'do_pings');
}

WordPress Version: 3.9

/**
 * Hook to schedule pings and enclosures when a post is published.
 *
 * @since 2.3.0
 * @access private
 * @uses XMLRPC_REQUEST and WP_IMPORTING constants.
 *
 * @param int $post_id The ID in the database table of the post being published
 */
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');
    wp_schedule_single_event(time(), 'do_pings');
}

WordPress Version: 3.7

/**
 * Hook to schedule pings and enclosures when a post is published.
 *
 * @since 2.3.0
 * @access private
 * @uses XMLRPC_REQUEST and WP_IMPORTING constants.
 * @uses do_action() Calls 'xmlrpc_publish_post' on post ID if XMLRPC_REQUEST is defined.
 *
 * @param int $post_id The ID in the database table of the post being published
 */
function _publish_post_hook($post_id)
{
    if (defined('XMLRPC_REQUEST')) {
        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');
    wp_schedule_single_event(time(), 'do_pings');
}