SyndicatedPost::normalize_post PHP Méthode

normalize_post() public méthode

SyndicatedPost::normalize_post()
public normalize_post ( boolean $new = true ) : array
$new boolean If true, this post is to be inserted anew. If false, it is an update of an existing post.
Résultat array A normalized representation of the post ready to be inserted into the database or sent to the WordPress API functions
    function normalize_post($new = true)
    {
        global $wpdb;
        $out = $this->post;
        $fullPost = $out['post_title'] . $out['post_content'];
        $fullPost .= isset($out['post_excerpt']) ? $out['post_excerpt'] : '';
        if (strlen($fullPost) < 1) {
            // FIXME: Option for filtering out empty posts
        }
        if (strlen($out['post_title']) == 0) {
            $offset = (int) get_option('gmt_offset') * 60 * 60;
            if (isset($this->post['meta']['syndication_source'])) {
                $source_title = $this->post['meta']['syndication_source'];
            } else {
                $feed_url = parse_url($this->post['meta']['syndication_feed']);
                $source_title = $feed_url['host'];
            }
            $out['post_title'] = $source_title . ' ' . gmdate('Y-m-d H:i:s', $this->published() + $offset);
            // FIXME: Option for what to fill a blank title with...
        }
        // Normalize the guid if necessary.
        $out['guid'] = SyndicatedPost::normalize_guid($out['guid']);
        return $out;
    }