snipt

Ctrl+h for KB shortcuts

PHP

Social sharing links, properly sanitized

1
2
3
4
5
6
7
<?php
$share_title = get_the_title();
$share_link  = get_permalink();
?>
<a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode($share_link); ?>" class="share-link facebook" target="_blank"><?php get_inline_svg('icon-social-facebook-f.svg'); ?><span class="screen-reader-text">Share on Facebook</span></a>
<a href="https://twitter.com/intent/tweet?url=<?php echo urlencode($share_link); ?>&amp;via=vital_design&amp;text=<?php echo esc_attr($share_title); ?>" class="share-link twitter" target="_blank"><?php get_inline_svg('icon-social-twitter.svg'); ?><span class="screen-reader-text">Share on Twitter</span></a>
<a href="mailto:?subject=<?php echo esc_attr($share_title); ?>&body=<?php echo esc_attr($share_title); ?>%0A<?php echo esc_url($share_link); ?>" class="share-link email"><?php get_inline_svg('icon-social-email.svg'); ?><span class="screen-reader-text">Share via Email</span></a>
https://snipt.net/embed/9b7efb032b0042ce48cd398c504f7ed8/
https://snipt.net/raw/9b7efb032b0042ce48cd398c504f7ed8/
9b7efb032b0042ce48cd398c504f7ed8
php
PHP
7
2016-09-24T09:26:12
True
False
False
Aug 12, 2016 at 04:05 PM
/api/public/snipt/147552/
social-sharing-links-properly-sanitized
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">$share_title</span> <span class="o">=</span> <span class="nx">get_the_title</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$share_link</span> <span class="o">=</span> <span class="nx">get_permalink</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a><span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-5"><a name="L-5"></a><span class="x">&lt;a href=&quot;http://www.facebook.com/sharer.php?u=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nb">urlencode</span><span class="p">(</span><span class="nv">$share_link</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&quot; class=&quot;share-link facebook&quot; target=&quot;_blank&quot;&gt;</span><span class="cp">&lt;?php</span> <span class="nx">get_inline_svg</span><span class="p">(</span><span class="s1">&#39;icon-social-facebook-f.svg&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&lt;span class=&quot;screen-reader-text&quot;&gt;Share on Facebook&lt;/span&gt;&lt;/a&gt;</span> </span><span id="L-6"><a name="L-6"></a><span class="x">&lt;a href=&quot;https://twitter.com/intent/tweet?url=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nb">urlencode</span><span class="p">(</span><span class="nv">$share_link</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&amp;amp;via=vital_design&amp;amp;text=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_attr</span><span class="p">(</span><span class="nv">$share_title</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&quot; class=&quot;share-link twitter&quot; target=&quot;_blank&quot;&gt;</span><span class="cp">&lt;?php</span> <span class="nx">get_inline_svg</span><span class="p">(</span><span class="s1">&#39;icon-social-twitter.svg&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&lt;span class=&quot;screen-reader-text&quot;&gt;Share on Twitter&lt;/span&gt;&lt;/a&gt;</span> </span><span id="L-7"><a name="L-7"></a><span class="x">&lt;a href=&quot;mailto:?subject=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_attr</span><span class="p">(</span><span class="nv">$share_title</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&amp;body=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_attr</span><span class="p">(</span><span class="nv">$share_title</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">%0A</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">esc_url</span><span class="p">(</span><span class="nv">$share_link</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&quot; class=&quot;share-link email&quot;&gt;</span><span class="cp">&lt;?php</span> <span class="nx">get_inline_svg</span><span class="p">(</span><span class="s1">&#39;icon-social-email.svg&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">&lt;span class=&quot;screen-reader-text&quot;&gt;Share via Email&lt;/span&gt;&lt;/a&gt;</span> </span></pre></div> </td></tr></table>
sanitize, security, share, social, validate

HTML

Like and +1 buttons per domain

1
2
3
4
5
6
7
<!-- replace domain --> 
<!-- Let's social --> 
            <div style="text-align:right;width:100%;display:block;"> 
                <g:plusone href="DOMAIN" size="medium"></g:plusone><script type="text/javascript">  window.___gcfg = {lang: 'ro'};  (function() {    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;    po.src = 'https://apis.google.com/js/plusone.js';    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);  })();</script> 
                <div id="fb-root" style="display:inline-block;"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="DOMAIN" send="true" layout="button_count" show_faces="true" font="arial"></fb:like> 
            </div> 
        <!-- END Let's social -->    
