sitepress = $sitepress; $this->url_converter = $wpml_url_converter; $this->http_client = $client; } public function get_validation_url( $sample_lang_code ) { $url_glue = false === strpos ( $this->posted_url, '?' ) ? '?' : '&'; return $this->get_sample_url ( $sample_lang_code ) . $url_glue . '____icl_validate_directory=1'; } public function validate_langs_in_dirs( $sample_lang ) { $icl_folder_url_disabled = true; $validation_url = $this->get_validation_url( $sample_lang ); $response = $this->do_request( $validation_url ); if ( $response ) { $validation_token = ''; $is_wp_error = is_wp_error( $response ); $is_self_signed_certificate_error = isset( $response->errors['http_request_failed'] ) && $response->errors['http_request_failed'][0] === 'SSL certificate problem: self signed certificate'; $is_valid_response = ! $is_wp_error && isset( $response['response']['code'] ) && ( '200' === (string) $response['response']['code'] ); if ( ( $is_valid_response && false !== strpos( $response['body'], $validation_token ) ) || ( $is_wp_error && $is_self_signed_certificate_error ) ) { $icl_folder_url_disabled = false; } } return $icl_folder_url_disabled; } public function print_error_response() { $response = $this->response; $output = ''; if ( is_wp_error ( $response ) ) { $output .= ''; $output .= $response->get_error_message (); $output .= ''; } elseif ( $response[ 'response' ][ 'code' ] != '200' ) { $output .= ''; $output .= sprintf ( __ ( 'HTTP code: %s (%s)', 'sitepress' ), $response[ 'response' ][ 'code' ], $response[ 'response' ][ 'message' ] ); $output .= ''; } else { $output .= '