On this page
add_ping( int|WP_Post $post, string|array $uri ): int|false
Adds a URL to those already pinged.
Parameters
$postint|WP_Post Required-
Post ID or post object.
$uristring|array Required-
Ping URI or array of URIs.
Return
int|false How many rows were updated.
Source
File: wp-includes/post.php. View all references
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;
}
Hooks
- apply_filters( 'add_ping',
string $new ) -
Filters the new ping URL to add for the given post.
Related
Uses
| Uses | Description |
|---|---|
| clean_post_cache() wp-includes/post.php | Will clean the post in the cache. |
| wpdb::update() wp-includes/class-wpdb.php | Updates a row in the table. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_post() wp-includes/post.php | Retrieves post data given a post ID or post object. |
Used By
| Used By | Description |
|---|---|
| pingback() wp-includes/comment.php | Pings back the links found in a post. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/add_ping