/** * Step #1: Choose File */ public function index($post_type = 'post') { $default = PMAI_Plugin::get_default_import_options(); $this->data['id'] = $id = $this->input->get('id'); $this->data['import'] = $import = new PMXI_Import_Record(); if (!$id or $import->getById($id)->isEmpty()) { // specified import is not found $post = $this->input->post((isset(PMXI_Plugin::$session->options) ? PMXI_Plugin::$session->options : array()) + $default); } else { $post = $this->input->post($this->data['import']->options + $default); } $this->data['is_loaded_template'] = !empty(PMXI_Plugin::$session->is_loaded_template) ? PMXI_Plugin::$session->is_loaded_template : false; $load_options = $this->input->post('load_template'); if ($load_options) { // init form with template selected $template = new PMXI_Template_Record(); if (!$template->getById($this->data['is_loaded_template'])->isEmpty()) { $post = (!empty($template->options) ? $template->options : array()) + $default; } } elseif ($load_options == -1) { $post = $default; } $this->data['post_type'] = $post_type; $this->data['post'] =& $post; $this->render(); }
function pmai_admin_notices() { // notify user if history folder is not writable if (!class_exists('PMXI_Plugin')) { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: WP All Import must be installed. Free edition of WP All Import at <a href="http://wordpress.org/plugins/wp-all-import/" target="_blank">http://wordpress.org/plugins/wp-all-import/</a> and the paid edition at <a href="http://www.wpallimport.com/">http://www.wpallimport.com/</a>', 'PMAI_Plugin'), PMAI_Plugin::getInstance()->getName()); ?> </p></div> <?php deactivate_plugins(PMAI_ROOT_DIR . '/wpai-acf-add-on.php'); } if (class_exists('PMXI_Plugin') and (version_compare(PMXI_VERSION, '4.1.1') < 0 and PMXI_EDITION == 'paid' or version_compare(PMXI_VERSION, '3.2.3') <= 0 and PMXI_EDITION == 'free')) { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import to the latest version', 'pmai_plugin'), PMAI_Plugin::getInstance()->getName()); ?> </p></div> <?php deactivate_plugins(PMAI_ROOT_DIR . '/wpai-acf-add-on.php'); } if (!class_exists('acf')) { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: <a target="_blank" href="http://wordpress.org/plugins/advanced-custom-fields/">Advanced Custom Fields</a> must be installed', 'pmai_plugin'), PMAI_Plugin::getInstance()->getName()); ?> </p></div> <?php deactivate_plugins(PMAI_ROOT_DIR . '/wpai-acf-add-on.php'); } $input = new PMAI_Input(); $messages = $input->get('pmai_nt', array()); if ($messages) { is_array($messages) or $messages = array($messages); foreach ($messages as $type => $m) { in_array((string) $type, array('updated', 'error')) or $type = 'updated'; ?> <div class="<?php echo $type; ?> "><p><?php echo $m; ?> </p></div> <?php } } }
/** * @see Controller::render() */ protected function render($viewPath = NULL) { // assume template file name depending on calling function if (is_null($viewPath)) { $trace = debug_backtrace(); $viewPath = str_replace('_', '/', preg_replace('%^' . preg_quote(PMAI_Plugin::PREFIX, '%') . '%', '', strtolower($trace[1]['class']))) . '/' . $trace[1]['function']; } // render contextual help automatically $viewHelpPath = $viewPath; // append file extension if not specified if (!preg_match('%\\.php$%', $viewHelpPath)) { $viewHelpPath .= '.php'; } $viewHelpPath = preg_replace('%\\.php$%', '-help.php', $viewHelpPath); $fileHelpPath = PMAI_Plugin::ROOT_DIR . '/views/' . $viewHelpPath; if (is_file($fileHelpPath)) { // there is help file defined ob_start(); include $fileHelpPath; add_contextual_help(PMAI_Plugin::getInstance()->getAdminCurrentScreen()->id, ob_get_clean()); } parent::render($viewPath); }
function pmxi_admin_notices() { // notify user if history folder is not writable $uploads = wp_upload_dir(); // compare woocommerce add-on version if (class_exists('PMWI_Plugin') and (defined('PMWI_VERSION') and version_compare(PMWI_VERSION, '2.1.4') < 0 and PMWI_EDITION == 'paid' or defined('PMWI_FREE_VERSION') and version_compare(PMWI_FREE_VERSION, '1.2.2') < 0 and PMWI_EDITION == 'free')) { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import WooCommerce add-on to the latest version', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMWI_EDITION') and PMWI_EDITION == 'paid') { deactivate_plugins(PMWI_ROOT_DIR . '/wpai-woocommerce-add-on.php'); } else { if (defined('PMWI_FREE_ROOT_DIR')) { deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php'); } else { deactivate_plugins(PMWI_ROOT_DIR . '/plugin.php'); } } } // compare ACF add-on if (class_exists('PMAI_Plugin') and defined('PMAI_VERSION') and version_compare(PMAI_VERSION, '3.0.0-beta1') < 0 and PMAI_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import ACF add-on to the latest version', 'pmwi_plugin'), PMAI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMAI_EDITION') and PMAI_EDITION == 'paid') { deactivate_plugins(PMAI_ROOT_DIR . '/wpai-acf-add-on.php'); } } // compare Linkcloak add-on if (class_exists('PMLCA_Plugin') and defined('PMLCA_VERSION') and version_compare(PMLCA_VERSION, '1.0.0-beta1') < 0 and PMLCA_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import Linkcloak add-on to the latest version', 'pmwi_plugin'), PMLCA_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMLCA_EDITION') and PMLCA_EDITION == 'paid') { deactivate_plugins(PMLCA_ROOT_DIR . '/wpai-linkcloak-add-on.php'); } } // compare User add-on if (class_exists('PMUI_Plugin') and defined('PMUI_VERSION') and version_compare(PMUI_VERSION, '1.0.0-beta1') < 0 and PMUI_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import User add-on to the latest version', 'pmwi_plugin'), PMUI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMUI_EDITION') and PMUI_EDITION == 'paid') { deactivate_plugins(PMUI_ROOT_DIR . '/wpai-user-add-on.php'); } } // compare WPML add-on if (class_exists('PMLI_Plugin') and defined('PMLI_VERSION') and version_compare(PMLI_VERSION, '1.0.0-beta1') < 0 and PMLI_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import WPML add-on to the latest version', 'pmwi_plugin'), PMLI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMLI_EDITION') and PMLI_EDITION == 'paid') { deactivate_plugins(PMLI_ROOT_DIR . '/plugin.php'); } } $input = new PMXI_Input(); $messages = $input->get('pmxi_nt', array()); if ($messages) { is_array($messages) or $messages = array($messages); foreach ($messages as $type => $m) { in_array((string) $type, array('updated', 'error')) or $type = 'updated'; ?> <div class="<?php echo $type; ?> "><p><?php echo $m; ?> </p></div> <?php } } $warnings = $input->get('warnings', array()); if ($warnings) { is_array($warnings) or $warnings = explode(',', $warnings); foreach ($warnings as $code) { switch ($code) { case 1: $m = __('<strong>Warning:</strong> your title is blank.', 'pmxi_plugin'); break; case 2: $m = __('<strong>Warning:</strong> your content is blank.', 'pmxi_plugin'); break; case 3: $m = __('<strong>Warning:</strong> You must <a href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=images" target="_blank">upgrade to the Pro edition of WP All Import</a> to import images. The settings you configured in the images section will be ignored.', 'pmxi_plugin'); break; case 4: $m = __('<strong>Warning:</strong> You must <a href="http://www.wpallimport.com/upgrade-to-pro/?utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=custom-fields" target="_blank">upgrade to the Pro edition of WP All Import</a> to import data to Custom Fields. The settings you configured in the Custom Fields section will be ignored.', 'pmxi_plugin'); break; default: $m = false; break; } if ($m) { ?> <div class="error"><p><?php echo $m; ?> </p></div> <?php } } } wp_all_import_addon_notifications(); }
/** * Return singletone instance * @return PMAI_Plugin */ static public function getInstance() { if (self::$instance == NULL) { self::$instance = new self(); } return self::$instance; }
public function __construct() { parent::__construct(); $this->setTable(PMAI_Plugin::getInstance()->getTablePrefix() . 'imports'); }
function pmxi_admin_notices() { // notify user if history folder is not writable $uploads = wp_upload_dir(); // compare woocommerce add-on version if (class_exists('PMWI_Plugin') and (defined('PMWI_VERSION') and version_compare(PMWI_VERSION, '2.1.3 RC5') < 0 and PMWI_EDITION == 'paid' or defined('PMWI_FREE_VERSION') and version_compare(PMWI_FREE_VERSION, '1.2.1') <= 0 and PMWI_EDITION == 'free')) { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import WooCommerce add-on to the latest version', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMWI_EDITION') and PMWI_EDITION == 'paid') { deactivate_plugins(PMWI_ROOT_DIR . '/wpai-woocommerce-add-on.php'); } else { if (defined('PMWI_FREE_ROOT_DIR')) { deactivate_plugins(PMWI_FREE_ROOT_DIR . '/plugin.php'); } else { deactivate_plugins(PMWI_ROOT_DIR . '/plugin.php'); } } } // compare ACF add-on if (class_exists('PMAI_Plugin') and defined('PMAI_VERSION') and version_compare(PMAI_VERSION, '3.0.0-beta1') < 0 and PMAI_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import ACF add-on to the latest version', 'pmwi_plugin'), PMAI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMAI_EDITION') and PMAI_EDITION == 'paid') { deactivate_plugins(PMAI_ROOT_DIR . '/wpai-acf-add-on.php'); } } // compare Linkcloak add-on if (class_exists('PMLCA_Plugin') and defined('PMLCA_VERSION') and version_compare(PMLCA_VERSION, '1.0.0-beta1') < 0 and PMLCA_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import Linkcloak add-on to the latest version', 'pmwi_plugin'), PMLCA_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMLCA_EDITION') and PMLCA_EDITION == 'paid') { deactivate_plugins(PMLCA_ROOT_DIR . '/wpai-linkcloak-add-on.php'); } } // compare User add-on if (class_exists('PMUI_Plugin') and defined('PMUI_VERSION') and version_compare(PMUI_VERSION, '1.0.0-beta1') < 0 and PMUI_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: Please update your WP All Import User add-on to the latest version', 'pmwi_plugin'), PMUI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMUI_EDITION') and PMUI_EDITION == 'paid') { deactivate_plugins(PMUI_ROOT_DIR . '/wpai-user-add-on.php'); } } // compare WPML add-on if (class_exists('PMLI_Plugin') and defined('PMLI_VERSION') and version_compare(PMLI_VERSION, '1.0.0-beta1') < 0 and PMLI_EDITION == 'paid') { ?> <div class="error"><p> <?php printf(__('<b>%s Plugin</b>: The WPML Add-On Plugin is no longer compatible with this version of WP All Import - please contact support@wpallimport.com and we will supply the latest version of WP All Import that is compatible with the WPML Add-On.', 'pmwi_plugin'), PMLI_Plugin::getInstance()->getName()); ?> </p></div> <?php if (defined('PMLI_EDITION') and PMLI_EDITION == 'paid') { deactivate_plugins(PMLI_ROOT_DIR . '/plugin.php'); } } $input = new PMXI_Input(); $messages = $input->get('pmxi_nt', array()); if ($messages) { is_array($messages) or $messages = array($messages); foreach ($messages as $type => $m) { in_array((string) $type, array('updated', 'error')) or $type = 'updated'; ?> <div class="<?php echo $type; ?> "><p><?php echo $m; ?> </p></div> <?php } } $warnings = $input->get('warnings', array()); if ($warnings) { is_array($warnings) or $warnings = explode(',', $warnings); foreach ($warnings as $code) { switch ($code) { case 1: $m = __('<strong>Warning:</strong> your title is blank.', 'wp_all_import_plugin'); break; case 2: $m = __('<strong>Warning:</strong> your content is blank.', 'wp_all_import_plugin'); break; default: $m = false; break; } if ($m) { ?> <div class="error"><p><?php echo $m; ?> </p></div> <?php } } } wp_all_import_addon_notifications(); }
function pmai_wp_ajax_get_acf() { if (!check_ajax_referer('wp_all_import_secure', 'security', false)) { exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin')))); } if (!current_user_can('manage_options')) { exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin')))); } global $acf; $version = $acf ? $acf->settings['version'] : false; ob_start(); $acf_groups = PMXI_Plugin::$session->acf_groups; $acf_obj = false; if (!empty($acf_groups)) { foreach ($acf_groups as $key => $group) { if ($group['ID'] == $_GET['acf']) { $acf_obj = $group; break; } } } $import = new PMXI_Import_Record(); if (!empty($_GET['id'])) { $import->getById($_GET['id']); } $is_loaded_template = !empty(PMXI_Plugin::$session->is_loaded_template) ? PMXI_Plugin::$session->is_loaded_template : false; if ($is_loaded_template) { $default = PMAI_Plugin::get_default_import_options(); $template = new PMXI_Template_Record(); if (!$template->getById($is_loaded_template)->isEmpty()) { $options = (!empty($template->options) ? $template->options : array()) + $default; } } else { if (!$import->isEmpty()) { $options = $import->options; } else { $options = PMXI_Plugin::$session->options; } } ?> <div class="postbox acf_postbox default acf_signle_group rad4" rel="<?php echo $acf_obj['ID']; ?> "> <h3 class="hndle" style="margin-top:0;"><span><?php echo $acf_obj['title']; ?> </span></h3> <div class="inside"> <?php if ($version and version_compare($version, '5.0.0') >= 0) { if (is_numeric($acf_obj['ID'])) { $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $_GET['acf'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC')); if (!empty($acf_fields)) { foreach ($acf_fields as $field) { $fieldData = !empty($field->post_content) ? unserialize($field->post_content) : array(); $fieldData['ID'] = $field->ID; $fieldData['id'] = $field->ID; $fieldData['label'] = $field->post_title; $fieldData['key'] = $field->post_name; if (empty($fieldData['name'])) { $fieldData['name'] = $field->post_excerpt; } echo pmai_render_field($fieldData, !empty($options) ? $options : array()); } } } else { $fields = acf_local()->fields; if (!empty($fields)) { foreach ($fields as $key => $field) { if ($field['parent'] == $acf_obj['key']) { $fieldData = $field; $fieldData['id'] = uniqid(); $fieldData['label'] = $field['label']; $fieldData['key'] = $field['key']; echo pmai_render_field($fieldData, !empty($options) ? $options : array()); } } } } } else { if (is_numeric($acf_obj['ID'])) { $fields = array(); foreach (get_post_meta($acf_obj['ID'], '') as $cur_meta_key => $cur_meta_val) { if (strpos($cur_meta_key, 'field_') !== 0) { continue; } $fields[] = !empty($cur_meta_val[0]) ? unserialize($cur_meta_val[0]) : array(); } if (count($fields)) { $sortArray = array(); foreach ($fields as $field) { foreach ($field as $key => $value) { if (!isset($sortArray[$key])) { $sortArray[$key] = array(); } $sortArray[$key][] = $value; } } $orderby = "order_no"; array_multisort($sortArray[$orderby], SORT_ASC, $fields); foreach ($fields as $field) { echo pmai_render_field($field, !empty($options) ? $options : array()); } } } else { global $acf_register_field_group; if (!empty($acf_register_field_group)) { foreach ($acf_register_field_group as $key => $group) { if ($group['id'] == $acf_obj['ID']) { foreach ($group['fields'] as $field) { echo pmai_render_field($field, !empty($options) ? $options : array()); } } } } } } ?> </div> </div> <?php exit(json_encode(array('html' => ob_get_clean()))); die; }