Advertisement
palsushobhan

wcfm-vendor-tiktok-social-link-support

Jan 25th, 2023
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. add_filter('wcfm_profile_fields_social', function($social_fields, $vendor_id) {
  2.     $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
  3.     $social_accounts = $vendor_data['social'] ?? array();
  4.     $tiktok = $social_accounts['tiktok'] ?? '';
  5.     return array_merge(
  6.         $social_fields,
  7.         array(
  8.             "tiktok" => array(
  9.                 'label' => __('TikTok', 'wc-frontend-manager') ,
  10.                 'type' => 'text',
  11.                 'class' => 'wcfm-text wcfm_ele',
  12.                 'label_class' => 'wcfm_title wcfm_ele',
  13.                 'value' => $tiktok,
  14.                 'placeholder' => __('TikTok Handler', 'wc-frontend-manager')
  15.             )
  16.         )
  17.     );
  18. }, 10, 2);
  19.  
  20. add_filter('wcfm_profile_social_types', function($types) {
  21.     return array_merge(
  22.         $types,
  23.         ['tiktok' => 'tiktok',]
  24.     );
  25. });
  26.  
  27. add_action('wcfmmp_store_after_social', function($vendor_id) {
  28.     $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
  29.     if( isset( $store_info['social']['tiktok'] ) && !empty( $store_info['social']['tiktok'] ) ) { ?>
  30.         <li><a href="<?php echo wcfmmp_generate_social_url( $store_info['social']['tiktok'], 'tiktok' ); ?>" target="_blank"><i class="wcfmfa fa-link" aria-hidden="true"></i></a></li>
  31.     <?php }
  32. });
  33.  
  34. add_filter('wcfm_social_url', function($social_handle, $social) {
  35.     if( $social == 'tiktok' && strpos( $social_handle, 'tiktok' ) === false) {
  36.         $social_handle = 'https://tiktok.com/' . $social_handle;
  37.     }
  38.     return $social_handle;
  39. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement