2

This is a Social share script. I want to echo each Array to show the Links. Could somebody explain me please how I can do it?

This is the Share button Part

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

}

I have tried to do it by this way echo simple_social_sharing($share_output[1]); but did not worked.

4

0 に答える 0