Clever ideas & creative functionality.
Better wordpress extensions with an object oriented approach.
When searching the web for WordPress plugin tutorials and introductions the vast majority utilizes procedural programming. However having recently discovered Object Oriented programming in PHP 5 i decided to take another approach to both plugins and themes.
When encapsulating plugins or parts of your themes in classes, you create a container for variable, constant and function names thus avoiding name clashes with the core or with other plugins. You can also encapsulate your class in a statement checking if the class already exists to ensure that in the rare case of a name collision your plugin will not initialize and crash the WordPress installation.
Here is a simple example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | < ?php // Plugin Name: Text Barking Dog if (!class_exists('OurWpPluginDog')) { class OurWpPluginDog { function __construct() { $this->text = "wuff wuff"; } function bark() { echo '<!--' . $this->text . '-->'; } } $dog = new OurWpPluginDog; add_action('wp_footer', array(&$dog, 'bark')); } |
This plugin will insert “wuff wuff” as an html comment at the hook wp_footer. The __construct function runs when the class is constructed you can also place your actions and filters here, if you do you simply reference array(&$this … instead.
Object oriented programming encourages DRY - it simply makes it more convenient to reuse your code. As your plugin grows you will also find it easier to get an overview of the code.
Website for 3D visualization studio
I have worked with geist on this website for the 3D visualization studio CENARIO. The project is the largest I have taken upon me in web development to this date and i have worked with several technologies that i have not utilized professionally before. The site is developed in Zend framework and uses the amazing mootools for the frontend. The site is hosted on Media Temples (dv).
Content Management Confusion
After many problems with my Radiant Installation on my Ruby on Rails container at Media Temples grid service i have decided to dump the development of the Radiant Site and i have gone with Wordpress instead. I really like Radiant CMS and its simple and logical structure, it has a sort of grace. As do Ruby. But i found myself unable to solve the problem that would sometime cause my Radiant site to display nothing but a 502 Error.I sought help on the mailing list but got no answer so far. And (mt) gave poor support on the subject. I know of workin Radiant installations on (mt)s (gs) are out there, and i would very much like to use radiant for future projects. So if your the one with a healthy installation i would very much like to hear how you did it!For now im off with wordpress which i am very satisfied with, but it certainly doesn’t have the grace of ruby and radiant, however there is an enormous community to seek support from, not to mention the wide selection of plugins and themes. …it just works!
Lately i have been looking for a new host, that would give me more flexibility and performance in order to experiment with web applications. My first project is to evolve accidentdesigns.com which i moved to the gridserver from my old host.
Currently my idea is to make Accident Designs more of a personal brand covering what i am. Instead of the corporate Second Life focus its has now. My main expertise will still be Second Life, ad least for a while until i get better at something else.
With the website i am experimenting with freemind as the structure of the site. Through a flashviewer my vision is to merge it with a cms and create a simple site build around the mindmap including a blog. This blogger blog or perhaps directly hosted within the cms. This is my thoughts right now but i don’t seem near a solution yet so the old site will still be available at accidentdesigns.com/old
If you have feedback on the new site, i would love to hear from you!
You are currently browsing the archives for the Web category.