Advertisement
palsushobhan

vendor-website-on-social-tab

Apr 25th, 2024
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 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.     $website = $social_accounts['website'] ?? '';
  5.     return array_merge(
  6.         $social_fields,
  7.         array(
  8.             "website" => array(
  9.                 'label' => __('Website', 'wc-frontend-manager') ,
  10.                 'type' => 'text',
  11.                 'class' => 'wcfm-text wcfm_ele',
  12.                 'label_class' => 'wcfm_title wcfm_ele',
  13.                 'value' => $website,
  14.                 'placeholder' => __('website address', '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.         ['website' => 'website',]
  24.     );
  25. });
  26.  
  27. add_action('wcfmmp_store_after_social', function($vendor_id) {
  28.     ?>
  29.     <style>
  30.         .store-website-logo{
  31.             display: block;
  32.             margin-top: 50%;
  33.             transform: translateY(-50%);
  34.         }
  35.     </style>
  36.     <?php
  37.     $store_info = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
  38.     if( isset( $store_info['social']['website'] ) && !empty( $store_info['social']['website'] ) ) { ?>
  39.         <li><a href="<?php echo esc_url( $store_info['social']['website'] ); ?>" class="store-website-logo" target="_blank">
  40.         <i class="wcfmfa fa-globe" aria-hidden="true"></i>
  41.         </a></li>
  42.     <?php }
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement