If you are a plugin writer like me and you write random WordPress plugins for various purposes, chances are you have to write many SQL queries for many cases. But if you look into modern PHP frameworks like Laravel, Symfony, Zend and every other frameworks, you will see they don’t write much raw SQL queries by hand. Instead, everyone is using ORM. In few cases you might have to write raw SQL queries, with ORM you can do that as well.
If you look at the WordPress world, we are still stuck with the WPDB global object. It’s an Active Record class, but can’t be called an ORM. The main reason I like ORM is it reduces so much codes and facilitates many magical features without writing raw queries, instead of manipulate them using an Object Oriented like language. Also you can use many adapters for many databases (though it’s not possible right now in WordPress).
If you are writing a large plugin which involves many custom database tables, chances are you will get lost among those tables and queries very shortly. It happened to me as well and I was looking for using ORM’s in WordPress. But there aren’t so many good tools for that. So I looked into Laravel as it’s huge popular now a days. Laravel uses a package named Eloquent as its ORM provider. As it’s a composer package, you can easily use Eloquent into any PHP application.
There are ways to use Eloquent independently, but it requires you to create a separate connection to database. But as WordPress is already connected to the database, why create a new connection? And if we use Eloquent like that, we will miss database reporting from various debugging plugins like debug-bar, query-monitor, etc.
That’s why I wrote a composer package to use Eloquent ORM inside WordPress using the same database connection using WPDB. The benefits are:
- Eloquent is mainly used here as the query builder
- WPDB is used to run queries built by Eloquent
- It doesn’t create any extra MySQL connection
- You get to use the WordPress debug tools/plugins
The package is not perfect, but please do checkout the Github repository for detailed information and usage instruction. Pull requests are always welcome.
View on Github
From yesterday (09-02-2015), the biggest tech conference in South Asia is happening at BICC called Digital World Conference, 2015.
All sorts of software exhibition, tech talks, conference are being arranged in this 4 day long exhibition. There is a slot named CMS Developers Conference where we managed developers from WordPress and Joomla to give their talks. It was a blast with about 1300 attendees.
I gave a talk on Open Source Contribution in WordPress and here is the slide link.
Made it through the credits page and the feeling is really great 😀
Shit just got real, all of a sudden today I made my first WordPress core contribution at this ticket and in this commit :D.
I was checking trac today and stumbled upon this ticket. It was really easy to find and replace some texts. So quickly I submitted a patch and it was accepted within few hours. I just can’t believe that, yes I am excited 😀
Hopefully WordPress 4.0 is going to be released at 27th August, 2014. As this version is going to have language selection from the installation phase, translation is important.
As the validator of WordPress Bengali project, I proposed a translation collaboration effort to give a boost in our Bengali translation. From the banner of our local group WordPressians, today we arranged a “contributor day” to contribute in Bengali translation to WordPress and it was really great. About 30 WordPress lovers joined us in weDevs office to help the Bengali language grow. We already have completed 100% translation in WordPress part, but the Administration area was barely touched (23%). But after the announcement, now we have only about 150 strings left to translate, which was about 1800 before. So that was really an amazing effort.
We have never arranged something like this collaboratively and this worked out really good. It’s always better to do something together rather than doing it alone. More than 50% of them who never translated before. Hats off to everyone who took part at this effort 😀
I am working with WordPress for about 6 years. Web development is my passion and I fell in love with WordPress very shortly as it was really easy to pick up and get going.
Since then, I wrote many plugins and created a lot of themes and got involved with WordPress. Also I maintain the official Bengali translation project. Though I couldn’t get my head around with WordPress trac and still I couldn’t contribute to WordPress core, I intend to do so in near future. I am watching closely WordPress development and know the community and developers around it through blogs, twitter, github and so on. But as I am living in a third world country, face to face interaction was not an option.
I see people gather in WordCamps and meet other WordPress folks in person, networking is a breeze in WordCamps. I always wanted to attend a WordCamp and this year I was planning to attend one anyhow. I chose WordCamp Europe firstly because of the cultural gatherings it brings. Countries all over the Europe and America gathers on that event, it was the main attraction to me. But sadly, it’s happening on Sofia, Bulgaria and there is no embassy of Bulgaria in Bangladesh. So I had to skip it.
Next target is WordCamp San Francisco. It should have been the first choice, because it’s The Grand WordCamp! But as it’s harder to get an US visa, I was skeptic on this. But as WCEU was out of question, WCSF was the choice. Interestingly, WCSF offered a travel assistance program this time to bring more diversity. I applied for it and luckily, I got selected. Hell yeah! 😀
I got the official invitation letter from Jen Mylo with details. I submitted my visa application on 4th August (this month) and got the visa interview date at 10th August (today), though I didn’t expect the interview date too soon. So today I attended for the visa interview and I got the visa 😀 . Well, to be specific not today, will get the passport back at 13th August.
So, if everything goes right, I will be attending WordCamp San Francisco this year. I hope it’ll be a blast and planning to arrange the first ever WordCamp in Dhaka next year. Fingers crossed 😀
Happened to many users, may be happened to you as well. You translated a language file in your theme or plugin, but you lost that file when an update came. Your hours of work, lost! That’s why WordPress has a hidden feature just for that.
WordPress loads the language files based on the plugin language scheme. Some prefers to put their language files in the
languages folder, or some in
lang folder. It’s the plugin authors personal preference. But either way, if WordPress doesn’t find the current language in that plugins/themes folder, it searches on the
/wp-content/languages/plugins folder. Note that, it’s the
languages folder in the
If you have
wpuf textdomain in a plugin, it’ll search for
wp-content/languages/plugins/wpuf-LOCALE_CODE.mo file. Similarly for themes,
So if you are translating a theme or plugin and you don’t want to lose the changes when an update comes, place them on the global languages folder. The better approach would be to contact the plugin or theme author and place them in the plugin/theme officially.
Gave this presentation on 6th WordPressian Meetup at 28th June, 2014
Here in Dhaka, a big technology fair is going on from 4th – 7th June, 2014 at Bangabandhu International Conference Center. Today (6th June, 2014), phpXperts arranged a DevCon with 11 interesting topic and thousands of viewers participated over there. It was such a blast!
Among them I also gave a talk on Composer and here’s my presentation.
Rifat Nabi on Build Tools
Jan Jongboom from Mozilla
Machine Learning by Nhm Tanveer Hossain Khan
CSS Preprocessor, Why and How – Mizanur Rahman
Getting the most out of Chrome Developer Tools – M. Mahbubur Rahman
Introduction to Laravel 4 by Mozammel Haque
Angular JS by Mafinar Khan
User Experience by Azec Elahi
Beyond PHP4 by Mohammad Emran Hasan
Crowd from the front view
Hasin Hayder as Anchor
Crowd from the behind
Composer – The missing package manager for PHP by Tareq Hasan
Making consistent naming after my company weDevs, I named the documentation theme as weDocs. Now another plugin came as weGallery, very consistent!
There are many plugins available in the WordPress.org plugin directory for the same needs, gallery. I’ve seen the most downloaded NextGEN Gallery, it has lots of feature and very complex. If you need a simple gallery, it’s an overkill. So I wanted to create a new one, that would be very simple. Then I found Rocket Galleries via WP Tavern. It’s very simple and what I wanted, mostly!
As I found the features I was looking for in rocket gallery, but it felt short. The plugin is nicely built and I liked the way it’s written, the codes! But it didn’t do something right:
- Taking advantage of Custom Post Type
- It used a custom table for galleries that I didn’t wanted.
- It didn’t have a github repo, so I couldn’t contribute.
- I saw some features that I would need, but no way to integrate there without forking.
- Lastly, I want to use things that acts the way I want. If none does, I create them!
So weGallery born
I needed a gallery for a next venture I am working on. It’ll be public next month I hope, my first SaaS project. So as rocket gallery felt short, I jumped into the code and weGallery was born. It’s always fun to create new things and I hope to integrate more features into it. But if you are like me, wanted a gallery plugin, please feel free to add new features into the plugin.