本文整理汇总了PHP中wp_import_cleanup函数 的典型用法代码示例。如果您正苦于以下问题:PHP wp_import_cleanup函数的具体用法?PHP wp_import_cleanup怎么用?PHP wp_import_cleanup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_import_cleanup函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
do_action('import_end');
}
开发者ID:RDePoppe, 项目名称:luminaterealestate, 代码行数:15, 代码来源:class-dt-dummy-import.php
示例2: step2
/**
* The form of the second step.
*
* @param none
* @return none
*/
private function step2()
{
$file = wp_import_handle_upload();
if (isset($file['error'])) {
return new WP_Error('Error', esc_html($file['error']));
} else {
if (!file_exists($file['file'])) {
return new WP_Error('Error', sprintf(__('The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'advanced-csv-importer'), esc_html($file['file'])));
}
}
$csv_file = get_attached_file($file['id']);
$post_objects = Main::get_post_objects($csv_file);
if (is_wp_error($post_objects)) {
echo '<p><strong>' . __('Failed to open file.', 'advanced-csv-importer') . '</strong></p>';
wp_import_cleanup($file['id']);
return $post_objects;
} else {
$inserted_posts = Main::insert_posts($post_objects);
wp_import_cleanup($file['id']);
return $inserted_posts;
}
}
开发者ID:adaminfinitum, 项目名称:advanced-csv-importer, 代码行数:28, 代码来源:Importer.php
示例3: handle_upload
/**
* Handles the JSON upload and initial parsing of the file to prepare for
* displaying author import options
*
* @return bool False if error uploading or invalid file, true otherwise
*/
private function handle_upload()
{
$file = wp_import_handle_upload();
if (isset($file['error'])) {
return $this->error_message(esc_html__('Sorry, there has been an error.', 'wp-options-importer'), esc_html($file['error']));
}
if (!isset($file['file'], $file['id'])) {
return $this->error_message(esc_html__('Sorry, there has been an error.', 'wp-options-importer'), esc_html__('The file did not upload properly. Please try again.', 'wp-options-importer'));
}
$this->file_id = intval($file['id']);
if (!file_exists($file['file'])) {
wp_import_cleanup($this->file_id);
return $this->error_message(esc_html__('Sorry, there has been an error.', 'wp-options-importer'), sprintf(esc_html__('The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'wp-options-importer'), esc_html($file['file'])));
}
if (!is_file($file['file'])) {
wp_import_cleanup($this->file_id);
return $this->error_message(esc_html__('Sorry, there has been an error.', 'wordpress-importer'), esc_html__('The path is not a file, please try again.', 'wordpress-importer'));
}
$file_contents = file_get_contents($file['file']);
$this->import_data = json_decode($file_contents, true);
set_transient($this->transient_key(), $this->import_data, DAY_IN_SECONDS);
wp_import_cleanup($this->file_id);
return $this->run_data_check();
}
开发者ID:gopinathshiva, 项目名称:wordpress-vip-plugins, 代码行数:30, 代码来源:options-importer.php
示例4: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
echo '<p>' . __('Import complete.', 'wc_customer_relationship_manager') . '</p>';
echo '<p>' . sprintf(_n('%d Customer has been successfully added.', '%d Customers has been successfully added.', $this->row, 'wc_customer_relationship_manager'), $this->row) . '</p>';
if (!empty($this->groups_added)) {
echo '<p>' . sprintf(_n('%d Group has been successfully added.', '%d Groups has been successfully added.', count($this->groups_added), 'wc_customer_relationship_manager'), count($this->groups_added)) . ' (' . implode(', ', $this->groups_added) . ')</p>';
}
if (!empty($this->statuses_added)) {
echo '<p>' . sprintf(_n('%d Customer status has been successfully added.', '%d Customer statuses has been successfully added.', count($this->statuses_added), 'wc_customer_relationship_manager'), count($this->statuses_added)) . ' (' . implode(', ', $this->statuses_added) . ')</p>';
}
if (!empty($this->not_import)) {
echo '<p>' . sprintf(_n('%d Customer was not added.', '%d Customers was not added.', count($this->not_import), 'wc_customer_relationship_manager'), count($this->not_import)) . '</p>';
echo '<code>';
foreach ($this->not_import as $key => $value) {
echo $value[0] . '<br>';
}
echo '</code>';
}
do_action('wcrm_import_end');
}
开发者ID:sajidshah, 项目名称:le-dolci, 代码行数:27, 代码来源:wc_crm_importer.php
示例5: get_posts
private function get_posts($field)
{
$xml = $this->load_XML($field);
if ($xml) {
if ($field == 'artists') {
return $this->parse_artists($xml);
}
if ($field == 'venues') {
return $this->parse_venues($xml);
} else {
if ($field == "shows") {
return $this->parse_shows($xml);
} else {
if ($field == "workshops") {
return $this->parse_workshops($xml);
} else {
if ($field == "contacts") {
return $this->parse_contacts($xml);
} else {
if ($field == "vendors") {
return $this->parse_vendors($xml);
} else {
return array();
}
}
}
}
}
wp_import_cleanup($xml['id']);
} else {
return false;
}
}
开发者ID:jamiemitchell, 项目名称:marcato_festival_wordpress_plugin, 代码行数:33, 代码来源:marcatoxml.php
示例6: import
function import()
{
$options = get_option('html_import');
if ($_POST['import_files'] == 'file') {
// preserve original file name so we can use it for slugs later ( maybe )
$this->filename = $_FILES['import']['name'];
// upload the file
$file = wp_import_handle_upload();
if (isset($file['error'])) {
echo $file['error'];
return;
}
echo '<h2>' . __('Importing HTML file...', 'import-html-pages') . '</h2>';
$this->file = $file['file'];
$this->get_single_file();
$this->print_results($options['type']);
wp_import_cleanup($file['id']);
if ($options['import_images']) {
$this->find_images();
}
if ($options['import_documents']) {
$this->find_documents();
}
if ($options['fix_links']) {
$this->find_internal_links();
}
} elseif ($_POST['import_files'] == 'directory') {
// in case they entered something dumb and didn't fix it when we showed an error on the options page...
if (validate_import_file($options['root_directory']) > 0) {
wp_die(__("The beginning directory you entered is not an absolute path. Relative paths are not allowed here.", 'import-html-pages'));
}
$this->table = '';
$this->redirects = '';
$this->filearr = array();
$skipdirs = explode(",", $options['skipdirs']);
$this->skip = array_merge($skipdirs, array('.', '..', '_vti_cnf', '_notes'));
$this->allowed = explode(",", $options['file_extensions']);
echo '<h2>' . __('Importing HTML files...', 'import-html-pages') . '</h2>';
$this->get_files_from_directory($options['root_directory']);
$this->print_results($options['type']);
if (isset($options['import_images']) && $options['import_images']) {
$this->find_images();
}
if (isset($options['import_documents']) && $options['import_documents']) {
$this->find_documents();
}
if (isset($options['fix_links']) && $options['fix_links']) {
$this->find_internal_links();
}
} else {
_e("Your file upload didn't work. Try again?", 'html-import-pages');
}
do_action('import_done', 'html');
}
开发者ID:kevinotsuka, 项目名称:datapop, 代码行数:54, 代码来源:html-importer.php
示例7: process_posts
//.........这里部分代码省略.........
if ($post_id = post_exists($post_title, '', $post_date)) {
echo '<li>';
printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
} else {
echo '<li>';
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$post_author = $this->checkauthor($post_author);
//just so that if a post already exists, new users are not created by checkauthor
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
$post_id = wp_insert_post($postdata);
// Add categories.
if (0 != count($post_categories)) {
wp_create_categories($post_categories, $post_id);
}
}
$comment_post_ID = $post_id;
// Now for comments
$comments = explode("-----\nCOMMENT:", $comments[0]);
$num_comments = 0;
foreach ($comments as $comment) {
if ('' != trim($comment)) {
// Author
preg_match("|AUTHOR:(.*)|", $comment, $comment_author);
$comment_author = $wpdb->escape(trim($comment_author[1]));
$comment = preg_replace('|(\\n?AUTHOR:.*)|', '', $comment);
preg_match("|EMAIL:(.*)|", $comment, $comment_author_email);
$comment_author_email = $wpdb->escape(trim($comment_author_email[1]));
$comment = preg_replace('|(\\n?EMAIL:.*)|', '', $comment);
preg_match("|IP:(.*)|", $comment, $comment_author_IP);
$comment_author_IP = trim($comment_author_IP[1]);
$comment = preg_replace('|(\\n?IP:.*)|', '', $comment);
preg_match("|URL:(.*)|", $comment, $comment_author_url);
$comment_author_url = $wpdb->escape(trim($comment_author_url[1]));
$comment = preg_replace('|(\\n?URL:.*)|', '', $comment);
preg_match("|DATE:(.*)|", $comment, $comment_date);
$comment_date = trim($comment_date[1]);
$comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
$comment = preg_replace('|(\\n?DATE:.*)|', '', $comment);
$comment_content = $wpdb->escape(trim($comment));
$comment_content = str_replace('-----', '', $comment_content);
// Check if it's already there
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content');
$commentdata = wp_filter_comment($commentdata);
wp_insert_comment($commentdata);
$num_comments++;
}
}
}
if ($num_comments) {
printf(__('(%s comments)'), $num_comments);
}
// Finally the pings
// fix the double newline on the first one
$pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]);
$pings = explode("-----\nPING:", $pings[0]);
$num_pings = 0;
foreach ($pings as $ping) {
if ('' != trim($ping)) {
// 'Author'
preg_match("|BLOG NAME:(.*)|", $ping, $comment_author);
$comment_author = $wpdb->escape(trim($comment_author[1]));
$ping = preg_replace('|(\\n?BLOG NAME:.*)|', '', $ping);
preg_match("|IP:(.*)|", $ping, $comment_author_IP);
$comment_author_IP = trim($comment_author_IP[1]);
$ping = preg_replace('|(\\n?IP:.*)|', '', $ping);
preg_match("|URL:(.*)|", $ping, $comment_author_url);
$comment_author_url = $wpdb->escape(trim($comment_author_url[1]));
$ping = preg_replace('|(\\n?URL:.*)|', '', $ping);
preg_match("|DATE:(.*)|", $ping, $comment_date);
$comment_date = trim($comment_date[1]);
$comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
$ping = preg_replace('|(\\n?DATE:.*)|', '', $ping);
preg_match("|TITLE:(.*)|", $ping, $ping_title);
$ping_title = $wpdb->escape(trim($ping_title[1]));
$ping = preg_replace('|(\\n?TITLE:.*)|', '', $ping);
$comment_content = $wpdb->escape(trim($ping));
$comment_content = str_replace('-----', '', $comment_content);
$comment_content = "<strong>{$ping_title}</strong>\n\n{$comment_content}";
$comment_type = 'trackback';
// Check if it's already there
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type');
$commentdata = wp_filter_comment($commentdata);
wp_insert_comment($commentdata);
$num_pings++;
}
}
}
if ($num_pings) {
printf(__('(%s pings)'), $num_pings);
}
echo "</li>";
}
flush();
}
echo '</ol>';
wp_import_cleanup($this->id);
echo '<h3>' . sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')) . '</h3>';
}
开发者ID:robertlange81, 项目名称:Website, 代码行数:101, 代码来源:mt.php
示例8: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
wp_cache_flush();
$taxonomies = get_taxonomies();
foreach ($taxonomies as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
$args = array('hide_empty' => 0, 'fields' => 'ids');
$terms = get_terms($tax, $args);
if (is_array($terms) && !empty($terms)) {
wp_update_term_count_now($terms, $tax);
}
}
do_action('import_end');
}
开发者ID:fjbeteiligung, 项目名称:development, 代码行数:21, 代码来源:wordpress-importer.php
示例9: process_posts
function process_posts()
{
if (!($fp = fopen($this->file, "r"))) {
echo '<p><strong>' . __('Failed to open file.', 'wc2') . '</strong></p>';
wp_import_cleanup($this->id);
return false;
}
global $wpdb;
$wc2_item = WC2_DB_Item::get_instance();
//all delete
//$wc2_item->delete_all_item_data();
//die();
$err = new WP_Error();
$sp = ",";
$lines = array();
$buf = '';
while (!feof($fp)) {
$temp = fgets($fp, 10240);
if (0 == strlen($temp)) {
continue;
}
$num = substr_count($temp, '"');
if (0 == $num % 2 && '' == $buf) {
$lines[] = $temp;
} elseif (1 == $num % 2 && '' == $buf) {
$buf .= $temp;
} elseif (0 == $num % 2 && '' != $buf) {
$buf .= $temp;
} elseif (1 == $num % 2 && '' != $buf) {
$buf .= $temp;
$lines[] = $buf;
$buf = '';
}
}
fclose($fp);
//Post data - fixed
define('COL_POST_ID', 0);
define('COL_POST_AUTHOR', 1);
define('COL_POST_CONTENT', 2);
define('COL_POST_TITLE', 3);
define('COL_POST_EXCERPT', 4);
define('COL_POST_STATUS', 5);
define('COL_POST_COMMENT_STATUS', 6);
define('COL_POST_PASSWORD', 7);
define('COL_POST_NAME', 8);
define('COL_POST_MODIFIED', 9);
define('COL_POST_CATEGORY', 10);
define('COL_POST_TAG', 11);
define('COL_POST_CUSTOM_FIELD', 12);
define('COL_ITEM_CODE', 13);
define('COL_ITEM_NAME', 14);
$item_base_column = $wc2_item->get_item_base_column();
$item_meta_column = $wc2_item->get_item_meta_column();
$item_sku_column = $wc2_item->get_item_sku_column();
$item_sku_meta_column = $wc2_item->get_item_sku_meta_column();
$system = wc2_get_option('system');
$this->encode_type = isset($system['csv_encode_type']) ? $system['csv_encode_type'] : 0;
$start_col = 13;
$sku_start_col = $start_col;
foreach ((array) $item_base_column as $key => $column) {
if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
$sku_start_col++;
}
}
foreach ((array) $item_meta_column as $key => $column) {
if ($column['display'] != 'none' and $column['type'] != TYPE_PARENT) {
$sku_start_col++;
}
}
$post_status = array('publish', 'future', 'draft', 'pending', 'private');
$pre_item_code = '';
$item_id = 0;
$sku_id = 1;
$this->data_rows = count($lines);
$this->success = 0;
$this->false = 0;
//Progressbar 処理件数SET
echo '<script type="text/javascript">PG_Set_Max(' . $this->data_rows . ');</script>' . "\r\n";
ob_flush();
flush();
foreach ($lines as $row => $line) {
$datas = array();
$datas = explode($sp, trim($line));
$this->values = array();
$buf = '';
foreach ($datas as $data) {
$num = substr_count($data, '"');
if (0 == $num % 2 && '' == $buf) {
if ('"' == substr($data, 0, 1)) {
$data = substr($data, 1);
}
if ('"' == substr($data, -1)) {
$data = substr($data, 0, -1);
}
$data = str_replace(array('""'), '"', $data);
$this->values[] = false !== $data ? $data : '';
} elseif (1 == $num % 2 && '' == $buf) {
$buf .= $data;
} elseif (0 == $num % 2 && '' != $buf) {
$buf .= $sp . $data;
//.........这里部分代码省略.........
开发者ID:nanbu-collne, 项目名称:test2, 代码行数:101, 代码来源:class-item-import.php
示例10: process_posts
function process_posts()
{
global $wpdb;
$i = -1;
echo '<ol>';
foreach ($this->posts as $post) {
// There are only ever one of these
$post_title = $this->get_tag($post, 'title');
$post_date = $this->get_tag($post, 'wp:post_date');
$post_date_gmt = $this->get_tag($post, 'wp:post_date_gmt');
$comment_status = $this->get_tag($post, 'wp:comment_status');
$ping_status = $this->get_tag($post, 'wp:ping_status');
$post_status = $this->get_tag($post, 'wp:status');
$post_parent = $this->get_tag($post, 'wp:post_parent');
$post_type = $this->get_tag($post, 'wp:post_type');
$guid = $this->get_tag($post, 'guid');
$post_author = $this->get_tag($post, 'dc:creator');
$post_content = $this->get_tag($post, 'content:encoded');
$post_content = str_replace(array('<![CDATA[', ']]>'), '', $post_content);
$post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('\$1')", $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
$categories = $categories[1];
$cat_index = 0;
foreach ($categories as $category) {
$categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array('<![CDATA[', ']]>'), '', $category)));
$cat_index++;
}
if ($post_id = post_exists($post_title, '', $post_date)) {
echo '<li>';
printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
} else {
echo '<li>';
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$post_author = $this->checkauthor($post_author);
//just so that if a post already exists, new users are not created by checkauthor
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'post_type');
$comment_post_ID = $post_id = wp_insert_post($postdata);
// Add categories.
if (0 != count($categories)) {
wp_create_categories($categories, $post_id);
}
}
// Now for comments
preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
$comments = $comments[1];
$num_comments = 0;
if ($comments) {
foreach ($comments as $comment) {
$comment_author = $this->get_tag($comment, 'wp:comment_author');
$comment_author_email = $this->get_tag($comment, 'wp:comment_author_email');
$comment_author_IP = $this->get_tag($comment, 'wp:comment_author_IP');
$comment_author_url = $this->get_tag($comment, 'wp:comment_author_url');
$comment_date = $this->get_tag($comment, 'wp:comment_date');
$comment_date_gmt = $this->get_tag($comment, 'wp:comment_date_gmt');
$comment_content = $this->get_tag($comment, 'wp:comment_content');
$comment_approved = $this->get_tag($comment, 'wp:comment_approved');
$comment_type = $this->get_tag($comment, 'wp:comment_type');
$comment_parent = $this->get_tag($comment, 'wp:comment_parent');
if (!comment_exists($comment_author, $comment_date)) {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent');
wp_insert_comment($commentdata);
$num_comments++;
}
}
}
if ($num_comments) {
printf(' ' . __('(%s comments)'), $num_comments);
}
// Now for post meta
preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta);
$postmeta = $postmeta[1];
if ($postmeta) {
foreach ($postmeta as $p) {
$key = $this->get_tag($p, 'wp:meta_key');
$value = $this->get_tag($p, 'wp:meta_value');
add_post_meta($post_id, $key, $value);
}
}
$index++;
}
echo '</ol>';
wp_import_cleanup($this->id);
echo '<h3>' . sprintf(__('All done.') . ' <a href="%s">' . __('Have fun!') . '</a>', get_option('home')) . '</h3>';
}
开发者ID:staylor, 项目名称:develop.svn.wordpress.org, 代码行数:86, 代码来源:wordpress.php
示例11: import_end
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
echo '<p>' . __('All done.', 'wordpress-importer') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'wordpress-importer') . '</a>' . '</p>';
}
开发者ID:mclesceri, 项目名称:webworkerme-Framework, 代码行数:6, 代码来源:themesupports-init.php
示例12: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
echo '<p>' . __('All done.', 'wordpress-importer') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'wordpress-importer') . '</a>' . '</p>';
echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'wordpress-importer') . '</p>';
if ($this->one_click) {
$main_menu = get_term_by('slug', 'main-menu', 'nav_menu');
$top_menu = get_term_by('slug', 'top-menu', 'nav_menu');
$footer_menu = get_term_by('slug', 'menu-footer', 'nav_menu');
$menu_locations = get_theme_mod('nav_menu_locations');
if ($main_menu) {
$menu_locations['menu-header'] = $main_menu->term_id;
}
if ($top_menu) {
$menu_locations['menu-top'] = $top_menu->term_id;
}
if ($footer_menu) {
$menu_locations['menu-footer'] = $footer_menu->term_id;
}
set_theme_mod('nav_menu_locations', $menu_locations);
if ($this->front_page) {
update_option('page_on_front', $this->processed_posts[intval($this->front_page)]);
update_option('show_on_front', 'page');
}
$quick_setup = admin_url('admin.php?page=wpv_import');
echo <<<REDIRECT
\t\t\t<script>
\t\t\t\t/*<![CDATA[*/
\t\t\t\tsetTimeout(function() {
\t\t\t\t\twindow.location = '{$quick_setup}';
\t\t\t\t}, 3000);
\t\t\t\t/*]]>*/
\t\t\t</script>
REDIRECT;
}
do_action('import_end');
}
开发者ID:amitmula, 项目名称:amitandaastha.in, 代码行数:47, 代码来源:importer.php
示例13: name_directory_import
/**
* Import names from a csv file into directory
*/
function name_directory_import()
{
if (!current_user_can('manage_options')) {
wp_die(__('You do not have sufficient permissions to access this page.', 'name-directory'));
}
global $wpdb;
global $table_directory;
global $table_directory_name;
$directory_id = intval($_GET['dir']);
$import_success = false;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$file = wp_import_handle_upload();
if (isset($file['error'])) {
echo $file['error'];
return;
}
$csv = array_map('str_getcsv', file($file['file']));
wp_import_cleanup($file['id']);
array_shift($csv);
$names_imported = 0;
$names_duplicate = 0;
foreach ($csv as $entry) {
if (!($prepared_row = name_directory_prepared_import_row($entry))) {
continue;
}
if (name_directory_name_exists_in_directory($prepared_row['name'], $directory_id)) {
$names_duplicate++;
continue;
}
$wpdb->insert($table_directory_name, array('directory' => $directory_id, 'name' => stripslashes_deep($prepared_row['name']), 'letter' => name_directory_get_first_char($prepared_row['name']), 'description' => stripslashes_deep($prepared_row['description']), 'published' => $prepared_row['published'], 'submitted_by' => $prepared_row['submitted_by']), array('%d', '%s', '%s', '%s', '%d', '%s'));
$names_imported++;
}
$notice_class = 'updated';
$import_success = true;
$import_message = sprintf(__('Imported %d entries in this directory', 'name-directory'), $names_imported);
if ($names_imported === 0) {
$notice_class = 'error';
$import_success = false;
$import_message = __('Could not import any names into Name Directory', 'name-directory');
}
if ($names_duplicate > 0) {
$ignored = count($csv) == $names_duplicate ? __('all', 'name-directory') : $names_duplicate;
echo '<div class="error" style="border-left: 4px solid #ffba00;"><p>' . sprintf(__('Ignored %s names, because they were duplicate (already in the directory)', 'name-directory'), $ignored) . '</p></div>';
} elseif ($names_imported === 0) {
$import_message .= ', ' . __('please check your .csv-file', 'name-directory');
}
echo '<div class="' . $notice_class . '"><p>' . $import_message . '</p></div>';
}
$wp_file = admin_url('options-general.php');
$wp_page = $_GET['page'];
$wp_sub = $_GET['sub'];
$overview_url = sprintf("%s?page=%s", $wp_file, $wp_page);
$wp_url_path = sprintf("%s?page=%s&sub=%s&dir=%d", $wp_file, $wp_page, $wp_sub, $directory_id);
$wp_ndir_path = sprintf("%s?page=%s&sub=%s&dir=%d", $wp_file, $wp_page, 'manage-directory', $directory_id);
$directory = $wpdb->get_row("SELECT * FROM " . $table_directory . " WHERE `id` = " . $directory_id, ARRAY_A);
echo '<div class="wrap">';
echo '<h2>' . sprintf(__('Import names for %s', 'name-directory'), $directory['name']) . '</h2>';
echo '<div class="narrow"><p>';
if (!$import_success && empty($names_duplicate)) {
echo __('Use the upload form below to upload a .csv-file containing all of your names (in the first column), description and submitter are optional.', 'name-directory') . ' ';
echo '<h4>' . __('If you saved it from Excel or OpenOffice, please ensure that:', 'name-directory') . '</h4> ';
echo '<ol><li>' . __('There is a header row (this contains the column names, the first row will NOT be imported)', 'name-directory');
echo '</li><li>' . __('Fields are encapsulated by double quotes', 'name-directory');
echo '</li><li>' . __('Fields are comma-separated', 'name-directory');
echo '</li></ol>';
echo '<h4>' . __('If uploading or importing fails, these are your options', 'name-directory') . ':</h4><ol><li>';
echo sprintf(__('Please check out %s first and ensure your file is formatted the same.', 'name-directory'), '<a href="http://plugins.svn.wordpress.org/name-directory/assets/name-directory-import-example.csv" target="_blank">' . __('the example import file', 'name-directory') . '</a>') . '</li>';
echo '<li>
<a href="https://wiki.openoffice.org/wiki/Documentation/OOo3_User_Guides/Calc_Guide/Saving_spreadsheets#Saving_as_a_CSV_file">OpenOffice csv-export help</a>
</li>
<li>
<a href="https://support.office.com/en-us/article/Import-or-export-text-txt-or-csv-files-e8ab9ff3-be8d-43f1-9d52-b5e8a008ba5c?CorrelationId=fa46399d-2d7a-40bd-b0a5-27b99e96cf68&ui=en-US&rs=en-US&ad=US#bmexport">Excel csv-export help</a>
</li>
<li>
<a href="http://www.freefileconvert.com" target="_blank">' . __('Use an online File Convertor', 'name-directory') . '</a>
</li><li>';
echo sprintf(__('If everything else fails, you can always ask a question at the %s.', 'name-directory'), '<a href="https://wordpress.org/support/plugin/name-directory" target="_blank">' . __('plugin support forums', 'name-directory') . '</a>') . ' ';
echo '</li></ol></p>';
if (!function_exists('str_getcsv')) {
echo '<div class="error"><p>';
echo __('Name Directory Import requires PHP 5.3, you seem to have in older version. Importing names will not work for your website.', 'name-directory');
echo '</p></div>';
}
echo '<h3>' . __('Upload your .csv-file', 'name-directory') . '</h3>';
wp_import_upload_form($wp_url_path);
}
echo '</div></div>';
echo '<a href="' . $wp_ndir_path . '">' . sprintf(__('Back to %s', 'name-directory'), '<i>' . $directory['name'] . '</i>') . '</a>';
echo ' | ';
echo '<a href="' . $overview_url . '">' . __('Go to Name Directory Overview', 'name-directory') . '</a>';
}
开发者ID:alphacityco, 项目名称:kotobanokumo-wp-content, 代码行数:94, 代码来源:admin.php
示例14: process_posts
function process_posts()
{
$i = -1;
echo '<ol>';
$numPosts = count($this->posts);
//Kavinda: Uncomment the next line to test the import with only 10 post.
//$numPosts = 10;
for ($i = 0; $i < $numPosts; $i++) {
$this->process_post($this->posts[$i]);
}
echo '</ol>';
wp_import_cleanup($this->id);
// Write out a CSV file with URL mappings - this should persist beyond this import,
// so write it out to disk ourselves
if (count($this->old_new_post_mapping) > 0) {
$output_filename = 'permalinkmap.csv';
// Delete old permalink file
if (file_exists($output_filename)) {
unlink($output_filename);
}
$csv_file_contents = "OldPermalink,NewPermalink\n";
foreach ($this->old_new_post_mapping as $key => $value) {
// Append the items - escape any commas
$csv_file_contents .= sprintf("%s,%s\n", str_replace(',', ',,', $key), str_replace(',', ',,', $value));
}
$fhandle = fopen($output_filename, 'w');
fwrite($fhandle, $csv_file_contents);
fclose($fhandle);
echo '<a href="permalinkmap.csv">Click here to download a CSV file containing mappings from imported Permalinks to the new WordPress Permalinks</a><br />Note that this file is statically generated, it will need to be manually deleted.<br />';
}
echo '<h3>' . sprintf(__('All done.') . ' <a href="%s">' . __('Have fun!') . '</a>', get_option('home')) . '</h3>';
}
开发者ID:jishnus, 项目名称:blogml-wordpress-import, 代码行数:32, 代码来源:blogml-importer.php
示例15: process_comments
function process_comments()
{
echo '<ol>';
// Parse the file: and act on comments as directed
$this->get_entries(array(&$this, 'process_comment'));
$this->process_orphan_comments();
// call it once to capture replies on the last post
$this->process_orphan_comments(TRUE);
// call it again to force import any remaining unmatched orphans
echo '</ol>';
wp_import_cleanup($this->id);
do_action('import_done', 'disqus-importer');
if ($this->num_comments) {
echo '<h3>' . sprintf(_n('Imported %s comment.', 'Imported %s comments.', $this->num_comments, 'disqus-importer'), $this->num_comments) . '</h3>';
}
if ($this->num_duplicates) {
echo '<h3>' . sprintf(_n('Skipped %s duplicate.', 'Skipped %s duplicates.', $this->num_duplicates, 'disqus-importer'), $this->num_duplicates) . '</h3>';
}
if ($this->num_uncertain) {
echo '<h3>' . sprintf(_n('Could not determine the correct item to attach %s comment to.', 'Could not determine the correct item to attach %s comments to.', $this->num_uncertain, 'disqus-importer'), $this->num_uncertain) . '</h3>';
}
echo '<h3>' . sprintf(__('All done.', 'disqus-importer') . ' <a href="%s">' . __('Have fun!', 'disqus-importer') . '</a>', get_option('home')) . '</h3>';
}
开发者ID:kemayo, 项目名称:wp-disqus-importer, 代码行数:23, 代码来源:disqus-importer.php
示例16: lastfmimport_upload
private function lastfmimport_upload()
{
$file = wp_import_handle_upload();
if (isset($file['error'])) {
echo $file['error'];
return;
}
$this->importfile = $file['file'];
$this->extractzip();
$this->lastfmimport_import();
//if ( is_wp_error( $result ) )
// return $result;
wp_import_cleanup($file['id']);
$this->rm_r($this->tmpdir);
$this->tmpdir = null;
echo '<h3>';
printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
echo '</h3>';
}
开发者ID:petermolnar, 项目名称:wordpress-playlistlog, 代码行数:19, 代码来源:playlistlog.php
示例17: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
echo '<p>' . __('All done.', 'wordpress-importer') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'wordpress-importer') . '</a></p>';
echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'wordpress-importer') . '</p>';
do_action('import_end');
// deprecated
do_action('tf_ext_import_end', array('version' => @$this->version, 'authors' => @$this->authors, 'posts' => @$this->posts, 'terms' => @$this->terms, 'categories' => @$this->categories, 'tags' => @$this->tags, 'base_url' => @$this->base_url, 'processed_authors' => @$this->processed_authors, 'author_mapping' => @$this->author_mapping, 'processed_terms' => @$this->processed_terms, 'processed_posts' => @$this->processed_posts, 'post_orphans' => @$this->post_orphans, 'processed_menu_items' => @$this->processed_menu_items, 'menu_item_orphans' => @$this->menu_item_orphans, 'missing_menu_items' => @$this->missing_menu_items, 'fetch_attachments' => @$this->fetch_attachments, 'url_remap' => @$this->url_remap, 'featured_images' => @$this->featured_images, 'old_site_url' => @$this->old_site_url, 'new_site_url' => @$this->new_site_url, 'upload_url_old' => @$this->upload_url_old, 'install_url' => @$this->install_url, 'tfuse_options' => @$this->tfuse_options));
}
开发者ID:pinchpointer, 项目名称:ppsitewordpress, 代码行数:19, 代码来源:wordpress-importer.php
solegalli/feature-selection-for-machine-learning: Code repository for the online
阅读:904| 2022-08-18
tianli/matlab_offscreen: Matlab offscreen rendering toolbox.
阅读:1039| 2022-08-17
win7系统电脑使用过程中有不少朋友表示遇到过win7系统重装系统初始设置的状况,当出现
阅读:824| 2022-11-06
底的笔顺怎么写?底的笔顺笔画顺序是什么?聊聊底字的笔画顺序怎么写了解到好多的写字朋
阅读:933| 2022-07-30
これがマストドンだ! 使い方からインスタンスの作り方まで | 電子書籍とプリントオン
阅读:834| 2022-08-17
raichen/LinuxServerCodes: Linux高性能服务器编程源码
阅读:405| 2022-08-15
; not allowed before ELSEElSE前不允许有“;” clause not allowed in OLE automatio
阅读:651| 2022-07-18
由于人们消费水平的提高,人们越来越多的追求美的享受,瓷砖美缝就是一种让瓷砖缝隙变
阅读:602| 2022-11-06
@fastify/bearer-auth is a Fastify plugin to require bearer Authorization headers
阅读:791| 2022-07-29
evijit/material-chess-android: An opensource Material Design Chess Game for Andr
阅读:696| 2022-08-17
请发表评论