• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pll_get_post_language函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getPostLanguage

 /**
  * @param int $postId the post id
  * @return string language of the post or false if not found
  */
 public static function getPostLanguage($postId)
 {
     if (function_exists('pll_get_post_language')) {
         return pll_get_post_language($postId);
     }
     return false;
 }
开发者ID:jackblackCH,项目名称:polylang-supertext,代码行数:11,代码来源:Multilang.php


示例2: syncProductsMeta

 /**
  * Sync porduct meta
  *
  * @return false if the current post type is not "porduct"
  */
 public function syncProductsMeta()
 {
     $currentScreen = get_current_screen();
     if ($currentScreen->post_type !== 'product') {
         return false;
     }
     // sync product meta with polylang
     add_filter('pll_copy_post_metas', array(__CLASS__, 'getProductMetaToCopy'));
     $ID = false;
     $disable = false;
     /*
      * Disable editing product meta for translation
      *
      * if the "post" is defined in $_GET then we should check if the current
      * porduct has a translation and it is the same as the default translation
      * lang defined in polylang then porduct meta editing must by enabled
      *
      * if the "new_lang" is defined or if the current page is the "edit"
      * page then porduct meta editing must by disabled
      */
     if (isset($_GET['post'])) {
         $ID = absint($_GET['post']);
         $disable = $ID && pll_get_post_language($ID) != pll_default_language();
     } elseif (isset($_GET['new_lang']) || $currentScreen->base == 'edit') {
         $disable = isset($_GET['new_lang']) && esc_attr($_GET['new_lang']) != pll_default_language() ? true : false;
         $ID = isset($_GET['from_post']) ? absint($_GET['from_post']) : false;
     }
     // disable fields edit for translation
     if ($disable) {
         add_action('admin_print_scripts', array($this, 'addFieldsLocker'), 100);
     }
     /* sync selected prodcut type */
     $this->syncSelectedProdcutType($ID);
 }
开发者ID:qRoC,项目名称:woo-poly-integration,代码行数:39,代码来源:Meta.php


示例3: getProductAttributesInLanguage

 /**
  * Get product attributes in right language
  *
  * @param array $args array of arguments for get_terms function in WooCommerce attributes html markup
  *
  * @return array
  */
 public function getProductAttributesInLanguage($args)
 {
     $lang = '';
     global $post;
     if (isset($_GET['new_lang'])) {
         $lang = esc_attr($_GET['new_lang']);
     } elseif (!empty($post)) {
         $lang = pll_get_post_language($post->ID);
     } else {
         $lang = PLL()->pref_lang;
     }
     $args['lang'] = $lang;
     return $args;
 }
开发者ID:decarvalhoaa,项目名称:woopoly,代码行数:21,代码来源:Product.php


示例4: display_payment_language

    public function display_payment_language($payment_id)
    {
        ?>
		<div class="column-container">
			<div class="column">
				<strong><?php 
        _e('Language:', 'edd-polylang');
        ?>
</strong>&nbsp;
				<input type="text" name="edd-payment-language" value="<?php 
        echo esc_attr(pll_get_post_language($payment_id, 'name'));
        ?>
" class="medium-text"/>
			</div>
		</div>
<?php 
    }
开发者ID:Netzberufler,项目名称:edd-polylang,代码行数:17,代码来源:class-edd-polylang.php


