add_ping

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

WordPress Version: 6.1

//
// Comment, trackback, and pingback functions.
//
/**
 * Adds a URL to those already pinged.
 *
 * @since 1.5.0
 * @since 4.7.0 `$post` can be a WP_Post object.
 * @since 4.7.0 `$uri` can be an array of URIs.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Post  $post Post ID or post object.
 * @param string|array $uri  Ping URI or array of URIs.
 * @return int|false How many rows were updated.
 */
function add_ping($post, $uri)
{
    global $wpdb;
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $pung = trim($post->pinged);
    $pung = preg_split('/\s/', $pung);
    if (is_array($uri)) {
        $pung = array_merge($pung, $uri);
    } else {
        $pung[] = $uri;
    }
    $new = implode("\n", $pung);
    /**
     * Filters the new ping URL to add for the given post.
     *
     * @since 2.0.0
     *
     * @param string $new New ping URL to add.
     */
    $new = apply_filters('add_ping', $new);
    $return = $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post->ID));
    clean_post_cache($post->ID);
    return $return;
}

WordPress Version: 5.1

//
// Comment, trackback, and pingback functions.
//
/**
 * Add a URL to those already pinged.
 *
 * @since 1.5.0
 * @since 4.7.0 `$post_id` can be a WP_Post object.
 * @since 4.7.0 `$uri` can be an array of URIs.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Post  $post_id Post object or ID.
 * @param string|array $uri     Ping URI or array of URIs.
 * @return int|false How many rows were updated.
 */
function add_ping($post_id, $uri)
{
    global $wpdb;
    $post = get_post($post_id);
    if (!$post) {
        return false;
    }
    $pung = trim($post->pinged);
    $pung = preg_split('/\s/', $pung);
    if (is_array($uri)) {
        $pung = array_merge($pung, $uri);
    } else {
        $pung[] = $uri;
    }
    $new = implode("\n", $pung);
    /**
     * Filters the new ping URL to add for the given post.
     *
     * @since 2.0.0
     *
     * @param string $new New ping URL to add.
     */
    $new = apply_filters('add_ping', $new);
    $return = $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post->ID));
    clean_post_cache($post->ID);
    return $return;
}

WordPress Version: 4.7

//
// Comment, trackback, and pingback functions.
//
/**
 * Add a URL to those already pinged.
 *
 * @since 1.5.0
 * @since 4.7.0 $post_id can be a WP_Post object.
 * @since 4.7.0 $uri can be an array of URIs.
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|WP_Post  $post_id Post object or ID.
 * @param string|array $uri     Ping URI or array of URIs.
 * @return int|false How many rows were updated.
 */
function add_ping($post_id, $uri)
{
    global $wpdb;
    $post = get_post($post_id);
    if (!$post) {
        return false;
    }
    $pung = trim($post->pinged);
    $pung = preg_split('/\s/', $pung);
    if (is_array($uri)) {
        $pung = array_merge($pung, $uri);
    } else {
        $pung[] = $uri;
    }
    $new = implode("\n", $pung);
    /**
     * Filters the new ping URL to add for the given post.
     *
     * @since 2.0.0
     *
     * @param string $new New ping URL to add.
     */
    $new = apply_filters('add_ping', $new);
    $return = $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post->ID));
    clean_post_cache($post->ID);
    return $return;
}

WordPress Version: 4.6

//
// Comment, trackback, and pingback functions.
//
/**
 * Add a URL to those already pinged.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int    $post_id Post ID.
 * @param string $uri     Ping URI.
 * @return int|false How many rows were updated.
 */
function add_ping($post_id, $uri)
{
    global $wpdb;
    $pung = $wpdb->get_var($wpdb->prepare("SELECT pinged FROM {$wpdb->posts} WHERE ID = %d", $post_id));
    $pung = trim($pung);
    $pung = preg_split('/\s/', $pung);
    $pung[] = $uri;
    $new = implode("\n", $pung);
    /**
     * Filters the new ping URL to add for the given post.
     *
     * @since 2.0.0
     *
     * @param string $new New ping URL to add.
     */
    $new = apply_filters('add_ping', $new);
    // expected_slashed ($new).
    $new = wp_unslash($new);
    return $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post_id));
}

