One of the most used open-source CMS platforms worldwide is WordPress. It is a veteran of content management systems, starting initially as just a blogging platform in 2003 and evolving over the years in one of the best platforms for general presentation websites, small community portals and small e-commerce shops.
As Wikipedia states, as of January 2015 WordPress is used on 23.3% out of the top 10 million sites online, being the platform used for the blog you are now reading.
WordPress is built using PHP with a MySQL database driven backend and provides quite a good environment for lightweight websites. Starting as a blog platform the base architecture is built around the post object which is further extended to other base post types, like pages, attachments and revisions and also to any type of custom post type you will need to develop for your needs.
Due to this the database architecture is not very scalable as all post contents are saved in only one database table, with all the extra information as part of a postmeta key-value table, creating a huge overhead with very complex systems due to the number of database query joins that need to be done. Of course this is not a problem for smaller websites, that explaining its popularity.
WordPress is also one of the best platforms from a search engine optimization point of view, as it makes uses of a great routing engine based on permalink structures and a very good URL rewrite API, which can be very useful when developing custom modules.
Extending features is done through WordPress plugins, which are mostly freely available in the WordPress plugin repository, with high quality plugins that provide a lot of what you'll need out of the box. Furthermore you can easily develop new plugins with less than medium web development knowledge due to how easy connecting over to actions is by the usage of action filters.
For example building a plugin that hooks over to the wp_mail function (which is the base email sending feature) is done by using two filters:
- a filter that hooks to the wp_init action, which runs each time the platform is initialized and with a very high priority (small priority number, smaller number is the first to run) set will ensure your code runs first, setting up the way for the secondary filter to run.
- a filter that hooks to the wp_mail action, with a very low priority (high priority number), making sure that it runs last and is the one that actually sends the email overriding the default mail function or any other mail override up to that point.
Here is an example on how this is achieved:
function your_plugin_initialization(){ // 999 - low priority add_filter('wp_mail', 'your_wp_mail_filter',999); } // 1 - high priority add_action('init', 'your_plugin_initialization',1); function your_wp_mail_filter($args){ // override email headers $headers = array('From: test@test.com','Content-Type: text/html; charset=UTF-8'); $message = "We are overriding your emails"; // as you can see we are modifying just the message and the email headers, while keeping the initial arguments of the hook $new_wp_mail = array( 'to' => $args['to'], 'subject' => $args['subject'], 'message' => $message, 'headers' => $headers, 'attachments' => $args['attachments'], ); return $new_wp_mail; }
Please provide in your comments any questions you may have on the matter and I'll provide help for this or any other problem you might have with extending WordPress.
image source: smashblogtrends.com