示例5: change

 /**
  * Change the product stock in the given order item.
  *
  * @param array  $item   the order data
  * @param string $action STOCK_REDUCE_ACTION | STOCK_INCREASE_ACTION
  */
 protected function change(array $item, $action = self::STOCK_REDUCE_ACTION)
 {
     $productID = $item['product_id'];
     $productObject = wc_get_product($productID);
     $productLang = pll_get_post_language($productID);
     $variationID = $item['variation_id'];
     /* Handle Products */
     if ($productObject && $productLang) {
         /* Get the translations IDS */
         $translations = Utilities::getProductTranslationsArrayByObject($productObject);
         /* Remove the current product from translation array */
         unset($translations[$productLang]);
         $isManageStock = $productObject->managing_stock();
         $isVariation = $variationID && $variationID > 0;
         $method = $action === self::STOCK_REDUCE_ACTION ? 'reduce_stock' : 'increase_stock';
         $change = $action === self::STOCK_REDUCE_ACTION ? $item['qty'] : $item['change'];
         /* Sync stock for all translation */
         foreach ($translations as $ID) {
             /* Only if product is managing stock */
             if ($isManageStock) {
                 if ($translation = wc_get_product($ID)) {
                     $translation->{$method}($change);
                 }
             }
             $general = Settings::getOption('general', MetasList::getID(), array('total_sales'));
             if (in_array('total_sales', $general)) {
                 update_post_meta($ID, 'total_sales', get_post_meta($productID, 'total_sales', true));
             }
         }
         /* Handle variation */
         if ($isVariation) {
             $posts = Variation::getRelatedVariation($variationID);
             foreach ($posts as $post) {
                 if ($post->ID == $variationID) {
                     continue;
                 }
                 $variation = wc_get_product($post);
                 if ($variation && $variation->managing_stock()) {
                     $variation->{$method}($change);
                 }
             }
         }
     }
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:50,代码来源:Stock.php


示例6: syncProductsMeta

 /**
  * Sync product meta.
  *
  * @return false if the current post type is not "product"
  */
 public function syncProductsMeta()
 {
     // sync product meta with polylang
     add_filter('pll_copy_post_metas', array(__CLASS__, 'getProductMetaToCopy'));
     // Shipping Class translation is not supported after WooCommerce 2.6 but it is
     // still implemented by WooCommerce as a taxonomy. Therefore Polylang will not
     // copy the Shipping Class meta. We need to take care of it.
     if (Utilities::woocommerceVersionCheck('2.6')) {
         add_action('wp_insert_post', array($this, 'syncShippingClass'), 10, 3);
     }
     $currentScreen = get_current_screen();
     if ($currentScreen->post_type !== 'product') {
         return false;
     }
     $ID = false;
     $disable = false;
     /*
      * Disable editing product meta for translation
      *
      * if the "post" is defined in $_GET then we should check if the current
      * product has a translation and it is the same as the default translation
      * lang defined in polylang then product meta editing must by enabled
      *
      * if the "new_lang" is defined or if the current page is the "edit"
      * page then product meta editing must by disabled
      */
     if (isset($_GET['post'])) {
         $ID = absint($_GET['post']);
         $disable = $ID && pll_get_post_language($ID) != pll_default_language();
     } elseif (isset($_GET['new_lang']) || $currentScreen->base == 'edit') {
         $disable = isset($_GET['new_lang']) && esc_attr($_GET['new_lang']) != pll_default_language() ? true : false;
         $ID = isset($_GET['from_post']) ? absint($_GET['from_post']) : false;
         // Add the '_translation_porduct_type' meta, for the case where
         // the product was created before plugin acivation.
         $this->addProductTypeMeta($ID);
     }
     // disable fields edit for translation
     if ($disable) {
         add_action('admin_print_scripts', array($this, 'addFieldsLocker'), 100);
     }
     /* sync selected product type */
     $this->syncSelectedproductType($ID);
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:48,代码来源:Meta.php


示例7: polylang_slug_unique_slug_in_language

/**
 * Checks if the slug is unique within language.
 *
 * @since 0.1.0
 *
 * @global  wpdb  $wpdb        WordPress database abstraction object.
 *
 * @param  string $slug        The desired slug (post_name).
 * @param  int    $post_ID     Post ID.
 * @param  string $post_status No uniqueness checks are made if the post is still draft or pending.
 * @param  string $post_type   Post type.
 * @param  int    $post_parent Post parent ID.
 *
 * @return string              Unique slug for the post within language, based on $post_name (with a -1, -2, etc. suffix).
 */
function polylang_slug_unique_slug_in_language($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug)
{
    // Return slug if it was not changed.
    if ($original_slug === $slug) {
        return $slug;
    }
    global $wpdb;
    // Get language of a post
    $lang = pll_get_post_language($post_ID);
    $options = get_option('polylang');
    // return the slug if Polylang does not return post language or has incompatable redirect setting or is not translated post type.
    if (empty($lang) || 0 === $options['force_lang'] || !pll_is_translated_post_type($post_type)) {
        return $slug;
    }
    // " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = ID".
    $join_clause = polylang_slug_model_post_join_clause();
    // " AND pll_tr.term_taxonomy_id IN (" . implode(',', $languages) . ")".
    $where_clause = polylang_slug_model_post_where_clause($lang);
    // Polylang does not translate attachements - skip if it is one.
    // @TODO Recheck this with the Polylang settings
    if ('attachment' == $post_type) {
        // Attachment slugs must be unique across all types.
        $check_sql = "SELECT post_name FROM {$wpdb->posts} {$join_clause} WHERE post_name = %s AND ID != %d {$where_clause} LIMIT 1";
        $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $original_slug, $post_ID));
    } elseif (is_post_type_hierarchical($post_type)) {
        // Page slugs must be unique within their own trees. Pages are in a separate
        // namespace than posts so page slugs are allowed to overlap post slugs.
        $check_sql = "SELECT ID FROM {$wpdb->posts} {$join_clause} WHERE post_name = %s AND post_type IN ( %s, 'attachment' ) AND ID != %d AND post_parent = %d {$where_clause} LIMIT 1";
        $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $original_slug, $post_type, $post_ID, $post_parent));
    } else {
        // Post slugs must be unique across all posts.
        $check_sql = "SELECT post_name FROM {$wpdb->posts} {$join_clause} WHERE post_name = %s AND post_type = %s AND ID != %d {$where_clause} LIMIT 1";
        $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $original_slug, $post_type, $post_ID));
    }
    if (!$post_name_check) {
        return $original_slug;
    } else {
        return $slug;
    }
}
开发者ID:rasmusbe,项目名称:polylang-slug,代码行数:55,代码来源:polylang-slug.php


