1. 首页
  2. WordPress钩子手册

add_ping

apply_filters( ‘add_ping’, string $new )

过滤器::过滤要为给定文章添加的新ping URL。
Filter Hook: Filters the new ping URL to add for the given post.

目录锚点:#参数#源码


参数(Parameters)

参数 类型 说明
$new (string) 要添加的新ping URL。

源码(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 ) );
}
更新版本 源码位置 使用 被使用
2.0.0 wp-includes/post.php:4736 1 0

add_ping 为WP2原创文章,链接:https://www.wp2.cn/hook/add_ping/

发表评论

您的电子邮箱地址不会被公开。