/**
  * Runs on template_include filter. Check for $POST values coming from the filter and add them to the url
  * Also check for custom GET parameters and reattach them to the url to support combination with other functionalities
  * @since 1.0.0
  */
 public function catch_filter_values()
 {
     //Nope, this pageload was not due to our filter!
     if (!isset($_POST['btf_do_filtering_nonce']) || !wp_verify_nonce($_POST['btf_do_filtering_nonce'], "Beutiful-taxonomy-filters-do-filter")) {
         return;
     }
     //If we don't have an url, this wont work!
     $referer = isset($_POST['site-url']) ? $_POST['site-url'] : false;
     if (!$referer) {
         return;
     }
     //get current post type archive rewrite slug
     if (isset($_POST['post_type_rewrite']) && $_POST['post_type_rewrite'] != '') {
         $current_post_type_rewrite = $_POST['post_type_rewrite'];
     } else {
         //If there was no post type from the form (for some reason), try to get it anyway!
         $current_post_type_rewrite = self::get_current_posttype();
     }
     //get current post type archive
     if (isset($_POST['post_type']) && $_POST['post_type'] != '') {
         $current_post_type = $_POST['post_type'];
     } else {
         //If there was no post type from the form (for some reason), try to get it anyway!
         $current_post_type = self::get_current_posttype(false);
     }
     //post type validation
     if (!post_type_exists($current_post_type)) {
         return;
     }
     //Polylang support
     if (function_exists('pll_current_language')) {
         $language_slug = pll_current_language('slug');
         //If the post type is translated…
         if (pll_is_translated_post_type($current_post_type)) {
             $new_url = pll_home_url($language_slug);
         } else {
             //base url
             $new_url = $referer . '/';
         }
     } else {
         //base url
         $new_url = $referer . '/';
     }
     $new_url .= $current_post_type_rewrite . '/';
     //Get the taxonomies of the current post type
     $current_taxonomies = get_object_taxonomies($current_post_type, 'objects');
     if ($current_taxonomies) {
         foreach ($current_taxonomies as $key => $value) {
             //check for each taxonomy as a $_POST variable.
             //If it exists we want to append it along with the value (term) it has.
             $term = isset($_POST['select-' . $key]) ? $_POST['select-' . $key] : false;
             if ($term) {
                 //If the taxonomy has a rewrite slug we need to use that instead!
                 if (is_array($value->rewrite) && array_key_exists('slug', $value->rewrite)) {
                     $new_url .= $value->rewrite['slug'] . '/' . $term . '/';
                 } else {
                     $new_url .= $key . '/' . $term . '/';
                 }
             }
         }
     }
     //Perform actions before the redirect to the filtered page
     do_action('beautiful_actions_before_redirection', $current_post_type);
     //keep GET parameters
     $new_url = $this->append_get_parameters($new_url);
     //sanitize URL
     $new_url = esc_url_raw($new_url);
     //perform a redirect to the new filtered url
     wp_redirect(apply_filters('beautiful_filters_new_url', $new_url, $current_post_type));
     exit;
 }
Esempio n. 2
0
 function icl_get_home_url()
 {
     return pll_home_url();
 }
Esempio n. 3
0
/**
 * Get home URL of a specific lang
 *
 * @since 2.2
 *
 * @param string $lang (default: '') The language code
 * @return string $url
 */
function get_rocket_i18n_home_url($lang = '')
{
    $url = home_url();
    if (!rocket_has_i18n()) {
        return $url;
    }
    if (rocket_is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
        $url = $GLOBALS['sitepress']->language_url($lang);
    } elseif (rocket_is_plugin_active('qtranslate/qtranslate.php')) {
        $url = qtrans_convertURL(home_url(), $lang, true);
    } elseif (rocket_is_plugin_active('polylang/polylang.php') && !empty($GLOBALS['polylang']->options['force_lang'])) {
        $url = pll_home_url($lang);
    }
    return $url;
}
Esempio n. 4
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;
 }
 /**
  * Gets the site homepage URL in the specified language
  *
  * ## OPTIONS
  *
  * <language-code>
  * : The language to get the home URL to.
  *
  * ## EXAMPLES
  *
  *   wp polylang home
  *   wp polylang home fr
  *
  * @synopsis [<language-code>]
  */
 function home($args, $assocArgs)
 {
     $lang = count($args) == 1 ? $args[0] : '';
     $url = pll_home_url($lang);
     WP_CLI::line($url);
 }
