I just gave a talk in Bangalore PHP Meetup about ways in which we can use WordPress as a platform. The following is the slide I used and a little write up about the talk.
Category Archives: WordPress
Sometime back, I wrote about Matt’s announcement of merging WordPress and WordPress MU codebase together.
This will also mean that we will be able to run BuddyPress on single user WordPress installations, which is kind of cool. Eagerly waiting for WordPress 3.0 🙂
With the maintenance release out, we are planning to work on importers, which will allow you to import contact data from other programs.
I want you to help me to choose which importer I should work on first, which will be released in for the next version of RoloPress.
So please cast your vote and we will work on the importer which receives the most number of votes.
(You can cast your vote here directly, if you are not able to see the poll widget or if you are reading this post from a feed reader)
Try it out and if you have any feedback, please post it here or in the forums.
Sometime back, people from Packt Publishing contacted me asking whether I will be interested in reviewing their latest WordPress related book titled WordPress Plugin Development: Beginner’s guide by Vladimir Prelovac. Since the book suited my interests and also the topics which I write in this blog, I accepted, but got busy with RoloPress. Finally, I found some free time to read the book and here is my review. 🙂
Disclaimer: I just received a free copy of the ebook (in pdf format) for review. There was no condition that the review should be only positive and also I didn’t receive any payment for the review. So I am just writing what I felt about the book after reading it.
About the author
As most of you would know the book’s author Vladimir Prelovac is a popular WordPress Plugin author who does WordPress development as a full time job. He is the “Been there, done that” kind of guy for anything related to WordPress (themes, Plugins, security etc.) and we can be sure that he knows what he is talking about (which is evident from the book).
About the book
The book consists of 8 chapters in which the author dissects and discusses about 6 of his Plugins explaining the code and concept behind them. The first chapter is a general introduction and in the eighth chapter he discusses about post-development activities for the Plugin like generating pot files, generating readme files, deploying etc.
Positives about the book
As Ozh says, this book is great for beginners who want to get their hands dirty and quickly learn the concepts behind WordPress Plugins. It can quickly put you on track and from where you can easily be on your own. (Even I wish I had something like this 4-5 years ago when I initially started with WordPress Plugin development)
In each chapter, the author gives a brief explanation about the Plugin and then gradually converts it into code. After each code listing he explains what the code does and how it does it, which would be very useful to grasp the fundamental concepts behind WordPress Plugin development.
Things which are not too good (for me)
The major thing which caught my attention was that, the book is slightly outdated in certain places. It doesn’t mean that the code in the book will not work, but what I mean is that there are certain new and better ways to do things. For instance, using old methods to parse RSS Feeds, having hardcoded paths to wp-content and wp-config.php file etc. Even some of the screenshots are pre 2.7
I wouldn’t blame the author or the publisher for it, because this is bound to happen to any technical book. But I would be really happy if there could be a v2.0 of the book with these changes. 🙂
The other thing which I didn’t like about the book is that most of the code samples doesn’t follow WordPress coding standard (especially camelcase function names). This is just a matter of personal preference but I would have loved if the author followed the recommended coding standards, since this book is meant for beginners.
So my final verdict is that if you are a beginner or Intermediate WordPress Plugin developer then this book is a must have. It will easily get you on track.
The secret project was RoloPress, a WordPress based, open source contact manager, which I was developing with my friend Steve Bruner. The main distinction of RoloPress is that it is an application build on top of WordPress and is not a separate application with is tied up with WordPress.
As you may know already (and if you don’t, dude, follow me) I participated in the recent WordPress Plugin competition. The results are out and even though my Plugins were not selected, I received a much more valuable gift. Guess what, a detailed review of all my five Plugins by my favorite WordPress expert and a great inspiration Ozh.
The following are the lessons that I learned from the reviews
- The details that you enter in the Plugin’s page like Plugin Description, screenshot, installation instructions, FAQ, example usage etc, but really help you to get more users for your Plugins
- When you are using PHP 5+ only features, make sure that you have a fall back mechanism and correct warning to users.
- When making calls to API’s it is better to use the built-in WP_Http class instead of CURL or sockets
- Don’t hardcode the Plugin directory or file name, some users may change it, which might break your Plugin.
- Similarly don’t hard code wp-content directory path. Some users might move their wp-content directory to a different path which might again break your Plugin.
- If you need scripts or CSS, to be included, then include them only to the pages that need them and not to all pages.
- If you are creating a table or storing too many options in db, then it is always better to provide an uninstall hook to clean this stuff when the Plugin is delete by the user.
I am guilty of most of them and I am in the process of modifying my Plugins to fix these issues and over a next couple of days you could see updates to most of my Plugins.
It’s always nice to get feedback for your work from someone whom you respect and in that way I am really very happy that I participated. Thanks Ozh for your time and feedback and WTC for sponsoring the competition and wishes for the winners.
All you need to do is to create a (awesome) WordPress MU or BuddyPress Plugin and then release it. 🙂
The competition is open till Friday October 16th.
There are some cool prices and the first prize winner will be get a cash award of $1000.
The rules are similar the WordPress Plugin competition and the main thing to remember is that your Plugin should be in GPL or GPL-compatible licence.
So it’s time to start another WordPress project. 😉
BTW guys, I am looking for ideas. So if you wanted a Plugin for WordPress MU or BuddyPress, then let me know and I might be able to create it for you. 🙂
Update: The get_page_by_title() function now includes a third parameter that allows you to specify the post_type. You can use this parameter to get pages, posts or custom taxonomies. The below function is no longer needed.
Recently, I needed to retrieve posts and pages in WordPress based on their title. I digged into WordPress code to find out the function that can do it, but to my surprise, I found out that there isn’t a function that could work both for pages and posts.
Some people might argue that the easy way is to query the database directly, but I generally try to use a build-in function if available rather than querying the database directly.
After some poking around in the wp-hackers maling list and #wordpress irc channel, I used the following code in my Plugin. I thought of sharing this here, so that it could be helpful to others.
Retrieving pages based on title
For pages, there is a built-in function get_page_by_title() which we can use. The code would be
Retrieving posts based on title
For posts, we don’t have a built-in function. We have to manually query the database. I have written a function which can do this.
Retrieving multiple posts based on title
If you have more than one post with the same title, then the above function will return only the first post. If you want to retrieve all the posts which have the title, then you can use the below function. Thanks Jerry.
Including this as part of the core
As I said before, I always prefer to use a built-in function rather than querying the database directly. I am planning to add a new ticket to WordPress trac to add this function to the core. Will keep you all updated about the ticket status.
Update: I have created a ticket in WordPress trac, to add this function to the core. Let’s hope it gets to the core.
Well this question was asked to me for more than a couple of times now. So I thought of documenting it here, instead of answering them individually. 🙂
Long time readers of my blog would know that I use Google App for email. Ever since I moved to Linode for hosting, I stopped running a mail daemon in my server, and instead choose to use Gmail’s SMTP server for sending email.
There were two reasons for it. First most email providers ignore or mark as spam, emails sent from non-SMTP servers. Second, removing mail daemon from server will save some resources and will increase the over all performance of my server.
Using SMTP in WordPress
For WordPress there is an excellent Plugin called WP Mail SMTP, which can be used to send email through Google’s SMTP servers.
Download and install the Plugin and in the settings page you have to set the following options.
- SMTP Host: smtp.gmail.com
- SMTP Port: 465
- Encryption: Use SSL encryption
- Authentication: Yes
- Username: Your full Gmail address or Google App email
- Password: your account password
You can also checkout the following screenshot for reference.
I am also working on a Plugin to log all emails sent by WordPress. Expect it to be released soon 🙂 (Update: The Plugin to log all emails is ready. It is called Email Log and you can download it from the Plugins page.)
Update (Oct 2012)
I just realized that these days Google has added additional security for logging in using other clients. If your email is not sent properly after giving correct password, then refer to instructions at Gmail help to fix it.
Also if you have enabled two factor authentication, then refer to this Gmail support page.