本文整理汇总了PHP中wpml_like_escape函数的典型用法代码示例。如果您正苦于以下问题:PHP wpml_like_escape函数的具体用法?PHP wpml_like_escape怎么用?PHP wpml_like_escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpml_like_escape函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_inactive_content
function get_inactive_content()
{
global $wpdb;
$inactive = array();
$current_language = $this->get_current_language();
$res_p_prepared = $wpdb->prepare("\r\n\t\t\t\t SELECT COUNT(p.ID) AS c, p.post_type, lt.name AS language FROM {$wpdb->prefix}icl_translations t\r\n\t\t\t\t\tJOIN {$wpdb->posts} p ON t.element_id=p.ID AND t.element_type LIKE %s\r\n\t\t\t\t\tJOIN {$wpdb->prefix}icl_languages l ON t.language_code = l.code AND l.active = 0\r\n\t\t\t\t\tJOIN {$wpdb->prefix}icl_languages_translations lt ON lt.language_code = l.code AND lt.display_language_code=%s\r\n\t\t\t\t\tGROUP BY p.post_type, t.language_code\r\n\t\t\t\t", array(wpml_like_escape('post_') . '%', $current_language));
$res_p = $wpdb->get_results($res_p_prepared);
if ($res_p) {
foreach ($res_p as $r) {
$inactive[$r->language][$r->post_type] = $r->c;
}
}
$res_t_query = "\r\n\t\t SELECT COUNT(p.term_taxonomy_id) AS c, p.taxonomy, lt.name AS language FROM {$wpdb->prefix}icl_translations t\r\n\t\t\tJOIN {$wpdb->term_taxonomy} p ON t.element_id=p.term_taxonomy_id\r\n\t\t\tJOIN {$wpdb->prefix}icl_languages l ON t.language_code = l.code AND l.active = 0\r\n\t\t\tJOIN {$wpdb->prefix}icl_languages_translations lt ON lt.language_code = l.code AND lt.display_language_code=%s\r\n\t\t\tWHERE t.element_type LIKE %s\r\n\t\t\tGROUP BY p.taxonomy, t.language_code\r\n\t\t";
$res_t_query_prepared = $wpdb->prepare($res_t_query, $current_language, wpml_like_escape('tax_') . '%');
$res_t = $wpdb->get_results($res_t_query_prepared);
if ($res_t) {
foreach ($res_t as $r) {
if ($r->taxonomy == 'category' && $r->c == 1) {
continue;
//ignore the case of just the default category that gets automatically created for a new language
}
$inactive[$r->language][$r->taxonomy] = $r->c;
}
}
return $inactive;
}
开发者ID:pablomarsan,项目名称:iftheme-docs,代码行数:26,代码来源:sitepress.class.php
示例2: _e
_e('Translatable taxonomies linking', 'sitepress');
?>
<br/>
<small style="margin-left:10px;"><?php
_e('Allows linking existing translations after changing custom taxonomies definition (name) ', 'sitepress');
?>
</small>
<?php
global $wp_post_types, $wp_taxonomies;
$translatable_taxs = array();
foreach ($wp_post_types as $name => $post_type) {
$translatable_taxs = array_merge($translatable_taxs, $sitepress->get_translatable_taxonomies(true, $name));
}
$translatable_taxs = array_unique($translatable_taxs);
$res = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT element_type FROM {$wpdb->prefix}icl_translations WHERE element_type LIKE %s", array(wpml_like_escape('tax_') . '%')));
echo '<table class="widefat" style="width:300px;">';
foreach ($res as $row) {
$tax = preg_replace('#^tax_#', '', $row);
if ($tax == 'link_category' || $tax == 'nav_menu') {
continue;
}
echo '<tr>';
echo '<td>' . $tax . '</td>';
if (in_array($tax, $translatable_taxs)) {
echo '<td>' . __('linked to: ', 'sitepress') . $wp_taxonomies[$tax]->labels->name . '</td>';
} else {
echo '<td>';
echo '<select onchange="wpml_ts_link_taxonomy(jQuery(this), \'' . $tax . '\')">';
echo '<option value="">' . __('--select--', 'sitepress') . '</option>';
foreach ($translatable_taxs as $name) {
开发者ID:edgarter,项目名称:wecare,代码行数:31,代码来源:troubleshooting.php
示例3: parse_config
public function parse_config($config)
{
global $iclTranslationManagement, $sitepress;
if (function_exists('icl_register_string')) {
$requires_upgrade = !$sitepress->get_setting('admin_text_3_2_migration_complete', false);
$admin_texts = array();
if (!empty($config['wpml-config']['admin-texts'])) {
if (!is_numeric(key(@current($config['wpml-config']['admin-texts'])))) {
$admin_texts[0] = $config['wpml-config']['admin-texts']['key'];
} else {
$admin_texts = $config['wpml-config']['admin-texts']['key'];
}
$type = 'plugin';
$admin_text_context = '';
foreach ($admin_texts as $a) {
if (isset($a['type'])) {
$type = $a['type'];
}
if (isset($a['context'])) {
$admin_text_context = $a['context'];
}
if (!isset($type)) {
$type = 'plugin';
}
if (!isset($admin_text_context)) {
$admin_text_context = '';
}
$keys = array();
if (!isset($a['key'])) {
$arr[$a['attr']['name']] = 1;
$arr_context[$a['attr']['name']] = $admin_text_context;
$arr_type[$a['attr']['name']] = $type;
continue;
} elseif (!is_numeric(key($a['key']))) {
$keys[0] = $a['key'];
} else {
$keys = $a['key'];
}
foreach ($keys as $key) {
if (isset($key['key'])) {
$arr[$a['attr']['name']][$key['attr']['name']] = self::read_admin_texts_recursive($key['key'], $admin_text_context, $type, $arr_context, $arr_type);
} else {
$arr[$a['attr']['name']][$key['attr']['name']] = 1;
}
$arr_context[$a['attr']['name']] = $admin_text_context;
$arr_type[$a['attr']['name']] = $type;
}
}
if (isset($arr)) {
$iclTranslationManagement->admin_texts_to_translate = array_merge($iclTranslationManagement->admin_texts_to_translate, $arr);
}
$_icl_admin_option_names = get_option('_icl_admin_option_names');
$arr_options = array();
if (isset($arr) && is_array($arr)) {
foreach ($arr as $key => $v) {
$value = $this->get_option_without_filtering($key);
$value = maybe_unserialize($value);
if (is_array($value) && is_array($v)) {
$v = array_keys($v);
// only keep the values defined.
foreach ($value as $option_key => $option_value) {
if (!in_array($option_key, $v)) {
unset($value[$option_key]);
}
}
// Add any additional settings that are not in the options already.
foreach ($v as $option_key) {
if (!isset($value[$option_key])) {
$value[$option_key] = '';
}
}
}
$admin_text_context = isset($arr_context[$key]) ? $arr_context[$key] : '';
$type = isset($arr_type[$key]) ? $arr_type[$key] : '';
if (false === $value) {
// wildcard? register all matching options in wp_options
global $wpdb;
$src = str_replace('*', '%', wpml_like_escape($key));
$matches = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE '{$src}'");
foreach ($matches as $match) {
$value = maybe_unserialize($match->option_value);
if (is_array($value)) {
$this->register_string_recursive($match->option_name, $value, $value, '', $match->option_name, $requires_upgrade, $type, $admin_text_context);
} else {
icl_register_string('admin_texts_' . $match->option_name, $match->option_name, $match->option_value);
}
if ($requires_upgrade) {
$this->migrate_3_2($type, $admin_text_context, $match->option_name, $match->option_name);
}
$_icl_admin_option_names[$type][$admin_text_context][] = $match->option_name;
}
unset($arr[$key]);
}
if (is_scalar($value)) {
icl_register_string('admin_texts_' . $key, $key, $value);
if ($requires_upgrade) {
$this->migrate_3_2($type, $admin_text_context, $key, $key);
}
} else {
if (is_object($value)) {
//.........这里部分代码省略.........
开发者ID:edgarter,项目名称:wecare,代码行数:101,代码来源:wpml-admin-texts.class.php
示例4: delete_language
function delete_language($lang_id)
{
global $wpdb, $sitepress;
$lang = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_languages WHERE id=%d", $lang_id));
if ($lang) {
if (in_array($lang->code, $this->built_in_languages)) {
$error = __("Error: This is a built in language. You can't delete it.", 'sitepress');
} else {
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_languages WHERE id=%d", $lang_id));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_languages_translations WHERE language_code=%s", $lang->code));
$translation_ids = $wpdb->get_col($wpdb->prepare("SELECT translation_id FROM {$wpdb->prefix}icl_translations WHERE language_code=%s", $lang->code));
if ($translation_ids) {
$rids = $wpdb->get_col("SELECT rid FROM {$wpdb->prefix}icl_translation_status WHERE translation_id IN (" . wpml_prepare_in($translation_ids, '%d') . ")");
if ($rids) {
$job_ids = $wpdb->get_col("SELECT job_id FROM {$wpdb->prefix}icl_translate_job WHERE rid IN (" . wpml_prepare_in($rids, '%d') . ")");
if ($job_ids) {
$wpdb->query("DELETE FROM {$wpdb->prefix}icl_translate WHERE job_id IN (" . wpml_prepare_in($job_ids, '%d') . ")");
}
}
}
// delete posts
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE element_type LIKE %s AND language_code=%s", array(wpml_like_escape('post_') . '%', $lang->code)));
remove_action('delete_post', array($sitepress, 'delete_post_actions'));
foreach ($post_ids as $post_id) {
wp_delete_post($post_id, true);
}
add_action('delete_post', array($sitepress, 'delete_post_actions'));
// delete terms
remove_action('delete_term', array($sitepress, 'delete_term'), 1, 3);
$tax_ids = $wpdb->get_col($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE element_type LIKE %s AND language_code=%s", array(wpml_like_escape('tax_') . '%', $lang->code)));
foreach ($tax_ids as $tax_id) {
$row = $wpdb->get_row($wpdb->prepare("SELECT term_id, taxonomy FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id=%d", $tax_id));
if ($row) {
wp_delete_term($row->term_id, $row->taxonomy);
}
}
add_action('delete_term', array($sitepress, 'delete_term'), 1, 3);
// delete comments
global $IclCommentsTranslation;
remove_action('delete_comment', array($IclCommentsTranslation, 'delete_comment_actions'));
foreach ($post_ids as $post_id) {
wp_delete_post($post_id, true);
}
add_action('delete_comment', array($IclCommentsTranslation, 'delete_comment_actions'));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_translations WHERE language_code=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_strings WHERE language=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_string_translations WHERE language=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_locale_map WHERE code=%s", $lang->code));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}icl_flags WHERE lang_code=%s", $lang->code));
icl_cache_clear(false);
$sitepress->icl_translations_cache->clear();
$sitepress->clear_flags_cache();
$sitepress->icl_language_name_cache->clear();
$this->message(sprintf(__("The language %s was deleted.", 'sitepress'), '<strong>' . $lang->code . '</strong>'));
}
} else {
$error = __('Error: Language not found.', 'sitepress');
}
if (!empty($error)) {
$this->error($error);
}
}
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:62,代码来源:edit-languages.php
示例5: _process_generic_text
//.........这里部分代码省略.........
}
}
if ($p) {
if ($post_type == 'page') {
$qvid = 'page_id';
} else {
$qvid = 'p';
}
if ($sitepress_settings['language_negotiation_type'] == 1 && $lang) {
$langprefix = '/' . $lang;
} else {
$langprefix = '';
}
$perm_url = '(' . rtrim($home_url, '/') . ')?' . $langprefix . '/' . str_replace('?', '\\?', $m);
$regk = '@href=["\'](' . $perm_url . ')["\']@i';
if ($anchor) {
$anchor = "#" . $anchor;
} else {
$anchor = "";
}
// check if this is an offsite url
if ($p->post_type == 'page' && ($offsite_url = get_post_meta($p->ID, '_cms_nav_offsite_url', true))) {
$regv = 'href="' . $offsite_url . $anchor . '"';
} else {
$regv = 'href="' . '/' . ltrim($url_parts['path'], '/') . '?' . $qvid . '=' . $p->ID;
if ($req_uri_params != '') {
$regv .= '&' . $req_uri_params;
}
$regv .= $anchor . '"';
}
$def_url[$regk] = $regv;
} else {
$alp_broken_links[$alp_matches[2][$k]] = array();
$name = wpml_like_escape($post_name);
$p = $wpdb->get_results("SELECT ID, post_type FROM {$wpdb->posts} WHERE post_name LIKE '{$name}%' AND post_type IN('post','page')");
if ($p) {
foreach ($p as $post_suggestion) {
if ($post_suggestion->post_type == 'page') {
$qvid = 'page_id';
} else {
$qvid = 'p';
}
$alp_broken_links[$alp_matches[2][$k]]['suggestions'][] = array('absolute' => '/' . ltrim($url_parts['path'], '/') . '?' . $qvid . '=' . $post_suggestion->ID, 'perma' => '/' . ltrim(str_replace(site_url(), '', get_permalink($post_suggestion->ID)), '/'));
}
}
}
} elseif ($category_name) {
if (false !== strpos($category_name, '/')) {
$splits = explode('/', $category_name);
$category_name = array_pop($splits);
$category_parent = array_pop($splits);
$category_parent_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM {$wpdb->terms} WHERE slug=%s", $category_parent));
$c = $wpdb->get_row($wpdb->prepare("SELECT t.term_id FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id=t.term_id AND x.taxonomy='category' AND x.parent=%d AND t.slug=%s", $category_parent_id, $category_name));
} else {
$c = $wpdb->get_row($wpdb->prepare("SELECT term_id FROM {$wpdb->terms} WHERE slug=%s", $category_name));
}
if ($c) {
/* not used ?? */
if ($sitepress_settings['language_negotiation_type'] == 1 && $lang) {
$langprefix = '/' . $lang;
} else {
$langprefix = '';
}
/* not used ?? */
$perm_url = '(' . rtrim($home_url, '/') . ')?' . $langprefix . '/' . $m;
$regk = '@href=[\'"](' . $perm_url . ')[\'"]@i';
开发者ID:Artur-Qaramyan,项目名称:wordpress,代码行数:67,代码来源:absolute-links.class.php
示例6: icl_plugin_upgrade
function icl_plugin_upgrade()
{
global $wpdb;
$iclsettings = get_option('icl_sitepress_settings');
require_once ICL_PLUGIN_PATH . '/inc/cache.php';
icl_cache_clear('locale_cache_class');
icl_cache_clear('flags_cache_class');
icl_cache_clear('language_name_cache_class');
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.2', '<')) {
$wpdb->update($wpdb->prefix . 'icl_flags', array('flag' => 'ku.png'), array('lang_code' => 'ku'));
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'Magyar'), array('language_code' => 'hu', 'display_language_code' => 'hu'));
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'Hrvatski'), array('language_code' => 'hr', 'display_language_code' => 'hr'));
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'فارسی'), array('language_code' => 'fa', 'display_language_code' => 'fa'));
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.3', '<')) {
$wpdb->update($wpdb->prefix . 'icl_languages_translations', array('name' => 'پارسی'), array('language_code' => 'fa', 'display_language_code' => 'fa'));
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.7', '<')) {
if (!isset($iclsettings['promote_wpml'])) {
$iclsettings['promote_wpml'] = 0;
update_option('icl_sitepress_settings', $iclsettings);
}
if (!isset($iclsettings['auto_adjust_ids'])) {
$iclsettings['auto_adjust_ids'] = 0;
update_option('icl_sitepress_settings', $iclsettings);
}
$wpdb->query("UPDATE {$wpdb->prefix}icl_translations SET element_type='tax_post_tag' WHERE element_type='tag'");
// @since 3.1.5 - mysql_* function deprecated in php 5.5+
$wpdb->query("UPDATE {$wpdb->prefix}icl_translations SET element_type='tax_category' WHERE element_type='category'");
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.8', '<')) {
$res = $wpdb->get_results("SELECT ID, post_type FROM {$wpdb->posts}");
$post_types = array();
foreach ($res as $row) {
$post_types[$row->post_type][] = $row->ID;
}
foreach ($post_types as $type => $ids) {
if (!empty($ids)) {
$q = "UPDATE {$wpdb->prefix}icl_translations SET element_type=%s WHERE element_type='post' AND element_id IN(" . join(',', $ids) . ")";
$q_prepared = $wpdb->prepare($q, 'post_' . $type);
$wpdb->query($q_prepared);
// @since 3.1.5 - mysql_* function deprecated in php 5.5+
}
}
// fix categories & tags in icl_translations
$res = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM {$wpdb->term_taxonomy}");
foreach ($res as $row) {
$icltr = $wpdb->get_row($wpdb->prepare("SELECT translation_id, element_type FROM {$wpdb->prefix}icl_translations WHERE element_id=%d AND element_type LIKE %s", array($row->term_taxonomy_id, wpml_like_escape('tax_') . '%')));
if ('tax_' . $row->taxonomy != $icltr->element_type) {
$wpdb->update($wpdb->prefix . 'icl_translations', array('element_type' => 'tax_' . $row->taxonomy), array('translation_id' => $icltr->translation_id));
}
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '2.0.0', '<')) {
include_once ICL_PLUGIN_PATH . '/inc/upgrade-functions/upgrade-2.0.0.php';
if (empty($iclsettings['migrated_2_0_0'])) {
define('ICL_MULTI_STEP_UPGRADE', true);
return;
// GET OUT AND DO NOT SET THE NEW VERSION
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '2.0.4', '<')) {
$sql = "ALTER TABLE {$wpdb->prefix}icl_translation_status ADD COLUMN `_prevstate` longtext";
$wpdb->query($sql);
}
$versions = array('2.0.5', '2.2.2', '2.3.0', '2.3.1', '2.3.3', '2.4.0', '2.5.0', '2.5.2', '2.6.0', '2.7', '2.9', '2.9.3', '3.1', '3.1.5', '3.1.8', '3.1.9.5', '3.2', '3.2.3', '3.3', '3.3.7');
foreach ($versions as $version) {
icl_upgrade_version($version);
}
//Forcing upgrade logic when ICL_SITEPRESS_DEV_VERSION is defined
//This allow to run the logic between different alpha/beta/RC versions
//since we are now storing only the formal version in the options
if (defined('ICL_SITEPRESS_DEV_VERSION')) {
icl_upgrade_version(ICL_SITEPRESS_DEV_VERSION, true);
}
if (version_compare(get_option('icl_sitepress_version'), ICL_SITEPRESS_VERSION, '<')) {
update_option('icl_sitepress_version', ICL_SITEPRESS_VERSION);
}
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:79,代码来源:upgrade.php
示例7: build_where_clause
private static function build_where_clause($selects, $taxonomy, $search = false, $parent = false)
{
global $wpdb;
$where_clauses[] = $selects[$wpdb->term_taxonomy]['alias'] . '.taxonomy = ' . "'" . $taxonomy . "'";
$where_clauses[] = $selects[$wpdb->prefix . 'icl_translations']['alias'] . '.element_type = ' . "'tax_" . $taxonomy . "'";
if ($parent) {
$where_clauses[] = $selects[$wpdb->term_taxonomy]['alias'] . '.parent = ' . $parent;
}
if ($search) {
$where_clauses[] = "ts.name LIKE '%" . wpml_like_escape($search) . "%' ";
}
$where_clause = join(' AND ', $where_clauses);
return $where_clause;
}
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:14,代码来源:taxonomy-translation.php
示例8: parse_admin_texts
/**
* @param $config
*
* @return array
*/
protected static function parse_admin_texts($config)
{
global $iclTranslationManagement;
if (function_exists('icl_register_string')) {
$admin_texts = array();
if (!empty($config['wpml-config']['admin-texts'])) {
if (!is_numeric(key(@current($config['wpml-config']['admin-texts'])))) {
$admin_texts[0] = $config['wpml-config']['admin-texts']['key'];
} else {
$admin_texts = $config['wpml-config']['admin-texts']['key'];
}
$type = 'plugin';
$admin_text_context = '';
foreach ($admin_texts as $a) {
if (isset($a['type'])) {
$type = $a['type'];
}
if (isset($a['context'])) {
$admin_text_context = $a['context'];
}
if (!isset($type)) {
$type = 'plugin';
}
if (!isset($admin_text_context)) {
$admin_text_context = '';
}
$keys = array();
if (!isset($a['key'])) {
$arr[$a['attr']['name']] = 1;
$arr_context[$a['attr']['name']] = $admin_text_context;
$arr_type[$a['attr']['name']] = $type;
continue;
} elseif (!is_numeric(key($a['key']))) {
$keys[0] = $a['key'];
} else {
$keys = $a['key'];
}
foreach ($keys as $key) {
if (isset($key['key'])) {
$arr[$a['attr']['name']][$key['attr']['name']] = self::read_admin_texts_recursive($key['key'], $admin_text_context, $type, $arr_context, $arr_type);
} else {
$arr[$a['attr']['name']][$key['attr']['name']] = 1;
}
$arr_context[$a['attr']['name']] = $admin_text_context;
$arr_type[$a['attr']['name']] = $type;
}
}
if (isset($arr)) {
$iclTranslationManagement->admin_texts_to_translate = array_merge($iclTranslationManagement->admin_texts_to_translate, $arr);
}
$_icl_admin_option_names = get_option('_icl_admin_option_names');
$arr_options = array();
if (isset($arr) && is_array($arr)) {
foreach ($arr as $key => $v) {
remove_filter('option_' . $key, 'icl_st_translate_admin_string');
// dont try to translate this one below
$value = get_option($key);
add_filter('option_' . $key, 'icl_st_translate_admin_string');
// put the filter back on
$value = maybe_unserialize($value);
$admin_text_context = isset($arr_context[$key]) ? $arr_context[$key] : '';
$type = isset($arr_type[$key]) ? $arr_type[$key] : '';
if (false === $value) {
// wildcard? register all matching options in wp_options
global $wpdb;
$src = str_replace('*', '%', wpml_like_escape($key));
$matches = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE '{$src}'");
foreach ($matches as $match) {
icl_register_string('admin_texts_' . $type . '_' . $admin_text_context, $match->option_name, $match->option_value);
$_icl_admin_option_names[$type][$admin_text_context][] = $match->option_name;
}
unset($arr[$key]);
}
if (is_scalar($value)) {
icl_register_string('admin_texts_' . $type . '_' . $admin_text_context, $key, $value);
} else {
if (is_object($value)) {
$value = (array) $value;
}
if (!empty($value)) {
$iclTranslationManagement->_register_string_recursive($key, $value, $arr[$key], '', $type . '_' . $admin_text_context);
}
}
$arr_options[$type][$admin_text_context][$key] = $v;
}
if (is_array($_icl_admin_option_names)) {
$_icl_admin_option_names = @array_merge((array) $_icl_admin_option_names, $arr_options);
} else {
$_icl_admin_option_names = $arr_options;
}
}
//$_icl_admin_option_names[ $type ][ $admin_text_context ] = __array_unique_recursive( $_icl_admin_option_names[ $type ][ $admin_text_context ] );
update_option('_icl_admin_option_names', $_icl_admin_option_names);
}
}
//.........这里部分代码省略.........
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:101,代码来源:wpml-config.class.php
示例9: _process_generic_text
//.........这里部分代码省略.........
} elseif (isset($permalink_query_vars['name'])) {
$post_name = $permalink_query_vars['name'];
$post_type = 'post';
} elseif (isset($permalink_query_vars['category_name'])) {
$category_name = $permalink_query_vars['category_name'];
} elseif (isset($permalink_query_vars['p'])) {
// case or /archives/%post_id
$post_data_prepared = $wpdb->prepare("SELECT post_type, post_name FROM {$wpdb->posts} WHERE id=%d", $permalink_query_vars['p']);
list($post_type, $post_name) = $wpdb->get_row($post_data_prepared, ARRAY_N);
} else {
if (empty($this->custom_post_query_vars) or empty($this->taxonomies_query_vars)) {
$this->init_query_vars();
}
foreach ($this->custom_post_query_vars as $query_vars_key => $query_vars_value) {
if (isset($permalink_query_vars[$query_vars_value])) {
$post_name = $permalink_query_vars[$query_vars_value];
$post_type = $query_vars_key;
break;
}
}
foreach ($this->taxonomies_query_vars as $query_vars_value) {
if (isset($permalink_query_vars[$query_vars_value])) {
$tax_name = $permalink_query_vars[$query_vars_value];
$tax_type = $query_vars_value;
break;
}
}
}
if ($post_name && isset($post_type)) {
$get_page_by_path = new WPML_Get_Page_By_Path($wpdb, $sitepress);
$p = $get_page_by_path->get($post_name, $test_language, OBJECT, $post_type);
if (empty($p)) {
// fail safe
if ($post_id = url_to_postid($home_path . '/' . $post_name)) {
$p = get_post($post_id);
}
}
if ($p) {
if ($p->post_type == 'page' && ($offsite_url = get_post_meta($p->ID, '_cms_nav_offsite_url', true))) {
$def_url = $this->get_regex_replacement_offline($def_url, $offsite_url, $sitepress_settings['language_negotiation_type'], $lang, $dir_path, $home_url, $anchor_output);
} else {
$def_url = $this->get_regex_replacement($def_url, $p->post_type == 'page' ? 'page_id' : 'p', $p->ID, $sitepress_settings['language_negotiation_type'], $lang, $dir_path, $home_url, $url_parts, $req_uri_params, $anchor_output);
}
} else {
$alp_broken_links[$alp_matches[2][$k]] = array();
$name = wpml_like_escape($post_name);
$p = $this->_get_ids_and_post_types($name);
if ($p) {
foreach ($p as $post_suggestion) {
if ($post_suggestion->post_type == 'page') {
$qvid = 'page_id';
} else {
$qvid = 'p';
}
$alp_broken_links[$alp_matches[2][$k]]['suggestions'][] = array('absolute' => '/' . ltrim($url_parts['path'], '/') . '?' . $qvid . '=' . $post_suggestion->ID, 'perma' => '/' . ltrim(str_replace(site_url(), '', get_permalink($post_suggestion->ID)), '/'));
}
}
}
} elseif ($category_name) {
if (false !== strpos($category_name, '/')) {
$splits = explode('/', $category_name);
$category_name = array_pop($splits);
$category_parent = array_pop($splits);
$category_parent_id = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM {$wpdb->terms} WHERE slug=%s", $category_parent));
$c = $wpdb->get_row($wpdb->prepare("SELECT t.term_id FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id=t.term_id AND x.taxonomy='category' AND x.parent=%d AND t.slug=%s", $category_parent_id, $category_name));
} else {
$c = $wpdb->get_row($wpdb->prepare("SELECT term_id FROM {$wpdb->terms} WHERE slug=%s", $category_name));
}
if ($c) {
$def_url = $this->get_regex_replacement($def_url, 'cat_ID', $c->term_id, $sitepress_settings['language_negotiation_type'], $lang, $dir_path, $home_url, $url_parts, $req_uri_params, $anchor_output);
} elseif (isset($name)) {
$alp_broken_links[$alp_matches[2][$k]] = array();
$c_prepared = $wpdb->prepare("SELECT term_id FROM {$wpdb->terms} WHERE slug LIKE %s", array($name . '%'));
$c = $wpdb->get_results($c_prepared);
if ($c) {
foreach ($c as $cat_suggestion) {
$perma = '/' . ltrim(str_replace(get_home_url(), '', get_category_link($cat_suggestion->term_id)), '/');
$alp_broken_links[$alp_matches[2][$k]]['suggestions'][] = array('absolute' => '?cat_ID=' . $cat_suggestion->term_id, 'perma' => $perma);
}
}
}
} elseif ($tax_name && isset($tax_type)) {
$def_url = $this->get_regex_replacement($def_url, $tax_type, $tax_name, $sitepress_settings['language_negotiation_type'], $lang, $dir_path, $home_url, $url_parts, $req_uri_params, $anchor_output);
}
}
if (!empty($def_url)) {
$text = preg_replace(array_keys($def_url), array_values($def_url), $text);
}
$tx_qvs = !empty($this->taxonomies_query_vars) && is_array($this->taxonomies_query_vars) ? '|' . join('|', $this->taxonomies_query_vars) : '';
$post_qvs = !empty($this->custom_posts_query_vars) && is_array($this->custom_posts_query_vars) ? '|' . join('|', $this->custom_posts_query_vars) : '';
$int = preg_match_all('@href=[\'"](' . rtrim(get_home_url(), '/') . '/?\\?(p|page_id' . $tx_qvs . $post_qvs . ')=([0-9a-z-]+)(#.+)?)[\'"]@i', $text, $matches2);
if ($int) {
$url_parts = parse_url(rtrim(get_home_url(), '/') . '/');
$text = preg_replace('@href=[\'"](' . rtrim(get_home_url(), '/') . '/?\\?(p|page_id' . $tx_qvs . $post_qvs . ')=([0-9a-z-]+)(#.+)?)[\'"]@i', 'href="' . '/' . ltrim($url_parts['path'], '/') . '?$2=$3$4"', $text);
}
}
}
wp_cache_set($cache_key, $text, $cache_group);
return $text;
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:101,代码来源:absolute-links.class.php
注:本文中的wpml_like_escape函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论