コード例 #1
0
 /**
  * @param $url
  * Filters links to the root page, so that they are displayed properly in the front-end.
  *
  * @return mixed
  */
 public function filter_root_permalink($url)
 {
     global $wpml_url_converter;
     if (WPML_Root_Page::get_root_id() > 0 && WPML_Root_Page::is_root_page($url)) {
         $url_parts = parse_url($url);
         $query = isset($url_parts['query']) ? $url_parts['query'] : '';
         $path = isset($url_parts['path']) ? $url_parts['path'] : '';
         $slugs = array_filter(explode('/', $path));
         $last_slug = array_pop($slugs);
         $new_url = $wpml_url_converter->get_abs_home();
         $new_url = is_numeric($last_slug) ? trailingslashit(trailingslashit($new_url) . $last_slug) : $new_url;
         $query = self::unset_page_query_vars($query);
         $new_url = trailingslashit($new_url);
         $url = (bool) $query === true ? trailingslashit($new_url) . '?' . $query : $new_url;
     }
     return $url;
 }
コード例 #2
0
 public static function init()
 {
     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) {
         global $wpml_root_page_actions;
         $wpml_root_page_actions = wpml_get_root_page_actions_obj();
         add_action('init', array($wpml_root_page_actions, 'wpml_home_url_init'), 0);
         add_filter('wp_page_menu_args', array($wpml_root_page_actions, 'wpml_home_url_exclude_root_page_from_menus'));
         add_filter('wp_get_nav_menu_items', array($wpml_root_page_actions, 'exclude_root_page_menu_item'), 10, 1);
         add_filter('wp_list_pages_excludes', array($wpml_root_page_actions, 'wpml_home_url_exclude_root_page'));
         add_filter('page_attributes_dropdown_pages_args', array($wpml_root_page_actions, 'wpml_home_url_exclude_root_page2'));
         add_filter('get_pages', array($wpml_root_page_actions, 'wpml_home_url_get_pages'));
         add_action('save_post', array($wpml_root_page_actions, 'wpml_home_url_save_post_actions'), 0, 2);
         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);
     }
 }
コード例 #3
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()
    {
コード例 #4
0
 public function wpml_root_page_posts_where_filter($where, $post_type)
 {
     global $wpdb;
     $where .= $wpdb->prepare(" AND ID != %d ", WPML_Root_Page::get_root_id());
     return $where;
 }