Esempio n. 6
0
<?php

//XXX: sorry future self, very ugly code
$default_language = pll_default_language();
$current_language = pll_current_language();
$search_language = $current_language != $default_language ? $current_language : '';
$search_text = $search_language == 'ru' ? 'Поиск' : 'Search';
$search_url = pll_home_url($default_language) . $search_language;
$search_url .= $search_language == '' ? '?s=' : '/?s=';
?>

<a class="search-link" href="<?php 
echo $search_url;
?>
">
    <?php 
echo $search_text;
?>
</a>
Esempio n. 7
0
     <hr class="line">
     <div class="medium-12 nav-lang-small">
      <div class="">
       <p><?php 
_e("LANGUAGE", "metropolis");
?>
 <a href="<?php 
echo pll_home_url("en");
?>
" <?php 
if ($idioma == "en") {
    echo 'class="active"';
}
?>
>EN</a> <a href="<?php 
echo pll_home_url("zh");
?>
" <?php 
if ($idioma == "zh") {
    echo 'class="active"';
}
?>
>中文</a></p>
       <p class="hide"><?php 
_e("AVAILABILITY", "metropolis");
?>
    —    <?php 
_e("floor plans", "metropolis");
?>
</p>
       <p><?php 
Esempio n. 8
0
 /**
  * Yoast SEO
  * Adds the home urls for all (active) 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;
     $languages = wp_list_pluck(wp_list_filter(PLL()->model->get_languages_list(), array('active' => false), 'NOT'), 'slug');
     foreach ($languages 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;
 }
Esempio n. 9
0
 /**
  * Translate WooCommerce Breadcrumbs home url.
  *
  * @return string translated home url
  */
 public function translateBreadrumbHomeUrl()
 {
     return pll_home_url();
 }
Esempio n. 10
0
                        <span class="a-social--phone"><a href="tel:210 330 800" class="a-link-phone a-link-phone--ligth">(+351) 210 330 800</a></span>
                    </li>
                    <li class="a-lang">
                        <ul class="a-lang__content">
                        <?php 
pll_the_languages(array('display_names_as' => "name", 'hide_if_empty' => 0));
?>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <div class="a-menu-content">
            <div class="a-container">
            <h1 class="a-logo"><a href="<?php 
echo pll_home_url();
?>
">Turim</a></h1>
            <div class="a-menu">
                <a href="#" class="a-btn a-btn--menu">MENU</a>
                <a href="#" class="a-btn a-btn--reservation"><?php 
_e('RESERVAR', 'turim');
?>
</a>
            </div>


        </div>

    </header>