示例8: syncProductsMeta

 /**
  * Sync porduct meta
  *
  * @return false if the current post type is not "product"
  */
 public function syncProductsMeta()
 {
     // sync product meta with polylang
     add_filter('pll_copy_post_metas', array(__CLASS__, 'getProductMetaToCopy'));
     $currentScreen = get_current_screen();
     if ($currentScreen->post_type !== 'product') {
         return false;
     }
     $ID = false;
     $disable = false;
     /*
      * Disable editing product meta for product translations
      *
      * In case of a "Add or update product" ($GET['post'] is set), and the
      * product language is different from the default, it is a product translation
      * and editing the product metadata should be disabled.
      *
      * In case of a "Add product translation" ($GET['new_lang'] is set), or the
      * 'edit' page, editing product metadata should be disabled.
      */
     if (isset($_GET['post'])) {
         // Add or update product
         $ID = absint($_GET['post']);
         $disable = $ID && pll_get_post_language($ID) != pll_default_language();
     } elseif (isset($_GET['new_lang']) || $currentScreen->base == 'edit') {
         // Add product translation
         $ID = isset($_GET['from_post']) ? absint($_GET['from_post']) : false;
         $disable = isset($_GET['new_lang']) && esc_attr($_GET['new_lang']) != pll_default_language() ? true : false;
         // Add the '_translation_porduct_type' meta,for the case the product
         // was created before plugin acivation.
         $this->add_product_type_meta($ID);
     }
     // disable fields edit for product translations
     if ($disable) {
         add_action('admin_print_scripts', array($this, 'addFieldsLocker'), 100);
     }
     // sync the product type selection in the product data settings box
     $this->sync_product_type_selection($ID);
 }
开发者ID:decarvalhoaa,项目名称:woopoly,代码行数:44,代码来源:Meta.php


示例9: duplicateVariations

 /**
  * Translate Variation for given variable product
  *
  * @param integer  $ID     product variable ID
  * @param \WP_Post $post   Product Post
  * @param boolean  $update true if update , false otherwise
  *
  * @return boolean
  */
 public function duplicateVariations($ID, \WP_Post $post, $update)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return false;
     }
     global $pagenow;
     if (!in_array($pagenow, array('post.php', 'post-new.php'))) {
         return false;
     }
     $product = wc_get_product($ID);
     if (!$product) {
         return false;
     }
     $from = null;
     if (pll_get_post_language($ID) == pll_default_language()) {
         $from = $product;
     } else {
         if (isset($_GET['from_post'])) {
             /*
              * This check will make sure that variation , will be
              * created for brand new products which are not saved yet by user
              */
             $from = Utilities::getProductTranslationByID(esc_attr($_GET['from_post']), pll_default_language());
         } else {
             $from = Utilities::getProductTranslationByObject($product, pll_default_language());
         }
     }
     if (!$from instanceof \WC_Product_Variable) {
         return false;
     }
     $langs = pll_languages_list();
     foreach ($langs as $lang) {
         $variation = new Variation($from, Utilities::getProductTranslationByObject($product, $lang));
         remove_action('save_post', array($this, __FUNCTION__), 10);
         $variation->duplicate();
         add_action('save_post', array($this, __FUNCTION__), 10, 3);
     }
 }
开发者ID:Frost-Bite,项目名称:woo-poly-integration,代码行数:47,代码来源:Variable.php


