From 055f7984c87778a79af74c94d9092be07eef2a01 Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 18 Jan 2023 13:47:07 +0200 Subject: [PATCH] - add tiktok --- includes/core/class-builtin.php | 17 +++++++++++++++++ includes/core/um-actions-form.php | 11 +++++++++-- includes/core/um-filters-fields.php | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php index a296437a..cf6bd47c 100644 --- a/includes/core/class-builtin.php +++ b/includes/core/class-builtin.php @@ -1057,6 +1057,22 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { 'validate' => 'discord', ), + 'tiktok' => array( + 'title' => __('TikTok','ultimate-member'), + 'metakey' => 'tiktok', + 'type' => 'url', + 'label' => __('TikTok','ultimate-member'), + 'required' => 0, + 'public' => 1, + 'editable' => 1, + 'url_target' => '_blank', + 'url_rel' => 'nofollow', + 'validate' => 'tiktok_url', + 'url_text' => 'TikTok', + 'advanced' => 'social', + 'match' => 'https://tiktok.com/@', + ), + 'youtube' => array( 'title' => __( 'YouTube', 'ultimate-member' ), 'metakey' => 'youtube', @@ -1487,6 +1503,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) { $array['youtube_url'] = __('YouTube Profile','ultimate-member'); $array['telegram_url'] = __('Telegram URL','ultimate-member'); $array['discord'] = __('Discord ID','ultimate-member'); + $array['tiktok_url'] = __('TikTok URL','ultimate-member'); $array['custom'] = __('Custom Validation','ultimate-member'); /** diff --git a/includes/core/um-actions-form.php b/includes/core/um-actions-form.php index 16adb5d5..c45ce4bb 100644 --- a/includes/core/um-actions-form.php +++ b/includes/core/um-actions-form.php @@ -770,6 +770,13 @@ function um_submit_form_errors_hook_( $args ) { } break; + case 'tiktok_url': + + if ( ! UM()->validation()->is_url( $args[ $key ], 'tiktok.com' ) ) { + UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) ); + } + break; + case 'url': if ( ! UM()->validation()->is_url( $args[ $key ] ) ) { UM()->form()->add_error( $key, __( 'Please enter a valid URL', 'ultimate-member' ) ); @@ -878,7 +885,7 @@ function um_submit_form_errors_hook_( $args ) { } } break; - + case 'alphabetic': if ( $args[ $key ] != '' ) { @@ -886,7 +893,7 @@ function um_submit_form_errors_hook_( $args ) { if ( ! preg_match( '/^\p{L}+$/u', str_replace( ' ', '', $args[ $key ] ) ) ) { UM()->form()->add_error( $key, __( 'You must provide alphabetic letters', 'ultimate-member' ) ); } - + } break; diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index 29527944..6c5ac23b 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -434,6 +434,7 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) { if ( $data['validate'] == 'linkedin_url' ) $value = 'https://linkedin.com/' . $value; if ( $data['validate'] == 'googleplus_url' ) $value = 'https://plus.google.com/' . $value; if ( $data['validate'] == 'instagram_url' ) $value = 'https://instagram.com/' . $value; + if ( $data['validate'] == 'tiktok_url' ) $value = 'https://tiktok.com/' . $value; if ( $data['validate'] == 'vk_url' ) $value = 'https://vk.com/' . $value; }