You do not have sufficient permissions to access this page.

Note to self: do not use non prefixed global variables in your wordpress plugin.

It causes all sorts of chaos. For example – gett the error “You do not have sufficient permissions to access this page.” whenever you load a page that is not your plugins.

For those playing at home, this is the code that I used to cause me headaches:

$plugin_page = add_action('admin_menu', function() {...});

Note that $plugin_page is used by wordpress, and overwriting it, well, makes things not work!

#FeelingLikeATurkey

{lang: 'en-GB'}

Get the WordPress Plugin URL

So today I was writing a plugin that belongs in the tools section of the wordpress admin and I found myself wondering how to get the URL of the plugin. So I created a little function that creates the URL with all the params I need for me – and here it is! (obviously change the my_ to your own plugin namespace)

function my_plugin_url($variables) {
    $url_bits = parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    $query = array();
    foreach (explode('&',$url_bits['query']) as $pair) {
        list($k,$v) = explode('=',$pair);
        $query[$k]=$v;
    }
    foreach ($variables as $k=>$v) {
        $query[$k] = $v;
    }

    return sprintf('%s://%s%s?%s', $url_bits['scheme'], $url_bits['host'], $url_bits['path'], http_build_query($query));
}

and you call it like this:

<a href="<?php echo my_plugin_url(array('param1'=>'value1'))?>">Example URL<a>

and it will output the url with your extra parameters

{lang: 'en-GB'}

Spiders!

So recently we had a spider infestation in the Kwinana, there seemed to be spiders everywhere!

So I got my camera and…

{lang: 'en-GB'}

western power is fun!

*yay* power outage… good enough time to try doing this portable hotspot thing through the android phone. Let’s just say that the vodafone Edge network is laaaaaaaggyy

Reply from 110.173.227.121: bytes=32 time=936ms TTL=47
Reply from 110.173.227.121: bytes=32 time=1664ms TTL=47
Reply from 110.173.227.121: bytes=32 time=3786ms TTL=47
Reply from 110.173.227.121: bytes=32 time=9418ms TTL=47
Reply from 110.173.227.121: bytes=32 time=6857ms TTL=47
Reply from 110.173.227.121: bytes=32 time=5424ms TTL=47
Reply from 110.173.227.121: bytes=32 time=5629ms TTL=47
Reply from 110.173.227.121: bytes=32 time=485ms TTL=47
Reply from 110.173.227.121: bytes=32 time=413ms TTL=47
Request timed out.
Reply from 110.173.227.121: bytes=32 time=2907ms TTL=47
Reply from 110.173.227.121: bytes=32 time=1394ms TTL=47
Reply from 110.173.227.121: bytes=32 time=2046ms TTL=47
Reply from 110.173.227.121: bytes=32 time=1841ms TTL=47
Reply from 110.173.227.121: bytes=32 time=1122ms TTL=47
Reply from 110.173.227.121: bytes=32 time=304ms TTL=47
Reply from 110.173.227.121: bytes=32 time=326ms TTL=47
Reply from 110.173.227.121: bytes=32 time=438ms TTL=47
Reply from 110.173.227.121: bytes=32 time=346ms TTL=47
Reply from 110.173.227.121: bytes=32 time=372ms TTL=47
Reply from 110.173.227.121: bytes=32 time=385ms TTL=47
Reply from 110.173.227.121: bytes=32 time=305ms TTL=47
{lang: 'en-GB'}