WordPress ORM

I know that there is a Doctrine integration within WordPress (not sure about v2, but at least some). However, this project looks pretty neat should you need anything more complex (or just want some sweet code involved in your database interaction): https://github.com/AdrianPop/Wordpress-ORM/blob/master/ORM.php Continue Reading

Settings API in 9 Steps

I'm going to update my DX Plugin Base script soon with sample code, but Settings API are something that needs a few lines of text too. There are several good resources for that, such as: http://codex.wordpress.org/Settings_API http://ottodestruct.com/blog/2009/wordpress-settings-api-tutorial/ http://wp.tutsplus.com/tutorials/the-complete-guide-to-the-wordpress-settings-api-part-2-sections-fields-and-settings/ (awesome btw) But for the very quick overview of what to be done, that's needed: hook to admin_init with a function registering settings call register_setting to reserve a slot in the DB where the setting is to be stored (setting name for DB, how is it stored in DB) call add_setting_section to create a section for settings (setting name, setting title, callback func,… Continue Reading

Xdebug on Ubuntu for WordPress

Turns out enabling Xdebug on Ubuntu for Eclipse PDT is easier than doing the same on Windows. The short version is installing the module as per this tutorial - http://ubuntuforums.org/showthread.php?t=525257 [bash] sudo apt-get install php5-dev php-pear sudo pecl install xdebug sudo updatedb locate xdebug (this one finds the xdebug path) sudo gedit /etc/php/apache2/php.ini [/bash] Adding this line (/w the path): [bash] zend_extension="/usr/lib/php5/20060613/xdebug.so" sudo /etc/init.d/apache2 restart (or sudo apache2ctl restart) [/bash] This install the xDebug and enables it. Then we need to add a few more lines of code in /etc/php5/apache2/php.ini (as in here): http://holisticsecurity.wordpress.com/2011/07/04/php-xdebug-xampp-win32/ [bash] xdebug.auto_trace = 0 xdebug.collect_includes =… Continue Reading

Plugin Base Skeleton

I got tired working on plugins and writing the same code snippets all over again, looking in the same old tutorial sites or my favorite WP 3 Plugin Dev book. So I released a startup script for plugins - http://wordpress.org/extend/plugins/dx-plugin-base/ . It contains most of the important snippets required for every plugin - registration of custom post types or taxonomies, registering activation and deactivation hooks, admin pages, metaboxes. I'm going to add widget/shortcode registration with some samples. This would make it easier to use it as a new plugin startup script and save some time about it. I also brainstorm on the… Continue Reading

eval() error check

We all know how dangerous eval() is in terms of security, but still it is the necessary evil sometimes. I've been developing a script last week that required eval() execution. I did pretty granular input validation with regular expressions and known troubleish test cases. Still, some expressions passed to the eval() function were prone to parse errors. Reading a bit I tried to use the exceptions handling mechanism in PHP 5 (try - catch blocks) to provide a solution, or using a error handler with the set_error_handler function. They work for exceptions and some basic errors, but most of the… Continue Reading

5 Things I Don’t Like About WishList Member

Almost a year ago we started developing a web project for a client on a social networking basis. This was actually the second similar project for the past 2 years as we have also designed a dating site and the latter solution was a social networks with custom profiles and more. There were a few tricky features such as custom profile type creation (different professions to be defined with their fields and labels through admin) and financial stats for paid users, and the speed was an important requirement. After some hardcore coding over 2 client-based websites using WishList member and… Continue Reading

Hook Interceptor and Logger

A client of mine has hired me to fix the workflow of his assignment that included a social network plugin, custom premium theme and few other plugins + the existing work of his coder. All this mess took me 3 hours to navigate through and see what happens. In addition to this - the social plugin was encrypted, therefore I was unable to grep for its hooks and where exactly does it do the changes. Long story short - it was modifying the results from calling the WP_Query instance. But there are lots of filters and actions related and I… Continue Reading

How to Start a WordPress Project?

Starting a new WordPress project requires some initial planning to avoid some common mistakes. Failing to adhere to an action plan may easily incur technical debt (with an unpredictable setup, libraries, and plugins). The WordPress Theme Industry There are tons of themes available - free or premium - and lots of theme markets for premium resources. I even mentioned a script for running your own theme market - that's how popular it got recently. Anyway, as a WordPress developer and consultant I try to select the best options for my clients. And I have some difficulties on the choice of… Continue Reading

WordPress custom pagination

When designing a theme pagination is required for listing of posts on the index page. WordPress, by default, presents only the ability of one to use "Previous page" and "Next page" - which might be enough to navigate through the archives but is however incomplete and annoying. The standard navigation has <<, >> and numbers for the current page and the pages before and after (at some range). One of the best solutions I have used is the Kriesi Pagination. Kriesi is one of the top sellers on the ThemeForest market with over 25 thousand sales at the moment of… Continue Reading