Incorrect result from WordPress plugin_dir_url

Consider this code in akismet.php from the ubiquitous Akismet plugin for WordPress: define(‘AKISMET_PLUGIN_URL’, plugin_dir_url( __FILE__ )); My WordPress installation is at /usr/share/wordpress, but the Akismet plugin is installed to /var/lib/wordpress/plugins/akismet/ and there is a symlink (symbolic link) inbetween. This means that __FILE__ is /var/lib/wordpress/plugins/akismet/akismet.php but plugin_dir_url does not understand this, and will incorrectly return: /wp-content/plugins/var/lib/wordpress/plugins/akismet/ This is not… Continue reading Incorrect result from WordPress plugin_dir_url

No application without a library, no web site without an API?

When I wrote the first versions of Dynamite and Unshield (eight and nine years ago!) I decided from the start that each project had to be implemented in two parts: a library (hopefully reusable) and a command line tool using the library. I believe I learned this from cURL and libcurl, and I still consider… Continue reading No application without a library, no web site without an API?

Pebble – more injection and less dependencies in PHP

Dependency Injection (DI) is hardly anything new. I see it as a must for Test Driven Development (TDD). The thing I like most about DI in Java is Autowired in Spring or javax.annotation.Resource, they way member variables are set “magically” and the exact details about creation and implementation is located elsewhere. For PHP there are… Continue reading Pebble – more injection and less dependencies in PHP

Marker and polygon tooltips in Google Maps v3

Before I get into the details, please note that this is a quick & dirty solution using google.maps.InfoWindow. No demo, sorry, but please add your improvements in the comments! Marker tooltip I start with the marker, as it is the simplest implementation: function attachMarkerInfoWindow(marker, html) { marker.infoWindow = new google.maps.InfoWindow({ content: html, }); google.maps.event.addListener(marker, ‘mouseover’,… Continue reading Marker and polygon tooltips in Google Maps v3

Facebook Graph API limitations

I have created a Facebook app for the flea market Facebook groups in my area. (Feel free to take a look at //loppis.blekinge.it/) To read and manage posts I use the Facebook Graph API, but there are a number of limitations: My application supports deleting posts, but Facebook does not allow applications to delete a photo… Continue reading Facebook Graph API limitations

Stop forum spam!

I run a Swedish site about energy drinks, along with a Swedish forum for energy drink collectors. In a tie between phpBB and Simple Machines (SMF) I chose the latter as forum software. Since I opened the forum there has been more and forum spam attempts. Actually there have been very few spam posts, and… Continue reading Stop forum spam!

Policy notification from Google

My Swedish site Folkmun allows anyone to add words and their definitions. It’s a simple Swedish version of Urban Dictionary. Some people add very explicit words and I had totally forgotten that such words may clash with Google AdSense policies. Today I received a friendly warning: While reviewing your account, we noticed that you are… Continue reading Policy notification from Google