本文整理汇总了PHP中wp_all_import_url_title函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_all_import_url_title函数的具体用法?PHP wp_all_import_url_title怎么用?PHP wp_all_import_url_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_all_import_url_title函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
public function parse()
{
$tmpname = wp_unique_filename($this->targetDir, str_replace("sql", "xml", basename($this->_filename)));
$this->xml_path = $this->targetDir . '/' . wp_all_import_url_title($tmpname);
$this->toXML();
return $this->xml_path;
}
示例2: __construct
/**
* Class constructor containing dispatching logic
* @param string $rootDir Plugin root dir
* @param string $pluginFilePath Plugin main file
*/
protected function __construct()
{
$this->load_plugin_textdomain();
// regirster autoloading method
if (function_exists('__autoload') and !in_array('__autoload', spl_autoload_functions())) {
// make sure old way of autoloading classes is not broken
spl_autoload_register('__autoload');
}
spl_autoload_register(array($this, '__autoload'));
// register helpers
if (is_dir(self::ROOT_DIR . '/helpers')) {
foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/helpers/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
require_once $filePath;
}
}
// init plugin options
$option_name = get_class($this) . '_Options';
$options_default = PMXI_Config::createFromFile(self::ROOT_DIR . '/config/options.php')->toArray();
$this->options = array_intersect_key(get_option($option_name, array()), $options_default) + $options_default;
$this->options = array_intersect_key($options_default, array_flip(array('info_api_url'))) + $this->options;
// make sure hidden options apply upon plugin reactivation
if ('' == $this->options['cron_job_key']) {
$this->options['cron_job_key'] = wp_all_import_url_title(wp_all_import_rand_char(12));
}
update_option($option_name, $this->options);
$this->options = get_option(get_class($this) . '_Options');
register_activation_hook(self::FILE, array($this, '__activation'));
// register action handlers
if (is_dir(self::ROOT_DIR . '/actions')) {
if (is_dir(self::ROOT_DIR . '/actions')) {
foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/actions/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
require_once $filePath;
$function = $actionName = basename($filePath, '.php');
if (preg_match('%^(.+?)[_-](\\d+)$%', $actionName, $m)) {
$actionName = $m[1];
$priority = intval($m[2]);
} else {
$priority = 10;
}
add_action($actionName, self::PREFIX . str_replace('-', '_', $function), $priority, 99);
// since we don't know at this point how many parameters each plugin expects, we make sure they will be provided with all of them (it's unlikely any developer will specify more than 99 parameters in a function)
}
}
}
// register filter handlers
if (is_dir(self::ROOT_DIR . '/filters')) {
foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/filters/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
require_once $filePath;
$function = $actionName = basename($filePath, '.php');
if (preg_match('%^(.+?)[_-](\\d+)$%', $actionName, $m)) {
$actionName = $m[1];
$priority = intval($m[2]);
} else {
$priority = 10;
}
add_filter($actionName, self::PREFIX . str_replace('-', '_', $function), $priority, 99);
// since we don't know at this point how many parameters each plugin expects, we make sure they will be provided with all of them (it's unlikely any developer will specify more than 99 parameters in a function)
}
}
// register shortcodes handlers
if (is_dir(self::ROOT_DIR . '/shortcodes')) {
foreach (PMXI_Helper::safe_glob(self::ROOT_DIR . '/shortcodes/*.php', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
$tag = strtolower(str_replace('/', '_', preg_replace('%^' . preg_quote(self::ROOT_DIR . '/shortcodes/', '%') . '|\\.php$%', '', $filePath)));
add_shortcode($tag, array($this, 'shortcodeDispatcher'));
}
}
// register admin page pre-dispatcher
add_action('admin_init', array($this, '__adminInit'));
add_action('admin_init', array($this, '_fix_options'));
}
示例3: file
public function file()
{
$template = false;
$wp_uploads = wp_upload_dir();
$uploads = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::FILES_DIRECTORY . DIRECTORY_SEPARATOR;
if (empty($this->file)) {
$this->errors->add('form-validation', __('Please specify a file to import.', 'wp_all_import_plugin'));
} elseif (preg_match('%\\W(zip)$%i', trim($this->file))) {
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
echo '<span style="display:none">';
copy($uploads . $this->file, $this->uploadsPath . '/' . basename($this->file));
echo '</span>';
$zipfilePath = $this->uploadsPath . '/' . basename($this->file);
if (!class_exists('PclZip')) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/pclzip.lib.php';
}
$archive = new PclZip($zipfilePath);
if (($v_result_list = $archive->extract(PCLZIP_OPT_PATH, $this->uploadsPath, PCLZIP_OPT_REPLACE_NEWER)) == 0) {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
} else {
$filePath = '';
if (!empty($v_result_list)) {
foreach ($v_result_list as $unzipped_file) {
if ($unzipped_file['status'] == 'ok' and preg_match('%\\W(xml|csv|txt|dat|psv|json|xls|xlsx)$%i', trim($unzipped_file['stored_filename'])) and strpos($unzipped_file['stored_filename'], 'readme.txt') === false) {
if (strpos(basename($unzipped_file['stored_filename']), 'WP All Import Template') === 0 || strpos(basename($unzipped_file['stored_filename']), 'templates_') === 0) {
$template = file_get_contents($unzipped_file['filename']);
} elseif ($filePath == '') {
$filePath = $unzipped_file['filename'];
}
}
}
}
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
if (empty($filePath)) {
$zip = zip_open(trim($zipfilePath));
if (is_resource($zip)) {
while ($zip_entry = zip_read($zip)) {
$filePath = zip_entry_name($zip_entry);
$fp = fopen($this->uploadsPath . "/" . $filePath, "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp, "{$buf}");
zip_entry_close($zip_entry);
fclose($fp);
}
break;
}
zip_close($zip);
} else {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
}
}
// Detect if file is very large
$source = array('name' => basename($this->file), 'type' => 'file', 'path' => $uploads . $this->file);
if (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($filePath))) {
// If CSV file found in archieve
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $filePath, 'targetDir' => $this->uploadsPath));
// create chunks
//wp_all_import_remove_source($filePath, false);
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(json)$%i', trim($filePath))) {
$json_str = file_get_contents($filePath);
$is_json = wp_all_import_is_json($json_str);
if (is_wp_error($is_json)) {
$this->errors->add('form-validation', $is_json->get_error_message(), 'wp_all_import_plugin');
} else {
$xml_data = wp_all_import_json_to_xml(json_decode($json_str, true));
if (empty($xml_data)) {
$this->errors->add('form-validation', __('Can not import this file. JSON to XML convertation failed.', 'wp_all_import_plugin'));
} else {
$jsontmpname = $this->uploadsPath . '/' . wp_all_import_url_title(wp_unique_filename($this->uploadsPath, str_replace("json", "xml", basename($filePath))));
file_put_contents($jsontmpname, $xml_data);
wp_all_import_remove_source($filePath);
$filePath = $jsontmpname;
}
}
} elseif (preg_match('%\\W(sql)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportSQLParse.php';
$localSQLPath = $filePath;
$sql = new PMXI_SQLParser($localSQLPath, $this->uploadsPath);
$filePath = $sql->parse();
wp_all_import_remove_source($localSQLPath, false);
} elseif (preg_match('%\\W(xls|xlsx)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportXLSParse.php';
$localXLSPath = $filePath;
$xls = new PMXI_XLSParser($localXLSPath, $this->uploadsPath);
$filePath = $xls->parse();
wp_all_import_remove_source($localXLSPath, false);
}
}
//.........这里部分代码省略.........
示例4: parse
/**
* csv parser
*
* reads csv data and transforms it into php-data
*
* @access protected
* @return boolean
*/
protected function parse()
{
if (!$this->validates()) {
return false;
}
$tmpname = wp_unique_filename($this->targetDir, str_replace("csv", "xml", basename($this->_filename)));
if ("" == $this->xml_path) {
$this->xml_path = $this->targetDir . '/' . wp_all_import_url_title($tmpname);
}
$this->toXML(true);
/*$file = new PMXI_Chunk($this->xml_path, array('element' => 'node'));
if ( empty($file->options['element']) ){
$this->toXML(true); // Remove non ASCII symbols and write CDATA
}*/
return true;
}
示例5: upload
public function upload()
{
$uploads = wp_upload_dir();
if (empty($this->file)) {
$this->errors->add('form-validation', __('Please specify a file to import.<br/><br/>If you are uploading the file from your computer, please wait for it to finish uploading (progress bar at 100%), before trying to continue.', 'wp_all_import_plugin'));
} elseif (!is_file($this->file)) {
$this->errors->add('form-validation', __('Uploaded file is empty', 'wp_all_import_plugin'));
} elseif (!preg_match('%\\W(xml|gzip|zip|csv|gz|json|txt|dat|psv|sql)$%i', trim(basename($this->file)))) {
$this->errors->add('form-validation', __('Uploaded file must be XML, CSV, ZIP, GZIP, GZ, JSON, SQL, TXT, DAT or PSV', 'wp_all_import_plugin'));
} elseif (preg_match('%\\W(zip)$%i', trim(basename($this->file)))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/pclzip.lib.php';
$archive = new PclZip($this->file);
if (($v_result_list = $archive->extract(PCLZIP_OPT_PATH, $this->uploadsPath, PCLZIP_OPT_REPLACE_NEWER)) == 0) {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
} else {
$filePath = '';
if (!empty($v_result_list)) {
foreach ($v_result_list as $unzipped_file) {
if ($unzipped_file['status'] == 'ok' and preg_match('%\\W(xml|csv|txt|dat|psv|json)$%i', trim($unzipped_file['stored_filename']))) {
$filePath = $unzipped_file['filename'];
break;
}
}
}
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
if (empty($filePath)) {
$zip = zip_open(trim($this->file));
if (is_resource($zip)) {
while ($zip_entry = zip_read($zip)) {
$filePath = zip_entry_name($zip_entry);
$fp = fopen($this->uploadsPath . "/" . $filePath, "w");
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp, "{$buf}");
zip_entry_close($zip_entry);
fclose($fp);
}
break;
}
zip_close($zip);
} else {
$this->errors->add('form-validation', __('WP All Import couldn\'t find a file to import inside your ZIP.<br/><br/>Either the .ZIP file is broken, or doesn\'t contain a file with an extension of XML, CSV, PSV, DAT, or TXT. <br/>Please attempt to unzip your .ZIP file on your computer to ensure it is a valid .ZIP file which can actually be unzipped, and that it contains a file which WP All Import can import.', 'wp_all_import_plugin'));
}
}
// Detect if file is very large
$source = array('name' => basename($this->file), 'type' => 'upload', 'path' => $this->file);
if (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($filePath))) {
// If CSV file found in archieve
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $filePath, 'targetDir' => $this->uploadsPath));
// create chunks
//wp_all_import_remove_source($filePath, false);
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(json)$%i', trim($filePath))) {
$json_str = file_get_contents($filePath);
$is_json = wp_all_import_is_json($json_str);
if (is_wp_error($is_json)) {
$this->errors->add('form-validation', $is_json->get_error_message(), 'wp_all_import_plugin');
} else {
$xml_data = wp_all_import_json_to_xml(json_decode($json_str, true));
if (empty($xml_data)) {
$this->errors->add('form-validation', __('Can not import this file. JSON to XML convertation failed.', 'wp_all_import_plugin'));
} else {
$jsontmpname = $this->uploadsPath . '/' . wp_all_import_url_title(wp_unique_filename($this->uploadsPath, str_replace("json", "xml", basename($filePath))));
file_put_contents($jsontmpname, $xml_data);
wp_all_import_remove_source($filePath, false);
$filePath = $jsontmpname;
}
}
} elseif (preg_match('%\\W(sql)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportSQLParse.php';
$localSQLPath = $filePath;
$sql = new PMXI_SQLParser($localSQLPath, $this->uploadsPath);
$filePath = $sql->parse();
wp_all_import_remove_source($localSQLPath, false);
}
}
} elseif (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($this->file))) {
// If CSV file uploaded
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
$filePath = $this->file;
$source = array('name' => basename($this->file), 'type' => 'upload', 'path' => $filePath);
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $this->file, 'targetDir' => $this->uploadsPath));
//@unlink($filePath);
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(gz)$%i', trim($this->file))) {
// If gz file uploaded
$fileInfo = wp_all_import_get_gz($this->file, 0, $this->uploadsPath);
//.........这里部分代码省略.........
示例6: array
<?php
/**
* List of plugin optins, contains only default values, actual values are stored in database
* and can be changed by corresponding wordpress function calls
*/
$config = array("info_api_url" => "http://www.wpallimport.com", "history_file_count" => 10000, "history_file_age" => 365, "highlight_limit" => 10000, "upload_max_filesize" => 2048, "post_max_size" => 2048, "max_input_time" => -1, "max_execution_time" => -1, "dismiss" => 0, "html_entities" => 0, "utf8_decode" => 0, "cron_job_key" => wp_all_import_url_title(wp_all_import_rand_char(12)), "chunk_size" => 32, "pingbacks" => 1, "legacy_special_character_handling" => 1, "case_sensitive" => 1, "session_mode" => 'default', "enable_ftp_import" => 0, "large_feed_limit" => 1000, "cron_processing_time_limit" => 120, "secure" => 1, "log_storage" => 5, "cron_sleep" => "", "port" => "", "google_client_id" => "", "google_signature" => "", "licenses" => array(), "statuses" => array());
if (!defined('WPALLIMPORT_SIGNATURE')) {
define('WPALLIMPORT_SIGNATURE', '');
}
示例7: parse
public function parse()
{
$tmpname = wp_unique_filename($this->targetDir, preg_replace('%\\W(xls|xlsx)$%i', ".csv", basename($this->_filename)));
$this->csv_path = $this->targetDir . '/' . wp_all_import_url_title($tmpname);
return $this->toXML();
}
示例8: get_xml_file
protected function get_xml_file($filePath)
{
$csv_path = '';
if (preg_match('%\\W(csv|txt|dat|psv)$%i', trim($filePath))) {
// If CSV file found in archieve
if ($this->uploadsPath === false) {
$this->errors->add('form-validation', __('WP All Import can\'t access your WordPress uploads folder.', 'wp_all_import_plugin'));
}
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
$csv = new PMXI_CsvParser(array('filename' => $filePath, 'targetDir' => $this->uploadsPath));
// create chunks
$csv_path = $filePath;
$filePath = $csv->xml_path;
$this->is_csv = $csv->is_csv;
$this->root_element = 'node';
} elseif (preg_match('%\\W(json)$%i', trim($filePath))) {
$json_str = file_get_contents($filePath);
$is_json = wp_all_import_is_json($json_str);
if (is_wp_error($is_json)) {
$this->errors->add('form-validation', $is_json->get_error_message(), 'wp_all_import_plugin');
} else {
$xml_data = wp_all_import_json_to_xml(json_decode($json_str, true));
if (empty($xml_data)) {
$this->errors->add('form-validation', __('Can not import this file. JSON to XML convertation failed.', 'wp_all_import_plugin'));
} else {
$jsontmpname = $this->uploadsPath . '/' . wp_all_import_url_title(wp_unique_filename($this->uploadsPath, str_replace("json", "xml", basename($filePath))));
file_put_contents($jsontmpname, $xml_data);
wp_all_import_remove_source($filePath, false);
$filePath = $jsontmpname;
}
}
} elseif (preg_match('%\\W(sql)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportSQLParse.php';
$localSQLPath = $filePath;
$sql = new PMXI_SQLParser($localSQLPath, $this->uploadsPath);
$filePath = $sql->parse();
wp_all_import_remove_source($localSQLPath, false);
} elseif (preg_match('%\\W(xls|xlsx)$%i', trim($filePath))) {
include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportXLSParse.php';
$localXLSPath = $filePath;
$xls = new PMXI_XLSParser($localXLSPath, $this->uploadsPath);
$filePath = $xls->parse();
wp_all_import_remove_source($localXLSPath, false);
}
return array('csv' => $csv_path, 'xml' => $filePath);
}
示例9: array
<?php
/**
* List of plugin optins, contains only default values, actual values are stored in database
* and can be changed by corresponding wordpress function calls
*/
$config = array("history_file_count" => 10000, "history_file_age" => 365, "highlight_limit" => 10000, "upload_max_filesize" => 2048, "post_max_size" => 2048, "max_input_time" => -1, "max_execution_time" => -1, "dismiss" => 0, "dismiss_speed_up" => 0, "dismiss_manage_top" => 0, "dismiss_manage_bottom" => 0, "html_entities" => 0, "utf8_decode" => 0, "cron_job_key" => wp_all_import_url_title(wp_all_import_rand_char(12)), "chunk_size" => 32, "pingbacks" => 1, "legacy_special_character_handling" => 1, "case_sensitive" => 1, "session_mode" => 'default', "enable_ftp_import" => 0, "large_feed_limit" => 1000, "cron_processing_time_limit" => 120, "secure" => 1, "log_storage" => 5, "cron_sleep" => "", "port" => "");