示例10: jetpack_widget_get_top_posts

 public function jetpack_widget_get_top_posts($posts, $post_ids, $count)
 {
     foreach ($posts as $k => $post) {
         if (pll_current_language() !== pll_get_post_language($post['post_id'])) {
             unset($posts[$k]);
         }
     }
     return $posts;
 }
开发者ID:radabass,项目名称:polylang,代码行数:9,代码来源:plugins-compat.php


示例11: jetpack_relatedposts_filter_filters

 /**
  * Jetpack
  * Allows to make sure that related posts are in the correct language
  *
  * @since 1.8
  *
  * @param array  $filters Array of ElasticSearch filters based on the post_id and args.
  * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
  * @return array
  */
 function jetpack_relatedposts_filter_filters($filters, $post_id)
 {
     $slug = sanitize_title(pll_get_post_language($post_id, 'name'));
     $filters[] = array('term' => array('taxonomy.language.slug' => $slug));
     return $filters;
 }
开发者ID:spielhoelle,项目名称:amnesty,代码行数:16,代码来源:plugins-compat.php


示例12: ajax_get_current_status

 public function ajax_get_current_status()
 {
     $lgtm =& $GLOBALS['wp_lingotek']->model;
     $pllm = $GLOBALS['polylang']->model;
     $languages = pll_languages_list(array('fields' => 'locale'));
     $object_ids = $_POST['check_ids'];
     if ($object_ids === null) {
         return;
     }
     $terms = isset($_POST['terms_translations']);
     //The main array consists of
     //ids and nonces. Each id has a source language, languages with statuses, and a workbench link
     $content_metadata = array();
     foreach ($object_ids as $object_id) {
         $id = $object_id;
         $type = $terms ? 'term' : 'post';
         if (isset($_POST['taxonomy'])) {
             $taxonomy = $_POST['taxonomy'];
             if (strpos($_POST['taxonomy'], '&')) {
                 $taxonomy = strstr($_POST['taxonomy'], '&', true);
             }
         } else {
             $taxonomy = get_post_type($id);
         }
         $content_metadata[$id] = array('existing_trans' => false, 'source' => false, 'doc_id' => null, 'source_id' => null, 'source_status' => null);
         $document = $lgtm->get_group($type, $object_id);
         if ($document && !isset($document->source) && count($document->desc_array) >= 3) {
             $content_metadata[$id]['existing_trans'] = true;
         }
         if ($document && isset($document->source) && isset($document->document_id) && isset($document->status) && isset($document->translations)) {
             if ($document->source !== (int) $object_id) {
                 $document = $lgtm->get_group($type, $document->source);
             }
             $source_id = $document->source !== null ? $document->source : $object_id;
             $source_language = $terms ? pll_get_term_language($document->source, 'locale') : pll_get_post_language($document->source, 'locale');
             $existing_translations = $pllm->get_translations($type, $source_id);
             if (count($existing_translations) > 1) {
                 $content_metadata[$id]['existing_trans'] = true;
             }
             $content_metadata[$id]['source'] = $source_language;
             $content_metadata[$id]['doc_id'] = $document->document_id;
             $content_metadata[$id]['source_id'] = $document->source;
             $content_metadata[$id]['source_status'] = $document->status;
             $target_status = $document->status == 'edited' || $document->status == null ? 'edited' : 'current';
             $content_metadata[$id][$source_language]['status'] = $document->source == $object_id ? $document->status : $target_status;
             if (is_array($document->translations)) {
                 foreach ($document->translations as $locale => $translation_status) {
                     $content_metadata[$id][$locale]['status'] = $translation_status;
                     $workbench_link = Lingotek_Actions::workbench_link($document->document_id, $locale);
                     $content_metadata[$id][$locale]['workbench_link'] = $workbench_link;
                 }
             }
             //fills in missing languages, makes life easier for the updater
             foreach ($languages as $language) {
                 foreach ($content_metadata as $group => $status) {
                     $language_obj = $pllm->get_language($source_language);
                     $target_lang_obj = $pllm->get_language($language);
                     $profile = Lingotek_Model::get_profile($taxonomy, $language_obj, $group);
                     if ($profile['profile'] != 'disabled' && $status['source'] != false) {
                         if (!isset($status[$language])) {
                             $content_metadata[$group][$language]['status'] = "none";
                             if ($document->is_disabled_target($pllm->get_language($source_language), $pllm->get_language($language)) || isset($document->desc_array[$target_lang_obj->slug]) && !isset($document->source)) {
                                 $content_metadata[$group][$language]['status'] = 'disabled';
                             }
                         }
                     }
                 }
             }
         }
         $language = $type == 'post' ? pll_get_post_language($id) : pll_get_term_language($id);
         $language = $pllm->get_language($language);
         if ($language) {
             $profile = Lingotek_Model::get_profile($taxonomy, $language, $id);
             if ($profile['profile'] == 'disabled' && $content_metadata[$id]['source'] == false) {
                 $content_metadata[$id]['source'] = 'disabled';
             }
         }
     }
     //get the nonces associated with the different actions
     $content_metadata['request_nonce'] = $this->lingotek_get_matching_nonce('lingotek-request');
     $content_metadata['download_nonce'] = $this->lingotek_get_matching_nonce('lingotek-download');
     $content_metadata['upload_nonce'] = $this->lingotek_get_matching_nonce('lingotek-upload');
     $content_metadata['status_nonce'] = $this->lingotek_get_matching_nonce('lingotek-status');
     wp_send_json($content_metadata);
 }
