本文整理汇总了PHP中wp_all_import_remove_source函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_all_import_remove_source函数的具体用法?PHP wp_all_import_remove_source怎么用?PHP wp_all_import_remove_source使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_all_import_remove_source函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete($unlink = true)
{
$import_file_path = wp_all_import_get_absolute_path($this->path);
if (@file_exists($import_file_path) and $unlink) {
wp_all_import_remove_source($import_file_path);
}
return parent::delete();
}
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:8,代码来源:record.php
示例2: delete
public function delete()
{
if ($this->id) {
// delete history file first
$uploads = wp_upload_dir();
$file_name = $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::HISTORY_DIRECTORY . DIRECTORY_SEPARATOR . $this->id;
@file_exists($file_name) and @is_file($file_name) and wp_all_import_remove_source($file_name, false);
}
return parent::delete();
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:10,代码来源:record.php
示例3: wp_all_import_secure_file
function wp_all_import_secure_file($targetDir, $importID = false, $remove_dir = false)
{
$is_secure_import = PMXI_Plugin::getInstance()->getOption('secure');
if ($is_secure_import) {
$dir = $targetDir . DIRECTORY_SEPARATOR . ($importID ? md5($importID . NONCE_SALT) : md5(time() . NONCE_SALT));
if (@is_dir($dir) and $remove_dir) {
wp_all_import_remove_source($dir . DIRECTORY_SEPARATOR . 'index.php');
}
@wp_mkdir_p($dir);
if (@is_writable($dir) and @is_dir($dir)) {
$targetDir = $dir;
if (!@file_exists($dir . DIRECTORY_SEPARATOR . 'index.php')) {
@touch($dir . DIRECTORY_SEPARATOR . 'index.php');
}
}
}
return $targetDir;
}
开发者ID:TakenCdosG,项目名称:chefs,代码行数:18,代码来源:wp_all_import_secure_file.php
示例4: deleteFiles
/**
* Delete associated files
* @return PMXI_Import_Record
* @chainable
*/
public function deleteFiles()
{
$fileList = new PMXI_File_List();
foreach ($fileList->getBy('import_id', $this->id)->convertRecords() as $f) {
if (@file_exists($f->path)) {
wp_all_import_remove_source($f->path);
}
$f->delete();
}
return $this;
}
开发者ID:k-hasan-19,项目名称:wp-all-import,代码行数:16,代码来源:record.php
示例5: pmxi_wp_loaded
function pmxi_wp_loaded()
{
@ini_set("max_input_time", PMXI_Plugin::getInstance()->getOption('max_input_time'));
@ini_set("max_execution_time", PMXI_Plugin::getInstance()->getOption('max_execution_time'));
$table = PMXI_Plugin::getInstance()->getTablePrefix() . 'imports';
global $wpdb;
$imports = $wpdb->get_results("SELECT `id`, `name`, `path` FROM {$table} WHERE `path` IS NULL", ARRAY_A);
if (!empty($imports)) {
$importRecord = new PMXI_Import_Record();
$importRecord->clear();
foreach ($imports as $imp) {
$importRecord->getById($imp['id']);
if (!$importRecord->isEmpty()) {
$importRecord->delete(true);
}
$importRecord->clear();
}
}
/* Check if cron is manualy, then execute import */
$cron_job_key = PMXI_Plugin::getInstance()->getOption('cron_job_key');
if (!empty($cron_job_key) and !empty($_GET['import_id']) and !empty($_GET['import_key']) and $_GET['import_key'] == $cron_job_key and !empty($_GET['action']) and in_array($_GET['action'], array('processing', 'trigger', 'pipe'))) {
$logger = create_function('$m', 'echo "<p>$m</p>\\n";');
$import = new PMXI_Import_Record();
$ids = explode(',', $_GET['import_id']);
if (!empty($ids) and is_array($ids)) {
foreach ($ids as $id) {
if (empty($id)) {
continue;
}
$import->getById($id);
if (!$import->isEmpty()) {
if (!in_array($import->type, array('url', 'ftp', 'file'))) {
$logger and call_user_func($logger, sprintf(__('Scheduling update is not working with "upload" import type. Import #%s.', 'wp_all_import_plugin'), $id));
}
switch ($_GET['action']) {
case 'trigger':
if ((int) $import->executing) {
$logger and call_user_func($logger, sprintf(__('Import #%s is currently in manually process. Request skipped.', 'wp_all_import_plugin'), $id));
} elseif (!$import->processing and !$import->triggered) {
$import->set(array('triggered' => 1, 'imported' => 0, 'created' => 0, 'updated' => 0, 'skipped' => 0, 'deleted' => 0, 'queue_chunk_number' => 0, 'last_activity' => date('Y-m-d H:i:s')))->update();
$history_log = new PMXI_History_Record();
$history_log->set(array('import_id' => $import->id, 'date' => date('Y-m-d H:i:s'), 'type' => 'trigger', 'summary' => __("triggered by cron", "wp_all_import_plugin")))->save();
$logger and call_user_func($logger, sprintf(__('#%s Cron job triggered.', 'wp_all_import_plugin'), $id));
} elseif ($import->processing and !$import->triggered) {
$logger and call_user_func($logger, sprintf(__('Import #%s currently in process. Request skipped.', 'wp_all_import_plugin'), $id));
} elseif (!$import->processing and $import->triggered) {
$logger and call_user_func($logger, sprintf(__('Import #%s already triggered. Request skipped.', 'wp_all_import_plugin'), $id));
}
break;
case 'processing':
if ($import->processing == 1 and time() - strtotime($import->registered_on) > (PMXI_Plugin::getInstance()->getOption('cron_processing_time_limit') ? PMXI_Plugin::getInstance()->getOption('cron_processing_time_limit') : 120)) {
// it means processor crashed, so it will reset processing to false, and terminate. Then next run it will work normally.
$import->set(array('processing' => 0))->update();
}
// start execution imports that is in the cron process
if (!(int) $import->triggered) {
$logger and call_user_func($logger, sprintf(__('Import #%s is not triggered. Request skipped.', 'wp_all_import_plugin'), $id));
} elseif ((int) $import->executing) {
$logger and call_user_func($logger, sprintf(__('Import #%s is currently in manually process. Request skipped.', 'wp_all_import_plugin'), $id));
} elseif ((int) $import->triggered and !(int) $import->processing) {
$log_storage = (int) PMXI_Plugin::getInstance()->getOption('log_storage');
// unlink previous logs
$by = array();
$by[] = array(array('import_id' => $id, 'type NOT LIKE' => 'trigger'), 'AND');
$historyLogs = new PMXI_History_List();
$historyLogs->setColumns('id', 'import_id', 'type', 'date')->getBy($by, 'id ASC');
if ($historyLogs->count() and $historyLogs->count() >= $log_storage) {
$logsToRemove = $historyLogs->count() - $log_storage;
foreach ($historyLogs as $i => $file) {
$historyRecord = new PMXI_History_Record();
$historyRecord->getBy('id', $file['id']);
if (!$historyRecord->isEmpty()) {
$historyRecord->delete();
}
// unlink history file only
if ($i == $logsToRemove) {
break;
}
}
}
$history_log = new PMXI_History_Record();
$history_log->set(array('import_id' => $import->id, 'date' => date('Y-m-d H:i:s'), 'type' => 'processing', 'summary' => __("cron processing", "wp_all_import_plugin")))->save();
if ($log_storage) {
$wp_uploads = wp_upload_dir();
$log_file = wp_all_import_secure_file($wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::LOGS_DIRECTORY, $history_log->id) . DIRECTORY_SEPARATOR . $history_log->id . '.html';
if (@file_exists($log_file)) {
wp_all_import_remove_source($log_file, false);
}
}
ob_start();
$import->set(array('canceled' => 0, 'failed' => 0))->execute($logger, true, $history_log->id);
$log_data = ob_get_clean();
if ($log_storage) {
$log = @fopen($log_file, 'a+');
@fwrite($log, $log_data);
@fclose($log);
}
if (!(int) $import->queue_chunk_number) {
$logger and call_user_func($logger, sprintf(__('Import #%s complete', 'wp_all_import_plugin'), $import->id));
} else {
//.........这里部分代码省略.........
开发者ID:jamesaveryw,项目名称:mississippi-staging,代码行数:101,代码来源:wp_loaded.php
示例6: delete_source
public function delete_source($logger = false)
{
if ($this->options['is_delete_source']) {
$uploads = wp_upload_dir();
$logger and call_user_func($logger, __('Deleting source XML file...', 'wp_all_import_plugin'));
// Delete chunks
foreach (PMXI_Helper::safe_glob($uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'pmxi_chunk_*', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
$logger and call_user_func($logger, __('Deleting chunks files...', 'wp_all_import_plugin'));
@file_exists($filePath) and wp_all_import_remove_source($filePath, false);
}
if ($this->type != "ftp") {
$apath = wp_all_import_get_absolute_path($this->path);
if (!@unlink($apath)) {
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to remove %s', 'wp_all_import_plugin'), $apath));
}
} else {
$file_path_array = PMXI_Helper::safe_glob($this->path, PMXI_Helper::GLOB_NODIR | PMXI_Helper::GLOB_PATH);
if (!empty($file_path_array)) {
foreach ($file_path_array as $path) {
$apath = wp_all_import_get_absolute_path($path);
if (!@unlink($apath)) {
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to remove %s', 'wp_all_import_plugin'), $apath));
}
}
}
}
}
}
开发者ID:TakenCdosG,项目名称:chefs,代码行数:28,代码来源:record.php
示例7: process
/**
* Import processing step (status console)
*/
public function process($save_history = true)
{
$wp_uploads = wp_upload_dir();
$import = $this->data['update_previous'];
$history_log = new PMXI_History_Record();
$input = new PMXI_Input();
if (!empty(PMXI_Plugin::$session->history_id)) {
$history_log->getById(PMXI_Plugin::$session->history_id);
}
$log_storage = (int) PMXI_Plugin::getInstance()->getOption('log_storage');
if (!PMXI_Plugin::is_ajax()) {
$import->set((empty(PMXI_Plugin::$session->source) ? array() : PMXI_Plugin::$session->source) + array('xpath' => PMXI_Plugin::$session->xpath, 'options' => PMXI_Plugin::$session->options, 'count' => PMXI_Plugin::$session->count, 'friendly_name' => PMXI_Plugin::$session->options['friendly_name'], 'feed_type' => PMXI_Plugin::$session->feed_type, 'parent_import_id' => $this->data['update_previous']->isEmpty() ? PMXI_Plugin::$session->parent_import_id : $this->data['update_previous']->parent_import_id, 'queue_chunk_number' => 0, 'triggered' => 0, 'processing' => 0, 'executing' => 1, 'iteration' => !empty($import->iteration) ? $import->iteration : 0))->save();
if (PMXI_Plugin::$session->action != 'continue') {
// store import info in database
$import->set(array('imported' => 0, 'created' => 0, 'updated' => 0, 'skipped' => 0, 'deleted' => 0))->update();
}
// add history log
$custom_type = get_post_type_object($import->options['custom_type']);
// unlink previous logs
$by = array();
$by[] = array(array('import_id' => $import->id, 'type NOT LIKE' => 'trigger'), 'AND');
$historyLogs = new PMXI_History_List();
$historyLogs->setColumns('id', 'import_id', 'type', 'date')->getBy($by, 'id ASC');
if ($historyLogs->count() and $historyLogs->count() >= $log_storage) {
$logsToRemove = $historyLogs->count() - $log_storage;
foreach ($historyLogs as $i => $file) {
$historyRecord = new PMXI_History_Record();
$historyRecord->getBy('id', $file['id']);
if (!$historyRecord->isEmpty()) {
$historyRecord->delete();
}
// unlink history file only
if ($i == $logsToRemove) {
break;
}
}
}
$history_log->set(array('import_id' => $import->id, 'date' => date('Y-m-d H:i:s'), 'type' => PMXI_Plugin::$session->action != 'continue' ? 'manual' : 'continue', 'summary' => sprintf(__("%d %ss created %d updated %d deleted %d skipped", "pmxi_plugin"), $import->created, $custom_type->labels->singular_name, $import->updated, $import->deleted, $import->skipped)))->save();
PMXI_Plugin::$session->set('history_id', $history_log->id);
foreach (get_taxonomies() as $tax) {
delete_transient("pmxi_{$tax}_terms");
}
do_action('pmxi_before_xml_import', $import->id);
PMXI_Plugin::$session->set('update_previous', $import->id);
if (empty($import->options['encoding'])) {
$currentOptions = $import->options;
$currentOptions['encoding'] = 'UTF-8';
$import->set(array('options' => $currentOptions))->update();
}
// unlink previous files
$history = new PMXI_File_List();
$history->setColumns('id', 'name', 'registered_on', 'path')->getBy(array('import_id' => $import->id), 'id DESC');
if ($history->count()) {
foreach ($history as $file) {
$history_file_path = wp_all_import_get_absolute_path($file['path']);
if (@file_exists($history_file_path) and $history_file_path != PMXI_Plugin::$session->filePath) {
if (in_array($import->type, array('upload'))) {
wp_all_import_remove_source($history_file_path, false);
} else {
wp_all_import_remove_source($history_file_path);
}
}
$history_file = new PMXI_File_Record();
$history_file->getBy('id', $file['id']);
if (!$history_file->isEmpty()) {
$history_file->delete();
}
}
}
if ($save_history) {
$history_file = new PMXI_File_Record();
$history_file->set(array('name' => $import->name, 'import_id' => $import->id, 'path' => wp_all_import_get_relative_path(PMXI_Plugin::$session->filePath), 'registered_on' => date('Y-m-d H:i:s')))->save();
}
/*
Split file up into 1000 record chunks.
This option will decrease the amount of slowdown experienced at the end of large imports.
The slowdown is partially caused by the need for WP All Import to read deeper and deeper into the file on each successive iteration.
Splitting the file into pieces means that, for example, instead of having to read 19000 records into a 20000 record file when importing the last 1000 records,
WP All Import will just split it into 20 chunks, and then read the last chunk from the beginning.
*/
if ("ajax" == $import->options['import_processing'] and $import->count > PMXI_Plugin::getInstance()->getOption('large_feed_limit') and $import->options['chuncking']) {
$chunk_files = array();
if (!empty(PMXI_Plugin::$session->local_paths)) {
$records_count = 0;
$chunk_records_count = 0;
$feed = "<?xml version=\"1.0\" encoding=\"" . $import->options['encoding'] . "\"?>" . "\n" . "<pmxi_records>";
foreach (PMXI_Plugin::$session->local_paths as $key => $path) {
$file = new PMXI_Chunk($path, array('element' => $import->root_element, 'encoding' => $import->options['encoding']));
// loop through the file until all lines are read
while ($xml = $file->read()) {
if (!empty($xml)) {
PMXI_Import_Record::preprocessXml($xml);
$chunk = "<?xml version=\"1.0\" encoding=\"" . $import->options['encoding'] . "\"?>" . "\n" . $xml;
$dom = new DOMDocument('1.0', $import->options['encoding']);
$old = libxml_use_internal_errors(true);
$dom->loadXML($chunk);
// FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
//.........这里部分代码省略.........
开发者ID:hikaram,项目名称:wee,代码行数:101,代码来源:import.php
示例8: file
public function file()
{
$template = false;
$wp_uploads = wp_upload_dir();
$uploads = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR;
if (empty($this->file)) {
$this->errors->add('form-validation', __('Please specify a file to import.', 'wp_all_import_plugin'));
} elseif (preg_match('%\\W(zip)$%i', trim($this->file))) {
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
echo '<span style="display:none">';
copy($uploads . $this->file, $this->uploadsPath . '/' . basename($this->file));
echo '</span>';
$zipfilePath = $this->uploadsPath . '/' . basename($this->file);
if (!class_exists('PclZip')) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/pclzip.lib.php';
}
$archive = new PclZip($zipfilePath);
if (($v_result_list = $archive->extract(PCLZIP_OPT_PATH, $this->uploadsPath, PCLZIP_OPT_REPLACE_NEWER)) == 0) {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
} else {
$filePath = '';
if (!empty($v_result_list)) {
foreach ($v_result_list as $unzipped_file) {
if ($unzipped_file['status'] == 'ok' and preg_match('%\\W(xml|csv|txt|dat|psv|json|xls|xlsx)$%i', trim($unzipped_file['stored_filename'])) and strpos($unzipped_file['stored_filename'], 'readme.txt') === false) {
if (strpos(basename($unzipped_file['stored_filename']), 'WP All Import Template') === 0 || strpos(basename($unzipped_file['stored_filename']), 'templates_') === 0) {
$template = file_get_contents($unzipped_file['filename']);
} elseif ($filePath == '') {
$filePath = $unzipped_file['filename'];
}
}
}
}
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
if (empty($filePath)) {
$zip = zip_open(trim($zipfilePath));
if (is_resource($zip)) {
while ($zip_entry = zip_read($zip)) {
$filePath = zip_entry_name($zip_entry);
$fp = fopen($this->uploadsPath . "/" . $filePath, "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp, "{$buf}");
zip_entry_close($zip_entry);
fclose($fp);
}
break;
}
zip_close($zip);
} else {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
}
}
// Detect if file is very large
$source = array('name' => basename($this->file), 'type' => 'file', 'path' => $uploads . $this->file);
if (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($filePath))) {
// If CSV file found in archieve
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $filePath, 'targetDir' => $this->uploadsPath));
// create chunks
//wp_all_import_remove_source($filePath, false);
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(json)$%i', trim($filePath))) {
$json_str = file_get_contents($filePath);
$is_json = wp_all_import_is_json($json_str);
if (is_wp_error($is_json)) {
$this->errors->add('form-validation', $is_json->get_error_message(), 'wp_all_import_plugin');
} else {
$xml_data = wp_all_import_json_to_xml(json_decode($json_str, true));
if (empty($xml_data)) {
$this->errors->add('form-validation', __('Can not import this file. JSON to XML convertation failed.', 'wp_all_import_plugin'));
} else {
$jsontmpname = $this->uploadsPath . '/' . wp_all_import_url_title(wp_unique_filename($this->uploadsPath, str_replace("json", "xml", basename($filePath))));
file_put_contents($jsontmpname, $xml_data);
wp_all_import_remove_source($filePath);
$filePath = $jsontmpname;
}
}
} elseif (preg_match('%\\W(sql)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportSQLParse.php';
$localSQLPath = $filePath;
$sql = new PMXI_SQLParser($localSQLPath, $this->uploadsPath);
$filePath = $sql->parse();
wp_all_import_remove_source($localSQLPath, false);
} elseif (preg_match('%\\W(xls|xlsx)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportXLSParse.php';
$localXLSPath = $filePath;
$xls = new PMXI_XLSParser($localXLSPath, $this->uploadsPath);
$filePath = $xls->parse();
wp_all_import_remove_source($localXLSPath, false);
}
}
//.........这里部分代码省略.........
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:101,代码来源:upload.php
示例9: process
//.........这里部分代码省略.........
update_post_meta($id, $this->options['update_missing_cf_name'], $this->options['update_missing_cf_value']);
$to_delete = false;
$logger and call_user_func($logger, sprintf(__('Instead of deletion post with ID `%s`, set Custom Field `%s` to value `%s`', 'wp_all_import_plugin'), $id, $this->options['update_missing_cf_name'], $this->options['update_missing_cf_value']));
}
// Instead of deletion, change post status to Draft
$final_post_type = get_post_type($pid);
if ($this->options['set_missing_to_draft'] and $final_post_type != 'product_variation') {
$this->wpdb->update($this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $id));
$to_delete = false;
$logger and call_user_func($logger, sprintf(__('Instead of deletion, change post with ID `%s` status to Draft', 'wp_all_import_plugin'), $id));
}
if ($to_delete) {
// Remove attachments
empty($this->options['is_keep_attachments']) and wp_delete_attachments($id, true, 'files');
// Remove images
empty($this->options['is_keep_imgs']) and wp_delete_attachments($id, true, 'images');
// Clear post's relationships
if ($post_type[$i] != "import_users") {
wp_delete_object_term_relationships($id, get_object_taxonomies('' != $this->options['custom_type'] ? $this->options['custom_type'] : 'post'));
}
} else {
unset($ids[$k]);
}
}
if (!empty($ids)) {
do_action('pmxi_delete_post', $ids);
if ($this->options['custom_type'] == "import_users") {
$sql = "delete a,b\n\t\t\t\t\t\t\t\t\t\tFROM " . $this->wpdb->users . " a\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . $this->wpdb->usermeta . " b ON ( a.ID = b.user_id )\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tWHERE a.ID IN (" . implode(',', $ids) . ");";
} else {
$sql = "delete a,b,c\n\t\t\t\t\t\t\t\t\t\tFROM " . $this->wpdb->posts . " a\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . $this->wpdb->term_relationships . " b ON ( a.ID = b.object_id )\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . $this->wpdb->postmeta . " c ON ( a.ID = c.post_id )\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tWHERE a.ID IN (" . implode(',', $ids) . ");";
}
$this->wpdb->query($sql);
// Delete record form pmxi_posts
$sql = "DELETE FROM " . PMXI_Plugin::getInstance()->getTablePrefix() . "posts WHERE post_id IN (" . implode(',', $ids) . ") AND import_id = %d";
$this->wpdb->query($this->wpdb->prepare($sql, $this->id));
$this->set(array('deleted' => $this->deleted + count($ids)))->update();
}
}
}
}
}
// Set out of stock status for missing records [Woocommerce add-on option]
if ($is_import_complete and empty($this->options['is_delete_missing']) and $post_type[$i] == "product" and class_exists('PMWI_Plugin') and !empty($this->options['missing_records_stock_status'])) {
$logger and call_user_func($logger, __('Update stock status previously imported posts which are no longer actual...', 'wp_all_import_plugin'));
$postList = new PMXI_Post_List();
$missingPosts = $postList->getBy(array('import_id' => $this->id, 'iteration !=' => $this->iteration));
if (!$missingPosts->isEmpty()) {
foreach ($missingPosts as $missingPost) {
update_post_meta($missingPost['post_id'], '_stock_status', 'outofstock');
update_post_meta($missingPost['post_id'], '_stock', 0);
$missingPostRecord = new PMXI_Post_Record();
$missingPostRecord->getBy('id', $missingPost['id']);
if (!$missingPostRecord->isEmpty()) {
$missingPostRecord->set(array('iteration' => $this->iteration))->update();
}
unset($missingPostRecord);
}
}
}
}
} catch (XmlImportException $e) {
$logger and call_user_func($logger, __('<b>ERROR</b>', 'wp_all_import_plugin') . ': ' . $e->getMessage());
$logger and !$is_cron and PMXI_Plugin::$session->errors++;
}
$logger and $is_import_complete and call_user_func($logger, __('Cleaning temporary data...', 'wp_all_import_plugin'));
foreach ($tmp_files as $file) {
// remove all temporary files created
@unlink($file);
}
if (($is_cron or $is_import_complete) and $this->options['is_delete_source']) {
$logger and call_user_func($logger, __('Deleting source XML file...', 'wp_all_import_plugin'));
// Delete chunks
foreach (PMXI_Helper::safe_glob($uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::TEMP_DIRECTORY . DIRECTORY_SEPARATOR . 'pmxi_chunk_*', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
$logger and call_user_func($logger, __('Deleting chunks files...', 'wp_all_import_plugin'));
@file_exists($filePath) and wp_all_import_remove_source($filePath, false);
}
if ($this->type != "ftp") {
if (!@unlink($this->path)) {
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to remove %s', 'wp_all_import_plugin'), $this->path));
}
} else {
$file_path_array = PMXI_Helper::safe_glob($this->path, PMXI_Helper::GLOB_NODIR | PMXI_Helper::GLOB_PATH);
if (!empty($file_path_array)) {
foreach ($file_path_array as $path) {
if (!@unlink($path)) {
$logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to remove %s', 'wp_all_import_plugin'), $path));
}
}
}
}
}
if (!$is_cron and $is_import_complete) {
$this->set(array('processing' => 0, 'triggered' => 0, 'queue_chunk_number' => 0, 'registered_on' => date('Y-m-d H:i:s'), 'iteration' => ++$this->iteration))->update();
$logger and call_user_func($logger, 'Done');
}
remove_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html'));
kses_init();
// return any filtering rules back if they has been disabled for import procedure
return $this;
}
开发者ID:seoduda,项目名称:Patua,代码行数:101,代码来源:record.php
示例10: upload
public function upload()
{
$uploads = wp_upload_dir();
if (empty($this->file)) {
$this->errors->add('form-validation', __('Please specify a file to import.<br/><br/>If you are uploading the file from your computer, please wait for it to finish uploading (progress bar at 100%), before trying to continue.', 'wp_all_import_plugin'));
} elseif (!is_file($this->file)) {
$this->errors->add('form-validation', __('Uploaded file is empty', 'wp_all_import_plugin'));
} elseif (!preg_match('%\\W(xml|gzip|zip|csv|gz|json|txt|dat|psv|sql)$%i', trim(basename($this->file)))) {
$this->errors->add('form-validation', __('Uploaded file must be XML, CSV, ZIP, GZIP, GZ, JSON, SQL, TXT, DAT or PSV', 'wp_all_import_plugin'));
} elseif (preg_match('%\\W(zip)$%i', trim(basename($this->file)))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/pclzip.lib.php';
$archive = new PclZip($this->file);
if (($v_result_list = $archive->extract(PCLZIP_OPT_PATH, $this->uploadsPath, PCLZIP_OPT_REPLACE_NEWER)) == 0) {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
} else {
$filePath = '';
if (!empty($v_result_list)) {
foreach ($v_result_list as $unzipped_file) {
if ($unzipped_file['status'] == 'ok' and preg_match('%\\W(xml|csv|txt|dat|psv|json)$%i', trim($unzipped_file['stored_filename']))) {
$filePath = $unzipped_file['filename'];
break;
}
}
}
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
if (empty($filePath)) {
$zip = zip_open(trim($this->file));
if (is_resource($zip)) {
while ($zip_entry = zip_read($zip)) {
$filePath = zip_entry_name($zip_entry);
$fp = fopen($this->uploadsPath . "/" . $filePath, "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp, "{$buf}");
zip_entry_close($zip_entry);
fclose($fp);
}
break;
}
zip_close($zip);
} else {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
}
}
// Detect if file is very large
$source = array('name' => basename($this->file), 'type' => 'upload', 'path' => $this->file);
if (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($filePath))) {
// If CSV file found in archieve
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $filePath, 'targetDir' => $this->uploadsPath));
// create chunks
//wp_all_import_remove_source($filePath, false);
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(json)$%i', trim($filePath))) {
$json_str = file_get_contents($filePath);
$is_json = wp_all_import_is_json($json_str);
if (is_wp_error($is_json)) {
$this->errors->add('form-validation', $is_json->get_error_message(), 'wp_all_import_plugin');
} else {
$xml_data = wp_all_import_json_to_xml(json_decode($json_str, true));
if (empty($xml_data)) {
$this->errors->add('form-validation', __('Can not import this file. JSON to XML convertation failed.', 'wp_all_import_plugin'));
} else {
$jsontmpname = $this->uploadsPath . '/' . wp_all_import_url_title(wp_unique_filename($this->uploadsPath, str_replace("json", "xml", basename($filePath))));
file_put_contents($jsontmpname, $xml_data);
wp_all_import_remove_source($filePath, false);
$filePath = $jsontmpname;
}
}
} elseif (preg_match('%\\W(sql)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportSQLParse.php';
$localSQLPath = $filePath;
$sql = new PMXI_SQLParser($localSQLPath, $this->uploadsPath);
$filePath = $sql->parse();
wp_all_import_remove_source($localSQLPath, false);
}
}
} elseif (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($this->file))) {
// If CSV file uploaded
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
$filePath = $this->file;
$source = array('name' => basename($this->file), 'type' => 'upload', 'path' => $filePath);
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $this->file, 'targetDir' => $this->uploadsPath));
//@unlink($filePath);
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(gz)$%i', trim($this->file))) {
// If gz file uploaded
$fileInfo = wp_all_import_get_gz($this->file, 0, $this->uploadsPath);
//.........这里部分代码省略.........
开发者ID:GolgoSoft,项目名称:KeenerWP,代码行数:101,代码来源:upload.php
示例11: get_xml_file
protected function get_xml_file($filePath)
{
$csv_path = '';
if (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($filePath))) {
// If CSV file found in archieve
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $filePath, 'targetDir' => $this->uploadsPath));
// create chunks
$csv_path = $filePath;
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(json)$%i', trim($filePath))) {
$json_str = file_get_contents($filePath);
$is_json = wp_all_import_is_json($json_str);
if (is_wp_error($is_json)) {
$this->errors->add('form-validation', $is_json->get_error_message(), 'wp_all_import_plugin');
} else {
$xml_data = wp_all_import_json_to_xml(json_decode($json_str, true));
if (empty($xml_data)) {
$this->errors->add('form-validation', __('Can not import this file. JSON to XML convertation failed.', 'wp_all_import_plugin'));
} else {
$jsontmpname = $this->uploadsPath . '/' . wp_all_import_url_title(wp_unique_filename($this->uploadsPath, str_replace("json", "xml", basename($filePath))));
file_put_contents($jsontmpname, $xml_data);
wp_all_import_remove_source($filePath, false);
$filePath = $jsontmpname;
}
}
} elseif (preg_match('%\\W(sql)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportSQLParse.php';
$localSQLPath = $filePath;
$sql = new PMXI_SQLParser($localSQLPath, $this->uploadsPath);
$filePath = $sql->parse();
wp_all_import_remove_source($localSQLPath, false);
} elseif (preg_match('%\\W(xls|xlsx)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportXLSParse.php';
$localXLSPath = $filePath;
$xls = new PMXI_XLSParser($localXLSPath, $this->uploadsPath);
$filePath = $xls->parse();
wp_all_import_remove_source($localXLSPath, false);
}
return array('csv' => $csv_path, 'xml' => $filePath);
}
开发者ID:estrategasdigitales,项目名称:rufiatta,代码行数:46,代码来源:upload.php
注:本文中的wp_all_import_remove_source函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论