function get_export($name, $data_sources = array()) { global $current_user; it_classes_load('it-zip.php'); $zip = new ITZip(); if (empty($data_sources)) { $data_sources = array_keys($this->_data_sources); } $theme_data = get_file_data(get_stylesheet_directory() . '/style.css', array('name' => 'Theme Name'), 'theme'); $export_path = $this->_get_export_path($this->_guid, $name); $info = array('name' => $name, 'guid' => $this->_guid, 'builder_version' => $GLOBALS['it_builder_core_version'], 'builder_theme_name' => $theme_data['name'], 'timestamp' => time(), 'site_url' => get_bloginfo('url'), 'site_wpurl' => get_bloginfo('wpurl'), 'exported_by' => $current_user->display_name, 'data_sources' => array(), 'attachments' => array()); add_action('builder_import_export_add_attachment', array($this, 'add_attachment')); foreach ((array) $data_sources as $var) { if (!isset($this->_data_sources[$var])) { continue; } $data = $this->_data_sources[$var]->get_export_data(); $this->_add_zip_file_content($zip, "data-sources/{$var}.txt", $data); $data_source = array('name' => $this->_data_sources[$var]->get_name(), 'version' => $this->_data_sources[$var]->get_version(), 'data_size' => strlen(serialize($data))); $info['data_sources'][$var] = $data_source; unset($data); } $this->_attachments = array_unique($this->_attachments); $attachments = $files = array(); it_classes_load('it-file-utility.php'); foreach ((array) $this->_attachments as $attachment_id) { $url = wp_get_attachment_url($attachment_id); if (empty($url)) { continue; } $file = ITFileUtility::get_file_from_url($url); $attachment = array(); $attachment['post'] = get_post($attachment_id); $attachment['file_name'] = basename($file); $attachment['metadata_alt'] = get_metadata('post', $attachment_id, '_wp_attachment_image_alt'); if (empty($attachment['metadata_alt'])) { unset($attachment['metadata_alt']); } $attachments[$attachment_id] = $attachment; $files[$attachment_id] = $file; } $info['attachments'] = $attachments; $this->_add_zip_file_content($zip, 'info.txt', $info); foreach ((array) $files as $id => $file) { $zip->add_file($file, "attachments/{$id}/"); } do_action('builder_exporter_modify_zip_content', $zip); $file = $zip->create_zip(array('file' => $export_path)); if (is_wp_error($file)) { return $file; } $this->_load_data(); $info['file'] = $file; $info['url'] = ITFileUtility::get_url_from_file($file); return $info; }