A WordPress-centric search engine for devs and theme authors



add_ping ›

Since1.5.0
Deprecatedn/a
add_ping ( $post_id, $uri )
Parameters: (2)
  • (int|WP_Post) $post_id Post object or ID.
    Required: Yes
  • (string|array) $uri Ping URI or array of URIs.
    Required: Yes
Returns:
  • (int|false) How many rows were updated.
Defined at:
Codex:
Change Log:
  • 4.7.0
  • 4.7.0

Add a URL to those already pinged.



Source

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;
}