SyndicatedPost::add_rss_meta PHP Méthode

add_rss_meta() public méthode

SyndicatedPost::add_rss_meta: adds interesting meta-data to each entry using the space for custom keys. The set of keys and values to add is specified by the keys and values of $post['meta']. This is used to store anything that the WordPress user might want to access from a template concerning the post's original source that isn't provided for by standard WP meta-data (i.e., any interesting data about the syndicated post other than author, title, timestamp, categories, and guid). It's also used to hook into WordPress's support for enclosures.
public add_rss_meta ( string $new_status, string $old_status, object $post )
$new_status string Unused action parameter.
$old_status string Unused action parameter.
$post object The database record for the post just inserted.
    function add_rss_meta($new_status, $old_status, $post)
    {
        global $wpdb;
        if ($new_status != 'inherit') {
            // Bail if we are creating a revision.
            FeedWordPress::diagnostic('syndicated_posts:meta_data', 'Adding post meta-data: {' . implode(", ", array_keys($this->post['meta'])) . '}');
            if (is_array($this->post) and isset($this->post['meta']) and is_array($this->post['meta'])) {
                $postId = $post->ID;
                // Aggregated posts should NOT send out pingbacks.
                // WordPress 2.1-2.2 claim you can tell them not to
                // using $post_pingback, but they don't listen, so we
                // make sure here.
                $result = $wpdb->query("\n\t\t\t\tDELETE FROM {$wpdb->postmeta}\n\t\t\t\tWHERE post_id='{$postId}' AND meta_key='_pingme'\n\t\t\t\t");
                foreach ($this->post['meta'] as $key => $values) {
                    $eKey = esc_sql($key);
                    // If this is an update, clear out the old
                    // values to avoid duplication.
                    $result = $wpdb->query("\n\t\t\t\t\tDELETE FROM {$wpdb->postmeta}\n\t\t\t\t\tWHERE post_id='{$postId}' AND meta_key='{$eKey}'\n\t\t\t\t\t");
                    // Allow for either a single value or an array
                    if (!is_array($values)) {
                        $values = array($values);
                    }
                    foreach ($values as $value) {
                        FeedWordPress::diagnostic('syndicated_posts:meta_data', "Adding post meta-datum to post [{$postId}]: [{$key}] = " . MyPHP::val($value, true));
                        add_post_meta($postId, $key, $value, false);
                    }
                }
            }
        }
    }