export.php
8 years ago
feedback.php
8 years ago
help.php
8 years ago
manage.php
8 years ago
settings.php
8 years ago
export.php
531 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Export configuration wizard |
| 4 | * |
| 5 | * @author Max Tsiplyakov <makstsiplyakov@gmail.com> |
| 6 | */ |
| 7 | |
| 8 | class PMXE_Admin_Export extends PMXE_Controller_Admin { |
| 9 | |
| 10 | protected $isWizard = true; // indicates whether controller is in wizard mode (otherwise it called to be delegated an edit action) |
| 11 | |
| 12 | protected function init() { |
| 13 | |
| 14 | parent::init(); |
| 15 | |
| 16 | if ('PMXE_Admin_Manage' == PMXE_Plugin::getInstance()->getAdminCurrentScreen()->base) { // prereqisites are not checked when flow control is deligated |
| 17 | $id = $this->input->get('id'); |
| 18 | $this->data['export'] = $export = new PMXE_Export_Record(); |
| 19 | if ( ! $id or $export->getById($id)->isEmpty()) { // specified import is not found |
| 20 | wp_redirect(add_query_arg('page', 'pmxe-admin-manage', admin_url('admin.php'))); die(); |
| 21 | } |
| 22 | $this->isWizard = false; |
| 23 | $export->fix_template_options(); |
| 24 | } else { |
| 25 | $action = PMXE_Plugin::getInstance()->getAdminCurrentScreen()->action; |
| 26 | $this->_step_ready($action); |
| 27 | } |
| 28 | |
| 29 | // preserve id parameter as part of baseUrl |
| 30 | $id = $this->input->get('id') and $this->baseUrl = add_query_arg('id', $id, $this->baseUrl); |
| 31 | |
| 32 | } |
| 33 | |
| 34 | public function set($var, $val) |
| 35 | { |
| 36 | $this->{$var} = $val; |
| 37 | } |
| 38 | public function get($var) |
| 39 | { |
| 40 | return $this->{$var}; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Checks whether corresponding step of wizard is complete |
| 45 | * @param string $action |
| 46 | * @return bool |
| 47 | */ |
| 48 | protected function _step_ready($action) { |
| 49 | |
| 50 | // step #1: xml selction - has no prerequisites |
| 51 | if ('index' == $action) return true; |
| 52 | |
| 53 | if ('element' == $action) return true; |
| 54 | |
| 55 | $this->data['update_previous'] = $update_previous = new PMXE_Export_Record(); |
| 56 | |
| 57 | $update_previous->getById(PMXE_Plugin::$session->update_previous); |
| 58 | |
| 59 | if ( ! $update_previous->isEmpty() ) |
| 60 | { |
| 61 | $update_previous->fix_template_options(); |
| 62 | } |
| 63 | |
| 64 | if ('options' == $action) return true; |
| 65 | |
| 66 | if ( ! PMXE_Plugin::$session->has_session()){ |
| 67 | wp_redirect_or_javascript($this->baseUrl); die(); |
| 68 | } |
| 69 | |
| 70 | if ('process' == $action) return true; |
| 71 | |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Step #1: Choose CPT |
| 76 | */ |
| 77 | public function index() { |
| 78 | |
| 79 | $action = $this->input->get('action'); |
| 80 | |
| 81 | $DefaultOptions = array( |
| 82 | 'cpt' => '', |
| 83 | 'export_to' => 'xml', |
| 84 | 'export_type' => 'specific', |
| 85 | 'wp_query' => '', |
| 86 | 'filter_rules_hierarhy' => '', |
| 87 | 'product_matching_mode' => 'strict', |
| 88 | 'wp_query_selector' => 'wp_query', |
| 89 | 'auto_generate' => 0, |
| 90 | 'taxonomy_to_export' => '', |
| 91 | 'created_at_version' => PMXE_VERSION |
| 92 | ); |
| 93 | |
| 94 | if ( ! in_array($action, array('index'))) |
| 95 | { |
| 96 | PMXE_Plugin::$session->clean_session(); |
| 97 | $this->data['preload'] = false; |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | $DefaultOptions = (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + $DefaultOptions; |
| 102 | $this->data['preload'] = true; |
| 103 | } |
| 104 | |
| 105 | $this->data['post'] = $post = $this->input->post($DefaultOptions); |
| 106 | |
| 107 | if ( is_array($this->data['post']['cpt']) ) $this->data['post']['cpt'] = $this->data['post']['cpt'][0]; |
| 108 | |
| 109 | // Delete history |
| 110 | $history_files = PMXE_Helper::safe_glob(PMXE_ROOT_DIR . '/history/*', PMXE_Helper::GLOB_RECURSE | PMXE_Helper::GLOB_PATH); |
| 111 | if ( ! empty($history_files) ){ |
| 112 | foreach ($history_files as $filePath) { |
| 113 | @file_exists($filePath) and @unlink($filePath); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | if ( ! class_exists('ZipArchive') ) |
| 118 | { |
| 119 | $this->errors->add('form-validation', __('ZipArchive class is missing on your server.<br/>Please contact your web hosting provider and ask them to install and activate ZipArchive.', 'wp_all_export_plugin')); |
| 120 | } |
| 121 | if ( ! class_exists('XMLReader') or ! class_exists('XMLWriter')) |
| 122 | { |
| 123 | $this->errors->add('form-validation', __('Required PHP components are missing.<br/><br/>WP All Export requires XMLReader, and XMLWriter PHP modules to be installed.<br/>These are standard features of PHP, and are necessary for WP All Export to write the files you are trying to export.<br/>Please contact your web hosting provider and ask them to install and activate the DOMDocument, XMLReader, and XMLWriter PHP modules.', 'wp_all_export_plugin')); |
| 124 | } |
| 125 | |
| 126 | if ($this->input->post('is_submitted')) |
| 127 | { |
| 128 | |
| 129 | PMXE_Plugin::$session->set('export_type', $post['export_type']); |
| 130 | PMXE_Plugin::$session->set('filter_rules_hierarhy', $post['filter_rules_hierarhy']); |
| 131 | PMXE_Plugin::$session->set('product_matching_mode', $post['product_matching_mode']); |
| 132 | PMXE_Plugin::$session->set('wp_query_selector', $post['wp_query_selector']); |
| 133 | PMXE_Plugin::$session->set('taxonomy_to_export', $post['taxonomy_to_export']); |
| 134 | PMXE_Plugin::$session->set('created_at_version', $post['created_at_version']); |
| 135 | |
| 136 | if (!empty($post['auto_generate'])) |
| 137 | { |
| 138 | $auto_generate = XmlCsvExport::auto_genetate_export_fields($post, $this->errors); |
| 139 | |
| 140 | foreach ($auto_generate as $key => $value) |
| 141 | { |
| 142 | PMXE_Plugin::$session->set($key, $value); |
| 143 | } |
| 144 | |
| 145 | PMXE_Plugin::$session->save_data(); |
| 146 | } |
| 147 | else |
| 148 | { |
| 149 | $engine = new XmlExportEngine($post, $this->errors); |
| 150 | $engine->init_additional_data(); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | if ($this->input->post('is_submitted') and ! $this->errors->get_error_codes()) { |
| 155 | |
| 156 | check_admin_referer('choose-cpt', '_wpnonce_choose-cpt'); |
| 157 | |
| 158 | PMXE_Plugin::$session->save_data(); |
| 159 | |
| 160 | if ( ! empty($post['auto_generate']) ) |
| 161 | { |
| 162 | wp_redirect(add_query_arg('action', 'options', $this->baseUrl)); die(); |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | wp_redirect(add_query_arg('action', 'template', $this->baseUrl)); die(); |
| 167 | } |
| 168 | |
| 169 | } |
| 170 | |
| 171 | $this->render(); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Step #2: Export Template |
| 176 | */ |
| 177 | public function template(){ |
| 178 | |
| 179 | $template = new PMXE_Template_Record(); |
| 180 | |
| 181 | $default = PMXE_Plugin::get_default_import_options(); |
| 182 | |
| 183 | $this->data['dismiss_warnings'] = 0; |
| 184 | if ($this->isWizard) { |
| 185 | // New export |
| 186 | $DefaultOptions = (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + $default; |
| 187 | $post = $this->input->post($DefaultOptions); |
| 188 | } |
| 189 | else{ |
| 190 | // Edit export |
| 191 | $DefaultOptions = $this->data['export']->options + $default; |
| 192 | |
| 193 | if (empty($this->data['export']->options['export_variations'])){ |
| 194 | $DefaultOptions['export_variations'] = XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION; |
| 195 | } |
| 196 | if (empty($this->data['export']->options['export_variations_title'])){ |
| 197 | $DefaultOptions['export_variations_title'] = XmlExportEngine::VARIATION_USE_DEFAULT_TITLE; |
| 198 | } |
| 199 | $post = $this->input->post($DefaultOptions); |
| 200 | $post['scheduled'] = $this->data['export']->scheduled; |
| 201 | |
| 202 | foreach ($post as $key => $value) { |
| 203 | PMXE_Plugin::$session->set($key, $value); |
| 204 | } |
| 205 | $this->data['dismiss_warnings'] = get_option('wpae_dismiss_warnings_' . $this->data['export']->id, 0); |
| 206 | } |
| 207 | |
| 208 | $max_input_vars = @ini_get('max_input_vars'); |
| 209 | |
| 210 | if(ctype_digit($max_input_vars) && count($_POST, COUNT_RECURSIVE) >= $max_input_vars) |
| 211 | { |
| 212 | $this->errors->add('form-validation', sprintf(__('You\'ve reached your max_input_vars limit of %d. Please contact your web host to increase it.', 'wp_all_export_plugin'), $max_input_vars)); |
| 213 | } |
| 214 | |
| 215 | PMXE_Plugin::$session->save_data(); |
| 216 | |
| 217 | $this->data['post'] =& $post; |
| 218 | |
| 219 | PMXE_Plugin::$session->set('is_loaded_template', ''); |
| 220 | |
| 221 | $this->data['engine'] = null; |
| 222 | |
| 223 | XmlExportEngine::$exportQuery = PMXE_Plugin::$session->get('exportQuery'); |
| 224 | |
| 225 | if (($load_template = $this->input->post('load_template'))) { // init form with template selected |
| 226 | if ( ! $template->getById($load_template)->isEmpty()) { |
| 227 | $template_options = $template->options; |
| 228 | unset($template_options['cpt']); |
| 229 | //unset($template_options['export_to']); |
| 230 | //unset($template_options['export_type']); |
| 231 | unset($template_options['wp_query']); |
| 232 | unset($template_options['filter_rules_hierarhy']); |
| 233 | unset($template_options['product_matching_mode']); |
| 234 | unset($template_options['wp_query_selector']); |
| 235 | $this->data['post'] = array_merge($post, $template_options); |
| 236 | PMXE_Plugin::$session->set('is_loaded_template', $load_template); |
| 237 | } |
| 238 | |
| 239 | } elseif ($this->input->post('is_submitted')) { |
| 240 | check_admin_referer('template', '_wpnonce_template'); |
| 241 | |
| 242 | if ( empty($post['cc_type'][0]) && ! in_array($post['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ){ |
| 243 | $this->errors->add('form-validation', __('You haven\'t selected any columns for export.', 'wp_all_export_plugin')); |
| 244 | } |
| 245 | |
| 246 | if ( 'csv' == $post['export_to'] and '' == $post['delimiter'] ){ |
| 247 | $this->errors->add('form-validation', __('CSV delimiter must be specified.', 'wp_all_export_plugin')); |
| 248 | } |
| 249 | |
| 250 | if ( 'xml' == $post['export_to'] && ! in_array($post['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) |
| 251 | { |
| 252 | $post['main_xml_tag'] = preg_replace('/[^a-z0-9_]/i', '', $post['main_xml_tag']); |
| 253 | if ( empty($post['main_xml_tag']) ){ |
| 254 | $this->errors->add('form-validation', __('Main XML Tag is required.', 'wp_all_export_plugin')); |
| 255 | } |
| 256 | |
| 257 | $post['record_xml_tag'] = preg_replace('/[^a-z0-9_]/i', '', $post['record_xml_tag']); |
| 258 | if ( empty($post['record_xml_tag']) ){ |
| 259 | $this->errors->add('form-validation', __('Single Record XML Tag is required.', 'wp_all_export_plugin')); |
| 260 | } |
| 261 | |
| 262 | if ($post['main_xml_tag'] == $post['record_xml_tag']){ |
| 263 | $this->errors->add('form-validation', __('Main XML Tag equals to Single Record XML Tag.', 'wp_all_export_plugin')); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | if ( in_array($post['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ){ |
| 268 | |
| 269 | if ( empty($post['custom_xml_template']) ) |
| 270 | { |
| 271 | $this->errors->add('form-validation', __('XML template is empty.', 'wp_all_export_plugin')); |
| 272 | } |
| 273 | |
| 274 | // Convert Custom XML template to default |
| 275 | if ( ! empty($post['custom_xml_template'])){ |
| 276 | |
| 277 | $post['custom_xml_template'] = str_replace('<ID>','<id>', $post['custom_xml_template'] ); |
| 278 | $post['custom_xml_template'] = str_replace('</ID>','</id>', $post['custom_xml_template'] ); |
| 279 | |
| 280 | $post['custom_xml_template'] = str_replace("<!-- BEGIN POST LOOP -->", "<!-- BEGIN LOOP -->", $post['custom_xml_template']); |
| 281 | $post['custom_xml_template'] = str_replace("<!-- END POST LOOP -->", "<!-- END LOOP -->", $post['custom_xml_template']); |
| 282 | |
| 283 | $this->data['engine'] = new XmlExportEngine($post, $this->errors); |
| 284 | |
| 285 | $this->data['engine']->init_additional_data(); |
| 286 | |
| 287 | $this->data = array_merge($this->data, $this->data['engine']->init_available_data()); |
| 288 | |
| 289 | $result = $this->data['engine']->parse_custom_xml_template(); |
| 290 | |
| 291 | if ( ! $this->errors->get_error_codes()) { |
| 292 | $post = array_merge($post, $result); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | if ( ! $this->errors->get_error_codes()) { |
| 298 | |
| 299 | if ( ! empty($post['name']) and !empty($post['save_template_as']) ) { // save template in database |
| 300 | $template->getByName($post['name'])->set(array( |
| 301 | 'name' => $post['name'], |
| 302 | 'options' => $post |
| 303 | ))->save(); |
| 304 | PMXE_Plugin::$session->set('saved_template', $template->id); |
| 305 | } |
| 306 | |
| 307 | if ($this->isWizard) { |
| 308 | foreach ($this->data['post'] as $key => $value) { |
| 309 | PMXE_Plugin::$session->set($key, $value); |
| 310 | } |
| 311 | PMXE_Plugin::$session->save_data(); |
| 312 | wp_redirect(add_query_arg('action', 'options', $this->baseUrl)); die(); |
| 313 | } |
| 314 | else { |
| 315 | $this->data['export']->set(array( 'options' => $post, 'settings_update_on' => date('Y-m-d H:i:s')))->save(); |
| 316 | if ( ! empty($post['friendly_name']) ) { |
| 317 | $this->data['export']->set( array( 'friendly_name' => $post['friendly_name'], 'scheduled' => (($post['is_scheduled']) ? $post['scheduled_period'] : '') ) )->save(); |
| 318 | } |
| 319 | wp_redirect(add_query_arg(array('page' => 'pmxe-admin-manage', 'pmxe_nt' => urlencode(__('Options updated', 'pmxi_plugin'))) + array_intersect_key($_GET, array_flip($this->baseUrlParamNames)), admin_url('admin.php'))); die(); |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | if ( empty($this->data['engine']) ){ |
| 325 | |
| 326 | $this->data['engine'] = new XmlExportEngine($post, $this->errors); |
| 327 | |
| 328 | $this->data['engine']->init_additional_data(); |
| 329 | |
| 330 | $this->data = array_merge($this->data, $this->data['engine']->init_available_data()); |
| 331 | } |
| 332 | |
| 333 | $this->data['available_data_view'] = $this->data['engine']->render(); |
| 334 | |
| 335 | $this->data['available_fields_view'] = $this->data['engine']->render_new_field(); |
| 336 | |
| 337 | if (class_exists('SitePress')){ |
| 338 | global $sitepress; |
| 339 | $langs = $sitepress->get_active_languages(); |
| 340 | if ( ! empty($langs) ){ |
| 341 | // prepare active languages list |
| 342 | $language_list = array('all' => 'All'); |
| 343 | foreach ($langs as $code => $langInfo){ |
| 344 | $language_list[$code] = "<img width='18' height='12' src='" . $sitepress->get_flag_url($code) . "' style='position:relative; top: 2px;'/> " . $langInfo['display_name']; |
| 345 | if ($code == $this->default_language) $language_list[$code] .= ' ( <strong>default</strong> )'; |
| 346 | } |
| 347 | } |
| 348 | $this->data['wpml_options'] = $language_list; |
| 349 | } |
| 350 | |
| 351 | $this->render(); |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Step #3: Export Options |
| 356 | */ |
| 357 | public function options() |
| 358 | { |
| 359 | $default = PMXE_Plugin::get_default_import_options(); |
| 360 | |
| 361 | if ($this->isWizard) { |
| 362 | $DefaultOptions = (PMXE_Plugin::$session->has_session() ? PMXE_Plugin::$session->get_clear_session_data() : array()) + $default; |
| 363 | $post = $this->input->post($DefaultOptions); |
| 364 | } |
| 365 | else{ |
| 366 | $DefaultOptions = $this->data['export']->options + $default; |
| 367 | if (empty($this->data['export']->options['export_variations'])){ |
| 368 | $DefaultOptions['export_variations'] = XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_PARENT_AND_VARIATION; |
| 369 | } |
| 370 | if (empty($this->data['export']->options['export_variations_title'])){ |
| 371 | $DefaultOptions['export_variations_title'] = XmlExportEngine::VARIATION_USE_DEFAULT_TITLE; |
| 372 | } |
| 373 | $post = $this->input->post($DefaultOptions); |
| 374 | $post['scheduled'] = $this->data['export']->scheduled; |
| 375 | |
| 376 | foreach ($post as $key => $value) { |
| 377 | PMXE_Plugin::$session->set($key, $value); |
| 378 | } |
| 379 | PMXE_Plugin::$session->save_data(); |
| 380 | } |
| 381 | |
| 382 | $this->data['engine'] = new XmlExportEngine($post, $this->errors); |
| 383 | |
| 384 | $this->data['engine']->init_available_data(); |
| 385 | |
| 386 | $this->data['post'] =& $post; |
| 387 | |
| 388 | if ($this->input->post('is_submitted')) { |
| 389 | |
| 390 | check_admin_referer('options', '_wpnonce_options'); |
| 391 | |
| 392 | if ($post['is_generate_templates'] and '' == $post['template_name']){ |
| 393 | $friendly_name = ''; |
| 394 | $post_types = PMXE_Plugin::$session->get('cpt'); |
| 395 | if ( ! empty($post_types) ) |
| 396 | { |
| 397 | if ( in_array('users', $post_types) ){ |
| 398 | $friendly_name = 'Users Export - ' . date("Y F d H:i"); |
| 399 | } |
| 400 | elseif ( in_array('shop_customer', $post_types)){ |
| 401 | $friendly_name = 'Customers Export - ' . date("Y F d H:i"); |
| 402 | } |
| 403 | elseif ( in_array('comments', $post_types) ){ |
| 404 | $friendly_name = 'Comments Export - ' . date("Y F d H:i"); |
| 405 | } |
| 406 | elseif ( in_array('taxonomies', $post_types) ){ |
| 407 | $tx = get_taxonomy( $post['taxonomy_to_export'] ); |
| 408 | if (!empty($tx->labels->name)){ |
| 409 | $friendly_name = $tx->labels->name . ' Export - ' . date("Y F d H:i"); |
| 410 | } |
| 411 | else{ |
| 412 | $friendly_name = 'Taxonomy Terms Export - ' . date("Y F d H:i"); |
| 413 | } |
| 414 | } |
| 415 | else |
| 416 | { |
| 417 | $post_type_details = get_post_type_object( array_shift($post_types) ); |
| 418 | $friendly_name = $post_type_details->labels->name . ' Export - ' . date("Y F d H:i"); |
| 419 | } |
| 420 | } |
| 421 | else |
| 422 | { |
| 423 | $friendly_name = 'WP_Query Export - ' . date("Y F d H:i"); |
| 424 | } |
| 425 | $post['template_name'] = $friendly_name; |
| 426 | } |
| 427 | |
| 428 | if ($this->isWizard) { |
| 429 | if ( ! $this->errors->get_error_codes()) { |
| 430 | foreach ($this->data['post'] as $key => $value) { |
| 431 | PMXE_Plugin::$session->set($key, $value); |
| 432 | } |
| 433 | PMXE_Plugin::$session->save_data(); |
| 434 | wp_redirect(add_query_arg('action', 'process', $this->baseUrl)); die(); |
| 435 | } |
| 436 | } |
| 437 | else { |
| 438 | $this->errors->remove('count-validation'); |
| 439 | if ( ! $this->errors->get_error_codes()) { |
| 440 | $this->data['export']->set(array( 'options' => $post, 'settings_update_on' => date('Y-m-d H:i:s')))->save(); |
| 441 | if ( ! empty($post['friendly_name']) ) { |
| 442 | $this->data['export']->set( array( 'friendly_name' => $post['friendly_name'], 'scheduled' => (($post['is_scheduled']) ? $post['scheduled_period'] : '') ) )->save(); |
| 443 | } |
| 444 | wp_redirect(add_query_arg(array('page' => 'pmxe-admin-manage', 'pmxe_nt' => urlencode(__('Options updated', 'wp_all_export_plugin'))) + array_intersect_key($_GET, array_flip($this->baseUrlParamNames)), admin_url('admin.php'))); die(); |
| 445 | } |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | $this->render(); |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Step #4: Export Processing |
| 454 | */ |
| 455 | public function process() |
| 456 | { |
| 457 | |
| 458 | @set_time_limit(0); |
| 459 | |
| 460 | $export = $this->data['update_previous']; |
| 461 | |
| 462 | if ( ! PMXE_Plugin::is_ajax() ) { |
| 463 | |
| 464 | if ("" == PMXE_Plugin::$session->friendly_name){ |
| 465 | |
| 466 | $post_types = PMXE_Plugin::$session->get('cpt'); |
| 467 | if ( ! empty($post_types) ) |
| 468 | { |
| 469 | if ( in_array('users', $post_types)){ |
| 470 | $friendly_name = 'Users Export - ' . date("Y F d H:i"); |
| 471 | } |
| 472 | elseif ( in_array('shop_customer', $post_types)){ |
| 473 | $friendly_name = 'Customers Export - ' . date("Y F d H:i"); |
| 474 | } |
| 475 | elseif ( in_array('comments', $post_types)){ |
| 476 | $friendly_name = 'Comments Export - ' . date("Y F d H:i"); |
| 477 | } |
| 478 | elseif ( in_array('taxonomies', $post_types)){ |
| 479 | $tx = get_taxonomy( PMXE_Plugin::$session->get('taxonomy_to_export') ); |
| 480 | if (!empty($tx->labels->name)){ |
| 481 | $friendly_name = $tx->labels->name . ' Export - ' . date("Y F d H:i"); |
| 482 | } |
| 483 | else{ |
| 484 | $friendly_name = 'Taxonomy Terms Export - ' . date("Y F d H:i"); |
| 485 | } |
| 486 | } |
| 487 | else |
| 488 | { |
| 489 | $post_type_details = get_post_type_object( array_shift($post_types) ); |
| 490 | $friendly_name = $post_type_details->labels->name . ' Export - ' . date("Y F d H:i"); |
| 491 | } |
| 492 | } |
| 493 | else |
| 494 | { |
| 495 | $friendly_name = 'WP_Query Export - ' . date("Y F d H:i"); |
| 496 | } |
| 497 | |
| 498 | PMXE_Plugin::$session->set('friendly_name', $friendly_name); |
| 499 | } |
| 500 | |
| 501 | PMXE_Plugin::$session->set('file', ''); |
| 502 | PMXE_Plugin::$session->save_data(); |
| 503 | |
| 504 | $export->set( |
| 505 | array( |
| 506 | 'triggered' => 0, |
| 507 | 'processing' => 0, |
| 508 | 'exported' => 0, |
| 509 | 'executing' => 1, |
| 510 | 'canceled' => 0, |
| 511 | 'options' => PMXE_Plugin::$session->get_clear_session_data(), |
| 512 | 'friendly_name' => PMXE_Plugin::$session->friendly_name, |
| 513 | 'scheduled' => (PMXE_Plugin::$session->is_scheduled) ? PMXE_Plugin::$session->scheduled_period : '', |
| 514 | //'registered_on' => date('Y-m-d H:i:s'), |
| 515 | 'last_activity' => date('Y-m-d H:i:s') |
| 516 | ) |
| 517 | )->save(); |
| 518 | |
| 519 | // create an import for this export |
| 520 | if ( $export->options['export_to'] == 'csv' || ! in_array($export->options['xml_template_type'], array('custom', 'XmlGoogleMerchants')) ) PMXE_Wpallimport::create_an_import( $export ); |
| 521 | PMXE_Plugin::$session->set('update_previous', $export->id); |
| 522 | PMXE_Plugin::$session->save_data(); |
| 523 | |
| 524 | do_action('pmxe_before_export', $export->id); |
| 525 | |
| 526 | } |
| 527 | |
| 528 | $this->render(); |
| 529 | |
| 530 | } |
| 531 | } |