add_ping()
Adds a URL to those already pinged.
Hooks from the function
Return
Int|false
. How many rows were updated.
Usage
add_ping( $post, $uri );
- $post(int|WP_Post) (required)
- Post ID or post object.
- $uri(string|array) (required)
- Ping URI or array of URIs.
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 1.5.0 | Introduced. |
Since 4.7.0 | $post can be a WP_Post object. |
Since 4.7.0 | $uri can be an array of URIs. |
add_ping() add ping code WP 6.1.1
function add_ping( $post, $uri ) { global $wpdb; $post = get_post( $post ); 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; }