language_cookie_name = $language_cookie_name; $this->current_language = $current_language; } public function add_hooks() { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), - PHP_INT_MAX ); } public function enqueue_scripts() { wp_enqueue_script( 'jquery.cookie', ICL_PLUGIN_URL . '/res/js/jquery.cookie.js', array( 'jquery' ), ICL_SITEPRESS_VERSION ); wp_enqueue_script( 'wpml-cookie', ICL_PLUGIN_URL . '/res/js/cookies/language-cookie.js', array( 'jquery', 'jquery.cookie' ) ); $cookies = array( $this->language_cookie_name => array( 'value' => $this->current_language, 'expires' => 1, 'path' => '/', ), ); wp_localize_script( 'wpml-cookie', 'wpml_cookies', $cookies ); } }