| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Frontend controller |
| 8 | 5 | * accessible as $polylang global object |
| @@ -20,8 +17,9 @@ | ||
| 20 | 17 | * filters_search => reference to PLL_Frontend_Filters_Search object |
| 21 | 18 | * posts => reference to PLL_CRUD_Posts object |
| 22 | 19 | * terms => reference to PLL_CRUD_Terms object |
| 23 | 20 | * nav_menu => reference to PLL_Frontend_Nav_Menu object |
| 21 | + * sync => reference to PLL_Sync object | |
| 24 | 22 | * auto_translate => optional, reference to PLL_Auto_Translate object |
| 25 | 23 | * |
| 26 | 24 | * @since 1.2 |
| 27 | 25 | */ |
| @@ -75,8 +73,35 @@ | ||
| 75 | 73 | $this->choose_lang->init(); |
| 76 | 74 | |
| 77 | 75 | // Need to load nav menu class early to correctly define the locations in the customizer when the language is set from the content |
| 78 | 76 | $this->nav_menu = new PLL_Frontend_Nav_Menu( $this ); |
| 77 | + | |
| 78 | + // Cross domain | |
| 79 | + if ( PLL_COOKIE ) { | |
| 80 | + $class = array( 2 => 'PLL_Xdata_Subdomain', 3 => 'PLL_Xdata_Domain' ); | |
| 81 | + if ( isset( $class[ $this->options['force_lang'] ] ) && class_exists( $class[ $this->options['force_lang'] ] ) ) { | |
| 82 | + $this->xdata = new $class[ $this->options['force_lang'] ]( $this ); | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 86 | + if ( get_option( 'permalink_structure' ) ) { | |
| 87 | + // Translate slugs | |
| 88 | + if ( class_exists( 'PLL_Frontend_Translate_Slugs' ) ) { | |
| 89 | + $slugs_model = new PLL_Translate_Slugs_Model( $this ); | |
| 90 | + $this->translate_slugs = new PLL_Frontend_Translate_Slugs( $slugs_model, $this->curlang ); | |
| 91 | + } | |
| 92 | + | |
| 93 | + // Share term slugs | |
| 94 | + if ( $this->options['force_lang'] && class_exists( 'PLL_Share_Term_Slug' ) ) { | |
| 95 | + $this->share_term_slug = version_compare( $GLOBALS['wp_version'], '4.8', '<' ) ? | |
| 96 | + new PLL_Frontend_Share_Term_Slug( $this ) : | |
| 97 | + new PLL_Share_Term_Slug( $this ); | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + if ( class_exists( 'PLL_Sync_Post' ) ) { | |
| 102 | + $this->sync_post = new PLL_Sync_Post( $this ); | |
| 103 | + } | |
| 79 | 104 | } |
| 80 | 105 | |
| 81 | 106 | /** |
| 82 | 107 | * Setups filters and nav menus once the language has been defined |
| @@ -87,9 +112,13 @@ | ||
| 87 | 112 | // Filters |
| 88 | 113 | $this->filters_links = new PLL_Frontend_Filters_Links( $this ); |
| 89 | 114 | $this->filters = new PLL_Frontend_Filters( $this ); |
| 90 | 115 | $this->filters_search = new PLL_Frontend_Filters_Search( $this ); |
| 116 | + $this->posts = new PLL_CRUD_Posts( $this ); | |
| 117 | + $this->terms = new PLL_CRUD_Terms( $this ); | |
| 91 | 118 | |
| 119 | + $this->sync = new PLL_Sync( $this ); | |
| 120 | + | |
| 92 | 121 | // Auto translate for Ajax |
| 93 | 122 | if ( ( ! defined( 'PLL_AUTO_TRANSLATE' ) || PLL_AUTO_TRANSLATE ) && wp_doing_ajax() ) { |
| 94 | 123 | $this->auto_translate(); |
| 95 | 124 | } |
| @@ -134,9 +163,9 @@ | ||
| 134 | 163 | $taxonomies = array_diff( $taxonomies, array( 'language', 'category', 'post_tag' ) ); |
| 135 | 164 | |
| 136 | 165 | // Remove pages query when the language is set unless we do a search |
| 137 | 166 | // Take care not to break the single page, attachment and taxonomies queries! |
| 138 | - if ( empty( $qv['post_type'] ) && ! $query->is_search && ! $query->is_singular && empty( $taxonomies ) && ! $query->is_category && ! $query->is_tag ) { | |
| 167 | + if ( empty( $qv['post_type'] ) && ! $query->is_search && ! $query->is_singular && empty( $taxonomies ) ) { | |
| 139 | 168 | $query->set( 'post_type', 'post' ); |
| 140 | 169 | } |
| 141 | 170 | |
| 142 | 171 | // Unset the is_archive flag for language pages to prevent loading the archive template |