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


PHP icl_object_id函数代码示例

本文整理汇总了PHP中icl_object_id函数的典型用法代码示例。如果您正苦于以下问题:PHP icl_object_id函数的具体用法?PHP icl_object_id怎么用?PHP icl_object_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: yit_wpml_get_translated_id

 /**
  * Get the id of the current translation of the post/custom type
  *
  * @since  2.0.0
  * @author Andrea Frascaspata <andrea.frascaspata@yithemes.com>
  */
 function yit_wpml_get_translated_id($id, $post_type)
 {
     if (function_exists('icl_object_id')) {
         $id = icl_object_id($id, $post_type, true);
     }
     return $id;
 }
开发者ID:NgocSon2412,项目名称:website_banhang,代码行数:13,代码来源:init.php

示例2: merge_comment_count

function merge_comment_count($count, $post_ID)
{
    // get all the languages for which this post exists
    $languages = icl_get_languages('skip_missing=1');
    $post = get_post($post_ID);
    $type = $post->post_type;
    foreach ($languages as $l) {
        // in $count is already the count from the current language
        if (!$l['active']) {
            $otherID = icl_object_id($post_ID, $type, false, $l['language_code']);
            if ($otherID) {
                // cannot use call_user_func due to php regressions
                if ($type == 'page') {
                    $otherpost = get_page($otherID);
                } else {
                    $otherpost = get_post($otherID);
                }
                if ($otherpost) {
                    // increment comment count using translation post comment count.
                    $count = $count + $otherpost->comment_count;
                }
            }
        }
    }
    return $count;
}
开发者ID:svenauhagen,项目名称:wpml-comments-merging,代码行数:26,代码来源:wpml-comments-merging.php

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

示例4: ebor_client_shortcode

/**
 * The Shortcode
 */
