Categories
Web Development WordPress

WordPress: How to create image sizes dynamically on the fly

WordPress is awesome. But like any system, it’s not great at everything. One of those things is media image size management, where it just doesn’t work well. The Problems: WordPress uses something called “Thumbnail Image Sizes” to maintain different versions of your images in different image sizes. You define these image sizes under Settings -> […]

Categories
Web Development WordPress

WordPress dynamically change user capabilities

I was looking for an easy way to dynamically add or remove capabilities for users based on either their IDs or roles, but I couldn’t find any elegant solution. That is until I found a beautiful filter: https://codex.wordpress.org/Plugin_API/Filter_Reference/user_has_cap It’s so simple, and you can just add this to your functions.php file, or use it in […]

Categories
Web Development WordPress

How to get the second level navigation only from WordPress wp_nav_menu()

We’ve all been there. There’s a perfectly good menu in the admin under Appearance -> Menus which has the whole site laid out perfectly. Now we start coding the templates and realize that we only need sub-menu items of a particular page, of a particular level from that menu. There are two ways to do […]

Categories
Magento Web Development

How to add a color picker in the Magento admin or anywhere

Greetings, developers of all colors! First of all this tutorial assumes that you already know how to make a Magento extension. Now there are many ways to add a color picker in the Magento admin (or anywhere). Here’s one “correct” and “extendable” way to do it: First, we would need a color picker. This color […]

Categories
Magento Web Development

Magento direct SQL queries with named binding

If you’ve been coding in Magento long enough, you would have come across a situation where you need to query the database directly. For whatever reason, no judgements. Well, here is my contribution to save you a lot of time. And this is as secure as using models to interact with your database. If you […]

Categories
Web Development WordPress

How to add custom styles in the WordPress TinyMCE editor without a plugin

I’m sure you’ve run into this issue so many times if you’ve made themes whose complexity ranges from medium to tearing-your-hair-out-and-wishing-the-designer-has-diarrhea: The admin needs to be able to add a custom style to one of the elements from the WordPress editor. Sounds simple enough, and it is. But before you go styling away, always keep […]

Categories
Magento Web Development

How to make a custom Magento payment extension for an external gateway

Note: This tutorial is for Magento versions 1.x.x, and does not work on Magento 2 +. Magento is a great open source e-commerce platform and has emerged as the market leader in the recent past. However, it still has a steep learning curve and although the community is growing exponentially, I was not able to […]