开发者ID:Gordondalos,项目名称:expert,代码行数:85,代码来源:admin.php


示例13: getOrderLangauge

 /**
  * Get the order language
  *
  * @param integer $ID order ID
  *
  * @return string|false language in success , false otherwise
  */
 public static function getOrderLangauge($ID)
 {
     return pll_get_post_language($ID);
 }
开发者ID:decarvalhoaa,项目名称:woopoly,代码行数:11,代码来源:Order.php


示例14: edit_form_top

 public function edit_form_top()
 {
     global $post_ID;
     printf('<input type="hidden" id="post_lang_choice" name="post_lang_choice" value="%s" />', pll_get_post_language($post_ID));
     wp_nonce_field('pll_language', '_pll_nonce');
 }
开发者ID:Gordondalos,项目名称:expert,代码行数:6,代码来源:filters-post.php


示例15: listing_images_default

 /**
  *	listing_images_default()
  *	
  *	Callback function to set the default
  *	gallery with translated images if
  *	these are available.
  *	
  *	@access	public
  *	@param	array	$field_args
  *	@param	object	$field
  *	@uses	pll_get_post_language()
  *	@uses	pll_default_language()
  *	@uses	pll_get_post()
  *	@uses	get_post_meta()
  *	@return	array
  *	
  *	@since 1.0.0
  */
 public function listing_images_default($field_args, $field)
 {
     // Get post language
     $post_lang = pll_get_post_language($field->object_id);
     // Get from post early
     $from_post = isset($_REQUEST['from_post']) ? $_REQUEST['from_post'] : false;
     // If from_post is not available anymore, use current post ID
     if (!$from_post) {
         $from_post = $field->object_id;
     }
     // Get post ID of default language
     $origial = pll_get_post($from_post, pll_default_language());
     // Get original gallery
     $gallery = get_post_meta($origial, '_gallery', true);
     if (empty($gallery)) {
         return;
     }
     // Set up translated gallery
     $gallery_lang = array();
     foreach ($gallery as $id => $url) {
         // Get ID of image translation
         $id_lang = pll_get_post($id, $post_lang);
         if ($id_lang) {
             // When available, set new ID
             $gallery_lang[$id_lang] = $url;
         }
     }
     // If there are image translations, set new gallery default
     if (!empty($gallery_lang)) {
         return $gallery_lang;
     }
 }
开发者ID:wpsight,项目名称:wpcasa-polylang,代码行数:50,代码来源:class-wpsight-polylang-admin.php


示例16: skip_default_attributes_meta

 public function skip_default_attributes_meta($check, $object_id, $meta_key, $meta_value)
 {
     // Ignore if not default attribute
     if ('_default_attributes' === $meta_key) {
         $product = wc_get_product($object_id);
         // Don't let anyone delete the meta. NO ONE!
         if ($product && current_filter() === 'delete_post_metadata') {
             return false;
         }
         // _default_attributes meta should be unique
         if ($product && current_filter() === 'add_post_metadata') {
             $old_value = get_post_meta($product->id, '_default_attributes');
             return empty($old_value) ? $check : false;
         }
         // Maybe is Variable Product
         // New translations of Variable Products are first created as simple
         if ($product && Utilities::maybe_variable_product($product)) {
             // Try Polylang first
             $lang = pll_get_post_language($product->id);
             if (!$lang) {
                 // Must be a new translation and Polylang doesn't stored the language yet
                 $lang = isset($_GET['new_lang']) ? $_GET['new_lang'] : '';
             }
             foreach ($meta_value as $key => $value) {
                 $term = get_term_by('slug', $value, $key);
                 if ($term && pll_is_translated_taxonomy($term->taxonomy)) {
                     $translated_term_id = pll_get_term($term->term_id, $lang);
                     $translated_term = get_term_by('id', $translated_term_id, $term->taxonomy);
                     // If meta is taxonomy managed by Polylang and is in the
                     // correct language process, otherwise return false to
                     // stop execution
                     return $value === $translated_term->slug ? $check : false;
                 }
             }
         }
     }
     return $check;
 }
