本文整理汇总了PHP中wpml_object_id_filter函数的典型用法代码示例。如果您正苦于以下问题:PHP wpml_object_id_filter函数的具体用法?PHP wpml_object_id_filter怎么用?PHP wpml_object_id_filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpml_object_id_filter函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: tptn_object_id_cur_lang
/**
* Fetch the post of the correct language.
*
* @since 2.1.0
*
* @param $post_id Post ID
*/
function tptn_object_id_cur_lang($post_id)
{
$return_original_if_missing = false;
/**
* Filter to modify if the original language ID is returned.
*
* @since 2.2.3
*
* @param bool $return_original_if_missing
* @param int $post_id Post ID
*/
$return_original_if_missing = apply_filters('tptn_wpml_return_original', $return_original_if_missing, $post_id);
if (function_exists('pll_get_post')) {
$post_id = pll_get_post($post_id);
} elseif (function_exists('wpml_object_id_filter')) {
$post_id = wpml_object_id_filter($post_id, 'any', $return_original_if_missing);
} elseif (function_exists('icl_object_id')) {
$post_id = icl_object_id($post_id, 'any', $return_original_if_missing);
}
/**
* Filters object ID for current language (WPML).
*
* @since 2.1.0
*
* @param int $post_id Post ID
*/
return apply_filters('tptn_object_id_cur_lang', $post_id);
}
开发者ID:designomx,项目名称:DMXFrmwrk,代码行数:35,代码来源:l10n.php
示例2: yit_wpml_get_translated_id
/**
* Get the id of the current translation of the post/custom type
*
* @since 2.0.0
* @author Andrea Frascaspata <[email protected]>
*/
function yit_wpml_get_translated_id($id, $post_type)
{
if (function_exists('wpml_object_id_filter')) {
$id = wpml_object_id_filter($id, $post_type, true);
}
return $id;
}
开发者ID:lieison,项目名称:IndustriasFenix,代码行数:13,代码来源:functions.yit-contact-form.php
示例3: wpmlretapi_slug_get_translations
/**
* Retrieve available translations
*
* @param array $object Details of current post.
* @param string $field_name Name of field.
* @param WP_REST_Request $request Current request
*
* @return mixed
*/
function wpmlretapi_slug_get_translations($object, $field_name, $request)
{
global $sitepress;
$languages = apply_filters('wpml_active_languages', null);
$translations = [];
foreach ($languages as $language) {
$post_id = wpml_object_id_filter($object['id'], 'post', false, $language['language_code']);
if ($post_id === null || $post_id == $object['id']) {
continue;
}
$thisPost = get_post($post_id);
$href = apply_filters('WPML_filter_link', $language['url'], $language);
if (strpos($href, '?') !== false) {
$href = str_replace('?', '/' . $thisPost->post_name . '/?', $href);
} else {
if (substr($href, -1) !== '/') {
$href .= '/';
}
$href .= $thisPost->post_name . '/';
}
$translations[] = array('locale' => $language['default_locale'], 'id' => $thisPost->ID, 'post_title' => $thisPost->post_title, 'href' => $href);
}
return $translations;
}
开发者ID:shawnhooper,项目名称:wpml-rest-api,代码行数:33,代码来源:wpml-rest-api.php
示例4: yit_wcan_localize_terms
/**
* Get current layered link
*
* @param $term_id The term id
* @param $taxonomy The taxonomy name
*
* @return string The new term_id
*
* @since 1.4
* @author Andrea Grillo <[email protected]>
*/
function yit_wcan_localize_terms($term_id, $taxonomy)
{
/* === WPML Support === */
global $sitepress;
if (!empty($sitepress) && function_exists('wpml_object_id_filter')) {
$term_id = wpml_object_id_filter($term_id, $taxonomy, true, $sitepress->get_default_language());
}
return $term_id;
}
开发者ID:sistercylon,项目名称:loverboy-wp-local,代码行数:20,代码来源:functions.yith-wcan.php
示例5: yith_wcwl_object_id
/**
* Retrieve translated page id, if wpml is installed
*
* @param $id int Original page id
* @return int Translation id
* @since 1.0.0
*/
function yith_wcwl_object_id($id)
{
if (function_exists('wpml_object_id_filter')) {
return wpml_object_id_filter($id, 'page', true);
} elseif (function_exists('icl_object_id')) {
return icl_object_id($id, 'page', true);
} else {
return $id;
}
}
开发者ID:websideas,项目名称:Mondova,代码行数:17,代码来源:functions.yith-wcwl.php
示例6: icl_object_id
/**
* @since unknown
* @deprecated 3.2 use 'wpml_object_id' filter instead.
*
* @param $element_id
* @param string $element_type
* @param bool $return_original_if_missing
* @param null|string $ulanguage_code
*
* @return null|int
*/
function icl_object_id($element_id, $element_type = 'post', $return_original_if_missing = false, $ulanguage_code = null)
{
return wpml_object_id_filter($element_id, $element_type, $return_original_if_missing, $ulanguage_code);
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:15,代码来源:template-functions.php
示例7: get_wpml_parent_id
public function get_wpml_parent_id($product_id)
{
global $sitepress;
if (isset($sitepress)) {
$default_language = $sitepress->get_default_language();
if (function_exists('icl_object_id')) {
$product_id = icl_object_id($product_id, 'product', true, $default_language);
} else {
if (function_exists('wpml_object_id_filter')) {
$product_id = wpml_object_id_filter($product_id, 'product', true, $default_language);
}
}
}
return $product_id;
}
开发者ID:patrickcurl,项目名称:monks,代码行数:15,代码来源:class.yith-wcbm-frontend.php
示例8: getOptionTranslateId
/**
* Vrátí buď požadované originální nebo "přeložené" ID pro zadaný post type
* (pozn.: dle aktuálního jazyka + zavislé na pluginu WPML)
*
* @author Martin Hlaváč
* @link http://www.ktstudio.cz
*
* @param string $name
* @param string $postType
* @return string|null
*/
public function getOptionTranslateId($name, $postType)
{
$value = $this->getOption($name);
if (defined("ICL_LANGUAGE_CODE")) {
if (is_array($value)) {
$ids = array();
foreach ($value as $id) {
array_push($ids, wpml_object_id_filter($id, $postType, true, ICL_LANGUAGE_CODE));
}
return $ids;
} else {
$value = wpml_object_id_filter($value, $postType, true, ICL_LANGUAGE_CODE);
}
}
return $value;
}
开发者ID:ktstudio,项目名称:wp-framework,代码行数:27,代码来源:kt_wp_options_base_model.inc.php
示例9: populate_products_list
/**
* Populate the compare product list
*/
public function populate_products_list()
{
global $sitepress;
/**
* WPML Support
*/
$lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : false;
// get cookie val
$the_list = isset($_COOKIE[$this->cookie_name]) ? json_decode($_COOKIE[$this->cookie_name]) : array();
// switch lang for WPML
if (defined('ICL_LANGUAGE_CODE') && $lang && isset($sitepress)) {
$sitepress->switch_lang($lang, true);
}
foreach ($the_list as $product_id) {
if (function_exists('wpml_object_id_filter')) {
$product_id_translated = wpml_object_id_filter($product_id, 'product', false);
// get all product of current lang
if ($product_id_translated !== $product_id) {
continue;
}
}
// check for deleted|private products
$product = wc_get_product($product_id);
if (!$product || $product->post->post_status !== 'publish') {
continue;
}
$this->products_list[] = $product_id;
}
}
开发者ID:websideas,项目名称:Mondova,代码行数:32,代码来源:class.yith-woocompare-frontend.php
示例10: yit_wpml_object_id
/**
* Get id of post translation in current language
*
* @param int $element_id
* @param string $element_type
* @param bool $return_original_if_missing
* @param null|string $ulanguage_code
*
* @return int the translation id
* @since 2.0.0
* @author Antonio La Rocca <[email protected]>
*/
function yit_wpml_object_id($element_id, $element_type = 'post', $return_original_if_missing = false, $ulanguage_code = null)
{
if (function_exists('wpml_object_id_filter')) {
return wpml_object_id_filter($element_id, $element_type, $return_original_if_missing, $ulanguage_code);
} elseif (function_exists('icl_object_id')) {
return icl_object_id($element_id, $element_type, $return_original_if_missing, $ulanguage_code);
} else {
return $element_id;
}
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:22,代码来源:yit-functions.php
示例11: get_translated_post_id
/**
* Takes a post id, checks if the current language isn't the default language and returns a translated post id if it exists, used to switch our overriding pages or post types
* @param int $post_id
* @return int
*/
public static function get_translated_post_id($post_id, $post_type)
{
if (function_exists('wpml_object_id_filter')) {
return wpml_object_id_filter($post_id, $post_type);
}
//3.2 compatible
return icl_object_id($post_id, $post_type);
// <3.2 compatible
}
开发者ID:sajjadalisiddiqui,项目名称:cms,代码行数:14,代码来源:events-manager-wpml.php
注:本文中的wpml_object_id_filter函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论