当前位置: 首页>>代码示例>>PHP>>正文


PHP PMXI_Plugin类代码示例

本文整理汇总了PHP中PMXI_Plugin的典型用法代码示例。如果您正苦于以下问题:PHP PMXI_Plugin类的具体用法?PHP PMXI_Plugin怎么用?PHP PMXI_Plugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PMXI_Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pmxi_wp_ajax_nested_merge

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;
}
开发者ID:estrategasdigitales,项目名称:rufiatta,代码行数:28,代码来源:wp_ajax_nested_merge.php

示例2: pmxi_admin_notices

function pmxi_admin_notices()
{
    // notify user if history folder is not writable
    $uploads = wp_upload_dir();
    if (!@is_dir($uploads['basedir'] . '/wpallimport_history') or !@is_writable($uploads['basedir'] . '/wpallimport_history')) {
        ?>
		<div class="error"><p>
			<?php 
        printf(__('<b>%s Plugin</b>: History folder %s must be writable for the plugin to function properly. Please deactivate the plugin, set proper permissions to the folder and activate the plugin again.', 'pmxi_plugin'), PMXI_Plugin::getInstance()->getName(), $uploads['basedir'] . '/wpallimport_history');
        ?>
		</p></div>
		<?php 
    }
    // notify user
    if (!PMXI_Plugin::getInstance()->getOption('dismiss') and strpos($_SERVER['REQUEST_URI'], 'pmxi-admin') !== false) {
        ?>
		<div class="updated"><p>
			<?php 
        printf(__('Welcome to WP All Import. We hope you like it. Please send all support requests and feedback to <a href="mailto:support@soflyy.com">support@soflyy.com</a>.<br/><br/><a href="javascript:void(0);" id="dismiss">dismiss</a>', 'pmxi_plugin'));
        ?>
		</p></div>
		<?php 
    }
    if (class_exists('PMWI_Plugin') and (defined('PMWI_VERSION') and version_compare(PMWI_VERSION, '1.2.8') <= 0 and PMWI_EDITION == 'paid' or defined('PMWI_FREE_VERSION') and version_compare(PMWI_FREE_VERSION, '1.1.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</a>', 'pmwi_plugin'), PMWI_Plugin::getInstance()->getName());
        ?>
		</p></div>
		<?php 
        if (defined('PMWI_EDITION') and PMWI_EDITION == 'paid') {
            deactivate_plugins(PMWI_ROOT_DIR . '/plugin.php');
        } else {
            deactivate_plugins(PMWI_FREE_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 
        }
    }
}
开发者ID:thabofletcher,项目名称:tc-site,代码行数:55,代码来源:admin_notices.php

示例3: pmxi_wp_session_garbage_collection

function pmxi_wp_session_garbage_collection()
{
    global $wpdb;
    if (defined('WP_SETUP_CONFIG')) {
        return;
    }
    $session_mode = PMXI_Plugin::getInstance()->getOption('session_mode');
    if (!defined('WP_INSTALLING')) {
        if ($session_mode == 'database') {
            $expiration_keys = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE '_pmxi_session_expires_%'");
            $now = time();
            $expired_sessions = array();
            foreach ($expiration_keys as $expiration) {
                // If the session has expired
                if ($now > intval($expiration->option_value)) {
                    // Get the session ID by parsing the option_name
                    $session_id = str_replace("_pmxi_session_expires_", "", $expiration->option_name);
                    $expired_sessions[] = $expiration->option_name;
                    $expired_sessions[] = "_pmxi_session_{$session_id}";
                }
            }
            // Delete all expired sessions in a single query
            if (!empty($expired_sessions)) {
                $option_names = implode("','", $expired_sessions);
                $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name IN ('{$option_names}')");
            }
        } elseif ($session_mode == 'files') {
            $session_files = scandir(PMXI_ROOT_DIR . '/sessions');
            if (!empty($session_files)) {
                $now = time();
                $expired_sessions = array();
                foreach ($session_files as $key => $file) {
                    if (strpos($file, "_pmxi_session_expires_") !== false) {
                        $expiration_value = @file_get_contents(PMXI_ROOT_DIR . "/sessions/" . $file);
                        if ($now > intval($expiration_value)) {
                            $session_id = str_replace("_pmxi_session_expires_", "", $file);
                            $expired_sessions[] = $file;
                            $expired_sessions[] = "_pmxi_session_{$session_id}";
                        }
                    }
                }
                // Delete all expired sessions in a single query
                if (!empty($expired_sessions)) {
                    foreach ($expired_sessions as $key => $file) {
                        @unlink(PMXI_ROOT_DIR . "/sessions/" . $file);
                    }
                }
            }
        }
    }
    // Allow other plugins to hook in to the garbage collection process.
    do_action('pmxi_session_cleanup');
}
开发者ID:thabofletcher,项目名称:tc-site,代码行数:53,代码来源:wp_session_garbage_collection.php

示例4: wp_all_import_secure_file

 function wp_all_import_secure_file($targetDir, $importID = 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));
         @mkdir($dir, 0755);
         if (@is_writable($dir) and @is_dir($dir)) {
             $targetDir = $dir;
             @touch($dir . DIRECTORY_SEPARATOR . 'index.php');
         }
     }
     return $targetDir;
 }
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:13,代码来源:wp_all_import_secure_file.php

