WordPress at a glance
function is not described

wp_xmlrpc_server::add_enclosure_if_new() public WP 2.8.0

Adds an enclosure to a post if it's new.

{} It's a method of the class: wp_xmlrpc_server{}

No Hooks.

Return

Null. Nothing.

Usage

$wp_xmlrpc_server = new wp_xmlrpc_server();
$wp_xmlrpc_server->add_enclosure_if_new( $post_ID, $enclosure );
$post_ID(int) (required)
Post ID.
$enclosure(array) (required)
Enclosure data.

Changelog

Since 2.8.0 Introduced.

Code of wp_xmlrpc_server::add_enclosure_if_new() WP 5.5.1

<?php
public function add_enclosure_if_new( $post_ID, $enclosure ) {
	if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
		$encstring  = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
		$found      = false;
		$enclosures = get_post_meta( $post_ID, 'enclosure' );
		if ( $enclosures ) {
			foreach ( $enclosures as $enc ) {
				// This method used to omit the trailing new line. #23219
				if ( rtrim( $enc, "\n" ) == rtrim( $encstring, "\n" ) ) {
					$found = true;
					break;
				}
			}
		}
		if ( ! $found ) {
			add_post_meta( $post_ID, 'enclosure', $encstring );
		}
	}
}