Pressbooks\Modules\Import\WordPress\Wxr::setCurrentImportOption PHP Метод

setCurrentImportOption() публичный Метод

public setCurrentImportOption ( array $upload ) : boolean
$upload array
Результат boolean
    function setCurrentImportOption(array $upload)
    {
        try {
            $parser = new Parser();
            $xml = $parser->parse($upload['file']);
        } catch (\Exception $e) {
            return false;
        }
        $this->pbCheck($xml);
        $option = array('file' => $upload['file'], 'file_type' => $upload['type'], 'type_of' => 'wxr', 'chapters' => array(), 'post_types' => array(), 'allow_parts' => true);
        $supported_post_types = apply_filters('pb_import_custom_post_types', array('post', 'page', 'front-matter', 'chapter', 'part', 'back-matter', 'metadata'));
        if ($this->isPbWxr) {
            //put the posts in correct part / menu_order order
            $xml['posts'] = $this->customNestedSort($xml['posts']);
        }
        foreach ($xml['posts'] as $p) {
            // Skip
            if (!in_array($p['post_type'], $supported_post_types)) {
                continue;
            }
            if (empty($p['post_content']) && !in_array($p['post_type'], array('part', 'metadata'))) {
                continue;
            }
            if ('<!-- Here be dragons.-->' == $p['post_content']) {
                continue;
            }
            // Set
            $option['chapters'][$p['post_id']] = $p['post_title'];
            $option['post_types'][$p['post_id']] = $p['post_type'];
        }
        return update_option('pressbooks_current_import', $option);
    }