示例5: pmxi_admin_menu

/**
 * Register plugin specific admin menu
 */
function pmxi_admin_menu()
{
    global $menu, $submenu;
    if (current_user_can('manage_options')) {
        // admin management options
        $wpai_menu = array(array('pmxi-admin-import', __('New Import', 'pmxi_plugin')), array('pmxi-admin-manage', __('Manage Imports', 'pmxi_plugin')), array('pmxi-admin-settings', __('Settings', 'pmxi_plugin')), array('pmxi-admin-history', __('History', 'pmxi_plugin')));
        $wpai_menu = apply_filters('pmxi_admin_menu', $wpai_menu);
        add_menu_page(__('WP All Import', 'pmxi_plugin'), __('All Import', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-home', array(PMXI_Plugin::getInstance(), 'adminDispatcher'), PMXI_Plugin::ROOT_URL . '/static/img/xmlicon.png');
        // workaround to rename 1st option to `Home`
        $submenu['pmxi-admin-home'] = array();
        foreach ($wpai_menu as $key => $value) {
            add_submenu_page('pmxi-admin-home', $value[1], $value[1], 'manage_options', $value[0], array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
        }
    }
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:18,代码来源:admin_menu.php

示例6: pmxi_wp_ajax_unmerge_file

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;
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:17,代码来源:wp_ajax_unmerge_file.php

示例7: 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

示例8: __construct

 /**
  * Default constructor.
  * Will rebuild the session collection from the given session ID if it exists. Otherwise, will
  * create a new session with that ID.
  *
  * @param $session_id
  * @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire.
  */
 protected function __construct()
 {
     if (version_compare(phpversion(), '5.4.0') >= 0 and session_status() == PHP_SESSION_DISABLED or 'default' == PMXI_Plugin::getInstance()->getOption('session_mode') and !session_id() and !@session_start()) {
         PMXI_Plugin::getInstance()->updateOption(array('session_mode' => 'files'));
     }
     $this->session_mode = PMXI_Plugin::getInstance()->getOption('session_mode');
     if ($this->session_mode != 'default') {
         if (isset($_COOKIE[PMXI_SESSION_COOKIE])) {
             $cookie = stripslashes($_COOKIE[PMXI_SESSION_COOKIE]);
             $cookie_crumbs = explode('||', $cookie);
             $this->session_id = !empty($cookie_crumbs[0]) ? $cookie_crumbs[0] : $this->generate_id();
             $this->expires = $cookie_crumbs[1];
             $this->exp_variant = $cookie_crumbs[2];
             // Update the session expiration if we're past the variant time
             if (time() > $this->exp_variant) {
                 $this->set_expiration();
                 if ($this->session_mode == 'database') {
                     update_option("_pmxi_session_expires_{$this->session_id}", $this->expires);
                 } elseif ($this->session_mode == 'files') {
                     @file_put_contents(PMXI_ROOT_DIR . "/sessions/_pmxi_session_expires_{$this->session_id}.txt", $this->expires);
                 }
             }
         } else {
             $this->session_id = $this->generate_id();
             $this->set_expiration();
         }
     } else {
         try {
             $path = @session_save_path();
             if (!@is_dir($path) or !@is_writable($path)) {
                 @ini_set("session.save_handler", "files");
                 @session_save_path(sys_get_temp_dir());
             }
         } catch (XmlImportException $e) {
         }
         // enable sessions
         if (!session_id()) {
             @session_start();
         }
     }
     $this->read_data();
     $this->set_cookie();
 }
开发者ID:thabofletcher,项目名称:tc-site,代码行数:51,代码来源:session.php

示例9: pmxi_wp_ajax_nested_merge

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;
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:21,代码来源:wp_ajax_nested_merge.php

示例10: sweepHistory

 /**
  * Sweep history files in accordance with plugin settings
  * @return PMXI_File_List
  * @chainable
  */
 public function sweepHistory()
 {
     $age = PMXI_Plugin::getInstance()->getOption('history_file_age');
     if ($age > 0) {
         $date = new DateTime();
         $date->modify('-' . $age . ' day');
         foreach ($this->getBy('registered_on <', $date->format('Y-m-d'))->convertRecords() as $f) {
             $f->delete();
         }
     }
     $count = PMXI_Plugin::getInstance()->getOption('history_file_count');
     if ($count > 0) {
         $count_actual = $this->countBy();
         if ($count_actual > $count) {
             foreach ($this->getBy(NULL, 'registered_on', 1, $count_actual - $count)->convertRecords() as $f) {
                 $f->delete();
             }
         }
     }
     return $this;
 }
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:26,代码来源:list.php

示例11: pmxi_wp_ajax_unmerge_file

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;
}
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:24,代码来源:wp_ajax_unmerge_file.php

示例12: __construct

 /**
  * data load initialize
  *
  * @param mixed $filename please look at the load() method
  *
  * @access public
  * @see load()
  * @return void
  */
 public function __construct($options = array('filename' => null, 'xpath' => '', 'delimiter' => '', 'encoding' => '', 'xml_path' => '', 'targetDir' => false))
 {
     PMXI_Plugin::$csv_path = $options['filename'];
     $this->xpath = !empty($options['xpath']) ? $options['xpath'] : (!empty($_POST['xpath']) ? $_POST['xpath'] : '/node');
     if (!empty($options['delimiter'])) {
         $this->delimiter = $options['delimiter'];
     } else {
         $input = new PMXI_Input();
         $id = $input->get('id', 0);
         if (!$id) {
             $id = $input->get('import_id', 0);
         }
         if ($id) {
             $import = new PMXI_Import_Record();
             $import->getbyId($id);
             if (!$import->isEmpty()) {
                 $this->delimiter = $import->options['delimiter'];
             }
         }
     }
     if (!empty($options['encoding'])) {
         $this->csv_encoding = $options['encoding'];
         $this->auto_encoding = false;
     }
     if (!empty($options['xml_path'])) {
         $this->xml_path = $options['xml_path'];
     }
     @ini_set("display_errors", 0);
     @ini_set('auto_detect_line_endings', true);
     $file_params = self::analyse_file($options['filename'], 1);
     $this->set_settings(array('delimiter' => $file_params['delimiter']['value'], 'eol' => $file_params['line_ending']['value']));
     unset($file_params);
     $wp_uploads = wp_upload_dir();
     $this->targetDir = empty($options['targetDir']) ? wp_all_import_secure_file($wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::UPLOADS_DIRECTORY) : $options['targetDir'];
     $this->load($options['filename']);
 }
开发者ID:Kilbourne,项目名称:restart,代码行数:45,代码来源:XmlImportCsvParse.php

示例13: 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

示例14: update

 /**
  * Re-run import
  */
 public function update()
 {
     $id = $this->input->get('id');
     PMXI_Plugin::$session->clean_session($id);
     $action_type = false;
     $this->data['import'] = $item = new PMXI_Import_Record();
     if (!$id or $item->getById($id)->isEmpty()) {
         wp_redirect($this->baseUrl);
         die;
     }
     $this->data['isWizard'] = false;
     $default = PMXI_Plugin::get_default_import_options();
     $DefaultOptions = $item->options + $default;
     foreach (PMXI_Admin_Addons::get_active_addons() as $class) {
         if (class_exists($class)) {
             $DefaultOptions += call_user_func(array($class, "get_default_import_options"));
         }
     }
     $this->data['post'] =& $DefaultOptions;
     $this->data['source'] = array('path' => $item->path, 'root_element' => $item->root_element);
     $this->data['xpath'] = $item->xpath;
     $this->data['count'] = $item->count;
     $history = new PMXI_File_List();
     $history->setColumns('id', 'name', 'registered_on', 'path')->getBy(array('import_id' => $item->id), 'id DESC');
     if ($history->count()) {
         foreach ($history as $file) {
             if (@file_exists($file['path'])) {
                 $this->data['locfilePath'] = $file['path'];
                 break;
             }
         }
     }
     $chunks = 0;
     if ($this->input->post('is_confirmed') and check_admin_referer('confirm', '_wpnonce_confirm')) {
         $continue = $this->input->post('is_continue', 'no');
         // mark action type ad continue
         if ($continue == 'yes') {
             $action_type = 'continue';
         }
         $filePath = '';
         // upload new file in case when import is not continue
         if (empty(PMXI_Plugin::$session->chunk_number)) {
             if ($item->type == 'upload') {
                 // retrieve already uploaded file
                 $uploader = new PMXI_Upload(trim($item->path), $this->errors, rtrim(str_replace(basename($item->path), '', $item->path), '/'));
                 $upload_result = $uploader->upload();
                 if ($upload_result instanceof WP_Error) {
                     $this->errors = $upload_result;
                 } else {
                     $filePath = $upload_result['filePath'];
                 }
             }
             if (empty($item->options['encoding'])) {
                 $currentOptions = $item->options;
                 $currentOptions['encoding'] = 'UTF-8';
                 $item->set(array('options' => $currentOptions))->update();
             }
             @set_time_limit(0);
             $local_paths = !empty($local_paths) ? $local_paths : array($filePath);
             foreach ($local_paths as $key => $path) {
                 if (!empty($action_type) and $action_type == 'continue') {
                     $chunks = $item->count;
                 } else {
                     $file = new PMXI_Chunk($path, array('element' => $item->root_element, 'encoding' => $item->options['encoding']));
                     while ($xml = $file->read()) {
                         if (!empty($xml)) {
                             PMXI_Import_Record::preprocessXml($xml);
                             $xml = "<?xml version=\"1.0\" encoding=\"" . $item->options['encoding'] . "\"?>" . "\n" . $xml;
                             $dom = new DOMDocument('1.0', !empty($item->options['encoding']) ? $item->options['encoding'] : 'UTF-8');
                             $old = libxml_use_internal_errors(true);
                             $dom->loadXML($xml);
                             // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
                             libxml_use_internal_errors($old);
                             $xpath = new DOMXPath($dom);
                             if ($elements = @$xpath->query($item->xpath) and !empty($elements) and !empty($elements->length)) {
                                 $chunks += $elements->length;
                             }
                             unset($dom, $xpath, $elements);
                         }
                     }
                     unset($file);
                 }
                 !$key and $filePath = $path;
             }
             if (empty($chunks)) {
                 $this->errors->add('form-validation', __('No matching elements found for Root element and XPath expression specified', 'wp_all_import_plugin'));
             }
         }
         if ($chunks) {
             // xml is valid
             if (!PMXI_Plugin::is_ajax() and empty(PMXI_Plugin::$session->chunk_number)) {
                 // compose data to look like result of wizard steps
                 $sesson_data = array('filePath' => $filePath, 'source' => array('name' => $item->name, 'type' => $item->type, 'path' => $item->path, 'root_element' => $item->root_element), 'feed_type' => $item->feed_type, 'update_previous' => $item->id, 'parent_import_id' => $item->parent_import_id, 'xpath' => $item->xpath, 'options' => $item->options, 'encoding' => !empty($item->options['encoding']) ? $item->options['encoding'] : 'UTF-8', 'is_csv' => !empty($item->options['delimiter']) ? $item->options['delimiter'] : PMXI_Plugin::$is_csv, 'csv_path' => PMXI_Plugin::$csv_path, 'chunk_number' => 1, 'log' => '', 'warnings' => 0, 'errors' => 0, 'start_time' => 0, 'pointer' => 1, 'count' => isset($chunks) ? $chunks : 0, 'local_paths' => !empty($local_paths) ? $local_paths : array(), 'action' => (!empty($action_type) and $action_type == 'continue') ? 'continue' : 'update', 'nonce' => wp_create_nonce('import'));
                 foreach ($sesson_data as $key => $value) {
                     PMXI_Plugin::$session->set($key, $value);
                 }
                 PMXI_Plugin::$session->save_data();
//.........这里部分代码省略.........
开发者ID:GolgoSoft,项目名称:KeenerWP,代码行数:101,代码来源:manage.php

示例15: deletePostsAjax

 /**
  * Clear associations with posts via Ajax
  * @param bool[optional] $keepPosts When set to false associated wordpress posts will be deleted as well
  * @return PMXI_Import_Record
  * @chainable
  */
 public function deletePostsAjax($keepPosts = TRUE, $is_deleted_images = 'auto', $is_delete_attachments = 'auto')
 {
     $postList = new PMXI_Post_List();
     if (!$keepPosts) {
         $missing_ids = array();
         $missingPosts = $postList->getBy(array('import_id' => $this->id));
         if (!$missingPosts->isEmpty()) {
             foreach ($missingPosts as $missingPost) {
                 $missing_ids[] = $missingPost['post_id'];
             }
         }
         // Delete posts from database
         if (!empty($missing_ids) && is_array($missing_ids)) {
             $missing_ids_arr = array_chunk($missing_ids, $this->options['records_per_request']);
             foreach ($missing_ids_arr as $key => $ids) {
                 if (!empty($ids)) {
                     $this->deleteRecords($is_delete_attachments, $is_deleted_images, $ids);
                     // 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();
                 }
                 break;
             }
             return count($missing_ids_arr) > 1 ? false : true;
         }
     }
     return true;
 }
开发者ID:TakenCdosG,项目名称:chefs,代码行数:35,代码来源:record.php


注:本文中的PMXI_Plugin类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。