2016-11-29 2 views
0

次のコードは訪問者のみに有効ですが、socials-links.phpの内容でinclude()を置き換えた場合、訪問者とユーザーの両方にとって問題ありません。include()の問題点は何ですか? はここにコードされていますこの機能が訪問者にのみ機能するのはなぜですか?

function render_social_links() { 
$current_post_id=get_the_ID(); 
$them_uri = get_stylesheet_directory_uri(); 
$featured_image_url = ''; 
if (has_post_thumbnail($current_post_id)) { 
    $featured_image_id = get_post_thumbnail_id($current_post_id); 
    $featured_image_url = $featured_image_id ? wp_get_attachment_url($featured_image_id) : ''; 
} 
if(is_home() || is_single()){ 
     if(is_home()){ 
     $bitlink = $lnk = get_bloginfo('url'); 
     $bitly = getBitly($bitlink); 
     $nam = get_bloginfo('name'); 
     } 
     elseif(is_single($current_post_id)){ 
      $bitlink = $lnk = get_permalink($current_post_id); 
      $bitly = getBitly($bitlink); 
      $nam = get_the_title($current_post_id); 
     } 
     $bitlink =esc_url($bitlink); 
     $lnk = esc_url($lnk); 
     $nam= esc_attr($nam); 
     $bitly = esc_url($bitly); 
     include($them_uri.'/social-links.php'); 
     } 

    } 

ここでは、ソーシャル・links.phpの内容です:

<div id="socialleft"> 
    <ul> 
     <li> 
     <img src="'.$them_uri.'/images/social/share-38.png" alt=""/> 
     </li> 
    <li> 
      <a href="http://www.facebook.com/sharer.php?u='.$lnk.'&amp;t='.$nam.'" title="شارك على فيسبوك" target="_blank"> 
     </li> 
      <img src="'.$them_uri.'/images/social/facebook-38.png" alt="" /> 
      </a> 
     </li> 
     <li> 
     <a href="http://twitter.com/home/?status='.$nam.' : '.$bitly.'" title="غرد" target="_blank"> 
     <img src="'.$them_uri.'/images/social/twitter-38.png" alt="" /> 
     </a> 
    </li> 
    <li> 
    <a href="https://plus.google.com/share?url='.$lnk.'" onclick="javascript:window.open(this.href,\'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=60\');return false;" title="شارك على جوجل+" target="_blank"> 
<img src="'.$them_uri.'/images/social/Google-plus-38.png" alt="" /> 
     </a> 
    </li> 
    </ul> 
</div> 

とCSS social_links.phpに関連:

#socialleft{ 
    position:fixed; 
    top: 35%; 
    left: 0; 
    height:100%; 
    width:45px; 
    margin-left:15px; 
    display:block; 
    z-index:100; 
    transition: width ease .5s;  
    } 
+0

だから、問題はどこにありますか? –

+0

問題はIncludeが出力を訪問者のみに利用可能にすることですが、私(管理者)または他のユーザーがログインしたときに出力がないときに、私は何を求めているのですか? –

+0

デバッグとチェックを有効にしてください –

答えて

0

この場合あり管理用インクルードファイルの条件

include($them_uri.'/social-links.php'); 

あなたのコードは条件付きタグ内で変形されています。

if (!is_admin()): 

end if; 
+0

ファイルは、私が 'get_stylesheet_directory_uri();'を使用している理由の子テーマの中に存在します。しかし、ログインしていないユーザーのみ –

+0

共有ファイルsocial-links.php –

+0

条件付きタグの中に歪んでいないので、少なくとも管理者にとってはうまくいくはずだが、訪問者のみに有効 –

関連する問題