This commit is contained in:
Nikita Sinelnikov
2022-10-24 17:34:54 +03:00
parent af13de140a
commit fac2f9fdc5
4 changed files with 61 additions and 29 deletions
+40 -12
View File
@@ -657,19 +657,47 @@ if ( ! class_exists( 'um\core\Form' ) ) {
$v = sanitize_text_field( $form[ $k ] );
// Make a proper social link
if ( ! empty( $v ) && ! strstr( $v, $f['match'] ) ) {
$domain = trim( strtr( $f['match'], array(
'https://' => '',
'http://' => '',
) ), ' /' );
if ( ! empty( $v ) ) {
$replace_match = is_array( $f['match'] ) ? $f['match'][0] : $f['match'];
if ( ! strstr( $v, $domain ) ) {
$v = $f['match'] . $v;
} else {
$v = 'https://' . trim( strtr( $v, array(
'https://' => '',
'http://' => '',
) ), ' /' );
$need_replace = false;
if ( is_array( $f['match'] ) ) {
$need_replace = true;
foreach ( $f['match'] as $arr_match ) {
if ( strstr( $v, $arr_match ) ) {
$need_replace = false;
}
}
}
if ( ! is_array( $f['match'] ) || $need_replace ) {
if ( ! strstr( $v, $replace_match ) ) {
$domain = trim(
strtr(
$replace_match,
array(
'https://' => '',
'http://' => '',
)
),
' /'
);
if ( ! strstr( $v, $domain ) ) {
$v = $replace_match . $v;
} else {
$v = 'https://' . trim(
strtr(
$v,
array(
'https://' => '',
'http://' => '',
)
),
' /'
);
}
}
}
}