Esempio n. 11
0
function simple_breadcrumb()
{
    global $post;
    global $staticVars;
    // print_r(has_term($staticVars['industryNewTypeID'], 'new-type', $post));exit;
    $sep = ' / ';
    echo '<a href="' . pll_home_url() . '">' . pll__('Lietuvos kino centras') . '</a>' . $sep;
    //echo '<a href="'.pll_home_url().'">'.get_bloginfo('name').'</a>'.$sep;
    /*	if ( is_category() || is_single() ) {
    		the_category(', ');
    		if ( is_single() ) {
    			echo $sep;
    			the_title();
    		}*/
    if (is_single()) {
        if (get_post_type() == 'post') {
            if (has_term($staticVars['industryNewTypeID'], 'new-type', $post)) {
                $news_link = $staticVars['industryNewsUrl'];
                $news_link_text = pll__('Industrijos naujienos');
            } else {
                $news_link = $staticVars['newsUrl'];
                $news_link_text = pll__('Naujienos');
            }
            echo '<a href="' . $news_link . '">';
            echo $news_link_text;
            echo "</a>";
        } elseif (get_post_type() == 'interesting-fact') {
            $pages = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'page-templates/interesting_facts.php', 'lang' => pll_current_language('slug')));
            //print_r($pages);
            echo '<a href="' . get_permalink($pages[0]->ID) . '">';
            pll_e('Įdomūs faktai');
            echo "</a>";
        } elseif (get_post_type() == 'tribe_events') {
            $url = $staticVars['eventsUrl'];
            echo '<a href="' . $url . '">' . pll__('Renginiai') . '</a>';
        } elseif (get_post_type() == 'education-resource') {
            $url = $staticVars['educationResourceUrl'];
            $title = get_the_title(kcsite_getPageByTempate('education_list.php'));
            echo '<a href="' . $url . '">' . $title . '</a>';
        } elseif (get_post_type() == 'film') {
            $url = get_permalink($staticVars['filmRegisterSearchPageId']);
            $title = get_the_title($staticVars['filmRegisterSearchPageId']);
            echo '<a href="' . $url . '">' . $title . '</a>';
        } elseif (get_post_type() == 'lithfilm') {
            $url = get_permalink($staticVars['lithuanianFilmsSearchPageId']);
            $title = get_the_title($staticVars['lithuanianFilmsSearchPageId']);
            echo '<a href="' . $url . '">' . $title . '</a>';
        }
        echo $sep;
        the_title();
    } elseif (!is_single() && get_post_type() == 'tribe_events') {
        //event calendar view
        pll_e('Renginiai');
    } elseif (is_page() && $post->post_parent) {
        //checkiing home page is not needed, but dos make no difference, so left
        $home = get_page_by_title('home');
        //show all ancestors (parent pages)
        for ($i = count($post->ancestors) - 1; $i >= 0; $i--) {
            if ($home->ID != $post->ancestors[$i]) {
                echo '<a href="';
                echo get_permalink($post->ancestors[$i]);
                echo '">';
                echo get_the_title($post->ancestors[$i]);
                echo "</a>" . $sep;
            }
        }
        echo the_title();
    } elseif (is_page()) {
        echo the_title();
    } elseif (is_404()) {
        echo of_get_option_by_lang('kcsite_404_page_title');
    }
}
 public function pll_sf_archive_results_url($results_url, $sfid, $page_slug)
 {
     if (function_exists('pll_home_url') && function_exists('pll_current_language')) {
         $results_url = pll_home_url(pll_current_language());
         if (get_option('permalink_structure')) {
             if ($page_slug != "") {
                 $results_url = trailingslashit(trailingslashit($results_url) . $page_slug);
             } else {
                 $results_url = trailingslashit($results_url);
                 $results_url = $this->add_url_args($results_url, "sfid={$sfid}");
             }
         } else {
             $results_url .= "&sfid=" . $sfid;
         }
     }
     return $results_url;
 }