https://snipt.net/embed/b618c0e481b6446ab685f4a971dfd0cc/
https://snipt.net/raw/b618c0e481b6446ab685f4a971dfd0cc/
b618c0e481b6446ab685f4a971dfd0cc
html
HTML
7
2016-09-25T18:22:32
True
False
False
/api/public/snipt/28960/
like-and-1-buttons-per-domain
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c">&lt;!-- replace domain --&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="c">&lt;!-- Let&#39;s social --&gt;</span> </span><span id="L-3"><a name="L-3"></a> <span class="nt">&lt;div</span> <span class="na">style=</span><span class="s">&quot;text-align:right;width:100%;display:block;&quot;</span><span class="nt">&gt;</span> </span><span id="L-4"><a name="L-4"></a> <span class="nt">&lt;g:plusone</span> <span class="na">href=</span><span class="s">&quot;DOMAIN&quot;</span> <span class="na">size=</span><span class="s">&quot;medium&quot;</span><span class="nt">&gt;&lt;/g:plusone&gt;&lt;script </span><span class="na">type=</span><span class="s">&quot;text/javascript&quot;</span><span class="nt">&gt;</span> <span class="nb">window</span><span class="p">.</span><span class="nx">___gcfg</span> <span class="o">=</span> <span class="p">{</span><span class="nx">lang</span><span class="o">:</span> <span class="s1">&#39;ro&#39;</span><span class="p">};</span> <span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <span class="kd">var</span> <span class="nx">po</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">&#39;script&#39;</span><span class="p">);</span> <span class="nx">po</span><span class="p">.</span><span class="nx">type</span> <span class="o">=</span> <span class="s1">&#39;text/javascript&#39;</span><span class="p">;</span> <span class="nx">po</span><span class="p">.</span><span class="nx">async</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span> <span class="nx">po</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="s1">&#39;https://apis.google.com/js/plusone.js&#39;</span><span class="p">;</span> <span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;script&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span> <span class="nx">s</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">.</span><span class="nx">insertBefore</span><span class="p">(</span><span class="nx">po</span><span class="p">,</span> <span class="nx">s</span><span class="p">);</span> <span class="p">})();</span><span class="nt">&lt;/script&gt;</span> </span><span id="L-5"><a name="L-5"></a> <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;fb-root&quot;</span> <span class="na">style=</span><span class="s">&quot;display:inline-block;&quot;</span><span class="nt">&gt;&lt;/div&gt;&lt;script </span><span class="na">src=</span><span class="s">&quot;http://connect.facebook.net/en_US/all.js#xfbml=1&quot;</span><span class="nt">&gt;&lt;/script&gt;&lt;fb:like</span> <span class="na">href=</span><span class="s">&quot;DOMAIN&quot;</span> <span class="na">send=</span><span class="s">&quot;true&quot;</span> <span class="na">layout=</span><span class="s">&quot;button_count&quot;</span> <span class="na">show_faces=</span><span class="s">&quot;true&quot;</span> <span class="na">font=</span><span class="s">&quot;arial&quot;</span><span class="nt">&gt;&lt;/fb:like&gt;</span> </span><span id="L-6"><a name="L-6"></a> <span class="nt">&lt;/div&gt;</span> </span><span id="L-7"><a name="L-7"></a> <span class="c">&lt;!-- END Let&#39;s social --&gt;</span> </span></pre></div> </td></tr></table>
social

HTML

social icons

1
2
3
4
5
6
7
8
<div id="social"style="padding-top: 7px;">
                <a rel="nofollow" target="_blank" href="http://www.facebook.com"><img src="/content/social/facebook.png"></a>
                <a href="http://www.yourblog.com"><img src="/content/social/feed.png"></a>
                <a rel="nofollow" target="_blank" href="http://www.twitter.com"><img src="/content/social/twitter.png"></a>
                <a rel="nofollow" target="_blank" href="http://www.linkedin.com"><img src="/content/social/linkedin.png"></a>
                <a rel="nofollow" target="_blank" href="http://www.youtube.com"><img src="/content/social/youtube.png"></a>
                <a href="mailto:someone@example.com"><img src="/content/social/email.png"></a>
