add_ping( int|WP_Post $post_id, string|array $uri )
Add a URL to those already pinged.
Description Description
Parameters Parameters
- $post_id
-
(int|WP_Post) (Required) Post object or ID.
- $uri
-
(string|array) (Required) Ping URI or array of URIs.
Return Return
(int|false) How many rows were updated.
Source Source
File: wp-includes/post.php
4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 | 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 ; } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.7.0 | $uri can be an array of URIs. |
1.5.0 | Introduced. |