Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

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-12-06T12:39:54
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></span><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

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-12-06T17:51:20
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></span><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 [email protected].