Uses
Uses | Description |
---|---|
wp-includes/post.php: get_post_meta() | Retrieves a post meta field for the given post ID. |
wp-includes/post.php: add_post_meta() | Adds a meta field to the given post. |
Adds an enclosure to a post if it’s new.
(integer) (Required) Post ID.
(array) (Required) Enclosure data.
File: wp-includes/class-wp-xmlrpc-server.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 ); } } }
Version | Description |
---|---|
2.8.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/add_enclosure_if_new