Esempio n. 13
0
function alm_get_canonical_url()
{
    $canonicalURL = '';
    // Date
    if (is_date()) {
        // Is archive page
        $archive_year = get_the_date('Y');
        $archive_month = get_the_date('m');
        $archive_day = get_the_date('d');
        if (is_year()) {
            $canonicalURL = get_year_link($archive_year);
        }
        if (is_month()) {
            $canonicalURL = get_month_link($archive_year, $archive_month);
        }
        if (is_day()) {
            $canonicalURL = get_month_link($archive_year, $archive_month, $archive_day);
        }
    } elseif (is_front_page()) {
        if (function_exists('pll_home_url')) {
            // Polylang support
            $canonicalURL = pll_home_url();
        } else {
            $canonicalURL = get_home_url() . '/';
        }
    } elseif (is_home()) {
        $canonicalURL = get_permalink(get_option('page_for_posts'));
    } elseif (is_category()) {
        $cur_cat_id = get_cat_id(single_cat_title('', false));
        $canonicalURL = get_category_link($cur_cat_id);
    } elseif (is_tag()) {
        $cur_tag_id = get_query_var('tag_id');
        $canonicalURL = get_tag_link($cur_tag_id);
    } elseif (is_author()) {
        $author_id = get_the_author_meta('ID');
        $canonicalURL = get_author_posts_url($author_id);
    } elseif (is_tax()) {
        $tax_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        $tax_id = $tax_term->term_id;
        $canonicalURL = get_term_link($tax_id);
    } elseif (is_post_type_archive()) {
        $post_type_archive = get_post_type();
        $canonicalURL = get_post_type_archive_link($post_type_archive);
    } else {
        $canonicalURL = get_permalink();
    }
    return $canonicalURL;
}
Esempio n. 14
0
global $neighborhood;
global $team;
global $press;
global $contact;
global $availability;
$home = get_permalink(pll_get_post(4, IDIOMA));
$live = get_permalink(pll_get_post(9, IDIOMA));
$work = get_permalink(pll_get_post(11, IDIOMA));
$neighborhood = get_permalink(pll_get_post(13, IDIOMA));
$team = get_permalink(pll_get_post(15, IDIOMA));
$press = get_permalink(pll_get_post(17, IDIOMA));
$contact = get_permalink(pll_get_post(19, IDIOMA));
$availability = get_permalink(pll_get_post(21, IDIOMA));
$classe = "class='current-menu-item'";
$enghome = pll_home_url("en");
$zhhome = pll_home_url("zh");
?>

<nav class="row tab-bar">
  <div class="large-4 column">
      <a class="icon-bar" href="<?php 
echo $home;
?>
"></a>
  </div>
  <div class="menu-sup large-8 column hide-for-medium hide-for-small">
      <ul class="lang">
        <li><a href="<?php 
echo $enghome;
?>
">EN</a>/</li>
Esempio n. 15
0
function pll_home_language_switcher($url, $slug)
{
    global $wp;
    $home = untrailingslashit(pll_home_url());
    $current_url = home_url(add_query_arg(array(), $wp->request));
    $is_index = $home == $current_url ? true : false;
    if ($is_index) {
        $posts = get_posts(array('post_type' => 'event', 'lang' => $slug, 'showposts' => 1));
        $url = !$posts || $url === null ? null : $url;
    }
    return $url;
}
Esempio n. 16
0
 private function getPolylangRedirectUrl($lang_code)
 {
     global $polylang;
     $lang = $polylang->model->get_language($lang_code);
     $from = $this->site_url . $this->request_uri;
     if (is_singular() && !is_front_page()) {
         $translated_post_id = pll_get_post(get_queried_object_id(), $lang->slug);
         if ($translated_post_id && get_post_status($translated_post_id) === 'publish') {
             return get_permalink($translated_post_id);
         } else {
             return new WP_Error('404', __('Page Not Found', 'wp-geo-redirect'));
         }
     }
     if (is_front_page()) {
         return pll_home_url($lang->slug);
     }
     if (is_home()) {
         if (get_option('show_on_front') === 'page') {
             $translated_post_id = pll_get_post(get_option('page_for_posts'), $lang->slug);
             if ($translated_post_id && get_post_status($translated_post_id) === 'publish') {
                 return get_permalink($translated_post_id);
             } else {
                 return new WP_Error('404', __('Page Not Found', 'wp-geo-redirect'));
             }
         } else {
             return pll_home_url($lang->slug);
         }
     }
     if (is_search()) {
         return $polylang->links_model->switch_language_in_link($from, $lang);
     }
     if (is_tax() || is_category() || is_tag()) {
         $translated_term_id = pll_get_term(get_queried_object_id(), $lang->slug);
         if (get_queried_object_id() === $translated_term_id) {
             return;
         }
         return get_term_link($translated_term_id, get_queried_object()->taxonomy);
     }
     return $polylang->links_model->switch_language_in_link($from, $lang);
 }