Social Sharing Links Code Snippets

This topic was published by and viewed 2266 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts

  • DevynCJohnson
    Keymaster
    • Topics - 437
    • @devyncjohnson

    Numerous websites have social bookmarking and sharing links. Obviously, many web developers want to add social sharing links and bookmarking links to their web-pages. Below are code snippets for adding these links to PHP code. If static (plain HTML) code is desired, then replace the single-quotes, concatenation periods, and the PHP variables with the desired static data.

    PHP Variables

    • Page Title - $EN_TITLE=urlencode(get_the_title());
    • Page URL - $EN_URL=urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    • Site Link - $EN_SITE=urlencode('https://dcjtech.info/');

    Social Sharing Code

    Usage Example

    DCJTech uses the below code for its social sharing links.

    <div class="share sharing"><h6>Share</h6>
    <?php
    $EN_TITLE=urlencode(get_the_title());
    $EN_URL=urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    $EN_SITE=urlencode('https://dcjtech.info/');
    echo '<a href="http://del.icio.us/post?url='.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Delicious</a> | <a href="http://www.designfloat.com/submit.php?url='.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Design Float</a> | <a href="http://digg.com/submit?url='.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Digg</a> | <a href="https://www.facebook.com/sharer/sharer.php?u='.$EN_URL.'" target="_blank">Facebook</a> | <a href="https://plus.google.com/share?url='.$EN_URL.'" target="_blank">Google+</a> | ';
    echo '<a href="https://www.linkedin.com/shareArticle?mini=true&amp;url='.$EN_URL.'&amp;source='.$EN_SITE.'" target="_blank">LinkedIn</a> | <a href="http://www.myspace.com/Modules/PostTo/Pages/?u='.$EN_URL.'&amp;t='.$EN_TITLE.'" target="_blank">MySpace</a> | <a href="http://www.newsvine.com/_tools/seed&amp;save?u='.$EN_URL.'&amp;h='.$EN_TITLE.'" target="_blank">Newsvine</a> | <a href="https://www.pinterest.com/pin/create/button/?url='.$EN_URL.'" target="_blank">Pinterest</a> | ';
    echo '<a href="http://reddit.com/submit?url='.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">Reddit</a> | <a href="http://www.stumbleupon.com/submit?url='.$EN_URL.'&amp;title='.$EN_TITLE.'" target="_blank">StumbleUpon</a> | <a href="http://www.tumblr.com/share?v=3&amp;u='.$EN_URL.'&amp;t='.$EN_TITLE.'" target="_blank">Tumblr</a> | <a href="https://twitter.com/intent/tweet/?text='.$EN_TITLE.'&amp;url='.$EN_URL.'&amp;via=DevynCJohnson" target="_blank">Twitter</a> | ';
    echo '<a href="javascript:window.print();" title="Print page">Print</a>';?>
    </div>
Viewing 1 post (of 1 total)