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


PHP PMXI_Plugin::getInstance方法代码示例

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


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

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

示例2: scheduling

 /**
  * Cron Scheduling
  */
 public function scheduling()
 {
     $this->data['id'] = $id = $this->input->get('id');
     $this->data['cron_job_key'] = PMXI_Plugin::getInstance()->getOption('cron_job_key');
     $this->data['item'] = $item = new PMXI_Import_Record();
     if (!$id or $item->getById($id)->isEmpty()) {
         wp_redirect($this->baseUrl);
         die;
     }
     $this->render();
 }
开发者ID:GolgoSoft,项目名称:KeenerWP,代码行数:14,代码来源:manage.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: 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

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

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

示例9: check_license

 public static function check_license($class)
 {
     global $wp_version;
     $options = PMXI_Plugin::getInstance()->getOption();
     if (!empty($options['licenses'][$class])) {
         $product_name = method_exists($class, 'getEddName') ? call_user_func(array($class, 'getEddName')) : false;
         if ($product_name !== false) {
             $api_params = array('edd_action' => 'check_license', 'license' => $license, 'item_name' => urlencode($product_name));
             // Call the custom API.
             $response = wp_remote_get(add_query_arg($api_params, $options['info_api_url']), array('timeout' => 15, 'sslverify' => false));
             if (is_wp_error($response)) {
                 return false;
             }
             $license_data = json_decode(wp_remote_retrieve_body($response));
             if ($license_data->license == 'valid') {
                 return true;
                 // this license is still valid
             } else {
                 return false;
                 // this license is no longer valid
             }
         }
     }
     return false;
 }
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:25,代码来源:license.php

