PHP社交分享添加计数器

时间:2013-02-09 15:50:54

标签: php

这是一个社交共享脚本。我想回显每个数组以显示链接。请问有人能解释我怎么做?

这是分享按钮部分

function simple_social_sharing( $attr_twitter = null, $attr_items = null ) {

    $share_items = array ();

    // set each item
    $item_facebook = array(
        "class" => "facebook",
        "href" => "http://www.facebook.com/sharer.php?u={$url}&t={$browser_title_encoded}",
        "text" => "Share on Facebook"
    );
    $item_twitter = array(
        "class" => "twitter",
        "href" => "http://twitter.com/share?text={$page_title_encoded}&url={$url}&via={$twitter_account}",
        "text" => "Share on Twitter"
    );

    // test whether to display each item
    if($item_toggles) {
        // explode into array
        $item_toggles_array = explode( ",", $item_toggles );
        // set each item on or off
        $show_facebook = $item_toggles_array['0'];
        $show_twitter = $item_toggles_array['1'];
    }
    else {
        $display_all_items = 1;
    }

    // form array of items set to 1
    if( $show_facebook==1 || $display_all_items ) {
        array_push( $share_items, $item_facebook );
    }
    if( $show_twitter==1 || $display_all_items) {
        array_push( $share_items, $item_twitter );
    }

    // if one or more items
    if ( ! empty( $share_items ) ) {
        // create output
        foreach ( $share_items as $share_item ) {   
            $share_output = "<a class=\"ss-share-link ico-{$share_item['class']}\" href=\"{$share_item["href"]}\" rel=\"nofollow\" target=\"_blank\">{$share_item['text']}</a>\n";      
        }
        // echo output
        echo $share_output;
    }

}

我试过这样做 echo simple_social_sharing($ share_output [1]); 但是没有用。

0 个答案:

没有答案