/**
  * Get all in polylang configured languages
  * @return \PLL_Language[] list of languages
  */
 public static function getLanguages()
 {
     if (function_exists('pll_languages_list')) {
         return pll_languages_list(array('fields' => array()));
     }
     return array();
 }
 /**
  * @inheritDoc
  *
  * @param string $language
  */
 public function __construct($language, $feedUri = null)
 {
     if (!function_exists('pll_languages_list')) {
         throw new Exception\RuntimeException(sprintf('function pll_languages_list not found'));
     }
     if (!empty($language) && !in_array($language, pll_languages_list())) {
         throw new Exception\UnexpectedValueException(sprintf('Language not found'));
     }
     $this->language = $language;
     return parent::__construct($feedUri);
 }
 /**
  * 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);
     }
 }
示例#4
0
 /**
  * Correct My account order query
  *
  * Will correct the query to display orders from all languages
  *
  * @param array $query
  *
  * @return array
  */
 public function correctMyAccountOrderQuery(array $query)
 {
     $query['lang'] = implode(',', pll_languages_list());
     return $query;
 }
示例#5
0
 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);
 }
 /**
  *	agent_description_options()
  *	
  *	Correctly update agent description
  *	for all registered languages to
  *	be available in our listing editor.
  *	
  *	@access	public
  *	@param	array	$agent_options
  *	@param	integer	$user_id
  *	@uses	pll_languages_list()
  *	
  *	@since 1.0.0
  */
 public function agent_description_options($agent_options, $user_id)
 {
     // Set descriptions in all languages
     foreach (pll_languages_list() as $lang) {
         $agent_options['_agent_description_' . $lang] = trim($_POST['description_' . $lang]);
     }
     return $agent_options;
 }
