Arkadaşlar selam bir sitemizde polylang kullanıyoruz.
Farklı domainler tek siteyi çalıştırdığı için polylang eklentisindeki bayraklara tıklanarak dil değiştirildiğinde URL yapısı domain.com/en şeklinde oluyor ancak biz tüm domainlerde sağlıklı çalışması için domain.com olmadan direk /en /fr gibi çalışmasını istiyoruz.
Bunu nasıl yapabiliriz?

Aşağıda eklentinin bazı sayfalarını ekledim bunlar olmayabilir belki ama ; sizinde önerilerinizle beraber çözebiliriz.
links-model.php
<?php/** * @package Polylang */
/** * Links model abstract class * * @since 1.5 */abstract class PLL_Links_Model { public $model, $options; public $home; // used to store the home url before it is filtered public $using_permalinks;
/** * Constructor * * @since 1.5 * * @param object $model PLL_Model instance */ public function __construct( &$model ) { $this->model = &$model; $this->options = &$model->options;
$this->home = home_url();
add_filter( 'pll_languages_list', array( $this, 'pll_languages_list' ), 4 ); // after PLL_Static_Pages add_filter( 'pll_after_languages_cache', array( $this, 'pll_after_languages_cache' ) );
// adds our domains or subdomains to allowed hosts for safe redirection add_filter( 'allowed_redirect_hosts', array( $this, 'allowed_redirect_hosts' ) ); }
/** * Changes the language code in url * * @since 1.5 * * @param string $url url to modify * @param object $lang language * @return string modified url */ public function switch_language_in_link( $url, $lang ) { $url = $this->remove_language_from_link( $url ); return $this->add_language_to_link( $url, $lang ); }
/** * Get hosts managed on the website * * @since 1.5 * * @return array list of hosts */ public function get_hosts() { return array( wp_parse_url( $this->home, PHP_URL_HOST ) ); }
/** * Returns the home url * * @since 1.3.1 * * @param object $lang PLL_Language object * @return string */ public function home_url( $lang ) { $url = trailingslashit( $this->home ); return $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ? $url : $this->add_language_to_link( $url, $lang ); }
/** * Sets the home urls * * @since 1.8 * * @param object $language */ protected function set_home_url( $language ) { // We should always have a default language here, except, temporarily, in PHPUnit tests. The test here protects against PHP notices. if ( isset( $this->options['default_lang'] ) ) { $search_url = $this->home_url( $language ); $home_url = empty( $language->page_on_front ) || $this->options['redirect_lang'] ? $search_url : $this->front_page_url( $language ); $language->set_home_url( $search_url, $home_url ); } }
/** * Sets the home urls and flags before the languages are persistently cached * * @since 1.8 * * @param array $languages array of PLL_Language objects * @return array */ public function pll_languages_list( $languages ) { foreach ( $languages as $language ) { $this->set_home_url( $language ); $language->set_flag(); } return $languages; }
/** * Sets the home urls when not cached * Sets the home urls scheme * * @since 1.8 * * @param array $languages array of PLL_Language objects * @return array */ public function pll_after_languages_cache( $languages ) { foreach ( $languages as $language ) { // Get the home urls when not cached if ( ( defined( 'PLL_CACHE_LANGUAGES' ) && ! PLL_CACHE_LANGUAGES ) || ( defined( 'PLL_CACHE_HOME_URL' ) && ! PLL_CACHE_HOME_URL ) ) { $this->set_home_url( $language ); }
// Ensures that the ( possibly cached ) home and flag urls use the right scheme http or https. $language->set_url_scheme(); } return $languages; }
/** * Adds our domains or subdomains to allowed hosts for safe redirection * * @since 1.4.3 * * @param array $hosts allowed hosts * @return array */ public function allowed_redirect_hosts( $hosts ) { return array_unique( array_merge( $hosts, array_values( $this->get_hosts() ) ) ); }}


links-domain.php
<?php/** * @package Polylang */
/** * Links model for use when using one domain per language * for example mysite.com/sth and mysite.fr/qqch * implements the "links_model interface" * * @since 1.2 */class PLL_Links_Domain extends PLL_Links_Abstract_Domain {
/** * Constructor * * @since 1.8 * * @param object $model PLL_Model instance */ public function __construct( &$model ) { parent::__construct( $model );
$this->hosts = $this->get_hosts();
// Filter the site url ( mainly to get the correct login form ) add_filter( 'site_url', array( $this, 'site_url' ) ); }

/** * Adds the language code in url * links_model interface * * @since 1.2 * * @param string $url url to modify * @param object $lang language * @return string modified url */ public function add_language_to_link( $url, $lang ) { if ( ! empty( $lang ) && ! empty( $this->hosts[ $lang->slug ] ) ) { $url = preg_replace( '#://(' . wp_parse_url( $this->home, PHP_URL_HOST ) . ')($|/.*)#', '://' . $this->hosts[ $lang->slug ] . '$2', $url ); } return $url; }
/** * Returns the url without language code * links_model interface * * @since 1.2 * * @param string $url url to modify * @return string modified url */ public function remove_language_from_link( $url ) { if ( ! empty( $this->hosts ) ) { $url = preg_replace( '#://(' . implode( '|', $this->hosts ) . ')($|/.*)#', '://' . wp_parse_url( $this->home, PHP_URL_HOST ) . '$2', $url ); } return $url; }
/** * Returns the home url * links_model interface * * @since 1.3.1 * * @param object $lang PLL_Language object * @return string */ public function home_url( $lang ) { return trailingslashit( empty( $this->options['domains'][ $lang->slug ] ) ? $this->home : $this->options['domains'][ $lang->slug ] ); }
/** * Get hosts managed on the website * * @since 1.5 * * @return array list of hosts */ public function get_hosts() { $hosts = array(); foreach ( $this->options['domains'] as $lang => $domain ) { $host = wp_parse_url( $domain, PHP_URL_HOST ); // idn_to_ascii is much faster than the WordPress method. if ( function_exists( 'idn_to_ascii' ) ) { // The use of the constant is mandatory in PHP 7.2 and PHP 7.3 to avoid a deprecated notice. $hosts[ $lang ] = defined( 'INTL_IDNA_VARIANT_UTS46' ) ? idn_to_ascii( $host, 0, INTL_IDNA_VARIANT_UTS46 ) : idn_to_ascii( $host ); } else { $hosts[ $lang ] = Requests_IDNAEncoder::encode( $host ); } }
return $hosts; }}


links-permalink.php
<?php/** * @package Polylang */
/** * Links model base class when using pretty permalinks * * @since 1.6 */abstract class PLL_Links_Permalinks extends PLL_Links_Model { public $using_permalinks = true; protected $index = 'index.php'; // Need this before $wp_rewrite is created, also hardcoded in wp-includes/rewrite.php protected $root, $use_trailing_slashes; protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' );
/** * Constructor * * @since 1.8 * * @param object $model PLL_Model instance */ public function __construct( &$model ) { parent::__construct( $model );
// Inspired by wp-includes/rewrite.php $permalink_structure = get_option( 'permalink_structure' ); $this->root = preg_match( '#^/*' . $this->index . '#', $permalink_structure ) ? $this->index . '/' : ''; $this->use_trailing_slashes = ( '/' == substr( $permalink_structure, -1, 1 ) ); }
/** * Returns the link to the first page when using pretty permalinks * * @since 1.2 * * @param string $url url to modify * @return string modified url */ public function remove_paged_from_link( $url ) { /** * Filter an url after the paged part has been removed * * @since 2.0.6 * * @param string $modified_url The link to the first page * @param string $original_url The link to the original paged page */ return apply_filters( 'pll_remove_paged_from_link', preg_replace( '#/page/[0-9]+/?#', $this->use_trailing_slashes ? '/' : '', $url ), $url ); }
/** * Returns the link to the paged page when using pretty permalinks * * @since 1.5 * * @param string $url url to modify * @param int $page * @return string modified url */ public function add_paged_to_link( $url, $page ) { /** * Filter an url after the paged part has been added * * @since 2.0.6 * * @param string $modified_url The link to the paged page * @param string $original_url The link to the original first page * @param int $page The page number */ return apply_filters( 'pll_add_paged_to_link', user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' ), $url, $page ); }
/** * Returns the home url * * @since 1.3.1 * * @param object $lang PLL_Language object * @return string */ public function home_url( $lang ) { return trailingslashit( parent::home_url( $lang ) ); }
/** * Returns the static front page url * * @since 1.8 * * @param object $lang * @return string */ public function front_page_url( $lang ) { if ( $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ) { return trailingslashit( $this->home ); } $url = home_url( $this->root . get_page_uri( $lang->page_on_front ) ); $url = $this->use_trailing_slashes ? trailingslashit( $url ) : untrailingslashit( $url ); return $this->options['force_lang'] ? $this->add_language_to_link( $url, $lang ) : $url; }
/** * Prepares rewrite rules filters * * @since 1.6 */ public function get_rewrite_rules_filters() { // Make sure we have the right post types and taxonomies $types = array_values( array_merge( $this->model->get_translated_post_types(), $this->model->get_translated_taxonomies(), $this->model->get_filtered_taxonomies() ) ); $types = array_merge( $this->always_rewrite, $types );
/** * Filter the list of rewrite rules filters to be used by Polylang * * @since 0.8.1 * * @param array $types the list of filters (without '_rewrite_rules' at the end) */ return apply_filters( 'pll_rewrite_rules', $types ); }}