snipt

Ctrl+h for KB shortcuts

PHP

wordpress is page

1
2
3
4
5
<?php 
if( is_page($page) ){
     //код
}
?>
https://snipt.net/embed/0357f38bb53492868a92989e8814b625/
https://snipt.net/raw/0357f38bb53492868a92989e8814b625/
0357f38bb53492868a92989e8814b625
php
PHP
5
2016-09-28T06:30:14
True
False
False
Mar 22, 2014 at 08:30 PM
/api/public/snipt/123971/
wordpress-is-page
<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 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">if</span><span class="p">(</span> <span class="nx">is_page</span><span class="p">(</span><span class="nv">$page</span><span class="p">)</span> <span class="p">){</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">//код</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="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
wordpress, wp

PHP

wordpress include plugin

include_once('advanced-custom-fields/acf.php');
https://snipt.net/embed/135c50ff60836ab7899efbb97cc4f9e7/
https://snipt.net/raw/135c50ff60836ab7899efbb97cc4f9e7/
135c50ff60836ab7899efbb97cc4f9e7
php
PHP
1
2016-09-21T23:43:14
True
False
False
/api/public/snipt/123944/
wordpress-include-plugin
<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 id="L-1"><a name="L-1"></a><span class="x">include_once(&#39;advanced-custom-fields/acf.php&#39;);</span> </span></pre></div> </td></tr></table>
plugin, wordpress, wp

PHP

Localize dates in Wordpress

1
2
3
<?php 
echo date_i18n(get_option('date_format') ,strtotime("11/15-1976"));
?>
https://snipt.net/embed/e7b487b882a71fd1dbf55f6c235b3df1/
https://snipt.net/raw/e7b487b882a71fd1dbf55f6c235b3df1/
e7b487b882a71fd1dbf55f6c235b3df1
php
PHP
3
2016-09-22T04:46:07
True
False
False
Dec 11, 2013 at 07:25 AM
/api/public/snipt/99832/
localize-dates-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></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="k">echo</span> <span class="nx">date_i18n</span><span class="p">(</span><span class="nx">get_option</span><span class="p">(</span><span class="s1">&#39;date_format&#39;</span><span class="p">)</span> <span class="p">,</span><span class="nb">strtotime</span><span class="p">(</span><span class="s2">&quot;11/15-1976&quot;</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>
date, localize, wordpress, wp

PHP

Get attached file size

1
2
3
<?php
filesize( get_attached_file( $attachment->ID ) );
?>
https://snipt.net/embed/b6f8a64ff28dbbfbf082660c07534b17/
https://snipt.net/raw/b6f8a64ff28dbbfbf082660c07534b17/
b6f8a64ff28dbbfbf082660c07534b17
php
PHP
3
2016-09-29T18:15:48
True
False
False
Aug 01, 2013 at 07:11 AM
/api/public/snipt/71160/
get-attached-file-size
<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 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">filesize</span><span class="p">(</span> <span class="nx">get_attached_file</span><span class="p">(</span> <span class="nv">$attachment</span><span class="o">-&gt;</span><span class="na">ID</span> <span class="p">)</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>
attach, attached, file, get, size, wordpress, wp

PHP

add iva or cf to woocommerce invoices

1
2
3
4
5
<?php
global $wcdn;
$billing_cfs = $wcdn->print->get_order()->order_custom_fields['_billing_cf'];
echo(strtoupper($billing_cfs[0]));
?>
https://snipt.net/embed/ec663333031a904ee5562eea703c7e26/
https://snipt.net/raw/ec663333031a904ee5562eea703c7e26/
ec663333031a904ee5562eea703c7e26
php
PHP
5
2016-09-20T17:04:54
True
False
True
Jun 21, 2013 at 06:11 AM
/api/public/snipt/65166/
add-iva-or-cf-to-woocommerce-invoices
<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 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">global</span> <span class="nv">$wcdn</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="nv">$billing_cfs</span> <span class="o">=</span> <span class="nv">$wcdn</span><span class="o">-&gt;</span><span class="na">print</span><span class="o">-&gt;</span><span class="na">get_order</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">order_custom_fields</span><span class="p">[</span><span class="s1">&#39;_billing_cf&#39;</span><span class="p">];</span> </span><span id="L-4"><a name="L-4"></a><span class="k">echo</span><span class="p">(</span><span class="nb">strtoupper</span><span class="p">(</span><span class="nv">$billing_cfs</span><span class="p">[</span><span class="mi">0</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>
cf, codice, delivery, fiscale, invoice, iva, note, parita, woocommerce, wordpress, wp
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.