account.php
1 month ago
header.php
1 month ago
preferences.php
1 month ago
reset-password-modal.php
1 month ago
security.php
1 month ago
social-accounts.php
1 month ago
withdraw.php
1 month ago
social-accounts.php
72 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Settings Social Profile Link |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @author Themeum |
| 7 | * @link https://themeum.com |
| 8 | * @since 4.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | use TUTOR\Icon; |
| 14 | use Tutor\Components\SvgIcon; |
| 15 | use Tutor\Components\InputField; |
| 16 | use Tutor\Components\Constants\InputType; |
| 17 | |
| 18 | $user = wp_get_current_user(); |
| 19 | |
| 20 | $social_fields = tutor_utils()->tutor_user_social_icons(); |
| 21 | |
| 22 | $social_links = array(); |
| 23 | foreach ( $social_fields as $key => $field ) { |
| 24 | $social_links[ $key ] = get_user_meta( $user->ID, $key, true ); |
| 25 | } |
| 26 | |
| 27 | ?> |
| 28 | |
| 29 | <section class="tutor-social-accounts"> |
| 30 | <h5 class="tutor-h5 tutor-md-hidden tutor-my-none"><?php echo esc_html__( 'Social Profile Link', 'tutor' ); ?></h5> |
| 31 | <form |
| 32 | id="<?php echo esc_attr( $form_id ); ?>" |
| 33 | x-data='tutorForm({ |
| 34 | id: "<?php echo esc_attr( $form_id ); ?>", |
| 35 | mode: "onChange", |
| 36 | shouldFocusError: true, |
| 37 | defaultValues: <?php echo esc_attr( wp_json_encode( $social_links ) ); ?> |
| 38 | })' |
| 39 | x-bind="getFormBindings()" |
| 40 | @submit="handleSubmit((data) => handleSaveSocialProfile(data, '<?php echo esc_attr( $form_id ); ?>'))($event)" |
| 41 | class="tutor-card tutor-social-form" |
| 42 | > |
| 43 | <?php do_action( 'tutor_profile_edit_before_social_media', $user ); ?> |
| 44 | |
| 45 | <?php foreach ( $social_fields as $key => $field ) : ?> |
| 46 | <div class='tutor-social-field'> |
| 47 | <!-- Social icon --> |
| 48 | <div class="tutor-social-icon"> |
| 49 | <?php SvgIcon::make()->name( $field['svg_icon'] )->size( 20 )->render(); ?> |
| 50 | </div> |
| 51 | <?php |
| 52 | $message = sprintf( |
| 53 | /* translators: field label */ |
| 54 | __( 'Please enter a valid %s URL', 'tutor' ), |
| 55 | $field['label'] |
| 56 | ); |
| 57 | |
| 58 | InputField::make() |
| 59 | ->type( InputType::TEXT ) |
| 60 | ->id( $key ) |
| 61 | ->name( $key ) |
| 62 | ->label( $field['label'] ) |
| 63 | ->clearable() |
| 64 | ->placeholder( $field['placeholder'] ) |
| 65 | ->attr( 'x-bind', "register('$key', { pattern: { value: /$field[pattern]/i, message: '" . esc_js( $message ) . "' } })" ) |
| 66 | ->render(); |
| 67 | ?> |
| 68 | </div> |
| 69 | <?php endforeach; ?> |
| 70 | </form> |
| 71 | </section> |
| 72 |