Archive for the ‘Uncategorized’ Category

DesenSlice – Free PSD

page home

As Promissed (a long long time ago),  I finally managed to upload a new psd design that i had laying around… It’s 100% free to use how ever you wish…

Download PSD

How to get a wordpress plugin directory path – the best, easiest, correct way

A lot of developers when building plugins are confronted with this problem and a big percentage of them approach this in a wrong way.

How NOT to do it:

#1 A lot of developers think it is ok to add the path using the bloginfo function:

<script src=”<?php bloginfo(‘wpurl’); ?>/wp-content/plugins/plugin-name/script.js” type=”text/javascript“></script>

First of all, adding scripts to a wordpress plugin is not done by adding the <script> tag in the header! If you are doing that, please stop! It will only make yet another request to the server and help make a blog load slower. Scripts need to be in 1.. so wordpress has something for this and it’s called wp_enqueue_script (for scripts) and wp_enqueue_style for styles. But that is not our issue here.

Why is the above code incorrect?

One other problem with the above path (besides the big obvious one we just talked about) is the path itself. Don’t ever use a path with wp-content in it. You never know if the wp-content is even named that or where it lays(might be one folder up). Same problem with plugin name… What if someone changes that name?

#2 Non-newbies choose a better way to do this ..

<script src=”<?php echo WP_PLUGIN_URL; ?>/plugin-name/script.js” type=”text/javascript“></script>

Well, this is ok, if nobody changes the plugin name at 1 point. If someone changes that name, GAME OVER.

So what can be done?

How to do it:

The answer is plugins_url function (that’s right.. there’s a plugins_url function in wordpress) and it will return the full path to a plugin (inside the plugin directory). It’s really easy to use and it’s not as long as the others… So this is the best, correct, easy way to doing the above examples:

<script src=”<?php echo plugins_url(’script.js’,__FILE__); ?>“ type=”text/javascript“></script>

Easy. no?

But again, read #1 on how not to do it… to include scripts and styles in a right way.