</div>
https://snipt.net/embed/50ac6a191d79bc0813329bfa72793f67/
https://snipt.net/raw/50ac6a191d79bc0813329bfa72793f67/
50ac6a191d79bc0813329bfa72793f67
html
HTML
8
2016-09-22T00:51:52
True
False
False
/api/public/snipt/28271/
social-icons
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;social&quot;</span><span class="na">style=</span><span class="s">&quot;padding-top: 7px;&quot;</span><span class="nt">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="nt">&lt;a</span> <span class="na">rel=</span><span class="s">&quot;nofollow&quot;</span> <span class="na">target=</span><span class="s">&quot;_blank&quot;</span> <span class="na">href=</span><span class="s">&quot;http://www.facebook.com&quot;</span><span class="nt">&gt;&lt;img</span> <span class="na">src=</span><span class="s">&quot;/content/social/facebook.png&quot;</span><span class="nt">&gt;&lt;/a&gt;</span> </span><span id="L-3"><a name="L-3"></a> <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">&quot;http://www.yourblog.com&quot;</span><span class="nt">&gt;&lt;img</span> <span class="na">src=</span><span class="s">&quot;/content/social/feed.png&quot;</span><span class="nt">&gt;&lt;/a&gt;</span> </span><span id="L-4"><a name="L-4"></a> <span class="nt">&lt;a</span> <span class="na">rel=</span><span class="s">&quot;nofollow&quot;</span> <span class="na">target=</span><span class="s">&quot;_blank&quot;</span> <span class="na">href=</span><span class="s">&quot;http://www.twitter.com&quot;</span><span class="nt">&gt;&lt;img</span> <span class="na">src=</span><span class="s">&quot;/content/social/twitter.png&quot;</span><span class="nt">&gt;&lt;/a&gt;</span> </span><span id="L-5"><a name="L-5"></a> <span class="nt">&lt;a</span> <span class="na">rel=</span><span class="s">&quot;nofollow&quot;</span> <span class="na">target=</span><span class="s">&quot;_blank&quot;</span> <span class="na">href=</span><span class="s">&quot;http://www.linkedin.com&quot;</span><span class="nt">&gt;&lt;img</span> <span class="na">src=</span><span class="s">&quot;/content/social/linkedin.png&quot;</span><span class="nt">&gt;&lt;/a&gt;</span> </span><span id="L-6"><a name="L-6"></a> <span class="nt">&lt;a</span> <span class="na">rel=</span><span class="s">&quot;nofollow&quot;</span> <span class="na">target=</span><span class="s">&quot;_blank&quot;</span> <span class="na">href=</span><span class="s">&quot;http://www.youtube.com&quot;</span><span class="nt">&gt;&lt;img</span> <span class="na">src=</span><span class="s">&quot;/content/social/youtube.png&quot;</span><span class="nt">&gt;&lt;/a&gt;</span> </span><span id="L-7"><a name="L-7"></a> <span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">&quot;mailto:someone@example.com&quot;</span><span class="nt">&gt;&lt;img</span> <span class="na">src=</span><span class="s">&quot;/content/social/email.png&quot;</span><span class="nt">&gt;&lt;/a&gt;</span> </span><span id="L-8"><a name="L-8"></a><span class="nt">&lt;/div&gt;</span> </span></pre></div> </td></tr></table>
social

JavaScript

Official Facebook Share button in Wordpress

1
2
3
4
<a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

/*compact version*/
<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
https://snipt.net/embed/a8df990f7464faf49b7d75bc6f309e90/
https://snipt.net/raw/a8df990f7464faf49b7d75bc6f309e90/
a8df990f7464faf49b7d75bc6f309e90
js
JavaScript
4
2016-09-26T00:00:48
True
False
False
/api/public/snipt/26752/
official-facebook-share-button-in-wordpress
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="o">&lt;</span><span class="nx">a</span> <span class="nx">name</span><span class="o">=</span><span class="s2">&quot;fb_share&quot;</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;box_count&quot;</span> <span class="nx">href</span><span class="o">=</span><span class="s2">&quot;http://www.facebook.com/sharer.php&quot;</span><span class="o">&gt;</span><span class="nx">Share</span><span class="o">&lt;</span><span class="sr">/a&gt;&lt;script src=&quot;http:/</span><span class="o">/</span><span class="kr">static</span><span class="p">.</span><span class="nx">ak</span><span class="p">.</span><span class="nx">fbcdn</span><span class="p">.</span><span class="nx">net</span><span class="o">/</span><span class="nx">connect</span><span class="p">.</span><span class="nx">php</span><span class="o">/</span><span class="nx">js</span><span class="o">/</span><span class="nx">FB</span><span class="p">.</span><span class="nx">Share</span><span class="s2">&quot; type=&quot;</span><span class="nx">text</span><span class="o">/</span><span class="nx">javascript</span><span class="s2">&quot;&gt;&lt;/script&gt;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="s2">/*compact version*/</span> </span><span id="L-4"><a name="L-4"></a><span class="s2">&lt;a name=&quot;</span><span class="nx">fb_share</span><span class="s2">&quot; type=&quot;</span><span class="nx">button_count</span><span class="s2">&quot; href=&quot;</span><span class="nx">http</span><span class="o">:</span><span class="c1">//www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</span> </span></pre></div> </td></tr></table>
share, social, wordpress
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.