PHP code example of rezozero / social-links

1. Go to this page and download the library: Download rezozero/social-links library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rezozero / social-links example snippets


// Construct a new SocialLinks
$share = new \RZ\SocialLinks\SocialLinks(array(
    'url' => 'http://www.rezo-zero.com',
    'title' => 'REZO ZERO website homepage',
    // Optional image source url for pinterest. must be at least 200px by 200px, if you intent to use for facebook
    'imageUrl' => 'http://www.rezo-zero.com/templates/rezo-zero/img/apple-icon.png',
    // Optional status for overriding title for twitter, whatsapp and emails body
    'status' => 'Hey! Look at this awesome website.'
));

// Set link class prefix
$share->setClassPrefix('social-link');

// Set social icons class prefix
// Use fa for Font Awesome or an
// other for a custom icon set.
$share->setIconPrefix('fa');

// Optional:
// Set link additional classes, for example
// to add "btn" bootstrap classes.
$share->setLinkClasses('btn btn-default');

echo $share->getUrl('twitter');

// https://twitter.com/intent/tweet?text=Hey%21%20Look%20at%20this%20awesome%20website.%20%E2%80%94%20http%3A%2F%2Fwww.rezo-zero.com

$share->setClassPrefix('social-link');
$share->setIconPrefix('fa');
echo $share->getLink('facebook', $share->getIcon('facebook'));

// <a class="social-link social-link-facebook" target="_blank" rel="nofollow" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.rezo-zero.com"><i class="social-link-icon fa fa-brands fa-square-facebook"></i><span class="social-link-name">Facebook</span></a>

$share->setClassPrefix('social-link');
$share->setIconPrefix('fa');
echo $share->getLink('facebook', $share->getUseSVG('facebook'));

// <a class="social-link social-link-facebook" target="_blank" rel="nofollow" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.rezo-zero.com"><svg class="social-link-icon fa fa-brands fa-square-facebook"><use xlink:href="#fa-facebook"></use></svg><span class="social-link-name">Facebook</span></a>

echo $share->getLinks(array('facebook', 'twitter', 'linked-in'));

echo $share->getLinksWithIcon(array('facebook', 'twitter', 'linked-in'));

echo $share->getLinksWithSVG(array('facebook', 'twitter', 'linked-in'));

echo $share->getLinksWithIcon(array('facebook', 'twitter', 'linked-in'), ' - ');

$twig->addExtension(new \RZ\SocialLinks\Twig\SocialLinksExtension());