add_ping()
add_ping( int|WP_Post $post_id, string|array $uri ) 为那些…
add_ping( int|WP_Post $post_id, string|array $uri )
为那些已经ping的添加一个URL。
Add a URL to those already pinged.
为那些已经ping的添加一个URL。
Add a URL to those already pinged.
目录锚点:#参数#返回#源码
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $post_id | (int | WP_Post) | 必需 | Post对象或ID。 |
| $uri | (string | array) | 必需 | Ping URI或URI数组。 |
返回(Return)
(int|false)更新了多少行。
源码(Source)
/**
* 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("
", $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 ) );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 4.7.0 | wp-includes/post.php:4711 | 1 function | 5 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!