本文整理汇总了PHP中pll_is_translated_post_type函数的典型用法代码示例。如果您正苦于以下问题:PHP pll_is_translated_post_type函数的具体用法?PHP pll_is_translated_post_type怎么用?PHP pll_is_translated_post_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pll_is_translated_post_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relevanssi_wpml_filter
function relevanssi_wpml_filter($data)
{
$use_filter = get_option('relevanssi_wpml_only_current');
if ('on' == $use_filter) {
//save current blog language
$lang = get_bloginfo('language');
$filtered_hits = array();
foreach ($data[0] as $hit) {
if (isset($hit->blog_id)) {
switch_to_blog($hit->blog_id);
}
global $sitepress;
if (function_exists('icl_object_id') && $sitepress->is_translated_post_type($hit->post_type)) {
if ($hit->ID == icl_object_id($hit->ID, $hit->post_type, false, ICL_LANGUAGE_CODE)) {
$filtered_hits[] = $hit;
}
} elseif (function_exists('icl_object_id') && function_exists('pll_is_translated_post_type')) {
if (pll_is_translated_post_type($hit->post_type)) {
if ($hit->ID == icl_object_id($hit->ID, $hit->post_type, false, ICL_LANGUAGE_CODE)) {
$filtered_hits[] = $hit;
}
}
} elseif (get_bloginfo('language') == $lang) {
$filtered_hits[] = $hit;
}
if (isset($hit->blog_id)) {
restore_current_blog();
}
}
return array($filtered_hits, $data[1]);
}
return $data;
}
示例2: catch_filter_values
/**
* Runs on template_include filter. Check for $POST values coming from the filter and add them to the url
* Also check for custom GET parameters and reattach them to the url to support combination with other functionalities
* @since 1.0.0
*/
public function catch_filter_values()
{
//Nope, this pageload was not due to our filter!
if (!isset($_POST['btf_do_filtering_nonce']) || !wp_verify_nonce($_POST['btf_do_filtering_nonce'], "Beutiful-taxonomy-filters-do-filter")) {
return;
}
//If we don't have an url, this wont work!
$referer = isset($_POST['site-url']) ? $_POST['site-url'] : false;
if (!$referer) {
return;
}
//get current post type archive rewrite slug
if (isset($_POST['post_type_rewrite']) && $_POST['post_type_rewrite'] != '') {
$current_post_type_rewrite = $_POST['post_type_rewrite'];
} else {
//If there was no post type from the form (for some reason), try to get it anyway!
$current_post_type_rewrite = self::get_current_posttype();
}
//get current post type archive
if (isset($_POST['post_type']) && $_POST['post_type'] != '') {
$current_post_type = $_POST['post_type'];
} else {
//If there was no post type from the form (for some reason), try to get it anyway!
$current_post_type = self::get_current_posttype(false);
}
//post type validation
if (!post_type_exists($current_post_type)) {
return;
}
//Polylang support
if (function_exists('pll_current_language')) {
$language_slug = pll_current_language('slug');
//If the post type is translated…
if (pll_is_translated_post_type($current_post_type)) {
$new_url = pll_home_url($language_slug);
} else {
//base url
$new_url = $referer . '/';
}
} else {
//base url
$new_url = $referer . '/';
}
$new_url .= $current_post_type_rewrite . '/';
//Get the taxonomies of the current post type
$current_taxonomies = get_object_taxonomies($current_post_type, 'objects');
if ($current_taxonomies) {
foreach ($current_taxonomies as $key => $value) {
//check for each taxonomy as a $_POST variable.
//If it exists we want to append it along with the value (term) it has.
$term = isset($_POST['select-' . $key]) ? $_POST['select-' . $key] : false;
if ($term) {
//If the taxonomy has a rewrite slug we need to use that instead!
if (is_array($value->rewrite) && array_key_exists('slug', $value->rewrite)) {
$new_url .= $value->rewrite['slug'] . '/' . $term . '/';
} else {
$new_url .= $key . '/' . $term . '/';
}
}
}
}
//Perform actions before the redirect to the filtered page
do_action('beautiful_actions_before_redirection', $current_post_type);
//keep GET parameters
$new_url = $this->append_get_parameters($new_url);
//sanitize URL
$new_url = esc_url_raw($new_url);
//perform a redirect to the new filtered url
wp_redirect(apply_filters('beautiful_filters_new_url', $new_url, $current_post_type));
exit;
}
示例3: icl_object_id
function icl_object_id($id, $type, $return_original_if_missing = false, $lang = false)
{
$pll_type = 'post' === $type || pll_is_translated_post_type($type) ? 'post' : ('term' === $type || pll_is_translated_taxonomy($type) ? 'term' : false);
return $pll_type && ($lang = $lang ? $lang : pll_current_language()) && ($tr_id = PLL()->model->{$pll_type}->get_translation($id, $lang)) ? $tr_id : ($return_original_if_missing ? $id : null);
}
示例4: get_table_info
//.........这里部分代码省略.........
} else {
$info['pod_table'] = $wpdb->prefix . 'pods_' . pods_clean_name($post_type, true, false);
}
$post_type_object = get_post_type_object($post_type);
if (is_object($post_type_object) && $post_type_object->hierarchical) {
$info['object_hierarchical'] = true;
}
/**
* Default Post Status to query for.
*
* Use to change "default" post status from publish to any other status or statuses.
*
* @param array $post_status List of post statuses. Default is 'publish'
* @param string $post_type Post type of current object
* @param array $info Array of information about the object.
* @param string $object Type of object
* @param string $name Name of pod to load
* @param array $pod Array with Pod information. Result of PodsAPI::load_pod()
* @param array $field Array with field information
*
* @since unknown
*/
$post_status = apply_filters('pods_api_get_table_info_default_post_status', array('publish'), $post_type, $info, $object_type, $object, $name, $pod, $field);
$info['where'] = array('post_type' => '`t`.`' . $info['field_type'] . '` = "' . $post_type . '"');
if ('post_type' == $object_type) {
$info['where_default'] = '`t`.`post_status` IN ( "' . implode('", "', $post_status) . '" )';
}
$info['orderby'] = '`t`.`menu_order`, `t`.`' . $info['field_index'] . '`, `t`.`post_date`';
// WPML support
if (is_object($sitepress) && $sitepress->is_translated_post_type($post_type) && !$icl_adjust_id_url_filter_off) {
$info['join']['wpml_translations'] = "\n LEFT JOIN `{$wpdb->prefix}icl_translations` AS `wpml_translations`\n ON `wpml_translations`.`element_id` = `t`.`ID`\n AND `wpml_translations`.`element_type` = 'post_{$post_type}'\n AND `wpml_translations`.`language_code` = '{$current_language}'\n ";
$info['join']['wpml_languages'] = "\n LEFT JOIN `{$wpdb->prefix}icl_languages` AS `wpml_languages`\n ON `wpml_languages`.`code` = `wpml_translations`.`language_code` AND `wpml_languages`.`active` = 1\n ";
$info['where']['wpml_languages'] = "`wpml_languages`.`code` IS NOT NULL";
} elseif (is_object($polylang) && !empty($current_language) && function_exists('pll_is_translated_post_type') && pll_is_translated_post_type($post_type)) {
$info['join']['polylang_languages'] = "\n LEFT JOIN `{$wpdb->term_relationships}` AS `polylang_languages`\n ON `polylang_languages`.`object_id` = `t`.`ID`\n AND `polylang_languages`.`term_taxonomy_id` = {$current_language_tt_id}\n ";
$info['where']['polylang_languages'] = "`polylang_languages`.`object_id` IS NOT NULL";
}
$info['object_fields'] = $this->get_wp_object_fields($object_type, $info['pod']);
} elseif (0 === strpos($object_type, 'taxonomy') || in_array($object_type, array('nav_menu', 'post_format')) || 'taxonomy' == pods_var_raw('type', $info['pod'])) {
$info['table'] = $info['meta_table'] = $wpdb->terms;
$info['join']['tt'] = "LEFT JOIN `{$wpdb->term_taxonomy}` AS `tt` ON `tt`.`term_id` = `t`.`term_id`";
$info['field_id'] = $info['meta_field_id'] = 'term_id';
$info['field_index'] = $info['meta_field_index'] = $info['meta_field_value'] = 'name';
$info['field_slug'] = 'slug';
$info['field_type'] = 'taxonomy';
$info['field_parent'] = 'parent';
$info['field_parent_select'] = '`tt`.`' . $info['field_parent'] . '`';
if ('nav_menu' == $object_type) {
$object = 'nav_menu';
} elseif ('post_format' == $object_type) {
$object = 'post_format';
}
if (empty($name)) {
$prefix = 'taxonomy-';
// Make sure we actually have the prefix before trying anything with the name
if (0 === strpos($object_type, $prefix)) {
$name = substr($object_type, strlen($prefix), strlen($object_type));
}
}
if (!in_array($object_type, array('nav_menu', 'post_format'))) {
$object_type = 'taxonomy';
}
$taxonomy = pods_sanitize(empty($object) ? $name : $object);
$info['pod_table'] = $wpdb->prefix . 'pods_' . pods_clean_name($taxonomy, true, false);
$taxonomy_object = get_taxonomy($taxonomy);
if (is_object($taxonomy_object) && $taxonomy_object->hierarchical) {
示例5: wpseo_posts_where
/**
* Yoast SEO
* Modifies the sql request for posts sitemaps
* Only when using multiple domains or subdomains
*
* @since 1.6.4
*
* @param string $sql WHERE clause
* @param string $post_type
* @return string
*/
public function wpseo_posts_where($sql, $post_type)
{
return pll_is_translated_post_type($post_type) ? $sql . PLL()->model->post->where_clause(PLL()->curlang) : $sql;
}
示例6: get_object_data
//.........这里部分代码省略.........
$object = $result['post_type'];
$object_type = 'post_type';
} elseif ($wpdb->terms == $search_data->table && isset($result['taxonomy'])) {
$object = $result['taxonomy'];
$object_type = 'taxonomy';
}
// WPML integration for Post Types and Taxonomies
if (is_object($sitepress) && in_array($object_type, array('post_type', 'taxonomy'))) {
$translated = false;
if ('post_type' == $object_type && $sitepress->is_translated_post_type($object)) {
$translated = true;
} elseif ('taxonomy' == $object_type && $sitepress->is_translated_taxonomy($object)) {
$translated = true;
}
if ($translated) {
$object_id = icl_object_id($result[$search_data->field_id], $object, false, $current_language);
if (0 < $object_id && !in_array($object_id, $ids)) {
$text = $result[$search_data->field_index];
if ($result[$search_data->field_id] != $object_id) {
if ($wpdb->posts == $search_data->table) {
$text = trim(get_the_title($object_id));
} elseif ($wpdb->terms == $search_data->table) {
$text = trim(get_term($object_id, $object)->name);
}
}
$result[$search_data->field_id] = $object_id;
$result[$search_data->field_index] = $text;
} else {
continue;
}
}
} elseif (is_object($polylang) && in_array($object_type, array('post_type', 'taxonomy')) && method_exists($polylang, 'get_translation')) {
$translated = false;
if ('post_type' == $object_type && pll_is_translated_post_type($object)) {
$translated = true;
} elseif ('taxonomy' == $object_type && pll_is_translated_taxonomy($object)) {
$translated = true;
}
if ($translated) {
$object_id = $polylang->get_translation($object, $result[$search_data->field_id], $current_language);
if (0 < $object_id && !in_array($object_id, $ids)) {
$text = $result[$search_data->field_index];
if ($result[$search_data->field_id] != $object_id) {
if ($wpdb->posts == $search_data->table) {
$text = trim(get_the_title($object_id));
} elseif ($wpdb->terms == $search_data->table) {
$text = trim(get_term($object_id, $object)->name);
}
}
$result[$search_data->field_id] = $object_id;
$result[$search_data->field_index] = $text;
} else {
continue;
}
}
}
if (0 < strlen($display_filter)) {
$display_filter_args = pods_var('display_filter_args', pods_var_raw('options', pods_var_raw($search_data->field_index, $search_data->pod_data['object_fields'])));
$args = array($display_filter, $result[$search_data->field_index]);
if (!empty($display_filter_args)) {
foreach ((array) $display_filter_args as $display_filter_arg) {
if (isset($result[$display_filter_arg])) {
$args[] = $result[$display_filter_arg];
}
}
}
示例7: object_link
/**
* Retrieve the permalink for a post type object.
*
* @param string $post_link The post's permalink.
* @param int|WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
* @param bool $sample Is it a sample permalink.
*/
public function object_link($link, $post, $leavename = false, $sample = false)
{
global $polylang, $wp_rewrite;
$key = $link . '|' . (int) $leavename . '|' . (int) $sample;
/** Emulate Polylang's "cached" collection */
if (isset($this->_links[$key])) {
return $this->_links[$key];
} else {
// Manipulate a copy
$post_link = $link;
$permastruct = '';
// This filter uses the ID instead of the post object
if ('_get_page_link' == current_filter()) {
$post = get_post($post);
}
if (!isset($wp_rewrite->extra_permastructs[$post->post_type])) {
$post_language = $polylang->model->get_post_language($post->ID);
if (is_object($post_language)) {
$post_language = $post_language->slug;
}
if (!$post_language && pll_is_translated_post_type($post->post_type)) {
$post_language = pll_current_language();
}
if ($post_language) {
$permastruct = $wp_rewrite->get_extra_permastruct($post->post_type . '_' . $post_language);
}
$post_type = get_post_type_object($post->post_type);
$slug = $post->post_name;
// If we aren't published, permalinks don't work
$draft_or_pending = isset($post->post_status) && in_array($post->post_status, ['draft', 'pending', 'auto-draft']);
if ((!empty($post_link) || !empty($permastruct)) && (!$draft_or_pending || $sample)) {
$filter_name = "parse_{$post->post_type}_link";
$filter_link = empty($permastruct) ? $post_link : $permastruct;
if (has_filter($filter_name)) {
// Don't bother filtering and parsing if no plugins are hooked in.
/**
* Filter the post link with the permastruct manually.
*
* @param string $post_link The post's permalink.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*/
$post_link = apply_filters($filter_name, $filter_link, $post, $leavename);
} else {
$post_link = parse_permalink_tags(empty($permastruct) ? $post_link : $permastruct, $post, $leavename);
}
}
}
/**
* Filter the permalink for a post with a custom post type.
*
* @param string $post_link The post's permalink.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
* @param bool $sample Is it a sample permalink.
*/
$post_link = apply_filters('pll_post_type_link', $post_link, $post, $leavename, $sample);
$this->_links[$key] = $post_link;
}
return $post_link;
}
示例8: wpseo_posts_where
public function wpseo_posts_where($sql, $post_type)
{
global $polylang;
return pll_is_translated_post_type($post_type) ? $sql . $polylang->model->where_clause($polylang->curlang, 'post') : $sql;
}
示例9: parse_main_query
public function parse_main_query($query)
{
if ($query !== $GLOBALS['wp_the_query']) {
return;
}
$qv = $query->query_vars;
// homepage is requested, let's set the language
// take care to avoid posts page for which is_home = 1
if (empty($query->query) && (is_home() || is_page() && $qv['page_id'] == $this->page_on_front)) {
$this->home_language();
$this->home_requested();
}
parent::parse_main_query($query);
$is_archive = count($query->query) == 1 && !empty($qv['paged']) || $query->is_date || $query->is_author || !empty($qv['post_type']) && $query->is_post_type_archive && pll_is_translated_post_type($qv['post_type']);
// sets the language in case we hide the default language
// use $query->query['s'] as is_search is not set when search is empty
// http://wordpress.org/support/topic/search-for-empty-string-in-default-language
if ($this->options['hide_default'] && !isset($qv['lang']) && ($is_archive || isset($query->query['s']) || count($query->query) == 1 && !empty($qv['feed']))) {
$this->set_language($this->model->get_language($this->options['default_lang']));
$this->set_lang_query_var($query, $this->curlang);
}
}
示例10: wpseo_posts_where
/**
* Yoast SEO
* Modifies the sql request for posts sitemaps
* Only when using multiple domains or subdomains or if some languages are not active
*
* @since 1.6.4
*
* @param string $sql WHERE clause
* @param string $post_type
* @return string
*/
public function wpseo_posts_where($sql, $post_type)
{
if (pll_is_translated_post_type($post_type)) {
if (PLL()->options['force_lang'] > 1) {
return $sql . PLL()->model->post->where_clause(PLL()->curlang);
}
if ($languages = $this->wpseo_get_active_languages()) {
return $sql . PLL()->model->post->where_clause($languages);
}
}
return $sql;
}
示例11: polylang_slug_should_run
/**
* Check if the query needs to be adapted.
*
* @since 0.2.0
*
* @param WP_Query $query The WP_Query instance (passed by reference).
*
* @return bool
*/
function polylang_slug_should_run($query = '')
{
/**
* Disable front end query modification.
*
* Allows disabling front end query modification if not needed.
*
* @since 0.2.0
*
* @param bool false Not disabling run.
* @param WP_Query $query The WP_Query instance (passed by reference).
*/
$disable = apply_filters('polylang_slug_disable', false, $query);
// The lang query should be defined if the URL contains the language
$lang = empty($query->query['lang']) ? pll_current_language() : $query->query['lang'];
// Checks if the post type is translated when doing a custom query with the post type defined
$is_translated = !empty($query->query['post_type']) && !pll_is_translated_post_type($query->query['post_type']);
if (is_admin() || !$lang || $is_translated || $disable) {
return false;
} else {
return true;
}
}
示例12: parse_permastruct_tags
/**
* Parse permalink rewrite tags
*
* Replicates the operations performed in {@see get_permalink()}
* to build a valid URL from a permastruct.
*
* This offers a more flexible solution for custom permalinks.
*
* @global Polylang $polylang If Polylang is available, translations will be considered.
*
* @param string $post_link The permalink building blocks.
* @param int|WP_Post $id Optional. Post ID or post object. Default current post.
* @param bool $leavename Optional. Whether to keep post name or page name. Default false.
* @return string|bool $post_link The permalink URL or false if post does not exist.
*/
function parse_permastruct_tags($post_link, $id = 0, $leavename = false)
{
$rewritecode = ['%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename ? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename ? '' : '%pagename%'];
if (is_object($id) && isset($id->filter) && 'sample' == $id->filter) {
$post = $id;
$sample = true;
} else {
$post = get_post($id);
$sample = false;
}
if (empty($post->ID)) {
return false;
}
// If we aren't published, permalinks don't work
$draft_or_pending = isset($post->post_status) && in_array($post->post_status, ['draft', 'pending', 'auto-draft']);
if (!empty($post_link) && !$draft_or_pending) {
$post_type = get_post_type_object($post->post_type);
/**
* Filter the post name to use as a slug.
*
* @param string $post_name The post's name.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*/
$slug = apply_filters("parse_{$post->post_type}_link/postname", $post->post_name, $post, $leavename);
if (!$leavename) {
if ($post_type->hierarchical) {
$slug = get_page_uri($id);
}
$post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
}
if (class_exists('Polylang')) {
global $polylang;
if (is_object($polylang) && $polylang->options['force_lang']) {
$post_language = $polylang->model->get_post_language($post->ID);
if (is_object($post_language)) {
$post_language = $post_language->slug;
}
if (!$post_language && pll_is_translated_post_type($post->post_type)) {
$post_language = pll_current_language();
}
if ($post_language) {
// $post_link = $polylang->links_model->add_language_to_link( $post_link, $post_language );
$lang = $polylang->options['default_lang'] == $post_language && $polylang->options['hide_default'] ? '' : ($polylang->options['rewrite'] ? '' : 'language/') . $post_language;
$post_link = str_replace('%language%', $lang, $post_link);
}
}
}
$unixtime = strtotime($post->post_date);
$category = '';
if (strpos($post_link, '%category%') !== false) {
$cats = get_the_category($post->ID);
if ($cats) {
usort($cats, '_usort_terms_by_ID');
// order by ID
/**
* Filter the category that gets used in the %category% permalink token.
*
* @param stdClass $cat The category to use in the permalink.
* @param array $cats Array of all categories associated with the post.
* @param WP_Post $post The post in question.
*/
$category_object = apply_filters('post_link_category', $cats[0], $cats, $post);
$category_object = get_term($category_object, 'category');
$category = $category_object->slug;
if ($parent = $category_object->parent) {
$category = get_category_parents($parent, false, '/', true) . $category;
}
}
// show default category in permalinks, without
// having to assign it explicitly
if (empty($category)) {
$default_category = get_term(get_option('default_category'), 'category');
$category = is_wp_error($default_category) ? '' : $default_category->slug;
}
}
$author = '';
if (strpos($post_link, '%author%') !== false) {
$authordata = get_userdata($post->post_author);
$author = $authordata->user_nicename;
}
$date = explode(' ', date('Y m d H i s', $unixtime));
$rewritereplace = [$date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $category, $author, $post->post_name];
$post_link = home_url(str_replace($rewritecode, $rewritereplace, $post_link));
$post_link = user_trailingslashit($post_link, 'single');
//.........这里部分代码省略.........
示例13: get_current_language
/**
* Get current language information from Multilingual plugins
*
* @since 2.6.6
*
* @return array
*/
public static function get_current_language()
{
/**
* @var $sitepress SitePress object
* @var $polylang object
*/
/*
* @todo wpml-comp Remove global object usage
*/
global $sitepress, $polylang;
$lang_data = false;
$translator = false;
$current_language = false;
// Multilingual support
if (did_action('wpml_loaded') && apply_filters('wpml_setting', true, 'auto_adjust_ids')) {
// WPML support
$translator = 'WPML';
// Get the global current language (if set)
$wpml_language = apply_filters('wpml_current_language', null);
$current_language = $wpml_language != 'all' ? $wpml_language : '';
} elseif ((function_exists('PLL') || is_object($polylang)) && function_exists('pll_current_language')) {
// Polylang support
$translator = 'PLL';
// Get the global current language (if set)
$current_language = pll_current_language('slug');
}
/**
* Admin functions that overwrite the current language
*
* @since 2.6.6
*/
if (is_admin() && !empty($translator)) {
if ($translator == 'PLL') {
/**
* Polylang support
* Get the current user's perferred language.
* This is a user meta setting that will overwrite the language returned from pll_current_language()
* @see polylang/admin/admin-base.php -> init_user()
*/
$current_language = get_user_meta(get_current_user_id(), 'pll_filter_content', true);
}
// Get current language based on the object language if available
if (function_exists('get_current_screen')) {
$current_screen = get_current_screen();
/**
* Overwrite the current language if needed for post types
*/
if (isset($current_screen->base) && ($current_screen->base == 'post' || $current_screen->base == 'edit')) {
if (!empty($_GET['post'])) {
/**
* WPML support
* In WPML the current language is always set to default on an edit screen
* We need to overwrite this when the current object is not-translatable to enable relationships with different languages
*/
if ($translator == 'WPML' && !apply_filters('wpml_is_translated_post_type', false, get_post_type($_GET['post']))) {
// Overwrite the current language to nothing if this is a NOT-translatable post_type
$current_language = '';
}
/**
* Polylang support (1.5.4+)
* In polylang the preferred language could be anything.
* We only want the related objects if they are not translatable OR the same language as the current object
*/
if ($translator == 'PLL' && function_exists('pll_get_post_language') && pll_is_translated_post_type(get_post_type($_GET['post']))) {
// Overwrite the current language if this is a translateable post_type
$current_language = pll_get_post_language((int) $_GET['post']);
}
}
/**
* Polylang support (1.0.1+)
* In polylang the preferred language could be anything.
* When we're adding a new object and language is set we only want the related objects if they are not translatable OR the same language
*/
if ($translator == 'PLL' && !empty($_GET['new_lang']) && !empty($_GET['post_type']) && pll_is_translated_post_type(sanitize_text_field($_GET['post_type']))) {
$current_language = $_GET['new_lang'];
}
/**
* Overwrite the current language if needed for taxonomies
*/
} elseif (isset($current_screen->base) && ($current_screen->base == 'term' || $current_screen->base == 'edit-tags')) {
// @todo MAYBE: Similar function like get_post_type for taxonomies so we don't need to check for $_GET['taxonomy']
if (!empty($_GET['taxonomy'])) {
/*
* @todo wpml-comp API call for taxonomy needed!
* Suggested API call:
* add_filter( 'wpml_is_translated_taxonomy', $_GET['taxonomy'], 10, 2 );
*/
/**
* WPML support
* In WPML the current language is always set to default on an edit screen
* We need to overwrite this when the current object is not-translatable to enable relationships with different languages
*/
if ($translator == 'WPML' && method_exists($sitepress, 'is_translated_taxonomy') && !$sitepress->is_translated_taxonomy($_GET['taxonomy'])) {
//.........这里部分代码省略.........
示例14: get_table_info
//.........这里部分代码省略.........
$object = 'attachment';
}
if (empty($name)) {
$prefix = 'post_type-';
// Make sure we actually have the prefix before trying anything with the name
if (0 === strpos($object_type, $prefix)) {
$name = substr($object_type, strlen($prefix), strlen($object_type));
}
}
if ('media' != $object_type) {
$object_type = 'post_type';
}
$post_type = pods_sanitize(empty($object) ? $name : $object);
if ('attachment' == $post_type || 'media' == $object_type) {
$info['pod_table'] = $wpdb->prefix . 'pods_media';
} else {
$info['pod_table'] = $wpdb->prefix . 'pods_' . pods_clean_name($post_type, true, false);
}
$post_type_object = get_post_type_object($post_type);
if (is_object($post_type_object) && $post_type_object->hierarchical) {
$info['object_hierarchical'] = true;
}
$post_stati = $this->do_hook('get_table_info_default_post_status', array('publish'), $post_type, $info, $object_type, $object, $name, $pod, $field);
$info['where'] = array('post_type' => '`t`.`' . $info['field_type'] . '` = "' . $post_type . '"');
if ('post_type' == $object_type) {
$info['where_default'] = '`t`.`post_status` IN ( "' . implode('", "', $post_stati) . '" )';
}
$info['orderby'] = '`t`.`menu_order`, `t`.`' . $info['field_index'] . '`, `t`.`post_date`';
// WPML support
if (is_object($sitepress) && $sitepress->is_translated_post_type($post_type) && !$icl_adjust_id_url_filter_off) {
$info['join']['wpml_translations'] = "\n LEFT JOIN `{$wpdb->prefix}icl_translations` AS `wpml_translations`\n ON `wpml_translations`.`element_id` = `t`.`ID`\n AND `wpml_translations`.`element_type` = 'post_{$post_type}'\n AND `wpml_translations`.`language_code` = '{$current_language}'\n ";
$info['join']['wpml_languages'] = "\n LEFT JOIN `{$wpdb->prefix}icl_languages` AS `wpml_languages`\n ON `wpml_languages`.`code` = `wpml_translations`.`language_code` AND `wpml_languages`.`active` = 1\n ";
$info['where']['wpml_languages'] = "`wpml_languages`.`code` IS NOT NULL";
} elseif (is_object($polylang) && !empty($current_language) && function_exists('pll_is_translated_post_type') && pll_is_translated_post_type($post_type)) {
$info['join']['polylang_languages'] = "\n LEFT JOIN `{$wpdb->term_relationships}` AS `polylang_languages`\n ON `polylang_languages`.`object_id` = `t`.`ID`\n AND `polylang_languages`.`term_taxonomy_id` = {$current_language_tt_id}\n ";
$info['where']['polylang_languages'] = "`polylang_languages`.`object_id` IS NOT NULL";
}
$info['object_fields'] = $this->get_wp_object_fields($object_type, $info['pod']);
} elseif (0 === strpos($object_type, 'taxonomy') || in_array($object_type, array('nav_menu', 'post_format')) || 'taxonomy' == pods_var_raw('type', $info['pod'])) {
$info['table'] = $info['meta_table'] = $wpdb->terms;
$info['join']['tt'] = "LEFT JOIN `{$wpdb->term_taxonomy}` AS `tt` ON `tt`.`term_id` = `t`.`term_id`";
$info['field_id'] = $info['meta_field_id'] = 'term_id';
$info['field_index'] = $info['meta_field_index'] = $info['meta_field_value'] = 'name';
$info['field_slug'] = 'slug';
$info['field_type'] = 'taxonomy';
$info['field_parent'] = 'parent';
$info['field_parent_select'] = '`tt`.`' . $info['field_parent'] . '`';
if ('nav_menu' == $object_type) {
$object = 'nav_menu';
} elseif ('post_format' == $object_type) {
$object = 'post_format';
}
if (empty($name)) {
$prefix = 'taxonomy-';
// Make sure we actually have the prefix before trying anything with the name
if (0 === strpos($object_type, $prefix)) {
$name = substr($object_type, strlen($prefix), strlen($object_type));
}
}
if (!in_array($object_type, array('nav_menu', 'post_format'))) {
$object_type = 'taxonomy';
}
$taxonomy = pods_sanitize(empty($object) ? $name : $object);
$info['pod_table'] = $wpdb->prefix . 'pods_' . pods_clean_name($taxonomy, true, false);
$taxonomy_object = get_taxonomy($taxonomy);
if (is_object($taxonomy_object) && $taxonomy_object->hierarchical) {
示例15: wpml_element_has_translations
/**
* Find out whether a post type or a taxonomy term is translated
*
* @since 2.0
*
* @param mixed $null
* @param int $id post_id or term_id
* @param string $type post type or taxonomy
* @return bool
*/
public function wpml_element_has_translations($null, $id, $type)
{
$pll_type = 'post' == $type || pll_is_translated_post_type($type) ? 'post' : ('term' == $type || pll_is_translated_taxonomy($type) ? 'term' : false);
return $pll_type && ($translations = call_user_func("pll_get_{$pll_type}_translations", $id)) ? count($translations) > 1 : false;
}