示例10: render

 /**
  * @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(PMXI_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 = PMXI_Plugin::ROOT_DIR . '/views/' . $viewHelpPath;
     if (is_file($fileHelpPath)) {
         // there is help file defined
         ob_start();
         include $fileHelpPath;
         add_contextual_help(PMXI_Plugin::getInstance()->getAdminCurrentScreen()->id, ob_get_clean());
     }
     parent::render($viewPath);
 }
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:26,代码来源:admin.php

示例11: process

    /**
     * Import processing step (status console)
     */
    public function process($save_history = true)
    {
        $wp_uploads = wp_upload_dir();
        $import = $this->data['update_previous'];
        $history_log = new PMXI_History_Record();
        $input = new PMXI_Input();
        if (!empty(PMXI_Plugin::$session->history_id)) {
            $history_log->getById(PMXI_Plugin::$session->history_id);
        }
        $log_storage = (int) PMXI_Plugin::getInstance()->getOption('log_storage');
        if (!PMXI_Plugin::is_ajax()) {
            $import->set((empty(PMXI_Plugin::$session->source) ? array() : PMXI_Plugin::$session->source) + array('xpath' => PMXI_Plugin::$session->xpath, 'options' => PMXI_Plugin::$session->options, 'count' => PMXI_Plugin::$session->count, 'friendly_name' => PMXI_Plugin::$session->options['friendly_name'], 'feed_type' => PMXI_Plugin::$session->feed_type, 'parent_import_id' => $this->data['update_previous']->isEmpty() ? PMXI_Plugin::$session->parent_import_id : $this->data['update_previous']->parent_import_id, 'queue_chunk_number' => 0, 'triggered' => 0, 'processing' => 0, 'executing' => 1, 'iteration' => !empty($import->iteration) ? $import->iteration : 0))->save();
            if (PMXI_Plugin::$session->action != 'continue') {
                // store import info in database
                $import->set(array('imported' => 0, 'created' => 0, 'updated' => 0, 'skipped' => 0, 'deleted' => 0))->update();
            }
            // add history log
            $custom_type = get_post_type_object($import->options['custom_type']);
            // unlink previous logs
            $by = array();
            $by[] = array(array('import_id' => $import->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->set(array('import_id' => $import->id, 'date' => date('Y-m-d H:i:s'), 'type' => PMXI_Plugin::$session->action != 'continue' ? 'manual' : 'continue', 'summary' => sprintf(__("%d %ss created %d updated %d deleted %d skipped", "pmxi_plugin"), $import->created, $custom_type->labels->singular_name, $import->updated, $import->deleted, $import->skipped)))->save();
            PMXI_Plugin::$session->set('history_id', $history_log->id);
            foreach (get_taxonomies() as $tax) {
                delete_transient("pmxi_{$tax}_terms");
            }
            do_action('pmxi_before_xml_import', $import->id);
            PMXI_Plugin::$session->set('update_previous', $import->id);
            if (empty($import->options['encoding'])) {
                $currentOptions = $import->options;
                $currentOptions['encoding'] = 'UTF-8';
                $import->set(array('options' => $currentOptions))->update();
            }
            // unlink previous files
            $history = new PMXI_File_List();
            $history->setColumns('id', 'name', 'registered_on', 'path')->getBy(array('import_id' => $import->id), 'id DESC');
            if ($history->count()) {
                foreach ($history as $file) {
                    $history_file_path = wp_all_import_get_absolute_path($file['path']);
                    if (@file_exists($history_file_path) and $history_file_path != PMXI_Plugin::$session->filePath) {
                        if (in_array($import->type, array('upload'))) {
                            wp_all_import_remove_source($history_file_path, false);
                        } else {
                            wp_all_import_remove_source($history_file_path);
                        }
                    }
                    $history_file = new PMXI_File_Record();
                    $history_file->getBy('id', $file['id']);
                    if (!$history_file->isEmpty()) {
                        $history_file->delete();
                    }
                }
            }
            if ($save_history) {
                $history_file = new PMXI_File_Record();
                $history_file->set(array('name' => $import->name, 'import_id' => $import->id, 'path' => wp_all_import_get_relative_path(PMXI_Plugin::$session->filePath), 'registered_on' => date('Y-m-d H:i:s')))->save();
            }
            /*
            	Split file up into 1000 record chunks.			
            	This option will decrease the amount of slowdown experienced at the end of large imports. 
            	The slowdown is partially caused by the need for WP All Import to read deeper and deeper into the file on each successive iteration. 
            	Splitting the file into pieces means that, for example, instead of having to read 19000 records into a 20000 record file when importing the last 1000 records, 
            	WP All Import will just split it into 20 chunks, and then read the last chunk from the beginning.
            */
            if ("ajax" == $import->options['import_processing'] and $import->count > PMXI_Plugin::getInstance()->getOption('large_feed_limit') and $import->options['chuncking']) {
                $chunk_files = array();
                if (!empty(PMXI_Plugin::$session->local_paths)) {
                    $records_count = 0;
                    $chunk_records_count = 0;
                    $feed = "<?xml version=\"1.0\" encoding=\"" . $import->options['encoding'] . "\"?>" . "\n" . "<pmxi_records>";
                    foreach (PMXI_Plugin::$session->local_paths as $key => $path) {
                        $file = new PMXI_Chunk($path, array('element' => $import->root_element, 'encoding' => $import->options['encoding']));
                        // loop through the file until all lines are read
                        while ($xml = $file->read()) {
                            if (!empty($xml)) {
                                PMXI_Import_Record::preprocessXml($xml);
                                $chunk = "<?xml version=\"1.0\" encoding=\"" . $import->options['encoding'] . "\"?>" . "\n" . $xml;
                                $dom = new DOMDocument('1.0', $import->options['encoding']);
                                $old = libxml_use_internal_errors(true);
                                $dom->loadXML($chunk);
                                // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
//.........这里部分代码省略.........
开发者ID:hikaram,项目名称:wee,代码行数:101,代码来源:import.php

示例12: meta_values

 public function meta_values()
 {
     if (!PMXI_Plugin::getInstance()->getAdminCurrentScreen()->is_ajax) {
         // call is only valid when send with ajax
         exit('nice try!');
     }
     if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
         exit(json_encode(array('meta_values' => array())));
     }
     global $wpdb;
     $meta_key = $_POST['key'];
     $r = $wpdb->get_results("\n\t\t\tSELECT DISTINCT postmeta.meta_value\n\t\t\tFROM " . $wpdb->postmeta . " as postmeta\n\t\t\tWHERE postmeta.meta_key='" . $meta_key . "' LIMIT 0,10\n\t\t", ARRAY_A);
     $meta_values = array();
     if (!empty($r)) {
         foreach ($r as $key => $value) {
             if (empty($value['meta_value'])) {
                 continue;
             }
             $meta_values[] = esc_html($value['meta_value']);
         }
     }
     exit(json_encode(array('meta_values' => $meta_values)));
 }
开发者ID:hikaram,项目名称:wee,代码行数:23,代码来源:settings.php

示例13: urlencode

<div class="wrap">
	<?php 
$homeurl = "http://www.wpallimport.com/adminpanel/index.php?v=" . urlencode(PMXI_Plugin::getInstance()->getVersion());
$contents = @file_get_contents($homeurl);
if (!$contents) {
    ?>
			<iframe src='<?php 
    echo $homeurl;
    ?>
' width='600'></iframe><br />
			<?php 
} else {
    echo $contents;
}
?>
</div>



开发者ID:lizbur10,项目名称:js_finalproject,代码行数:16,代码来源:index.php

示例14: init_addon_fields

 /**
  *
  *	Init addons' view
  *
  */
 private function init_addon_fields()
 {
     global $wpdb;
     $table = PMXI_Plugin::getInstance()->getTablePrefix() . 'imports';
     $imports = $wpdb->get_results("SELECT * FROM {$table} WHERE `parent_import_id` = 0", ARRAY_A);
     if (empty($imports)) {
         $this->wpml_addon->add_text("This is your first import. Default language will be choosen automatically ( " . $this->get_flag_html($this->default_language) . $this->wpml->get_display_language_name($this->default_language, 'en') . " ).");
     }
     $langs = $this->wpml->get_active_languages();
     if (!empty($langs)) {
         // prepare active languages list
         $language_list = array();
         foreach ($langs as $code => $langInfo) {
             $language_list[$code] = $this->get_flag_html($code) . $langInfo['display_name'];
             if ($code == $this->default_language) {
                 $language_list[$code] .= ' ( <strong>default</strong> )';
             }
         }
         $this->wpml_addon->add_field('lng', 'Content Language', 'radio', $language_list);
         if (!empty($imports)) {
             // prepare active imports list
             $import_list = array();
             foreach ($imports as $import) {
                 if (!empty($_GET['id']) and $_GET['id'] == $import['id']) {
                     continue;
                 }
                 $import_options = unserialize($import['options']);
                 $import_list[$import['id']] = '[ ID: ' . $import['id'] . ' ] ' . (!empty($import_options['wpml_addon']['lng']) ? $this->get_flag_html($import_options['wpml_addon']['lng']) : '') . (!empty($import['friendly_name']) ? $import['friendly_name'] : $import['name']);
             }
             $this->wpml_addon->add_options(null, 'Automatic Record Matching to Translate', array($this->wpml_addon->add_field('matching_logic', 'Records matching logic', 'radio', array('' => '<strong>Import data in main language (' . $this->wpml->get_display_language_name($this->default_language, 'en') . ')</strong>', 'auto' => array('Define parent import', $this->wpml_addon->add_field('import', 'Import to translate', 'radio', $import_list), $this->wpml_addon->add_field('unique_key', 'Unique Key', 'text', null, 'To inform WPML that this new post is translation of another post put the same unique key like you did for post in main language.'))))));
             // Aditional Options [ TODO: taxonomies options, media options, etc. ]
             // $this->wpml_addon->add_options(
             // 	null,
             // 	'Advanced Settings',
             // 	array(
             // 		$this->wpml_addon->add_field('translate_taxes', 'Translate taxonomies', 'radio', array('' => 'No', '1' => 'Yes'))
             // 	)
             // );
         }
         return;
     }
     $this->wpml_addon->add_text('Please set up site languages before using \'WP All Import - WPML add-on.\'');
 }
开发者ID:OnTheGoSystems,项目名称:wpml-all-import,代码行数:48,代码来源:wpml-all-import.php

示例15: process

 /**
  * Perform import operation
  * @param string $xml XML string to import
  * @param callback[optional] $logger Method where progress messages are submmitted
  * @return PMXI_Import_Record
  * @chainable
  */
 public function process($xml, $logger = NULL, $chunk = false, $is_cron = false, $xpath_prefix = '')
 {
     add_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html'));
     kses_init();
     // do not perform special filtering for imported content
     $cxpath = $xpath_prefix . $this->xpath;
     $this->options += PMXI_Plugin::get_default_import_options();
     // make sure all options are defined
     $avoid_pingbacks = PMXI_Plugin::getInstance()->getOption('pingbacks');
     if ($avoid_pingbacks and !defined('WP_IMPORTING')) {
         define('WP_IMPORTING', true);
     }
     $postRecord = new PMXI_Post_Record();
     $tmp_files = array();
     // compose records to import
     $records = array();
     $is_import_complete = false;
     try {
         $chunk == 1 and $logger and call_user_func($logger, __('Composing titles...', 'pmxi_plugin'));
         $titles = XmlImportParser::factory($xml, $cxpath, $this->template['title'], $file)->parse($records);
         $tmp_files[] = $file;
         $chunk == 1 and $logger and call_user_func($logger, __('Composing excerpts...', 'pmxi_plugin'));
         $post_excerpt = array();
         if (!empty($this->options['post_excerpt'])) {
             $post_excerpt = XmlImportParser::factory($xml, $cxpath, $this->options['post_excerpt'], $file)->parse($records);
             $tmp_files[] = $file;
         } else {
             count($titles) and $post_excerpt = array_fill(0, count($titles), '');
         }
         if ("xpath" == $this->options['status']) {
             $chunk == 1 and $logger and call_user_func($logger, __('Composing statuses...', 'pmxi_plugin'));
             $post_status = array();
             if (!empty($this->options['status_xpath'])) {
                 $post_status = XmlImportParser::factory($xml, $cxpath, $this->options['status_xpath'], $file)->parse($records);
                 $tmp_files[] = $file;
             } else {
                 count($titles) and $post_status = array_fill(0, count($titles), '');
             }
         }
         $chunk == 1 and $logger and call_user_func($logger, __('Composing authors...', 'pmxi_plugin'));
         $post_author = array();
         $current_user = wp_get_current_user();
         if (!empty($this->options['author'])) {
             $post_author = XmlImportParser::factory($xml, $cxpath, $this->options['author'], $file)->parse($records);
             $tmp_files[] = $file;
             foreach ($post_author as $key => $author) {
                 $user = get_user_by('login', $author) or $user = get_user_by('slug', $author) or $user = get_user_by('email', $author) or ctype_digit($author) and $user = get_user_by('id', $author);
                 $post_author[$key] = !empty($user) ? $user->ID : $current_user->ID;
             }
         } else {
             count($titles) and $post_author = array_fill(0, count($titles), $current_user->ID);
         }
         $chunk == 1 and $logger and call_user_func($logger, __('Composing slugs...', 'pmxi_plugin'));
         $post_slug = array();
         if (!empty($this->options['post_slug'])) {
             $post_slug = XmlImportParser::factory($xml, $cxpath, $this->options['post_slug'], $file)->parse($records);
             $tmp_files[] = $file;
         } else {
             count($titles) and $post_slug = array_fill(0, count($titles), '');
         }
         $chunk == 1 and $logger and call_user_func($logger, __('Composing contents...', 'pmxi_plugin'));
         $contents = XmlImportParser::factory((!empty($this->template['is_keep_linebreaks']) and intval($this->template['is_keep_linebreaks'])) ? $xml : preg_replace('%\\r\\n?|\\n%', ' ', $xml), $cxpath, $this->template['content'], $file)->parse($records);
         $tmp_files[] = $file;
         $chunk == 1 and $logger and call_user_func($logger, __('Composing dates...', 'pmxi_plugin'));
         if ('specific' == $this->options['date_type']) {
             $dates = XmlImportParser::factory($xml, $cxpath, $this->options['date'], $file)->parse($records);
             $tmp_files[] = $file;
             $warned = array();
             // used to prevent the same notice displaying several times
             foreach ($dates as $i => $d) {
                 if ($d == 'now') {
                     $d = current_time('mysql');
                 }
                 // Replace 'now' with the WordPress local time to account for timezone offsets (WordPress references its local time during publishing rather than the server’s time so it should use that)
                 $time = strtotime($d);
                 if (FALSE === $time) {
                     in_array($d, $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $d));
                     $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
                     $time = time();
                 }
                 $dates[$i] = date('Y-m-d H:i:s', $time);
             }
         } else {
             $dates_start = XmlImportParser::factory($xml, $cxpath, $this->options['date_start'], $file)->parse($records);
             $tmp_files[] = $file;
             $dates_end = XmlImportParser::factory($xml, $cxpath, $this->options['date_end'], $file)->parse($records);
             $tmp_files[] = $file;
             $warned = array();
             // used to prevent the same notice displaying several times
             foreach ($dates_start as $i => $d) {
                 $time_start = strtotime($dates_start[$i]);
                 if (FALSE === $time_start) {
                     in_array($dates_start[$i], $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $dates_start[$i]));
//.........这里部分代码省略.........
开发者ID:thabofletcher,项目名称:tc-site,代码行数:101,代码来源:record.php


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