示例#7
0
 /**
  * Sync default attributes between product translations
  *
  * @param int       $post_id    Post ID
  * @param \WP_Post  $post       Post Object
  * @param boolean   $update     true if updating the post, false otherwise
  */
 public function sync_default_attributes($post_id, $post, $update)
 {
     // Don't sync if not in the admin backend nor on autosave
     if (!is_admin() && defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // Don't sync if Default Attribute syncronization is disabled
     $metas = Meta::getProductMetaToCopy();
     if (!in_array('_default_attributes', $metas)) {
         return;
     }
     //  To avoid Polylang overwriting default attribute meta
     add_filter('delete_post_metadata', array($this, 'skip_default_attributes_meta'), 10, 4);
     add_filter('add_post_metadata', array($this, 'skip_default_attributes_meta'), 10, 4);
     add_filter('update_post_metadata', array($this, 'skip_default_attributes_meta'), 10, 4);
     // Don't sync if not a Variable Product
     $product = wc_get_product($post_id);
     if ($product && 'simple' === $product->product_type && Utilities::maybe_variable_product($product)) {
         // Maybe is Variable Product
         // New translations of Variable Products are first created as simple
         // Only need to sync for the new translation from source product
         // The other product translation stay untouched
         $attributes_translation = Utilities::get_default_attributes_translation($_GET['from_post'], $_GET['new_lang']);
         if (!empty($attributes_translation) && isset($attributes_translation[$_GET['new_lang']])) {
             update_post_meta($product->id, '_default_attributes', $attributes_translation[$_GET['new_lang']]);
         }
     } elseif ($product && 'variable' === $product->product_type) {
         // Variable Product
         // For each product translation, get the translated (default) terms/attributes
         $attributes_translation = Utilities::get_default_attributes_translation($product->id);
         $langs = pll_languages_list();
         foreach ($langs as $lang) {
             $translation_id = pll_get_post($product->id, $lang);
             if ($translation_id != $product->id) {
                 update_post_meta($translation_id, '_default_attributes', $attributes_translation[$lang]);
             }
         }
     }
 }
示例#8
0
     add_action('admin_notices', function () {
         echo '<div class="error">
             <p>' . sprintf(__("<strong>Leyka warning!</strong> Polylang plugin doesn't have any languages installed. Leyka may work strangely due to that. Please go to the <a href='%s'>languages settings page</a> and add at least one language.", 'leyka'), site_url('/wp-admin/options-general.php?page=mlang')) . '</p>
         </div>';
     });
     $locale = get_locale();
     if (!$locale) {
         $locale = 'en_US';
     }
     load_textdomain('leyka', LEYKA_PLUGIN_DIR . "lang/leyka-{$locale}.mo");
     do_action('leyka_init_actions');
 } else {
     //            $locale = is_admin() ? pll_default_language('locale') : pll_current_language('locale');
     if (is_admin() && !did_action('leyka_init_actions')) {
         do_action('leyka_init_actions');
         if (count(pll_languages_list()) > 1) {
             // Register user-defined strings:
             foreach (leyka_options()->get_options_names() as $option) {
                 $option_data = leyka_options()->get_info_of($option);
                 if ($option_data['type'] == 'text') {
                     pll_register_string($option_data['title'], $option_data['value'], 'leyka');
                 } elseif ($option_data['type'] == 'textarea' || $option_data['type'] == 'html' || $option_data['type'] == 'rich_html') {
                     pll_register_string($option_data['title'], leyka_options()->opt($option), 'leyka', true);
                 }
             }
         }
     }
     add_action('leyka_default_success_page_created', function ($page_id) {
         //                echo '<pre>' . print_r($page_id, 1) . '</pre>';
         //                die('<pre>' . print_r(pll_default_language(), 1) . '</pre>');
         // ... get localized strings from PL and update success page params
示例#9
0
 /**
  * Get variations default attributes translation.
  *
  * Get the translation of the default attributes of product passed by id, in
  * a given language, if one is passed, otherwise in all available languages.
  *
  * @param int       $product_id     (required) Product id.
  * @param string    $lang           (optional) Language slug.
  *
  * @return array    Indexed array, with language slug as key, of attributes
  *                  pairs [attribute] => attribute slug
  */
 public static function getDefaultAttributesTranslation($product_id, $lang = '')
 {
     $product = wc_get_product($product_id);
     $translated_attributes = array();
     if ($product && 'variable' === $product->product_type) {
         $default_attributes = $product->get_variation_default_attributes();
         $terms = array();
         // Array of terms: if the term is taxonomy each value is a term object, otherwise an array (term slug => term value)
         $langs = array();
         foreach ($default_attributes as $key => $value) {
             $term = get_term_by('name', $value, $key);
             if ($term && pll_is_translated_taxonomy($term->taxonomy)) {
                 $terms[] = $term;
             } else {
                 $terms[] = array($key => $value);
             }
         }
         // For each product translation, get the translated default attributes
         if (empty($lang)) {
             $langs = pll_languages_list();
         } else {
             $langs[] = $lang;
             // get translation for a specific language
         }
         foreach ($langs as $lang) {
             $translated_terms = array();
             foreach ($terms as $term) {
                 if (is_object($term)) {
                     $translated_term_id = pll_get_term($term->term_id, $lang);
                     $translated_term = get_term_by('id', $translated_term_id, $term->taxonomy);
                     $translated_terms[$translated_term->taxonomy] = $translated_term->slug;
                 } else {
                     $translated_terms[key($term)] = $term[key($term)];
                 }
             }
             $translated_attributes[$lang] = $translated_terms;
         }
     }
     return $translated_attributes;
 }
示例#10
0
pll_register_string('URL Suporte', 'suporte', 'timtec');
pll_register_string('URL Cadastro', 'cadastro', 'timtec');
//pll_register_string('URL Contato', 'contato', 'timtec');
//pll_register_string('URL Conselho', 'conselho', 'timtec');
pll_register_string('URL Manuais', 'manuais', 'timtec');
pll_register_string('URL Desenvolva', 'desenvolva-o-software', 'timtec');
pll_register_string('URL Download', 'download', 'timtec');
//pll_register_string('URL Faq', 'faq', 'timtec');
pll_register_string('URL Mural', 'mural', 'timtec');
pll_register_string('URL Conheça', 'conheca-timtec', 'timtec');
pll_register_string('URL MOOCS', 'o-que-sao-moocs', 'timtec');
pll_register_string('URL Explore', 'explore-a-plataforma', 'timtec');
// pll_register_string('URL Conheça a Rede', 'conheca-a-rede-tim-tec', 'timtec');
add_action('generate_rewrite_rules', function ($wp_rewrite) {
    $new_rules = [];
    foreach (pll_languages_list() as $lcode) {
        //    $str_courses = pll_translate_string('cursos', $lcode);
        //    $new_rules["^$lcode/$str_courses/?$"] = "index.php?template=courses";
        //    $str_conselho = pll_translate_string('conselho', $lcode);
        //    $new_rules["^$lcode/$str_conselho/?$"] = "index.php?template=conselho";
        //
        //    $str_software = pll_translate_string('software', $lcode);
        //    $new_rules["^$lcode/$str_software/?$"] = "index.php?template=software";
        //
        //    $str_redes = pll_translate_string('redes', $lcode);
        //    $new_rules["^$lcode/$str_redes/?$"] = "index.php?template=redes";
        //
        $str_noticias = pll_translate_string('noticias', $lcode);
        $new_rules["^{$lcode}/{$str_noticias}/?\$"] = "index.php?post_type=post";
        //
        //    $str_suporte = pll_translate_string('suporte', $lcode);
示例#11
0
function eme_detect_lang() {
   $language="";
   if (function_exists('qtrans_getLanguage')) {
      // if permalinks are on, $_GET doesn't contain lang as a parameter
      // so we get it like this to be sure
      $language=qtrans_getLanguage();
   } elseif (function_exists('ppqtrans_getLanguage')) {
      $language=ppqtrans_getLanguage();
   } elseif (function_exists('qtranxf_getLanguage')) {
      $language=qtranxf_getLanguage();
   } elseif (function_exists('pll_current_language') && function_exists('pll_languages_list')) {
      $languages=pll_languages_list();
      if (is_array($languages)) {
          foreach ($languages as $tmp_lang) {
             if (preg_match("/^$tmp_lang\/|\/$tmp_lang\//",$_SERVER['REQUEST_URI']))
                   $language=$tmp_lang;
          }
      }
      if (empty($language))
         $language=pll_current_language('slug');
   } elseif (defined('ICL_LANGUAGE_CODE')) {
      // Both polylang and wpml define this constant, so check polylang first (above)
      // if permalinks are on, $_GET doesn't contain lang as a parameter
      // so we get it like this to be sure
      $language=ICL_LANGUAGE_CODE;
   } elseif (isset($_GET['lang'])) {
      $language=eme_strip_tags($_GET['lang']);
   } else {
      $language="";
   }
   return $language;
}
 /**
  * Function to create network-wide term in a given site.
  *
  * This function will switch the given blog_id, create the term and then switch back to the current blog.
  *
  * @since    1.0.0
  * @param    string    $blog_id       the id of the blog in which to set the therm.
  */
 protected function create_blog_term($blog_id, $term_name = null, $term_slug = null, $term_description = 'Network-wide -- DO NOT DELETE')
 {
     if (!isset($term_name)) {
         $term_name = $this->term_name;
     }
     if (!isset($term_slug)) {
         $term_slug = $this->term_slug;
     }
     $current_blog_id = get_current_blog_id();
     switch_to_blog($blog_id);
     //let's get the languages used on that site
     $translations = pll_languages_list(array('hide_empty' => 0, 'fields' => 'slug'));
     $language_name = pll_languages_list(array('hide_empty' => 0, 'fields' => 'name'));
     //if we found some languages, let's cache them
     for ($idx = 0; $idx < sizeof($language_name); $idx++) {
         $this->set_language($translations[$idx], $language_name[$idx]);
     }
     //else we assume we are dealing with the default language
     if (empty($translations)) {
         $translations = array($this->default_lang);
         error_log("Warning (Network-wide-posts) No Polylang languages set in blog: " . $blog_id . ", assuming default language (" . $this->default_lang . ")");
     }
     $term_ids = array();
     //term id storage array
     foreach ($translations as $lang) {
         $term_slug = $this->term_slug . "-" . $lang;
         $term_name = $this->term_name . " (" . $lang . ")";
         if ($this->default_lang == $lang) {
             $term_slug = $this->term_slug;
             $term_name = $this->term_name;
         }
         $args = array('description' => $term_description, 'slug' => $term_slug);
         switch (true) {
             case self::AUTOMATIC_TAG === $this->term_type:
                 $taxonomy = 'post_tag';
                 $term = get_term_by('slug', $args['slug'], $taxonomy);
                 if (!$term) {
                     //create tag
                     $term = wp_insert_term($term_name, $taxonomy, $args);
                     if (is_array($term)) {
                         $term_id = $term['term_id'];
                     } else {
                         $term_id = -1;
                     }
                 } else {
                     $term_id = $term->term_id;
                 }
                 //associate the new term with the correct language
                 pll_set_term_language($term_id, $lang);
                 //let's keep a cache for quicker loading.
                 $term_ids[$lang] = $term_id;
                 $this->set_blog_term_id($blog_id, $term_ids);
                 break;
             case self::AUTOMATIC_CAT === $this->term_type:
                 $taxonomy = 'category';
                 $term_ids = array();
                 $term = get_term_by('slug', $args['slug'], $taxonomy);
                 if (!$term) {
                     //create tag
                     $term = wp_insert_term($term_name, $taxonomy, $args);
                     if (is_array($term)) {
                         $term_id = $term['term_id'];
                     } else {
                         $term_id = -1;
                     }
                 } else {
                     $term_id = $term->term_id;
                 }
                 pll_set_term_language($term_id, $lang['slug']);
                 $term_ids[$lang['slug']] = $term_id;
                 $this->set_blog_term_id($blog_id, $term_id);
                 break;
             case self::SELECTED_TAX === $this->term_type:
             default:
                 //TODO, nothing?
                 break;
         }
     }
     //switch back to current blog
     //switch_to_blog($current_blog_id); //back to where we started
     restore_current_blog();
 }
 /**
  * ...
  */
 public function add_taxonomy($taxonomy, $translated_slugs)
 {
     $taxonomy_object = get_taxonomy($taxonomy);
     // Sanity check
     if (is_null($taxonomy_object)) {
         return;
     }
     $languages = pll_languages_list(array('fields' => 'slug'));
     $translated_struct = array();
     foreach ($languages as $lang) {
         // Add non specified slug translation to taxonomy default.
         if (!array_key_exists($lang, $translated_slugs)) {
             $translated_slugs[$lang] = $taxonomy_object->rewrite['slug'];
         }
         // Trim "/".
         $translated_slugs[$lang] = trim($translated_slugs[$lang], '/');
         // Generate "struct" with "slug" as WordPress would do.
         $translated_struct[$lang] = $translated_slugs[$lang] . "/%{$taxonomy_object->name}%";
     }
     $this->taxonomies[$taxonomy] = new PLL_TRS_Taxonomy($taxonomy_object, $translated_slugs, $translated_struct);
 }
示例#14
0
 /**
  * Filter stock by language.
  *
  * Filter the stock table according to choosen language
  *
  * @param string $query stock query
  *
  * @return string final stock query
  */
 public function filterStockByLanguage($query)
 {
     $lang = ($current = pll_current_language()) ? array($current) : pll_languages_list();
     $join = PLL()->model->post->join_clause(Utilities::polylangVersionCheck('2.0') ? 'posts' : 'post');
     $where = PLL()->model->post->where_clause($lang, 'post');
     return str_replace('WHERE 1=1', "{$join} WHERE 1=1 {$where}", $query);
 }
示例#15
0
 /**
  *	dashboard_listings()
  *	
  *	Make sure dashboard add-on
  *	shows all languages.
  *	
  *	@uses	get_terms()
  *	@uses	pll_languages_list()
  *	
  *	@since 1.0.0
  */
 public function dashboard_listings($args)
 {
     $args['tax_query'] = array('relation' => 'OR', array('taxonomy' => 'language', 'terms' => get_terms('language', array('fields' => 'ids')), 'operator' => 'NOT IN'), array('taxonomy' => 'language', 'field' => 'slug', 'terms' => pll_languages_list()));
     return $args;
 }
示例#16
0
echo $thema_logo;
?>
"/>
							</div>
				<?php 
bloginfo('name');
?>
</a></h1>
			<p class="site-description"><?php 
bloginfo('description');
?>
</p>
			<div class = "thema-language-switch">
				<?php 
if (function_exists('pll_the_languages')) {
    $thema_number_of_lang = count(pll_languages_list());
    if ($thema_number_of_lang > 2) {
        $dropdown = 1;
    } else {
        $dropdown = 0;
    }
    $args = array('show_names' => 1, 'hide_current' => false, 'dropdown' => $dropdown);
    pll_the_languages($args);
}
?>
			</div>
			<?php 
$thema_url_twitter = get_theme_mod('thema-url-twitter');
$thema_url_facebook = get_theme_mod('thema-url-facebook');
?>
			<div class = "cyfryngau-cymdeithasol">
示例#17
0
 /**
  * Yoast SEO
  * Adds the home urls for all languages to the sitemap
  *
  * @since 1.9
  *
  * @param string $str additional urls to sitemap post
  * @return string
  */
 public function add_language_home_urls($str)
 {
     global $wpseo_sitemaps;
     foreach (pll_languages_list() as $lang) {
         if (empty(PLL()->options['hide_default']) || pll_default_language() !== $lang) {
             $str .= $wpseo_sitemaps->sitemap_url(array('loc' => pll_home_url($lang), 'pri' => 1, 'chf' => apply_filters('wpseo_sitemap_homepage_change_freq', 'daily', pll_home_url($lang))));
         }
     }
     return $str;
 }
 static function download_language_packs()
 {
     $languages = pll_languages_list(array('fields' => 'locale'));
     // prevents upgrade if the .po file is already here. Let WP manage the upgrades :)
     foreach ($languages as $key => $locale) {
         if (file_exists(WP_LANG_DIR . "/{$locale}.po")) {
             unset($languages[$key]);
         }
     }
     if (empty($languages)) {
         return;
     }
     require_once ABSPATH . 'wp-admin/includes/translation-install.php';
     $translations = wp_get_available_translations();
     if (!$translations) {
         return;
     }
     foreach ($translations as $translation) {
         if (in_array($translation['language'], $languages)) {
             $translation['type'] = 'core';
             $translations_to_load[] = (object) $translation;
         }
     }
     if (!empty($translations_to_load)) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         $upgrader = new Language_Pack_Upgrader(new Automatic_Upgrader_Skin());
         $upgrader->bulk_upgrade($translations_to_load, array('clear_update_cache' => false));
     }
 }
 /**
  * Get active language codes
  *
  * @return array Language codes
  */
 function get_languages()
 {
     /*
     		if ( isset( $this->languages ) ) {
     			// Use value
     			return $this->languages;
     		}*/
     $result = array();
     // Retrieve Polylang active languages
     $languages = pll_languages_list(array('fields' => ''));
     // Fill the result
     if (!empty($languages)) {
         foreach ($languages as $language) {
             $result[$language->slug] = array('language_code' => $language->slug, 'active' => true, 'term_id' => $language->term_id);
         }
     }
     return $result;
 }
示例#20
0
function thema_gychwynnol_dashfwrdd_help()
{
    echo '<h1>' . __('Croeso i Thema.', 'thema') . '</h1>';
    echo '<p>' . __("Mae Thema wedi ei weithredu. Croeso i WordPress amlieithog.", 'thema') . '</p>';
    if (function_exists('pll_default_language')) {
        echo __('<h3>Iaith Ragosodedig y Wefan:</h3>', 'thema');
        echo pll_default_language('name');
        echo __('<h3>Ieithoedd ar y Wefan</h3>', 'thema');
        echo '<ul>';
        foreach (pll_languages_list(array('fields' => 'name')) as $iaith) {
            echo '<li>' . $iaith . '</li>';
        }
        echo '</ul>';
        echo '<a href = "' . get_site_url() . '/wp-admin/options-general.php?page=mlang" class ="button-primary">' . __('Ychwanegu Iaith', 'thema') . '</a>';
    }
}
示例#21
0
 /**
  * Filter stock by langauge
  *
  * Filter the stock table according to choosen langauge
  *
  * @global \Polylang $polylang
  * @param string $query stock query
  *
  * @return string final stock query
  */
 public function filterStockByLangauge($query)
 {
     global $polylang;
     $lang = ($current = pll_current_language()) ? array($current) : pll_languages_list();
     $join = $polylang->model->join_clause('post');
     $where = $polylang->model->where_clause($lang, 'post');
     return str_replace('WHERE 1=1', "{$join} WHERE 1=1 {$where}", $query);
 }
<?php

$header = $settings['header'];
$current_lang = strtolower(get_bloginfo('language'));
$site_lang = substr($current_lang, 0, 2);
if (defined('POLYLANG_VERSION')) {
    $langs = pll_languages_list();
} else {
    $langs = array($site_lang);
}
?>
<tr>
	<th></th>
	<th class="centralize"><?php 
echo __('Image URL', 'bvs-events-calendar');
?>
</th>
	<th class="centralize"><?php 
echo __('Link', 'bvs-events-calendar');
?>
</th>
</tr>

<?php 
foreach ($langs as $lang) {
    ?>
    <tr>
    	<th>
            <label><?php 
    echo strtoupper(__('Logo', 'bvs-events-calendar'));
    ?>
示例#23
0
/**
 * Save options to the database after processing them
 *
 * @param $data Options array to save
 * @author Jonah Dahlquist
 * @since 1.4.0
 * @uses update_option()
 * @return void
 */
function of_save_options($data, $key = null)
{
    global $smof_data, $theme_name;
    if (empty($data)) {
        return;
    }
    $data_from_db = $data;
    if (defined('ICL_LANGUAGE_CODE') && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
        if (defined('ICL_SITEPRESS_VERSION')) {
            global $sitepress;
            $languages = icl_get_languages('skip_missing=1');
        } elseif (function_exists('pll_languages_list')) {
            $languages = pll_languages_list();
        }
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
            $url = $_SERVER['HTTP_REFERER'];
        } else {
            $url = $_SERVER['REQUEST_URI'];
        }
        if ($url) {
            $parse_referer = parse_url($url);
            wp_parse_str($parse_referer['query'], $parse_query);
            if (isset($parse_query['lang']) && $parse_query['lang'] == 'all') {
                foreach ($data as $posted_key => $posted_data) {
                    if ($data_from_db[$posted_key] != $posted_data) {
                        $data[$posted_key] = $posted_data;
                    }
                }
                foreach ($languages as $language) {
                    $language_name = '';
                    if ($language['language_code'] != 'all') {
                        $language_name = '_' . $language['language_code'];
                    }
                    if ($language['language_code'] == 'en') {
                        $language_name = '';
                    }
                    $options_name = $theme_name . '_options' . $language_name;
                    update_option($options_name, $data);
                }
            } elseif (isset($parse_query['lang']) && $parse_query['lang'] && $parse_query['lang'] != 'all' && $parse_query['lang'] != 'en') {
                $language_name = '_' . $parse_query['lang'];
                $options_name = $theme_name . '_options' . $language_name;
                update_option($options_name, $data);
            } elseif (isset($_POST['wpml']) && $_POST['wpml'] != 'all' && $_POST['wpml'] != 'en') {
                $language_name = '_' . $_POST['wpml'];
                $options_name = $theme_name . '_options' . $language_name;
                update_option($options_name, $data);
            } else {
                update_option(OPTIONS, $data);
            }
        } else {
            update_option(OPTIONS, $data);
        }
    } else {
        update_option(OPTIONS, $data);
    }
}
示例#24
0
 /**
  * Sync Product Shipping Class.
  * 
  * 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.
  *
  * @param int       $post_id    Id of the product being created or edited
  * @param \WP_Post  $post       Post object
  * @param boolean   $update     Whether this is an existing post being updated or not
  */
 public function syncShippingClass($post_id, $post, $update)
 {
     if (in_array('product_shipping_class', $this->getProductMetaToCopy())) {
         // If adding new product translation copy shipping class, otherwise
         // sync all product translations with shipping class of this.
         $copy = isset($_GET['new_lang']) && isset($_GET['from_post']);
         if ($copy) {
             // New translation - copy shipping class from product source
             $ID = isset($_GET['from_post']) ? absint($_GET['from_post']) : false;
             $product = wc_get_product($ID);
         } else {
             // Product edit - update shipping class of all product translations
             $product = wc_get_product($post_id);
         }
         if ($product) {
             $shipping_class = $product->get_shipping_class();
             if ($shipping_class) {
                 $shipping_terms = get_term_by('slug', $shipping_class, 'product_shipping_class');
                 if ($shipping_terms) {
                     if ($copy) {
                         // New translation - copy shipping class from product source
                         wp_set_post_terms($post_id, array($shipping_terms->term_id), 'product_shipping_class');
                     } else {
                         // Product edit - update shipping class of all product translations
                         $langs = pll_languages_list();
                         foreach ($langs as $lang) {
                             $translation_id = pll_get_post($post_id, $lang);
                             if ($translation_id != $post_id) {
                                 // Don't sync if is the same product
                                 wp_set_post_terms($translation_id, array($shipping_terms->term_id), 'product_shipping_class');
                             }
                         }
                     }
                 }
             }
         }
     }
 }