Exemplo n.º 1
0
 /**
  * Sets the current language in \SitePress::$this_lang, redirects if
  * frontend requests point to incomplete or incorrect urls, un-sets the
  * $_GET['lang'] and $_GET['admin_bar'] values so that upload.php is able to
  * enqueue 'media-grid' correctly without url parameters breaking its
  * functionality.
  */
 public function maybe_set_this_lang()
 {
     global $wpml_request_handler, $pagenow, $wpml_language_resolution;
     if (!defined('WP_ADMIN') && isset($_SERVER['HTTP_HOST']) && did_action('init')) {
         require_once ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-frontend-redirection.php';
         /** @var WPML_Frontend_Request $wpml_request_handler */
         $redirect_helper = _wpml_get_redirect_helper();
         $redirection = new WPML_Frontend_Redirection($this, $wpml_request_handler, $redirect_helper, $wpml_language_resolution);
         $this->this_lang = $redirection->maybe_redirect();
     } else {
         $this->this_lang = $wpml_request_handler->get_requested_lang();
     }
     $wpml_request_handler->set_language_cookie($this->this_lang);
     if ($pagenow === 'upload.php') {
         $_GET['lang'] = null;
         $_GET['admin_bar'] = null;
     }
 }
 public function maybe_set_this_lang()
 {
     global $wpml_request_handler;
     if (!defined('WP_ADMIN') && isset($_SERVER['HTTP_HOST']) && did_action('init')) {
         require ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-frontend-redirection.php';
         $redirect_helper = _wpml_get_redirect_helper();
         $redirection = new WPML_Frontend_Redirection($this, $wpml_request_handler, $redirect_helper);
         $this->this_lang = $redirection->maybe_redirect();
     } else {
         $this->this_lang = $wpml_request_handler->get_requested_lang();
     }
     $wpml_request_handler->set_language_cookie($this->this_lang);
 }