snipt

Ctrl+h for KB shortcuts

Text only

Gettext - Plural form - sv_SE

nplurals=2; plural=(n != 1);
https://snipt.net/embed/18b384cebafb8d86859017580f3dbe33/
/raw/18b384cebafb8d86859017580f3dbe33/
18b384cebafb8d86859017580f3dbe33
text
Text only
1
2019-07-11T00:51:25
True
False
False
Nov 01, 2013 at 05:38 AM
/api/public/snipt/91313/
gettext-plural-form-sv_se
<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>nplurals=2; plural=(n != 1); </span></pre></div> </td></tr></table>
gettext, plural, sv_SE

PHP

Debug mode by specific call in WordPress

1
2
3
4
5
<?php
// Debug mode by specific call http://example.com?debug=secret
if (isset($_GET['debug']) && $_GET['debug'] == 'secret')
  define('WP_DEBUG', true);
?>
https://snipt.net/embed/ad0b1708b3c93ba0991f40b27d83a829/
/raw/ad0b1708b3c93ba0991f40b27d83a829/
ad0b1708b3c93ba0991f40b27d83a829
php
PHP
5
2019-07-14T18:21:16
True
False
False
Jun 06, 2013 at 10:49 AM
/api/public/snipt/24972/
debug-mode-by-specifik-call-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> <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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// Debug mode by specific call http://example.com?debug=secret</span> </span><span id="L-3"><a name="L-3"></a><span class="k">if</span> <span class="p">(</span><span class="nb">isset</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s1">&#39;debug&#39;</span><span class="p">])</span> <span class="o">&amp;&amp;</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s1">&#39;debug&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;secret&#39;</span><span class="p">)</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">define</span><span class="p">(</span><span class="s1">&#39;WP_DEBUG&#39;</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
debug, wordpress

PHP

Simple WordPress Shortcode

1
2
3
4
5
6
<?php // Shortcode [hw]
function hello() {
	    return 'Hello, World!';
	}
add_shortcode('hw', 'hello');
?>
https://snipt.net/embed/d0eb2f8e1c7ec375a5a75ee20aaf51b0/
/raw/d0eb2f8e1c7ec375a5a75ee20aaf51b0/
d0eb2f8e1c7ec375a5a75ee20aaf51b0
php
PHP
6
2019-07-07T15:44:26
True
False
False
/api/public/snipt/23026/
simple-wordpress-shortcode
<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="cp">&lt;?php</span> <span class="c1">// Shortcode [hw]</span> </span><span id="L-2"><a name="L-2"></a><span class="k">function</span> <span class="nf">hello</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">return</span> <span class="s1">&#39;Hello, World!&#39;</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 class="nx">add_shortcode</span><span class="p">(</span><span class="s1">&#39;hw&#39;</span><span class="p">,</span> <span class="s1">&#39;hello&#39;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
shortcode, simple, wordpress

PHP

Excerpt length in WordPress

1
2
3
4
5
6
<?php
function new_excerpt_length($length) {
	return 15;
}
add_filter('excerpt_length', 'new_excerpt_length');
?>
https://snipt.net/embed/b302a9e0a30eaac75c25a8b4b161bcb6/
/raw/b302a9e0a30eaac75c25a8b4b161bcb6/
b302a9e0a30eaac75c25a8b4b161bcb6
php
PHP
6
2019-07-08T20:13:46
True
False
False
/api/public/snipt/22849/
excerpt-length-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> <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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="k">function</span> <span class="nf">new_excerpt_length</span><span class="p">(</span><span class="nv">$length</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">return</span> <span class="mi">15</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 class="nx">add_filter</span><span class="p">(</span><span class="s1">&#39;excerpt_length&#39;</span><span class="p">,</span> <span class="s1">&#39;new_excerpt_length&#39;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
excerpt, filter, length, wordpress

PHP

Load jQuery in your WP theme

<?php wp_enqueue_script("jquery"); ?>
https://snipt.net/embed/eab00bfdb2f285747ab8e25b1ec55b9c/
/raw/eab00bfdb2f285747ab8e25b1ec55b9c/
eab00bfdb2f285747ab8e25b1ec55b9c
php
PHP
1
2019-07-06T11:47:49
True
False
False
/api/public/snipt/22398/
load-jquery-in-your-wp-theme
<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">wp_enqueue_script</span><span class="p">(</span><span class="s2">&quot;jquery&quot;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
jquery, load, themes, wordpress

PHP

WP MS registration disabled redirect

1
2
3
4
<?php
// ** If registration is disabled redirect to this url ** //
define( 'NOBLOGREDIRECT', 'url-here' );
?>
https://snipt.net/embed/48bcb298bdc1652b86bb954d69a2e290/
/raw/48bcb298bdc1652b86bb954d69a2e290/
48bcb298bdc1652b86bb954d69a2e290
php
PHP
4
2019-07-13T20:53:29
True
False
False
/api/public/snipt/22150/
wp-ms-registration-disabled-redirect
<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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// ** If registration is disabled redirect to this url ** //</span> </span><span id="L-3"><a name="L-3"></a><span class="nb">define</span><span class="p">(</span> <span class="s1">&#39;NOBLOGREDIRECT&#39;</span><span class="p">,</span> <span class="s1">&#39;url-here&#39;</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></pre></div> </td></tr></table>
multisite, redirect, regastration, url, wordpress