snipt

Ctrl+h for KB shortcuts

PHP

Disable installing/updating new themes and plugins in WordPress

1
2
3
4
5
6
7
8
<?php
/** 
 * Disable new plugins and themes
 * ref: http://wp.tutsplus.com/tutorials/security/conquering-the-wp-config-php-file-11-good-practices/
 */

define('DISALLOW_FILE_MODS',true);
?>
https://snipt.net/embed/a376c64832c05d9284ec0cd66bf7e34d/
/raw/a376c64832c05d9284ec0cd66bf7e34d/
a376c64832c05d9284ec0cd66bf7e34d
php
PHP
8
2019-08-22T09:33:15
True
False
False
Aug 16, 2012 at 11:53 AM
/api/public/snipt/45787/
disable-installingupdating-new-themes-and-plugins-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> <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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="sd">/** </span> </span><span id="L-3"><a name="L-3"></a><span class="sd"> * Disable new plugins and themes</span> </span><span id="L-4"><a name="L-4"></a><span class="sd"> * ref: http://wp.tutsplus.com/tutorials/security/conquering-the-wp-config-php-file-11-good-practices/</span> </span><span id="L-5"><a name="L-5"></a><span class="sd"> */</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="nb">define</span><span class="p">(</span><span class="s1">&#39;DISALLOW_FILE_MODS&#39;</span><span class="p">,</span><span class="k">true</span><span class="p">);</span> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
disable, plugins, themes, wordpress, wp-config

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-08-22T06:18:10
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

PHP

Load jQuery in your WP theme

<?php wp_enqueue_script("jquery"); ?>
https://snipt.net/embed/eab00bfdb2f285747ab8e25b1ec55b9c/
/raw/eab00bfdb2f285747ab8e25b1ec55b9c/
eab00bfdb2f285747ab8e25b1ec55b9c
php
PHP
1
2019-08-19T21:55:07
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