PHP

2016-03-26 9 views
0

'da gösterilmiyorsa bir metin gösterme Sosyal medyadaki simgeleri gösteren bir kodum var. Fakat kullanıcı onları doldurmadığında, ortaya çıkmazlar. Hangi harika ama onları bir metin/link ile doldurmaya teşvik etmek istiyorum.PHP

<?php 
    add_filter("buddyboss_get_user_social_array", "buddyboss_user_social_remove_disabled"); //remove disabled. 

    //Allow users to display their social media links in their profiles. 
    $profile_social_media_links_switch = boss_get_option('profile_social_media_links_switch'); 
    if (! empty($profile_social_media_links_switch)): 
    $social_profiles = (array)boss_get_option('profile_social_media_links'); 

    foreach ($social_profiles as $social ): 

     if (empty($social['title'])) { 
      continue; 
     } 

     $social_key     = sanitize_title($social['title']); 
     $background_image_style  = ''; 
     $icon_url     = $social['thumb']; 
     $url      = buddyboss_get_user_social(bp_displayed_user_id(), $social_key); //Get user social link 

     //Set profile icon 
     if (! empty ($icon_url)) { 
      $background_image_style = "background-image: url($icon_url); background-size: cover;"; 
     } 
     ?> 
     <?php if (!empty($url)): ?> 
      <a class="btn" href="<?php echo $url; ?>" title="<?php echo esc_attr($social['title']); ?>" target="_blank"><i style="<?php echo $background_image_style ?>" class="alt-social-icon alt-<?php echo empty($background_image_style) ? $social_key : ''; ?>"></i> </a> 
     <?php endif; ?> 

    <?php endforeach; 
    endif; 
    ?> 

</div> 

Bu nasıl metin eklemek için: Burada

kodudur buradan Sosyal Profilleri Display ...

cevap

0

Ben ana hedefi yakalanmış ise, görüntülemek için gerekli olan sosyal_profiles olmaması durumunda Display your Social Profiles here... numaralı metin.

Hem boş hem de $profile_social_media_links_switch ve $social_profiles öğelerini işaretleyin.

<?php 
add_filter("buddyboss_get_user_social_array", "buddyboss_user_social_remove_disabled"); //remove disabled. 

//Allow users to display their social media links in their profiles. 
$profile_social_media_links_switch = boss_get_option('profile_social_media_links_switch'); 
if (! empty($profile_social_media_links_switch)) { 
    $social_profiles = (array)boss_get_option('profile_social_media_links'); 

    if (!empty($social_profiles)) { 
     foreach ($social_profiles as $social) { 
      if (empty($social['title'])) { 
       continue; 
      } 

      $social_key = sanitize_title($social['title']); 
      $background_image_style = ''; 
      $icon_url = $social['thumb']; 
      $url = buddyboss_get_user_social(bp_displayed_user_id(), $social_key); //Get user social link 

      //Set profile icon 
      if (!empty ($icon_url)) { 
       $background_image_style = "background-image: url($icon_url); background-size: cover;"; 
      } 

      if (!empty($url)) { ?> 
       <a class="btn" href="<?php echo $url; ?>" title="<?php echo esc_attr($social['title']); ?>" 
        target="_blank"><i 
         style="<?php echo $background_image_style ?>" 
         class="alt-social-icon alt-<?php echo empty($background_image_style) ? $social_key : ''; ?>"></i> 
       </a> 
      <?php 
      } 
     } 
    } else { 
     echo 'Display your Social Profiles here...'; 
    } 
} else { 
    echo 'Display your Social Profiles here...'; 
} 
?> 

</div> 
+0

Merhaba ve Cevabınız için teşekkür ederim: Bunlardan herhangi boşsa o zaman

bu kodu deneyin istediğiniz metni göstermek! Herhangi bir hata görüntülemiyor ama şu ya da çalışmıyor: (Belki başka bir çözüm? – FrenchyNYC

+0

Bu kod temelinde başka bir çözüm sunamıyorum. Eğer çalışırsa, bazı çıkışlar olmalıdır (simgeler, ya da bu satır). .') –

+0

Asla şanslı değilim, en basit kod benim için asla işe yaramaz: P yine de teşekkürler – FrenchyNYC