Top posts

Latest articles


Working on Ajax integration with WordPress

Posted by Jongerius under Development, WordPress
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

As part of the new theme I’ve been developing I’m including some richer user features. Like on the spot loading of comments and better mobile device support. One of the things I need to figure out during the development is how to use Ajax in WordPress, preferably native support. I know it should be possible, but have yet been unsuccessful to get it working.

So what I’ve been doing is setting up a new action using add_action for the following two action types:

  • wp_ajax_<myaction>
  • wp_ajax_nopriv_<myaction>

According to the documentation that should generate a hook to support both registered users (wp_ajax_<myaction>) and unregistered users (wp_ajax_nopriv_<myaction>). Which sounds great, since my theme should work for both type of users ;-) .

On the front-end I’ve created a Javascript method that should call the ajax command using the ‘wp-admin/admin-ajax.php’. With as action parameter the name of my ajax method. So in theory I should be setup correctly to handle ajax, but this is where the theory and actual situation start to differ.

To test my new theme I’ve been using the preview mode of WordPress, after all I don’t want to kill any existing feature or activate the theme before it is done. But for some reason my nicely setup Ajax hooks aren’t working as advertised.


My first steps into Android development

Posted by Jongerius under Development
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

After owning an Android phone for over an year, and using it on daily base, I thought it might be time to look into how easy it would be to start developing for the Android OS. As any good developer I first started reading a bit on how to develop for it, and what requirement’s I would have to meet.

Now I’m not going to be boring you with all kinds of tutorials on how to develop on Android, or give you any other clues on this subject. I just don’t know anything about Android development, well not yet anyhow. But some good reading material to get you on the right path might be:

The only thing I have learned so far is that I don’t really like the way of designing a UI for the Android. It’s just way to basic with XML files describing how the UI should look like. Feels like going back to 1990 when designing a UI was done in code rather then with a UI design tool.


PHP and browser detection

Posted by Jongerius under Development, Webdevelopment, WordPress
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

One of the things you might encounter as a web developer is detection of the browser that a visitor is using. In my specific case this was needed since I wanted to use some CSS3 styling, but only if the browser was capable. In all other cases the visitor had to see the CSS2 optimized page.

So I started looking into a way to let my web application determine what browser was visiting and what capabilities it had. Since this was for the new WordPress theme I’m developing it had to be in PHP and be sorta light-weight.

First thing was to figure out the basic browser that was visiting. This can be done by doing a simple strpos call in PHP on the user agent property. Having a list of the various user agents helped, I found just such a list at UserAgentString. A brief summary for some common browsers is below.

  $user_agent = $_SERVER['HTTP_USER_AGENT'];
  $IE        = strpos($this->_user_agent, 'MSIE') > -1;
  $IPad      = strpos($this->_user_agent, 'iPad') > -1;
  $Firefox   = strpos($this->_user_agent, 'Firefox/') > -1;
  $Chrome    = strpos($this->_user_agent, 'Chrome/') > -1;
  $Opera     = strpos($this->_user_agent, 'Opera/') > -1;
  $Android = strpos($this->_user_agent, 'Android') > -1;

As you can see determining the basic browser type is pretty simple. But to be able to determine if CSS3 is supported you will also need to locate the version of the browser. Keeping in mind that IE9+, Firefox 4+, Opera 10+ and Chrome are the only versions that support CSS3. The check for this is slightly different for each version. But you can do it easily with a regular expresion.

 // For all non IE browsers
 $locator;
 if ($Firefox) $locator = "Firefox\/";
 if ($Android) $locator = "Android\s";
 if ($Chrome) $locator = "Chrome\/";
 if ($Opera) $locator = "Version\/";
 preg_match('/'.$locator.'([0-9]{1,4}(.[0-9]{1,3})+)/', $user_agent, $version);

 // For IE
 preg_match('/MSIE\s([0-9]{1,2}.[0-9]{1,2})/', $user_agent, $version);
 if (count($version) > 1) $version = $version[1];
 else $version = 0;

Having the version and the type of browser allows us to do all kinds of fancy browser specific stuff. Mostly introduce hacks for IE7 (yes many are needed), or add CSS3 support.


Why Team Foundation Server is useless for Java

Posted by Jongerius under Development, General Rant
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

In the company I’m currently working for we are using the Team Foundation Server as a version control system. No for developers of C# or any other Microsoft related programming language this is probably fine. However being a Java developer TFS is less then perfect. In fact it is a near nightmare.

We are using various IDE’s for editing our Java projects, meanly because different developers like different IDE’s. Personally I’m using Netbeans, which has perfect Subversion, Git, CVS and Perforce support. Some other developers use IntelliJ from Netbrains. Which is sorta expensive and the version we are using has no support for TFS at all.

So when I want to edit a simple file I first locate it in my IDE, which takes me about 5 seconds. Then I need to look up its location on disk, followed by opening the completely useless Team Exporer. Then I again need to look up the file in TE, followed by a check-out. The whole process to the point that the file is checked out and ready to go takes probably about 1 minute, each and every time.

On an average day I probably waste up to an hour checking out files, and commiting them back into the version control system.

To ease the burden a bit I’ve tried the SvnBridge tool to link my IDE’s Subversion system with TFS, but this tool has many flaws. Just a few of which are:

  • No longer appears to be developed
  • A merge in TE causes all updates to fail, you need to do a clean checkout again
  • Random update failures due to commits of other developers

So for now I’m stuck. Really, really, really stuck.


New WordPress skin, Ajax loading vs. Google

Posted by Jongerius under Development, Webdevelopment, WordPress
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

As a major remodeling of this blog is on the way I’m going to try to build it more dynamic and more up to the Web 2.0 standards. So that includes usage of Ajax, JQuery and a more dynamically filled website. But how to build this and keep the Google Analytics working, as well as the search engine indexing. This will be one of my biggest challenges I’m afraid.

Developing a website with JQuery / Ajax and advanced JavaScript prototypes isn’t anything new to me. But having all of these features and still make the site indexable is! So far I’m stuck at the simple point that crawlers don’t support JavaScript, so no go for that part. It looks like I will have to create a module for the WordPress plugin to detect what type of user is visiting the website. Serving the search engines a version that will not use any of the advanced features that normal browsers will support.

Besides the issue with the indexing there is still the task of getting all the pages on the website to be tracked with Google Analytics. Currently that is easy, though the website is dynamic each page is a new request to the server. But using advanced features like Ajax stops that in its tracks. Currently I don’t even know if it is possible to track pages when the actual URL doesn’t change, just the content of the page. If it is possible to do this I would have to build a module to do so.

So after just ranting and brain storming for a few seconds I already found to nice features that would have to be build. Another person might call them serious issues, but I prefer good challenges. At least for the moment I do. Not even mentioning the fact that I have to build a complete new template for WordPress too.

Next Page »