WordPress函数文档add_ping()
为已有ping添加URL 描述 译文 为已有ping添加URL 原文 Add a URL to those a…
为已有ping添加URL
描述
译文
为已有ping添加URL
原文
Add a URL to those already pung.
用法
<?php add_ping( $post_id, $uri ) ?>
参数
$post_id
(integer) (必填) Post ID.
默认值: None
$uri
(string) (必填) Ping URI.
默认值: None
返回值
(integer)
Count of updated rows.
注意
- 使用到 global: (object) $wpdb to read and to update the _posts table in database.
- 使用到: apply_filters() on ‘add_ping’
历史
添加于 版本: 1.5.0
源文件
add_ping() 函数的代码位于 wp-includes/post.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* 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 ) );
}
|
- 原文:http://codex.wordpress.org/Function_Reference/add_ping
类别:WordPress函数文档、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!