Debugging WordPress with Eclipse PHP Development Toolkit


Firstly, you need to have insalled XAMPP, and Eclipse Luna (or and IDE with PDT support)

Configure PHP to Load Xdebug

Add these lines to your php.ini file (at c:\xampp\php\php.ini or somewhere else depending on your platform):

zend_extension = “C:\xampp\php\ext\php_xdebug.dll”
xdebug.remote_enable = 1

Verify XDebug

Create a page called test.php in your web root folder, and add a call to the phpinfo() function:

<?php phpinfo(); ?>

Configure PHP Debug in Eclipse

  1. Create a new project using the location of the current WordPress location.
  2. Click the Debug drop down arrow and select Debug Configurations.
  3. Enter the following information as shown in the picture:
    Name—Type a name for the server.
    Debugger—Select XDebug.
    Base URL—Type the URL for your local domain test.
    Local Web Root—Set the path of your web root.

Configure PHP Debug

Test the Debugger

Add the following code to the function.php fine in the active theme of the wordpress installation. Then add a break point and run the debug button.

[cc lang=”php”]
add_filter( ‘the_content’, ‘my_filter_content_func’ );
function my_filter_content_func( $content ) {
  $words_replace = array(‘wordpress’);
  $content = str_ireplace( $words_replace, ‘MyBlog’, $content );
  return $content;

Ajax in WordPress

AJAX is already used in WordPress’ back end. Every AJAX request goes through the admin-ajax.php file in the wp-admin folder.  Each request needs to supply at least one piece of data (using the GET or POST method) called action. Based on this action, the code in admin-ajax.php creates two hooks, wp_ajax_my_action (for logged-in users) and wp_ajax_nopriv_my_action (for logged-out users), where my_action is the value of the GETor POST variable action.

Here’s a simple plugin to demonstrate the concept. Just copy the code below and save a php file in your wordpress plugin folder. Then create a page and add the shortcode [SIMPLE_AJAX] to the content and view the page. You should see a button and when you click it the text of

would change from ‘Click button’ to ‘Result: Apple’.

Continue reading

How to retrieve posts from WordPress using Java

One way is to use the xml-rpc api. WordPress blogs have an xml-rpc API (which you need to enable on the WordPress blog under “Settings – Writing”. Since WordPress 3.5, XML-RPC is enabled by default). You will also need to create a user on the blog, which you give at least read access, and for which you include the credentials in your app. From then on, you can do xml-rpc calls to your WordPress blog(s).

Note that you can only use the xml-rpc api when you have a user with read access. If you do not have the credentials of a user with read access, you can’t get the posts using the xml-rpc api. Fetching the rss feed and parsing the rss feed with some java lib would probably be your best bet then check on how to read an rss feed using Java.

Also, the official WordPress Android app is open source. Instructions to get it are at: You could use this source code as a starting point and adapt it to your needs.

Continue reading

Creating a WordPress Plugin to Allow Users To Submit Images

Here’s a tutorial for creating a WordPress Plugin that will Allow Users To Submit Images To Your WordPress Site::

  • display an image upload form using a shortcode
  • accept only images of a certain type and maximum size
  • add a custom post type for user images
  • add images to the WordPress media library with a proper attachment caption
  • display unpublished images
  • allow users to delete their unpublished images

Documentation of Upload Class