コード例 #1
0
 /**
  * @param WPML_URL_Converter $url_converter
  * @param array              $active_languages
  * @param string             $default_language
  * @param WPML_Cookie        $cookie
  */
 public function __construct(&$url_converter, $active_languages, $default_language, $cookie)
 {
     parent::__construct($url_converter, $active_languages, $default_language, $cookie);
     global $wpml_url_filters;
     if (strpos((string) filter_var($_SERVER['REQUEST_URI']), 'wpml_root_page=1') !== false || $wpml_url_filters->frontend_uses_root() !== false) {
         WPML_Root_Page::init();
     }
 }
コード例 #2
0
 /**
  * @param WPML_Post_Translation $post_translation
  * @param WPML_URL_Converter    $url_converter
  * @param WPML_Canonicals       $canonicals
  * @param SitePress             $sitepress
  */
 public function __construct(&$post_translation, &$url_converter, WPML_Canonicals $canonicals, &$sitepress)
 {
     parent::__construct($post_translation, $sitepress);
     $this->url_converter =& $url_converter;
     $this->canonicals = $canonicals;
     if ($this->frontend_uses_root() === true) {
         WPML_Root_Page::init();
     }
     $this->add_hooks();
 }
コード例 #3
0
 /**
  * @param WPML_Post_Translation $post_translation
  * @param WPML_URL_Converter    $url_converter
  * @param SitePress             $sitepress
  */
 public function __construct(&$post_translation, &$url_converter, &$sitepress)
 {
     parent::__construct($post_translation, $sitepress);
     $this->url_converter =& $url_converter;
     if ($this->frontend_uses_root() === true) {
         WPML_Root_Page::init();
         add_filter('page_link', array($this, 'permalink_filter_root'), 1, 2);
     } else {
         add_filter('page_link', array($this, 'permalink_filter'), 1, 2);
     }
     add_filter('home_url', array($this, 'home_url_filter'), -10, 4);
     // posts and pages links filters
     add_filter('post_link', array($this, 'permalink_filter'), 1, 2);
     add_filter('post_type_link', array($this, 'permalink_filter'), 1, 2);
     add_filter('get_edit_post_link', array($this, 'get_edit_post_link'), 1, 3);
 }
コード例 #4
0
<?php

if (WPML_Root_Page::uses_html_root() || WPML_Root_Page::get_root_id() > 0 || strpos((string) filter_var($_SERVER['REQUEST_URI']), 'wpml_root_page=1') !== false || (bool) filter_input(INPUT_POST, '_wpml_root_page') === true) {
    $root_page_actions = wpml_get_root_page_actions_obj();
    add_action('init', array($root_page_actions, 'wpml_home_url_init'), 0);
    add_filter('wp_page_menu_args', array($root_page_actions, 'wpml_home_url_exclude_root_page_from_menus'));
    add_filter('wp_list_pages_excludes', array($root_page_actions, 'wpml_home_url_exclude_root_page'));
    add_filter('page_attributes_dropdown_pages_args', array($root_page_actions, 'wpml_home_url_exclude_root_page2'));
    add_filter('get_pages', array($root_page_actions, 'wpml_home_url_get_pages'));
    add_action('save_post', array($root_page_actions, 'wpml_home_url_save_post_actions'), 0, 2);
    WPML_Root_Page::init();
}
class WPML_Root_Page
{
    public static function init()
    {
        if (self::get_root_id() > 0) {
            add_filter('template_include', array('WPML_Root_Page', 'wpml_home_url_template_include'));
            add_filter('the_preview', array('WPML_Root_Page', 'front_page_id_filter'));
        }
        $root_page_actions = wpml_get_root_page_actions_obj();
        add_action('icl_set_element_language', array($root_page_actions, 'delete_root_page_lang'), 10, 0);
    }
    /**
     * Checks if the value in $_SERVER['REQUEST_URI] points towards the root page.
     * Therefore this can be used to check if the current request points towards the root page.
     *
     * @return bool
     */
    public static function is_current_request_root()
    {