WordPress Version: 4.3

//
// Comment, trackback, and pingback functions.
//
/**
 * Add a URL to those already pinged.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int    $post_id Post ID.
 * @param string $uri     Ping URI.
 * @return int|false How many rows were updated.
 */
function add_ping($post_id, $uri)
{
    global $wpdb;
    $pung = $wpdb->get_var($wpdb->prepare("SELECT pinged FROM {$wpdb->posts} WHERE ID = %d", $post_id));
    $pung = trim($pung);
    $pung = preg_split('/\s/', $pung);
    $pung[] = $uri;
    $new = implode("\n", $pung);
    /**
     * Filter the new ping URL to add for the given post.
     *
     * @since 2.0.0
     *
     * @param string $new New ping URL to add.
     */
    $new = apply_filters('add_ping', $new);
    // expected_slashed ($new).
    $new = wp_unslash($new);
    return $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post_id));
}

WordPress Version: 4.0

//
// Trackback and ping functions
//
/**
 * Add a URL to those already pinged.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int    $post_id Post ID.
 * @param string $uri     Ping URI.
 * @return int How many rows were updated.
 */
function add_ping($post_id, $uri)
{
    global $wpdb;
    $pung = $wpdb->get_var($wpdb->prepare("SELECT pinged FROM {$wpdb->posts} WHERE ID = %d", $post_id));
    $pung = trim($pung);
    $pung = preg_split('/\s/', $pung);
    $pung[] = $uri;
    $new = implode("\n", $pung);
    /**
     * Filter the new ping URL to add for the given post.
     *
     * @since 2.0.0
     *
     * @param string $new New ping URL to add.
     */
    $new = apply_filters('add_ping', $new);
    // expected_slashed ($new).
    $new = wp_unslash($new);
    return $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post_id));
}

WordPress Version: 3.9

//
// Trackback and ping functions
//
/**
 * Add a URL to those already pung.
 *
 * @since 1.5.0
 * @uses $wpdb
 *
 * @param int $post_id Post ID.
 * @param string $uri Ping URI.
 * @return int How many rows were updated.
 */
function add_ping($post_id, $uri)
{
    global $wpdb;
    $pung = $wpdb->get_var($wpdb->prepare("SELECT pinged FROM {$wpdb->posts} WHERE ID = %d", $post_id));
    $pung = trim($pung);
    $pung = preg_split('/\s/', $pung);
    $pung[] = $uri;
    $new = implode("\n", $pung);
    /**
     * Filter the new ping URL to add for the given post.
     *
     * @since 2.0.0
     *
     * @param string $new New ping URL to add.
     */
    $new = apply_filters('add_ping', $new);
    // expected_slashed ($new)
    $new = wp_unslash($new);
    return $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post_id));
}

WordPress Version: 3.7

//
// Trackback and ping functions
//
/**
 * Add a URL to those already pung.
 *
 * @since 1.5.0
 * @uses $wpdb
 *
 * @param int $post_id Post ID.
 * @param string $uri Ping URI.
 * @return int How many rows were updated.
 */
function add_ping($post_id, $uri)
{
    global $wpdb;
    $pung = $wpdb->get_var($wpdb->prepare("SELECT pinged FROM {$wpdb->posts} WHERE ID = %d", $post_id));
    $pung = trim($pung);
    $pung = preg_split('/\s/', $pung);
    $pung[] = $uri;
    $new = implode("\n", $pung);
    $new = apply_filters('add_ping', $new);
    // expected_slashed ($new)
    $new = wp_unslash($new);
    return $wpdb->update($wpdb->posts, array('pinged' => $new), array('ID' => $post_id));
}