Exemplo n.º 1
0
 protected function init()
 {
     parent::init();
     error_reporting(0);
     PMXI_Plugin::$session = PMXI_Session::get_instance();
     PMXI_Plugin::$session->session_started();
     if ('PMXI_Admin_Manage' == PMXI_Plugin::getInstance()->getAdminCurrentScreen()->base) {
         // prereqisites are not checked when flow control is deligated
         $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
             wp_redirect(add_query_arg('page', 'pmxi-admin-manage', admin_url('admin.php')));
             die;
         }
         $this->isWizard = false;
     } else {
         $action = PMXI_Plugin::getInstance()->getAdminCurrentScreen()->action;
         $this->_step_ready($action);
         $this->isInline = 'process' == $action;
     }
     XmlImportConfig::getInstance()->setCacheDirectory(sys_get_temp_dir());
     // preserve id parameter as part of baseUrl
     $id = $this->input->get('id') and $this->baseUrl = add_query_arg('id', $id, $this->baseUrl);
     $this->baseUrl = apply_filters('pmxi_base_url', $this->baseUrl);
 }
function pmxi_wp_ajax_nested_merge()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('success' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    if (!current_user_can(PMXI_Plugin::$capabilities)) {
        exit(json_encode(array('success' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    $input = new PMXI_Input();
    $post = $input->post(array('filePath' => ''));
    PMXI_Plugin::$session = PMXI_Session::get_instance();
    /*$nested_file = array(
    		'file' => $filePath,
    		'source' => $realPath,
    		'xpath' => $customXpath,
    		'root_element' => $root_element,
    		'main_xml_field' => $main_xml_field,
    		'child_xml_field' => $child_xml_field
    	);		*/
    $nested_files = empty(PMXI_Plugin::$session->options['nested_files']) ? array() : json_decode(PMXI_Plugin::$session->options['nested_files'], true);
    $nested_files[] = $post['filePath'];
    $options = PMXI_Plugin::$session->options;
    $options['nested_files'] = json_encode($nested_files);
    PMXI_Plugin::$session->set('options', $options);
    PMXI_Plugin::$session->save_data();
    exit(json_encode(array('success' => true, 'nested_files' => $nested_files)));
    die;
}
Exemplo n.º 3
0
function pmxi_wp_ajax_unmerge_file()
{
    extract($_POST);
    PMXI_Plugin::$session = PMXI_Session::get_instance();
    if (!empty(PMXI_Plugin::$session->options['nested_files'])) {
        $nested_files = json_decode(PMXI_Plugin::$session->options['nested_files'], true);
        unset($nested_files[$source]);
        $options = PMXI_Plugin::$session->options;
        $options['nested_files'] = json_encode($nested_files);
        PMXI_Plugin::$session->set('options', $options);
        PMXI_Plugin::$session->save_data();
        exit(json_encode(array('success' => true, 'nested_files' => $nested_files)));
        die;
    }
    exit(json_encode(array('success' => false)));
    die;
}
Exemplo n.º 4
0
function pmxi_wp_ajax_nested_merge()
{
    extract($_POST);
    PMXI_Plugin::$session = PMXI_Session::get_instance();
    /*$nested_file = array(
    		'file' => $filePath,
    		'source' => $realPath,
    		'xpath' => $customXpath,
    		'root_element' => $root_element,
    		'main_xml_field' => $main_xml_field,
    		'child_xml_field' => $child_xml_field
    	);		*/
    $nested_files = empty(PMXI_Plugin::$session->options['nested_files']) ? array() : json_decode(PMXI_Plugin::$session->options['nested_files'], true);
    $nested_files[] = $filePath;
    $options = PMXI_Plugin::$session->options;
    $options['nested_files'] = json_encode($nested_files);
    PMXI_Plugin::$session->set('options', $options);
    PMXI_Plugin::$session->save_data();
    exit(json_encode(array('success' => true, 'nested_files' => $nested_files)));
    die;
}
function pmxi_wp_ajax_unmerge_file()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('success' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    if (!current_user_can('manage_options')) {
        exit(json_encode(array('success' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    $input = new PMXI_Input();
    $post = $input->post(array('source' => ''));
    PMXI_Plugin::$session = PMXI_Session::get_instance();
    if (!empty(PMXI_Plugin::$session->options['nested_files']) and !empty($post['source'])) {
        $nested_files = json_decode(PMXI_Plugin::$session->options['nested_files'], true);
        unset($nested_files[$post['source']]);
        $options = PMXI_Plugin::$session->options;
        $options['nested_files'] = json_encode($nested_files);
        PMXI_Plugin::$session->set('options', $options);
        PMXI_Plugin::$session->save_data();
        exit(json_encode(array('success' => true, 'nested_files' => $nested_files)));
        die;
    }
    exit(json_encode(array('success' => false)));
    die;
}
Exemplo n.º 6
0
/**
 * Alias of wp_session_write_close()
 */
function pmxi_session_commit()
{
    PMXI_Plugin::$session = PMXI_Session::get_instance();
    PMXI_Plugin::$session->write_data();
    do_action('pmxi_session_commit');
}