add_ping() - WordPress 函数参考中文文档

返回介绍

add_ping()

发布于 2017-09-10 字数2057 浏览 1150 评论 0

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

Add a URL to those already pinged.


描述


参数

$post_id

(int|WP_Post)
(Required)
Post object or ID.

$uri

(string|array)
(Required)
Ping URI or array of URIs.


返回值

(int|false) How many rows were updated.


源代码

File: wp-includes/post.php

function add_ping( $post_id, $uri ) {
	global $wpdb;

	$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 = $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post->ID ) );
	clean_post_cache( $post->ID );
	return $return;
}

更新日志

Version 描述
4.7.0 $uri can be an array of URIs.
1.5.0 Introduced.

相关函数

Uses

  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/post.php:
    clean_post_cache()
  • wp-includes/post.php:
    add_ping
  • wp-includes/post.php:
    get_post()
  • wp-includes/wp-db.php:
    wpdb::update()

Used By

  • wp-includes/comment.php:
    pingback()

User Contributed Notes

上一篇:add_permastruct()

下一篇:add_plugins_page()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!