add_ping()
最后更新于:2021-11-25 19:24:20
add_ping( int|GC_Post$post_id, string|array$uri)Add a URL to those already pinged.
参数
- $post_id
-
(int|GC_Post) (Required) Post object or ID.
- $uri
-
(string|array) (Required) Ping URI or array of URIs.
响应
(int|false) How many rows were updated.
源文件
文件: gc-includes/post.php
function add_ping( $post_id, $uri ) {
global $gcdb;
$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 = $gcdb->update( $gcdb->posts, array( 'pinged' => $new ), array( 'ID' => $post->ID ) );
clean_post_cache( $post->ID );
return $return;
}