本文整理汇总了PHP中pll_current_language函数的典型用法代码示例。如果您正苦于以下问题:PHP pll_current_language函数的具体用法?PHP pll_current_language怎么用?PHP pll_current_language使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pll_current_language函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_language
/**
* Action: Set Language
*
* @param string $lang_slug
* @param object $current_lang Current language
*/
public function set_language($lang_slug, $current_lang)
{
$this->default_lang = pll_default_language();
$this->current_lang = pll_current_language();
acf_update_setting('default_language', $this->default_lang);
acf_update_setting('current_language', $this->current_lang);
}
示例2: saveOrderLanguage
/**
* Save the order language with every checkout
*
* @param integer $order the order object
*/
public function saveOrderLanguage($order)
{
$current = pll_current_language();
if ($current) {
pll_set_post_language($order, $current);
}
}
示例3: footsy
function footsy()
{
global $popupBoxen;
echo $popupBoxen;
if (class_exists('PLL_Base')) {
echo '<span id="pylangswitcher">';
// echo '<li><a id="notice-trans" href="#">notice! (08-30)</a></li>';
// these are the publicly-available languages
foreach (unserialize(PRODUCTION_LANGUAGES) as $lang) {
if ($lang != pll_current_language()) {
echo '<li><a href="' . get_permalink(pll_get_post(get_the_ID(), $lang)) . '">' . $lang . '</a></li>';
}
}
// these are the ones in development
if (userIsAdmin() || userIsTranslator() || userIsAssistant()) {
foreach (unserialize(DEVELOPMENT_LANGUAGES) as $lang) {
if ($lang != pll_current_language()) {
echo '<li><a href="' . get_permalink(pll_get_post(get_the_ID(), $lang)) . '">' . $lang . '</a></li>';
}
}
}
// old method: echo pll_the_languages(array('echo'=>0,'display_names_as' => 'slug','hide_current' => 1));
if (userIsAdmin() || userIsTranslator() || userIsAssistant()) {
echo '<li><a href="' . admin_url('edit.php?post_type=page') . '">' . __t('Editor') . '</a></li>';
}
echo '</span>';
}
}
示例4: wp_new_user_notification
function wp_new_user_notification($user_id, $plaintext_pass = '')
{
//pyboxlog('called wp_n_u_n', 1);
$user = new WP_User($user_id);
$body = __t('An account has been created for you on the Computer Science Circles website, with a randomly generated password.
User name: %username%
Current random password: %password%
Please visit
%loginurl%
and change your password to something you will remember.
Press "%upprof%" once you are done.
Thanks from the Computer Science Circles team!
%siteurl%');
//pyboxlog('locale:' . pll_current_language('locale'), 1);
if (class_exists('PLL_Base')) {
update_user_meta($user_id, 'user_lang', pll_current_language('locale'));
}
$subject = __t('Computer Science Circles: New account');
$user_login = stripslashes($user->user_login);
$user_email = stripslashes($user->user_email);
$find = array('/%username%/i', '/%password%/i', '/%blogname%/i', '/%siteurl%/i', '/%loginurl%/i', '/%useremail%/i', '/%upprof%/i');
$replace = array($user_login, $plaintext_pass, get_option('blogname'), get_option('siteurl'), get_option('siteurl') . '/wp-login.php', $user_email, __t('Update Profile'));
$body = preg_replace($find, $replace, $body);
$body = preg_replace("/%.*%/", "", $body);
pb_mail('"' . get_option('blogname') . '" <' . CSCIRCLES_BOUNCE_EMAIL . '>', '<' . $user_email . '>', $subject, $body);
}
示例5: nav_menu_add_classes2
function nav_menu_add_classes2($items, $args)
{
//print_r($items);
global $post;
$i = 0;
$j = false;
$a = false;
foreach ($items as $item) {
$i++;
if (is_single() && get_post_type() == 'interesting-fact') {
//get parent page ID by checking which page uses interesting fatcs page template
$pages = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'page-templates/interesting_facts.php', 'lang' => pll_current_language('slug')));
$parent_page_id = $pages[0]->ID;
if ($item->object_id == $parent_page_id) {
// $item->classes[] = 'current_page_parent';
$item->classes[] = 'current_menu_item';
$j = $i - 1;
$a = $item->ID;
}
}
}
if ($j) {
// $items[$j]->classes[] = 'current_page_parent';
$items[1]->classes[] = 'current_page_ancestor';
}
if ($a) {
echo $a;
}
return $items;
}
示例6: get_slug_pll
public static function get_slug_pll($slug, $type)
{
$id = self::get_id_by_slug($slug, $type);
$id = pll_get_post($id, pll_current_language());
$data = get_post($id, ARRAY_A);
return $data['post_name'];
}
示例7: get_context_data
/**
* Get data from context
* @author Joachim Jensen <jv@intox.dk>
* @since 2.0
* @return array
*/
public function get_context_data()
{
$data = array($this->id);
if (function_exists('pll_current_language')) {
$data[] = pll_current_language();
}
return $data;
}
示例8: pll_get_locale
/**
* Filter WordPress current locale with Polylang's current locale.
*
* @used-by Filters\"locale"
* @param string $locale The locale ID.
*/
public function pll_get_locale($locale)
{
$pll_locale = pll_current_language('locale');
if ($locale !== $pll_locale) {
$locale = $pll_locale;
}
return $locale;
}
示例9: dbProblemSummary
function dbProblemSummary($limit, $sortname, $sortorder, $req = NULL)
{
global $db_query_info;
$db_query_info = array();
if ($req == NULL) {
$req = $_REQUEST;
}
$db_query_info['type'] = 'problem-summary';
if (!is_user_logged_in()) {
return __t("You must log in to view past submissions.");
}
$problemslug = getSoft($req, "p", "");
//which problem?
if ($problemslug == "") {
return __t("You must enter a non-empty problem name.");
}
global $wpdb;
$problem_table = $wpdb->prefix . "pb_problems";
$problemname = $wpdb->get_var($wpdb->prepare("SELECT publicname FROM {$problem_table} WHERE lang = '%s' AND slug = '%s'", pll_current_language(), $problemslug));
if ($problemname == null) {
return sprintf(__t("Problem %s not found (at least in current language)"), $problemslug);
}
$db_query_info['problem'] = $problemslug;
$u = wp_get_current_user();
$uid = $u->ID;
$db_query_info['viewuser'] = $uid;
$ulogin = $u->user_login;
$submit_table = $wpdb->prefix . "pb_submissions";
$usermeta_table = $wpdb->prefix . "usermeta";
$user_table = $wpdb->prefix . "users";
$complete_table = $wpdb->prefix . "pb_completed";
$count = $wpdb->get_var(userIsAdmin() ? "SELECT count(1) FROM {$user_table}" : $wpdb->prepare("SELECT count(1) FROM {$usermeta_table} WHERE meta_key=%s AND meta_value=%s", 'pbguru', $ulogin));
$students = $wpdb->get_results(userIsAdmin() ? "SELECT ID FROM {$user_table} {$limit}" : $wpdb->prepare("SELECT user_id AS ID FROM {$usermeta_table} WHERE meta_key=%s AND meta_value=%s {$limit}", 'pbguru', $ulogin));
// no sorting allowed due to weird nature of query
$flexirows = array();
foreach ($students as $r) {
$sid = $r->ID;
$sdata = $wpdb->get_row($wpdb->prepare("SELECT usercode, beginstamp FROM {$submit_table} \n WHERE userid={$sid} and problem='%s' and result='Y'\n ORDER BY beginstamp DESC limit 1", $problemslug));
$s = get_userdata($sid);
$cell = array();
$cell['ID'] = $sid;
$cell['info'] = userString($sid);
if ($sdata != null) {
$cell[__t('latest correct')] = prebox($sdata->usercode);
$cell[__t('last time')] = $sdata->beginstamp;
$cell[__t('first time')] = $wpdb->get_var($wpdb->prepare("SELECT time FROM {$complete_table} WHERE userid={$sid} and problem='%s'", $problemslug));
} else {
$cell[__t('latest correct')] = '<i>n/a</i>';
$cell[__t('last time')] = '<i>n/a</i>';
$cell[__t('first time')] = '<i>n/a</i>';
}
$flexirows[] = array('id' => $sid, 'cell' => $cell);
}
return array('total' => $count, 'rows' => $flexirows);
}
示例10: nueva_url
function nueva_url()
{
if (pll_current_language('slug') == "fr") {
$url = home_url();
} elseif (pll_current_language('slug') == "es") {
$url = home_url();
} else {
$url = home_url();
}
echo $url;
}
示例11: addToContext
/**
* Add things to the context for every twig template
* @param $context
* @return mixed
*/
function addToContext($context)
{
$context['menu'] = new TimberMenu();
$context['site'] = $this;
$context['is_home'] = is_front_page() ? "true" : "false";
$context['home_url'] = get_home_url();
if (function_exists("pll_current_language")) {
$context['current_lang'] = pll_current_language();
}
return $context;
}
示例12: get_language
/**
* Return the language 2-4 letters code
*
* @since 1.0.0
*
* @return string 4 letters cod of the locale
*/
function get_language()
{
if (defined('ICL_LANGUAGE_CODE')) {
return ICL_LANGUAGE_CODE;
} elseif (function_exists('cml_get_browser_lang')) {
return cml_get_browser_lang();
} elseif (function_exists('pll_current_language')) {
return pll_current_language();
} else {
// Return a 2-4 letters code
return get_locale();
}
}
示例13: get_site_language
/**
* Get the current language.
*
* Uses the WordPress locale setting, but also checks for WPML and Polylang.
*
* @return string
*/
protected function get_site_language()
{
$language = get_bloginfo('language');
if (defined('ICL_LANGUAGE_CODE')) {
$language = ICL_LANGUAGE_CODE;
}
if (function_exists('pll_current_language')) {
$language = pll_current_language('slug');
}
/**
* Filters the displayed site language.
*
* @param string $language Site language.
*/
return apply_filters('user_feedback_site_language', $language);
}
示例14: add_to_context
public function add_to_context($context)
{
/* Menu */
$context['menu'] = new TimberMenu('primary_navigation');
/* Site info */
$context['site'] = $this;
/* Boolean if is homepage */
$context['is_home'] = is_front_page() ? "true" : "false";
/* homepage url */
$context['home_url'] = get_home_url();
/* if multilang is enabled return current language */
if (function_exists("pll_current_language")) {
$context['current_lang'] = pll_current_language();
}
return $context;
}
示例15: search_link
/**
* Retrieve permalink for search.
*
* @param string $query Optional. The query string to use. If empty the current query is used.
* @return string
*/
function search_link($link, $search)
{
$lang = pll_current_language();
$slug = pll_translations_x('search', 'URI slug', 'boilerplate', $lang);
//$link = "/$slug/$search";
$link = "/{$search}";
$link = home_url(user_trailingslashit($link, 'search'));
/**
* Filter the search permalink.
*
* @param string $link Search permalink.
* @param string $search The URL-encoded search term.
*/
var_dump($link);
var_dump($search);
return apply_filters('pll_search_link', $link, $search);
}