为什么此功能仅适用于访问者?

时间:2016-11-29 08:38:14

标签: php wordpress

以下代码仅适用于访问者,但如果我将include()替换为socials-links.php内容,则对访问者和用户都可以正常运行。那么,{{有什么问题? 1}}。  这是代码:

include()

这是social-links.php内容:

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' );
      }

  }

Css与social_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>

1 个答案:

答案 0 :(得分:0)

在这种情况下,admin

的包含文件中存在一个条件
include( $them_uri.'/social-links.php' );

您的代码在条件标记内变形。

if (!is_admin()):

end if;