function ebor_client_shortcode($atts)
{
    extract(shortcode_atts(array('pppage' => '8', 'filter' => 'all'), $atts));
    /**
     * Setup post query
     */
    $query_args = array('post_type' => 'client', 'posts_per_page' => $pppage);
    if (!($filter == 'all')) {
        if (function_exists('icl_object_id')) {
            $filter = (int) icl_object_id($filter, 'client_category', true);
        }
        $query_args['tax_query'] = array(array('taxonomy' => 'client_category', 'field' => 'id', 'terms' => $filter));
    }
    global $wp_query, $post;
    $old_query = $wp_query;
    $old_post = $post;
    $wp_query = new WP_Query($query_args);
    ob_start();
    get_template_part('loop/loop', 'client-carousel');
    $output = ob_get_contents();
    ob_end_clean();
    wp_reset_postdata();
    $wp_query = $old_query;
    $post = $old_post;
    return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:29,代码来源:vc_client_block.php

示例5: ebor_portfolio_shortcode

/**
 * The Shortcode
 */
function ebor_portfolio_shortcode($atts)
{
    extract(shortcode_atts(array('type' => 'grid', 'pppage' => '999', 'filter' => 'all', 'filters' => 'yes'), $atts));
    /**
     * Initial query args
     */
    $query_args = array('post_type' => 'portfolio', 'posts_per_page' => $pppage);
    if (!($filter == 'all')) {
        if (function_exists('icl_object_id')) {
            $filter = (int) icl_object_id($filter, 'portfolio_category', true);
        }
        $query_args['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'id', 'terms' => $filter));
    }
    if ($filter == 'all') {
        $cats = get_categories('taxonomy=portfolio_category');
    } else {
        $cats = get_categories('taxonomy=portfolio_category&exclude=' . $filter . '&child_of=' . $filter);
    }
    global $wp_query, $post;
    $old_post = $post;
    $wp_query = new WP_Query($query_args);
    ob_start();
    get_template_part('loop/loop-portfolio', $type);
    $output = ob_get_contents();
    ob_end_clean();
    wp_reset_postdata();
    $post = $old_post;
    return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:32,代码来源:vc_portfolio_block.php

示例6: wpex_parse_obj_id

/**
 * Returns correct ID for any object
 * Used to fix issues with translation plugins such as WPML
 *
 * @since 3.1.1
 */
function wpex_parse_obj_id($id, $type = 'page')
{
    if ($id && function_exists('icl_object_id')) {
        $id = icl_object_id($id, $type);
    }
    return $id;
}
开发者ID:VanessaGarcia-Freelance,项目名称:TheEmporiumGroup,代码行数:13,代码来源:core.php

示例7: ebor_testimonial_shortcode

/**
 * The Shortcode
 */
function ebor_testimonial_shortcode($atts)
{
    extract(shortcode_atts(array('pppage' => '999', 'filter' => 'all', 'type' => 'carousel-3col'), $atts));
    /**
     * Initial query args
     */
    $query_args = array('post_type' => 'testimonial', 'posts_per_page' => $pppage);
    if (!($filter == 'all')) {
        if (function_exists('icl_object_id')) {
            $filter = (int) icl_object_id($filter, 'testimonial_category', true);
        }
        $query_args['tax_query'] = array(array('taxonomy' => 'testimonial_category', 'field' => 'id', 'terms' => $filter));
    }
    /**
     * Finally, here's the query.
     */
    global $wp_query;
    $wp_query = new WP_Query($query_args);
    ob_start();
    get_template_part('loop/loop-testimonial', $type);
    wp_reset_postdata();
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:28,代码来源:vc_testimonial_block.php

示例8: filter_woocommerce_ajax_params

 function filter_woocommerce_ajax_params($woocommerce_params)
 {
     global $sitepress, $post;
     $value = array();
     $value = $woocommerce_params;
     if ($sitepress->get_current_language() !== $sitepress->get_default_language()) {
         $value['ajax_url'] = add_query_arg('lang', ICL_LANGUAGE_CODE, $woocommerce_params['ajax_url']);
         $value['checkout_url'] = add_query_arg('action', 'woocommerce-checkout', $value['ajax_url']);
     }
     if (!isset($post->ID)) {
         return $value;
     }
     $checkout_page_id = get_option('woocommerce_checkout_page_id');
     $pay_page_id = get_option('woocommerce_pay_page_id');
     $cart_page_id = get_option('woocommerce_cart_page_id');
     $translated_checkout_page_id = icl_object_id($checkout_page_id, 'page', false);
     $translated_pay_page_id = icl_object_id($pay_page_id, 'page', false);
     $translated_cart_page_id = icl_object_id($cart_page_id, 'page', false);
     if ($translated_cart_page_id == $post->ID) {
         $value['is_cart'] = 1;
         $value['cart_url'] = get_permalink($translated_cart_page_id);
     } else {
         if ($translated_checkout_page_id == $post->ID || $checkout_page_id == $post->ID) {
             $value['is_checkout'] = 1;
             $_SESSION['wpml_globalcart_language'] = $sitepress->get_current_language();
         } else {
             if ($translated_pay_page_id == $post->ID) {
                 $value['is_pay_page'] = 1;
             }
         }
     }
     return $value;
 }
开发者ID:sergioblanco86,项目名称:git-gitlab.com-kinivo-kinivo.com,代码行数:33,代码来源:ajax-setup.class.php

示例9: custom_get_wpml_language_link

 /**
  * Function: custom_get_wpml_language_link - custom code for getting wpml language toggle link
  * Author: JF
  * Date: May 29, 2014
  */
 function custom_get_wpml_language_link()
 {
     global $post, $current_child_site, $wp_query, $home_url;
     $wpml_post_name = '';
     //get current inactive language code
     $get_inactive_language = custom_get_inactive_language();
     // get the post ID in en
     $wpml_post_id = icl_object_id($post->ID, $post->post_type, true, $get_inactive_language['language_code']);
     // get the post object
     $wpml_post_obj = get_post($wpml_post_id);
     // get the name
     $wpml_post_name = $wpml_post_obj->post_name;
     if (is_archive()) {
         $wpml_post_name = $wp_query->query['post_type'];
     }
     if (is_singular('cpt')) {
         $wpml_post_name = 'cpt/' . $wpml_post_name;
     }
     if (is_front_page()) {
         $wpml_post_name = '';
     }
     if (is_home()) {
         //check home blog listing
         //$wpml_post_name = 'blog';
     }
     if (is_page()) {
         $translated_url = get_permalink($wpml_post_id);
         return '<a href="' . $translated_url . '">' . $get_inactive_language['native_name'] . '</a>';
     } else {
         //output language switch link
         return '<a href="' . $home_url . '/' . $get_inactive_language['language_code'] . '/' . $wpml_post_name . '/">' . $get_inactive_language['native_name'] . '</a>';
     }
 }
开发者ID:lin6224,项目名称:MJ,代码行数:38,代码来源:function_wpml_custom_language_switcher.php

示例10: content

 public function content($atts, $content = null)
 {
     $el_class = $width = $el_position = '';
     extract(shortcode_atts(array('el_class' => '', 'el_position' => '', 'width' => '1/2'), $atts));
     $output = $items_nav = $items = '';
     // get all the categories from the database
     $cat_args = array('taxonomy' => 'faqs-category');
     $cats = get_categories($cat_args);
     // FAQ NAVIGATION
     $items_nav .= '<h3>' . __("Browse F.A.Q. Topics", "swiftframework") . '</h3>';
     $items_nav .= '<ul class="faqs-nav clearfix">';
     foreach ($cats as $cat) {
         if (function_exists('icl_object_id')) {
             if ($cat->term_id != icl_object_id($cat->term_id, 'faqs-category', false, ICL_LANGUAGE_CODE)) {
                 return;
             }
         }
         $items_nav .= '<li><a href="#' . $cat->slug . '"><i class="icon-list"></i>' . $cat->name . '<span class="count">' . $cat->count . '</span></a></li>';
     }
     $items_nav .= '</ul>';
     // FAQ LISTINGS
     foreach ($cats as $cat) {
         // setup the category ID
         $cat_id = $cat->term_id;
         if (function_exists('icl_object_id')) {
             if ($cat_id != icl_object_id($cat_id, 'faqs-category', false, ICL_LANGUAGE_CODE)) {
                 return;
             }
         }
         // Make a header for the cateogry
         $items .= '<h3 class="faq-section-title" id="' . $cat->slug . '">' . $cat->name . '</h3>';
         $faqs_args = array('post_type' => 'faqs', 'post_status' => 'publish', 'faqs-category' => $cat->slug, 'posts_per_page' => 100);
         $faqs = new WP_Query($faqs_args);
         $items .= '<ul class="faqs-section clearfix">';
         // PORTFOLIO LOOP
         while ($faqs->have_posts()) {
             $faqs->the_post();
             $faq_title = get_the_title();
             $faq_text = get_the_content_with_formatting();
             $items .= '<li class="faq-item">';
             $items .= '<h6>' . $faq_title . '</h6>';
             $items .= '<div class="faq-text">' . do_shortcode($faq_text) . '</div>';
             $items .= '</li>';
         }
         $items .= '<div class="wpb_divider go_to_top_icon1 wpb_content_element "><a class="animate-top" href="#"><i class="icon-arrow-up"></i></a></div>';
         $items .= '</ul>';
         wp_reset_postdata();
     }
     $el_class = $this->getExtraClass($el_class);
     $width = wpb_translateColumnWidthToSpan($width);
     $output .= "\n\t" . '<div class="wpb_content_element ' . $width . $el_class . '">';
     $output .= "\n\t\t" . '<div class="wpb_wrapper faqs-wrap">';
     $output .= "\n\t\t\t" . $items_nav;
     $output .= "\n\t\t\t" . $items;
     $output .= "\n\t\t" . '</div> ' . $this->endBlockComment('.wpb_wrapper');
     $output .= "\n\t" . '</div> ' . $this->endBlockComment($width);
     //
     $output = $this->startRow($el_position) . $output . $this->endRow($el_position);
     return $output;
 }
开发者ID:nilmadhab,项目名称:webtutplus,代码行数:60,代码来源:faqs.php

示例11: ebor_blog_shortcode

/**
 * The Shortcode
 */
function ebor_blog_shortcode($atts)
{
    extract(shortcode_atts(array('type' => 'grid-3col', 'pppage' => '8', 'filter' => 'all'), $atts));
    // Fix for pagination
    if (is_front_page()) {
        $paged = get_query_var('page') ? get_query_var('page') : 1;
    } else {
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    }
    /**
     * Setup post query
     */
    $query_args = array('post_type' => 'post', 'posts_per_page' => $pppage, 'paged' => $paged);
    if (!($filter == 'all')) {
        if (function_exists('icl_object_id')) {
            $filter = (int) icl_object_id($filter, 'category', true);
        }
        $query_args['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $filter));
    }
    global $wp_query;
    $wp_query = new WP_Query($query_args);
    ob_start();
    get_template_part('loop/loop-post', $type);
    wp_reset_postdata();
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
开发者ID:tommusrhodus,项目名称:Ebor-Framework,代码行数:31,代码来源:vc_blog_block.php

示例12: TS_VCSC_Element_Widget_GetMeta

 function TS_VCSC_Element_Widget_GetMeta($id, $key)
 {
     if (function_exists('icl_object_id')) {
         $id = icl_object_id($id, 'post', true, ICL_LANGUAGE_CODE);
     }
     return get_post_meta($id, $key, true);
 }
开发者ID:Telemedellin,项目名称:fonvalmed,代码行数:7,代码来源:ts_vcsc_widgets_elements.php

示例13: woocommerce_order_get_items

 function woocommerce_order_get_items($items)
 {
     if (isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order') {
         global $sitepress_settings;
         foreach ($items as $index => $item) {
             foreach ($item as $key => $item_data) {
                 if ($key == 'product_id') {
                     $tr_product_id = icl_object_id($item_data, 'product', false, $sitepress_settings['admin_default_language']);
                     if (!is_null($tr_product_id)) {
                         $items[$index][$key] = $tr_product_id;
                         $items[$index]['name'] = get_the_title($tr_product_id);
                     }
                 }
                 if ($key == 'variation_id') {
                     $tr_variation_id = icl_object_id($item_data, 'product_variation', false, $sitepress_settings['admin_default_language']);
                     if (!is_null($tr_variation_id)) {
                         $items[$index][$key] = $tr_variation_id;
                     }
                 }
                 if (substr($key, 0, 3) == 'pa_') {
                     global $wpdb;
                     //attr is taxonomy
                     $default_term = get_term_by('slug', $item_data, $key);
                     $tr_id = icl_object_id($default_term->term_id, $key, false, $sitepress_settings['admin_default_language']);
                     if (!is_null($tr_id)) {
                         $translated_slug = $wpdb->get_var($wpdb->prepare("\n                                    SELECT t.slug FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $key));
                         $items[$index][$key] = $translated_slug;
                     }
                 }
             }
         }
     }
     return $items;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:34,代码来源:orders.class.php

示例14: 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;
}
开发者ID:umbezt,项目名称:Soka-Education-Student-Research-Project,代码行数:33,代码来源:common.php

示例15: sync_variation_swatches_and_photos

 function sync_variation_swatches_and_photos($original_product_id, $trnsl_product_id, $data = false)
 {
     global $sitepress, $wpdb;
     $atts = maybe_unserialize(get_post_meta($original_product_id, '_swatch_type_options', true));
     $lang = $sitepress->get_language_for_element($trnsl_product_id, 'post_product');
     $tr_atts = $atts;
     foreach ($atts as $att_name => $att_opts) {
         foreach ($att_opts['attributes'] as $slug => $options) {
             $o_term = get_term_by('slug', $slug, $att_name);
             $tr_term_id = icl_object_id($o_term->term_id, $att_name, false, $lang);
             if (!is_null($tr_term_id)) {
                 $tr_term = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_term_id, $att_name));
                 $tr_slug = $tr_term->slug;
                 if ($tr_slug != '') {
                     $tr_atts[$att_name]['attributes'][$tr_term->slug] = $atts[$att_name]['attributes'][$slug];
                     if (isset($options['image'])) {
                         $o_img_id = $options['image'];
                         $tr_img_id = icl_object_id($o_img_id, 'image', false, $lang);
                     }
                     unset($tr_atts[$att_name]['attributes'][$slug]);
                 }
             }
         }
     }
     update_post_meta($trnsl_product_id, '_swatch_type_options', $tr_atts);
     // Meta gets overwritten
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:27,代码来源:wc_variation_swatches_photos.class.php


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