开发者ID:decarvalhoaa,项目名称:woopoly,代码行数:38,代码来源:Variable.php


示例17: post_type_link_filter

 /**
  * Fix "get_permalink" for this post type.
  */
 public function post_type_link_filter($post_link, $post, $leavename, $sample)
 {
     // Check if the post type is handle.
     if (isset($this->post_types[$post->post_type])) {
         // We always check for the post language.
         $lang = pll_get_post_language($post->ID, 'slug');
         if (!$lang) {
             // If post has no language assigned, use default language as fallback.
             $lang = pll_default_language();
         }
         // Build URL. Lang prefix is already handle.
         return home_url('/' . $this->post_types[$post->post_type]->translated_slugs[$lang]->rewrite['slug'] . '/' . ($leavename ? "%{$post->post_type}%" : get_page_uri($post->ID)));
     }
     return $post_link;
 }
开发者ID:chesio,项目名称:wp-polylang-translate-rewrite-slugs,代码行数:18,代码来源:polylang-translate-rewrite-slugs.php


示例18: 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'])) {
//.........这里部分代码省略.........
开发者ID:pods-framework,项目名称:pods,代码行数:101,代码来源:PodsAPI.php


示例19: dashboard_column_lang

 /**
  *	dashboard_column_lang()
  *	
  *	Display language column
  *	in dashboard.
  *	
  *	@uses	wp_list_pluck()
  *	@uses	pll_the_languages()
  *	@uses	pll_get_post_language()
  *	
  *	@since 1.0.0
  */
 public function dashboard_column_lang($post)
 {
     $languages = wp_list_pluck(pll_the_languages(array('raw' => 1)), 'flag', 'slug');
     $lang = pll_get_post_language($post->ID);
     echo '<div style="text-align:center"><img src="' . $languages[$lang] . '" /></div>';
 }
开发者ID:wpsight,项目名称:wpcasa-polylang,代码行数:18,代码来源:wpcasa-polylang.php


示例20: translateEmailStringToOrderLanguage

 /**
  * Translates Woocommerce email subjects and headings content to the order language.
  *
  * @param string   $string      Subject or heading not translated
  * @param WC_Order $order       Order object
  * @param string   $string_type Type of string to translate <subject | heading>
  * @param string   $email_type  Email template
  *
  * @return string Translated string, returns the original $string on error
  */
 public function translateEmailStringToOrderLanguage($string, $order, $string_type, $email_type)
 {
     if (empty($order)) {
         return $string;
         // Returns the original $string on error (no order to get language from)
     }
     // Get order language
     $order_language = pll_get_post_language($order->id, 'locale');
     if ($order_language == '') {
         $order_language = pll_current_language('locale');
     }
     // Get setting used to register string in the Polylang strings translation table
     $_string = $string;
     // Store original string to return in case of error
     if (false == ($string = $this->getEmailSetting($string_type, $email_type)) && !isset($this->default_settings[$email_type . '_' . $string_type])) {
         return $_string;
         // No setting in Polylang strings translations table nor default string found to translate
     }
     // Switch language
     $this->switchLanguage($order_language);
     if ($string) {
         // Retrieve translation from Polylang Strings Translations table
         $string = pll__($string);
     } else {
         // If no user translation found in Polylang Strings Translations table, use WooCommerce default translation
         $string = __($this->default_settings[$email_type . '_' . $string_type], 'woocommerce');
     }
     $find = array();
     $replace = array();
     $find['order-date'] = '{order_date}';
     $find['order-number'] = '{order_number}';
     $find['site_title'] = '{site_title}';
     $replace['order-date'] = date_i18n(wc_date_format(), strtotime($order->order_date));
     $replace['order-number'] = $order->get_order_number();
     $replace['site_title'] = get_bloginfo('name');
     $string = str_replace($find, $replace, $string);
     return $string;
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:48,代码来源:Emails.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pll_get_term函数代码示例发布时间:2022-05-15
下一篇:
PHP pll_get_post函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap