Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

JavaScript

hashbang stylesheet change

1
2
3
4
5
// Swaps out the screen stylesheet for a print stylesheet
if (window.location.hash == '#print=true') {
	var printcssuri = $('link[media=print]:first').attr('href');
	$('link[media=screen]:first').attr('href', printcssuri);
}
https://snipt.net/embed/8316e7f10fd7cefa41accd90fe1f4036/
https://snipt.net/raw/8316e7f10fd7cefa41accd90fe1f4036/
8316e7f10fd7cefa41accd90fe1f4036
js
JavaScript
5
2016-12-10T05:40:54
True
False
False
Mar 18, 2014 at 03:12 AM
/api/public/snipt/122666/
hashbang-stylesheet-change
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// Swaps out the screen stylesheet for a print stylesheet</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">hash</span> <span class="o">==</span> <span class="s1">&#39;#print=true&#39;</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="kd">var</span> <span class="nx">printcssuri</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;link[media=print]:first&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;link[media=screen]:first&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">,</span> <span class="nx">printcssuri</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
CSS, jQuery, link, meta, theme

Text only

Drupal add region for theme on template.php

1
2
3
4
5
6
7
8
/*
* Implements hook_system_info_alter().
*/
function your_module_name_system_info_alter(&$info, $file, $type) {
  if ($type == 'theme') {
    $info['regions']['region_machine_name'] = t('Region name');
  }
}
https://snipt.net/embed/13a8f962b90d0daa267c62800aa5dd3d/
https://snipt.net/raw/13a8f962b90d0daa267c62800aa5dd3d/
13a8f962b90d0daa267c62800aa5dd3d
text
Text only
8
2016-12-06T12:15:19
True
False
False
/api/public/snipt/52133/
drupal-add-region-on-theme-on-templatephp
<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></span><span id="L-1"><a name="L-1"></a>/* </span><span id="L-2"><a name="L-2"></a>* Implements hook_system_info_alter(). </span><span id="L-3"><a name="L-3"></a>*/ </span><span id="L-4"><a name="L-4"></a>function your_module_name_system_info_alter(&amp;$info, $file, $type) { </span><span id="L-5"><a name="L-5"></a> if ($type == &#39;theme&#39;) { </span><span id="L-6"><a name="L-6"></a> $info[&#39;regions&#39;][&#39;region_machine_name&#39;] = t(&#39;Region name&#39;); </span><span id="L-7"><a name="L-7"></a> } </span><span id="L-8"><a name="L-8"></a>} </span></pre></div> </td></tr></table>
drupal, template.php, theme

PHP

Disallow theme/plugin editor

1
2
3
<?php
define( 'DISALLOW_FILE_EDIT', true );
?>
https://snipt.net/embed/d5352bee4c9e73c76301fd3b9d6648b9/
https://snipt.net/raw/d5352bee4c9e73c76301fd3b9d6648b9/
d5352bee4c9e73c76301fd3b9d6648b9
php
PHP
3
2016-12-11T06:03:52
True
False
False
Sep 20, 2012 at 10:40 AM
/api/public/snipt/47387/
disallow-themeplugin-editor
<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></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="nb">define</span><span class="p">(</span> <span class="s1">&#39;DISALLOW_FILE_EDIT&#39;</span><span class="p">,</span> <span class="k">true</span> <span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
editor, plugin, theme, wordpress, wpconfig

PHP

Echo template directory

<?php bloginfo('template_directory'); ?>
https://snipt.net/embed/4e8a8ea23d1868fd2604ac5ecd7a5be4/
https://snipt.net/raw/4e8a8ea23d1868fd2604ac5ecd7a5be4/
4e8a8ea23d1868fd2604ac5ecd7a5be4
php
PHP
1
2016-12-06T16:29:55
True
False
False
/api/public/snipt/41969/
echo-template-directory
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</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 class="nx">bloginfo</span><span class="p">(</span><span class="s1">&#39;template_directory&#39;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
theme, wordpress
Copyrighted, illegal, or inappropriate content? Email [email protected].