PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 3.0
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v3.0
3.9.5 3.9.6 4.0.0 4.0.1 4.1.0 trunk 2.12 2.13 2.14 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.3-beta-1.0 3.7.4 3.7.4-beta-1.0 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4
wp-all-import / plugin.php
wp-all-import Last commit date
actions 13 years ago classes 13 years ago config 13 years ago controllers 13 years ago filters 13 years ago helpers 13 years ago history 13 years ago libraries 13 years ago logs 13 years ago models 13 years ago shortcodes 13 years ago static 13 years ago upload 13 years ago views 13 years ago plugin.php 13 years ago readme.txt 13 years ago schema.php 13 years ago screenshot-1.png 13 years ago screenshot-2.png 13 years ago screenshot-3.png 13 years ago screenshot-4.png 13 years ago
plugin.php
603 lines
1 <?php
2 /*
3 Plugin Name: WP All Import Lite
4 Plugin URI: http://www.wpallimport.com/
5 Description: The most powerful solution for importing XML and CSV files to WordPress. Create Posts and Pages with content from any XML or CSV file. Perform scheduled updates and overwrite of existing import jobs. Free lite edition.
6 Version: 3.0
7 Author: Soflyy
8 */
9 /**
10 * Plugin root dir with forward slashes as directory separator regardless of actuall DIRECTORY_SEPARATOR value
11 * @var string
12 */
13 define('PMXI_ROOT_DIR', str_replace('\\', '/', dirname(__FILE__)));
14 /**
15 * Plugin root url for referencing static content
16 * @var string
17 */
18 define('PMXI_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
19 /**
20 * Plugin prefix for making names unique (be aware that this variable is used in conjuction with naming convention,
21 * i.e. in order to change it one must not only modify this constant but also rename all constants, classes and functions which
22 * names composed using this prefix)
23 * @var string
24 */
25 define('PMXI_PREFIX', 'pmxi_');
26
27 /**
28 * Main plugin file, Introduces MVC pattern
29 *
30 * @singletone
31 * @author Pavel Kulbakin <p.kulbakin@gmail.com>
32 */
33 final class PMXI_Plugin {
34 /**
35 * Singletone instance
36 * @var PMXI_Plugin
37 */
38 protected static $instance;
39
40 /**
41 * Plugin options
42 * @var array
43 */
44 protected $options = array();
45
46 /**
47 * Plugin root dir
48 * @var string
49 */
50 const ROOT_DIR = PMXI_ROOT_DIR;
51 /**
52 * Plugin root URL
53 * @var string
54 */
55 const ROOT_URL = PMXI_ROOT_URL;
56 /**
57 * Prefix used for names of shortcodes, action handlers, filter functions etc.
58 * @var string
59 */
60 const PREFIX = PMXI_PREFIX;
61 /**
62 * Plugin file path
63 * @var string
64 */
65 const FILE = __FILE__;
66 /**
67 * Max allowed file size (bytes) to import in default mode
68 * @var int
69 */
70 const LARGE_SIZE = 0; // all files will importing in large import mode
71
72 /**
73 * Return singletone instance
74 * @return PMXI_Plugin
75 */
76 static public function getInstance() {
77 if (self::$instance == NULL) {
78 self::$instance = new self();
79 }
80 return self::$instance;
81 }
82
83 /**
84 * Common logic for requestin plugin info fields
85 */
86 public function __call($method, $args) {
87 if (preg_match('%^get(.+)%i', $method, $mtch)) {
88 $info = get_plugin_data(self::FILE);
89 if (isset($info[$mtch[1]])) {
90 return $info[$mtch[1]];
91 }
92 }
93 throw new Exception("Requested method " . get_class($this) . "::$method doesn't exist.");
94 }
95
96 /**
97 * Get path to plagin dir relative to wordpress root
98 * @param bool[optional] $noForwardSlash Whether path should be returned withot forwarding slash
99 * @return string
100 */
101 public function getRelativePath($noForwardSlash = false) {
102 $wp_root = str_replace('\\', '/', ABSPATH);
103 return ($noForwardSlash ? '' : '/') . str_replace($wp_root, '', self::ROOT_DIR);
104 }
105
106 /**
107 * Check whether plugin is activated as network one
108 * @return bool
109 */
110 public function isNetwork() {
111 if ( !is_multisite() )
112 return false;
113
114 $plugins = get_site_option('active_sitewide_plugins');
115 if (isset($plugins[plugin_basename(self::FILE)]))
116 return true;
117
118 return false;
119 }
120
121 /**
122 * Check whether permalinks is enabled
123 * @return bool
124 */
125 public function isPermalinks() {
126 global $wp_rewrite;
127
128 return $wp_rewrite->using_permalinks();
129 }
130
131 /**
132 * Return prefix for plugin database tables
133 * @return string
134 */
135 public function getTablePrefix() {
136 global $wpdb;
137 return ($this->isNetwork() ? $wpdb->base_prefix : $wpdb->prefix) . self::PREFIX;
138 }
139
140 /**
141 * Return prefix for wordpress database tables
142 * @return string
143 */
144 public function getWPPrefix() {
145 global $wpdb;
146 return ($this->isNetwork() ? $wpdb->base_prefix : $wpdb->prefix);
147 }
148
149 /**
150 * Class constructor containing dispatching logic
151 * @param string $rootDir Plugin root dir
152 * @param string $pluginFilePath Plugin main file
153 */
154 protected function __construct() {
155
156 // create/update required database tables
157
158 // regirster autoloading method
159 if (function_exists('__autoload') and ! in_array('__autoload', spl_autoload_functions())) { // make sure old way of autoloading classes is not broken
160 spl_autoload_register('__autoload');
161 }
162 spl_autoload_register(array($this, '__autoload'));
163
164 // register helpers
165 if (is_dir(self::ROOT_DIR . '/helpers')) foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/helpers/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
166 require_once $filePath;
167 }
168
169 // create history folder
170 $uploads = wp_upload_dir();
171 if (!is_dir($uploads['basedir'] . '/wpallimport_history')) wp_mkdir_p($uploads['basedir'] . '/wpallimport_history');
172 // create logs folder
173 if (!is_dir($uploads['basedir'] . '/wpallimport_logs')) wp_mkdir_p($uploads['basedir'] . '/wpallimport_logs');
174
175 // init plugin options
176 $option_name = get_class($this) . '_Options';
177 $options_default = PMXI_Config::createFromFile(self::ROOT_DIR . '/config/options.php')->toArray();
178 $this->options = array_intersect_key(get_option($option_name, array()), $options_default) + $options_default;
179 $this->options = array_intersect_key($options_default, array_flip(array('info_api_url'))) + $this->options; // make sure hidden options apply upon plugin reactivation
180 if ('' == $this->options['cron_job_key']) $this->options['cron_job_key'] = url_title(rand_char(12));
181
182 update_option($option_name, $this->options);
183 $this->options = get_option(get_class($this) . '_Options');
184
185 register_activation_hook(self::FILE, array($this, '__activation'));
186
187 // register action handlers
188 if (is_dir(self::ROOT_DIR . '/actions')) if (is_dir(self::ROOT_DIR . '/actions')) foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/actions/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
189 require_once $filePath;
190 $function = $actionName = basename($filePath, '.php');
191 if (preg_match('%^(.+?)[_-](\d+)$%', $actionName, $m)) {
192 $actionName = $m[1];
193 $priority = intval($m[2]);
194 } else {
195 $priority = 10;
196 }
197 add_action($actionName, self::PREFIX . str_replace('-', '_', $function), $priority, 99); // since we don't know at this point how many parameters each plugin expects, we make sure they will be provided with all of them (it's unlikely any developer will specify more than 99 parameters in a function)
198 }
199
200 // register filter handlers
201 if (is_dir(self::ROOT_DIR . '/filters')) foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/filters/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
202 require_once $filePath;
203 $function = $actionName = basename($filePath, '.php');
204 if (preg_match('%^(.+?)[_-](\d+)$%', $actionName, $m)) {
205 $actionName = $m[1];
206 $priority = intval($m[2]);
207 } else {
208 $priority = 10;
209 }
210 add_filter($actionName, self::PREFIX . str_replace('-', '_', $function), $priority, 99); // since we don't know at this point how many parameters each plugin expects, we make sure they will be provided with all of them (it's unlikely any developer will specify more than 99 parameters in a function)
211 }
212
213 // register shortcodes handlers
214 if (is_dir(self::ROOT_DIR . '/shortcodes')) foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/shortcodes/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
215 $tag = strtolower(str_replace('/', '_', preg_replace('%^' . preg_quote(self::ROOT_DIR . '/shortcodes/', '%') . '|\.php$%', '', $filePath)));
216 add_shortcode($tag, array($this, 'shortcodeDispatcher'));
217 }
218
219 // register admin page pre-dispatcher
220 add_action('admin_init', array($this, '__adminInit'));
221
222 $this->__add_feed_type_fix(); // feature to version 2.22
223
224 }
225
226 /**
227 * pre-dispatching logic for admin page controllers
228 */
229 public function __adminInit() {
230 $input = new PMXI_Input();
231 $page = strtolower($input->getpost('page', ''));
232 if (preg_match('%^' . preg_quote(str_replace('_', '-', self::PREFIX), '%') . '([\w-]+)$%', $page)) {
233 $this->adminDispatcher($page, strtolower($input->getpost('action', 'index')));
234 }
235 }
236
237 /**
238 * Dispatch shorttag: create corresponding controller instance and call its index method
239 * @param array $args Shortcode tag attributes
240 * @param string $content Shortcode tag content
241 * @param string $tag Shortcode tag name which is being dispatched
242 * @return string
243 */
244 public function shortcodeDispatcher($args, $content, $tag) {
245
246 $controllerName = self::PREFIX . preg_replace('%(^|_).%e', 'strtoupper("$0")', $tag); // capitalize first letters of class name parts and add prefix
247 $controller = new $controllerName();
248 if ( ! $controller instanceof PMXI_Controller) {
249 throw new Exception("Shortcode `$tag` matches to a wrong controller type.");
250 }
251 ob_start();
252 $controller->index($args, $content);
253 return ob_get_clean();
254 }
255
256 /**
257 * Dispatch admin page: call corresponding controller based on get parameter `page`
258 * The method is called twice: 1st time as handler `parse_header` action and then as admin menu item handler
259 * @param string[optional] $page When $page set to empty string ealier buffered content is outputted, otherwise controller is called based on $page value
260 */
261 public function adminDispatcher($page = '', $action = 'index') {
262 static $buffer = NULL;
263 static $buffer_callback = NULL;
264 if ('' === $page) {
265 if ( ! is_null($buffer)) {
266 echo '<div class="wrap">';
267 echo $buffer;
268 do_action('pmxi_action_after');
269 echo '</div>';
270 } elseif ( ! is_null($buffer_callback)) {
271 echo '<div class="wrap">';
272 call_user_func($buffer_callback);
273 do_action('pmxi_action_after');
274 echo '</div>';
275 } else {
276 throw new Exception('There is no previousely buffered content to display.');
277 }
278 } else {
279 $controllerName = preg_replace('%(^' . preg_quote(self::PREFIX, '%') . '|_).%e', 'strtoupper("$0")', str_replace('-', '_', $page)); // capitalize prefix and first letters of class name parts
280 $actionName = str_replace('-', '_', $action);
281 if (method_exists($controllerName, $actionName)) {
282 $this->_admin_current_screen = (object)array(
283 'id' => $controllerName,
284 'base' => $controllerName,
285 'action' => $actionName,
286 'is_ajax' => isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest',
287 'is_network' => is_network_admin(),
288 'is_user' => is_user_admin(),
289 );
290 add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
291 add_filter('admin_body_class', create_function('', 'return "' . PMXI_Plugin::PREFIX . 'plugin";'));
292
293 $controller = new $controllerName();
294 if ( ! $controller instanceof PMXI_Controller_Admin) {
295 throw new Exception("Administration page `$page` matches to a wrong controller type.");
296 }
297
298 if ($this->_admin_current_screen->is_ajax) { // ajax request
299 $controller->$action();
300 do_action('pmxi_action_after');
301 die(); // stop processing since we want to output only what controller is randered, nothing in addition
302 } elseif ( ! $controller->isInline) {
303 ob_start();
304 $controller->$action();
305 $buffer = ob_get_clean();
306 } else {
307 $buffer_callback = array($controller, $action);
308 }
309 } else { // redirect to dashboard if requested page and/or action don't exist
310 wp_redirect(admin_url()); die();
311 }
312 }
313 }
314
315 protected $_admin_current_screen = NULL;
316 public function getAdminCurrentScreen()
317 {
318 return $this->_admin_current_screen;
319 }
320
321 /**
322 * Autoloader
323 * It's assumed class name consists of prefix folloed by its name which in turn corresponds to location of source file
324 * if `_` symbols replaced by directory path separator. File name consists of prefix folloed by last part in class name (i.e.
325 * symbols after last `_` in class name)
326 * When class has prefix it's source is looked in `models`, `controllers`, `shortcodes` folders, otherwise it looked in `core` or `library` folder
327 *
328 * @param string $className
329 * @return bool
330 */
331 public function __autoload($className) {
332 $is_prefix = false;
333 $filePath = str_replace('_', '/', preg_replace('%^' . preg_quote(self::PREFIX, '%') . '%', '', strtolower($className), 1, $is_prefix)) . '.php';
334 if ( ! $is_prefix) { // also check file with original letter case
335 $filePathAlt = $className . '.php';
336 }
337 foreach ($is_prefix ? array('models', 'controllers', 'shortcodes', 'classes') : array('libraries') as $subdir) {
338 $path = self::ROOT_DIR . '/' . $subdir . '/' . $filePath;
339 if (is_file($path)) {
340 require $path;
341 return TRUE;
342 }
343 if ( ! $is_prefix) {
344 $pathAlt = self::ROOT_DIR . '/' . $subdir . '/' . $filePathAlt;
345 if (is_file($pathAlt)) {
346 require $pathAlt;
347 return TRUE;
348 }
349 }
350 }
351
352 return FALSE;
353 }
354
355 /**
356 * Get plugin option
357 * @param string[optional] $option Parameter to return, all array of options is returned if not set
358 * @return mixed
359 */
360 public function getOption($option = NULL) {
361 if (is_null($option)) {
362 return $this->options;
363 } else if (isset($this->options[$option])) {
364 return $this->options[$option];
365 } else {
366 throw new Exception("Specified option is not defined for the plugin");
367 }
368 }
369 /**
370 * Update plugin option value
371 * @param string $option Parameter name or array of name => value pairs
372 * @param mixed[optional] $value New value for the option, if not set than 1st parameter is supposed to be array of name => value pairs
373 * @return array
374 */
375 public function updateOption($option, $value = NULL) {
376 is_null($value) or $option = array($option => $value);
377 if (array_diff_key($option, $this->options)) {
378 throw new Exception("Specified option is not defined for the plugin");
379 }
380 $this->options = $option + $this->options;
381 update_option(get_class($this) . '_Options', $this->options);
382
383 return $this->options;
384 }
385
386 /**
387 * Plugin activation logic
388 */
389 public function __activation() {
390 // uncaught exception doesn't prevent plugin from being activated, therefore replace it with fatal error so it does
391 set_exception_handler(create_function('$e', 'trigger_error($e->getMessage(), E_USER_ERROR);'));
392
393 // create plugin options
394 $option_name = get_class($this) . '_Options';
395 $options_default = PMXI_Config::createFromFile(self::ROOT_DIR . '/config/options.php')->toArray();
396 update_option($option_name, $options_default);
397
398 // create/update required database tables
399 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
400 require self::ROOT_DIR . '/schema.php';
401 dbDelta($plugin_queries);
402
403 $this->__ver_1_04_transition_fix();
404
405 // sync data between plugin tables and wordpress (mostly for the case when plugin is reactivated)
406 global $wpdb;
407 $post = new PMXI_Post_Record();
408 $wpdb->query('DELETE FROM ' . $post->getTable() . ' WHERE post_id NOT IN (SELECT ID FROM ' . $wpdb->posts . ')');
409
410 }
411
412 /**
413 * Method perfoms transition from version when file uploads has been stored in dabase to the solution when it stored on disk
414 * NOTE: the function can be removed when plugin version progress and it's sure matter nobody has ver 1.03
415 */
416 public function __ver_1_04_transition_fix() {
417 $uploads = wp_upload_dir();
418
419 if ( ! is_dir($uploads['basedir'] . '/wpallimport_history') or ! is_writable($uploads['basedir'] . '/wpallimport_history')) {
420 die(sprintf(__('Uploads folder %s must be writable', 'pmxi_plugin'), $uploads['basedir'] . '/wpallimport_history'));
421 }
422
423 if ( ! is_dir($uploads['basedir'] . '/wpallimport_logs') or ! is_writable($uploads['basedir'] . '/wpallimport_logs')) {
424 die(sprintf(__('Uploads folder %s must be writable', 'pmxi_plugin'), $uploads['basedir'] . '/wpallimport_logs'));
425 }
426
427 $table = $table = $this->getTablePrefix() . 'files';
428 global $wpdb;
429 $tablefields = $wpdb->get_results("DESCRIBE {$table};");
430 // For every field in the table
431 foreach ($tablefields as $tablefield) {
432 if ('contents' == $tablefield->Field) {
433 $list = new PMXI_File_List();
434 for ($i = 1; $list->getBy(NULL, 'id', $i, 1)->count(); $i++) {
435 foreach ($list->convertRecords() as $file) {
436 $file->save(); // resave file for file to be stored in uploads folder
437 }
438 }
439
440 $wpdb->query("ALTER TABLE {$table} DROP " . $tablefield->Field);
441 break;
442 }
443 }
444 }
445
446 public function __add_feed_type_fix(){
447
448 $table = $this->getTablePrefix() . 'imports';
449 global $wpdb;
450 $tablefields = $wpdb->get_results("DESCRIBE {$table};");
451 $large_import = false;
452 $root_element = false;
453 $processing = false;
454 $triggered = false;
455 $queue_chunk_number = false;
456 $current_post_ids = false;
457 $first_import = false;
458 $count = false;
459 $friendly_name = false;
460 $imported = false;
461 $created = false;
462 $updated = false;
463 $skipped = false;
464
465 // Check if field exists
466 foreach ($tablefields as $tablefield) {
467 if ('large_import' == $tablefield->Field) $large_import = true;
468 if ('root_element' == $tablefield->Field) $root_element = true;
469 if ('processing' == $tablefield->Field) $processing = true;
470 if ('triggered' == $tablefield->Field) $triggered = true;
471 if ('current_post_ids' == $tablefield->Field) $current_post_ids = true;
472 if ('queue_chunk_number' == $tablefield->Field) $queue_chunk_number = true;
473 if ('first_import' == $tablefield->Field) $first_import = true;
474 if ('count' == $tablefield->Field) $count = true;
475 if ('friendly_name' == $tablefield->Field) $friendly_name = true;
476 if ('imported' == $tablefield->Field) $imported = true;
477 if ('created' == $tablefield->Field) $created = true;
478 if ('updated' == $tablefield->Field) $updated = true;
479 if ('skipped' == $tablefield->Field) $skipped = true;
480 }
481 if (!$large_import) $wpdb->query("ALTER TABLE {$table} ADD `large_import` ENUM( 'Yes', 'No' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'No';");
482 if (!$root_element) $wpdb->query("ALTER TABLE {$table} ADD `root_element` VARCHAR(255) DEFAULT '';");
483 if (!$processing) $wpdb->query("ALTER TABLE {$table} ADD `processing` BOOL NOT NULL DEFAULT '0';");
484 if (!$triggered) $wpdb->query("ALTER TABLE {$table} ADD `triggered` BOOL NOT NULL DEFAULT '0';");
485 if (!$queue_chunk_number) $wpdb->query("ALTER TABLE {$table} ADD `queue_chunk_number` BIGINT(20) NOT NULL DEFAULT '0';");
486 if (!$current_post_ids) $wpdb->query("ALTER TABLE {$table} ADD `current_post_ids` TEXT NULL DEFAULT '';");
487 if (!$first_import) $wpdb->query("ALTER TABLE {$table} ADD `first_import` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;");
488 if (!$count) $wpdb->query("ALTER TABLE {$table} ADD `count` BIGINT(20) NOT NULL DEFAULT '0';");
489 if (!$imported) $wpdb->query("ALTER TABLE {$table} ADD `imported` BIGINT(20) NOT NULL DEFAULT '0';");
490 if (!$created) $wpdb->query("ALTER TABLE {$table} ADD `created` BIGINT(20) NOT NULL DEFAULT '0';");
491 if (!$updated) $wpdb->query("ALTER TABLE {$table} ADD `updated` BIGINT(20) NOT NULL DEFAULT '0';");
492 if (!$skipped) $wpdb->query("ALTER TABLE {$table} ADD `skipped` BIGINT(20) NOT NULL DEFAULT '0';");
493 if (!$friendly_name) $wpdb->query("ALTER TABLE {$table} ADD `friendly_name` VARCHAR(255) NOT NULL DEFAULT '';");
494
495 $table = $this->getTablePrefix() . 'templates';
496 global $wpdb;
497 $tablefields = $wpdb->get_results("DESCRIBE {$table};");
498 $is_leave_html = false;
499 // Check if field exists
500 foreach ($tablefields as $tablefield) {
501 if ('is_leave_html' == $tablefield->Field) $is_leave_html = true;
502 }
503 if (!$is_leave_html) $wpdb->query("ALTER TABLE {$table} ADD `is_leave_html` TINYINT( 1 ) NOT NULL DEFAULT '0';");
504
505 }
506
507 /**
508 * Method returns default import options, main utility of the method is to avoid warnings when new
509 * option is introduced but already registered imports don't have it
510 */
511 public static function get_default_import_options() {
512 return array(
513 'type' => 'post',
514 'custom_type' => '',
515 'categories' => '',
516 'tags' => '',
517 'tags_delim' => ',',
518 'categories_delim' => ',',
519 'featured_delim' => ',',
520 'atch_delim' => ',',
521 'post_taxonomies' => array(),
522 'parent' => '',
523 'order' => '0',
524 'status' => 'publish',
525 'page_template' => 'default',
526 'page_taxonomies' => array(),
527 'date_type' => 'specific',
528 'date' => 'now',
529 'date_start' => 'now',
530 'date_end' => 'now',
531 'custom_name' => array(),
532 'custom_value' => array(),
533 'comment_status' => 'open',
534 'ping_status' => 'open',
535 'create_draft' => 'no',
536 'author' => '',
537 'featured_image' => '',
538 'attachments' => '',
539 'is_import_specified' => 0,
540 'import_specified' => '',
541 'is_delete_source' => 0,
542 'is_cloak' => 0,
543 'unique_key' => '',
544 'feed_type' => 'auto',
545
546 'is_delete_missing' => 0,
547 'is_keep_former_posts' => 'no',
548 'is_keep_status' => 0,
549 'is_keep_content' => 0,
550 'is_keep_title' => 0,
551 'is_keep_excerpt' => 0,
552 'is_keep_categories' => 0,
553 'is_keep_attachments' => 0,
554 'is_keep_images' => 0,
555 'is_duplicates' => 0,
556 'is_keep_dates' => 0,
557 'is_keep_menu_order' => 0,
558 'records_per_request' => 10,
559 'not_create_records' => 0,
560 'no_create_featured_image' => 0,
561
562 'duplicate_indicator' => 'title',
563 'duplicate_action' => 'keep',
564 'is_update_previous' => 0,
565 'is_scheduled' => '',
566 'scheduled_period' => '',
567 'post_excerpt' => '',
568 'post_slug' => '',
569 'keep_custom_fields' => 0,
570 'keep_custom_fields_specific' => '',
571 'friendly_name' => '',
572 'custom_duplicate_name' => '',
573 'custom_duplicate_value' => '',
574 'duplicate_matching' => 'auto',
575 'create_chunks' => 0,
576 );
577 }
578
579 /*
580 * Convert csv to xml using yahoo API
581 */
582 public static function csv_to_xml($csv_url){
583
584 include_once(self::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
585
586 $csv = new PMXI_CsvParser($csv_url);
587
588 $wp_uploads = wp_upload_dir();
589 $tmpname = wp_unique_filename($wp_uploads['path'], str_replace("csv", "xml", basename($csv_url)));
590 $xml_file = $wp_uploads['path'] .'/'. $tmpname;
591 file_put_contents($xml_file, $csv->toXML());
592 return $xml_file;
593
594 }
595
596 public static function is_ajax(){
597 return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') ? true : false ;
598 }
599
600 }
601
602 PMXI_Plugin::getInstance();
603