current_user */ private $current_user; private $sitepress; /** * WPML_User_Options_Menu constructor. * * @param SitePress $sitepress * @param WP_User $current_user */ public function __construct( SitePress $sitepress, WP_User $current_user ) { $this->sitepress = $sitepress; $this->current_user = $current_user; $this->user_language = $this->sitepress->get_wp_api()->get_user_meta( $this->current_user->ID, 'icl_admin_language', true ); $this->user_admin_def_lang = $this->sitepress->get_setting( 'admin_default_language' ); $this->user_admin_def_lang = $this->user_admin_def_lang === '_default_' ? $this->sitepress->get_default_language() : $this->user_admin_def_lang; $this->lang_details = $this->sitepress->get_language_details( $this->user_admin_def_lang ); $this->admin_default_language = $this->lang_details['display_name']; $this->admin_language = $this->sitepress->get_admin_language(); $user_language_for_all_languages = $this->user_admin_def_lang; if ( $this->user_language ) { $user_language_for_all_languages = $this->user_language; } $this->all_languages = $this->sitepress->get_languages( $user_language_for_all_languages ); } /** * @return string the html for the user profile edit screen element WPML * adds to it */ public function render() { $wp_api = $this->sitepress->get_wp_api(); $hide_wpml_languages = $wp_api->version_compare_naked( get_bloginfo( 'version' ), '4.7', '>=' ) ? 'style="display: none"' : ''; ob_start(); $admin_default_language_selected = $this->user_language === $this->user_admin_def_lang; ?>

> get_hidden_languages_options( $use_admin_language_for_edit ); do_action( 'wpml_user_profile_options', $this->current_user->ID ); return ob_get_clean(); } /** * @param $use_admin_language_for_edit */ private function get_hidden_languages_options( $use_admin_language_for_edit ) { $wp_api = $this->sitepress->get_wp_api(); if ( $wp_api->current_user_can( 'translate' ) || $wp_api->current_user_can( 'manage_options' ) ) { $hidden_languages = $this->sitepress->get_setting( 'hidden_languages' ); $display_hidden_languages = $wp_api->get_user_meta( $this->current_user->ID, 'icl_show_hidden_languages', true ); ?> />  

all_languages[ end( $hidden_languages ) ]['display_name'] ) ); } else { $hidden_languages_array = array(); foreach ( (array) $hidden_languages as $l ) { $hidden_languages_array[] = $this->all_languages[ $l ]['display_name']; } $hidden_languages = implode( ', ', $hidden_languages_array ); echo esc_html( sprintf( __( '%s are currently hidden to visitors.', 'sitepress' ), $hidden_languages ) ); } } else { esc_html_e( 'All languages are currently displayed. Choose what to do when site languages are hidden.', 'sitepress' ); } ?>

/>