add_ping()

add_ping()函数是Wordpress函数,为那些已经ping的添加一个URL。

add_ping( int|WP_Post $post_id, string|array $uri )

为那些已经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.0wp-includes/post.php:47111 function5
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索