snipt

Ctrl+h for KB shortcuts

JavaScript

Equal Column Heights with jQuery

1
2
3
4
5
6
//http://www.broken-links.com/2009/01/20/very-quick-equal-height-columns-in-jquery/
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
}

// usage: $('div.unevenheights').setAllToMaxHeight();
https://snipt.net/embed/da54752a6d9aa0916d887c01edae1f02/
/raw/da54752a6d9aa0916d887c01edae1f02/
da54752a6d9aa0916d887c01edae1f02
js
JavaScript
6
2019-08-07T13:40:51
True
False
False
Sep 13, 2012 at 11:23 PM
/api/public/snipt/47161/
equal-column-heights-with-jquery
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">//http://www.broken-links.com/2009/01/20/very-quick-equal-height-columns-in-jquery/</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">$</span><span class="p">.</span><span class="nx">fn</span><span class="p">.</span><span class="nx">setAllToMaxHeight</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span> </span><span id="L-3"><a name="L-3"></a><span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">height</span><span class="p">(</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">max</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">$</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span> <span class="k">this</span> <span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> <span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">height</span><span class="p">()</span> <span class="p">})</span> <span class="p">)</span> <span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1">// usage: $(&#39;div.unevenheights&#39;).setAllToMaxHeight();</span> </span></pre></div> </td></tr></table>
equalHeights

JavaScript

Change url without refreshing

1
2
3
4
5
6
7
document.location.hash = "show_picture";


//You cannot change the whole url without redirecting, what you can do instead is change the hash.

//The hash is the part of the url that goes after the # symbol. 
//That was initially intended to direct you (locally) to sections of your HTML document, but you can read and modify it through javascript to use it somewhat like a global variable.
https://snipt.net/embed/0f567553963553461ce4fc49f2829650/
/raw/0f567553963553461ce4fc49f2829650/
0f567553963553461ce4fc49f2829650
js
JavaScript
7
2019-08-18T08:29:39
True
False
False
/api/public/snipt/46056/
change-url-without-refreshing
<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="nb">document</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="s2">&quot;show_picture&quot;</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">//You cannot change the whole url without redirecting, what you can do instead is change the hash.</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1">//The hash is the part of the url that goes after the # symbol. </span> </span><span id="L-7"><a name="L-7"></a><span class="c1">//That was initially intended to direct you (locally) to sections of your HTML document, but you can read and modify it through javascript to use it somewhat like a global variable.</span> </span></pre></div> </td></tr></table>
"url redirect", tabs, url

PHP

Override the wp-admin stylesheet

1
2
3
4
5
6
7
8
function customAdmin() {
    $url = get_settings('siteurl');
    $url = $url . '/wp-content/themes/my-theme/styles/wp-admin.css';
    echo '<!-- custom admin css -->
          <link rel="stylesheet" type="text/css" href="' . $url . '" />
          <!-- /end custom adming css -->';
}
add_action('admin_head', 'customAdmin');
https://snipt.net/embed/f347f215a10648396a490c24f054d5e1/
/raw/f347f215a10648396a490c24f054d5e1/
f347f215a10648396a490c24f054d5e1
php
PHP
8
2019-07-31T09:17:37
True
False
False
/api/public/snipt/33957/
override-the-wp-admin-stylesheet
<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 class="x">function customAdmin() {</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> $url = get_settings(&#39;siteurl&#39;);</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> $url = $url . &#39;/wp-content/themes/my-theme/styles/wp-admin.css&#39;;</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> echo &#39;&lt;!-- custom admin css --&gt;</span> </span><span id="L-5"><a name="L-5"></a><span class="x"> &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&#39; . $url . &#39;&quot; /&gt;</span> </span><span id="L-6"><a name="L-6"></a><span class="x"> &lt;!-- /end custom adming css --&gt;&#39;;</span> </span><span id="L-7"><a name="L-7"></a><span class="x">}</span> </span><span id="L-8"><a name="L-8"></a><span class="x">add_action(&#39;admin_head&#39;, &#39;customAdmin&#39;);</span> </span></pre></div> </td></tr></table>
themes, wordpress, wp-admin