Have you ever tried to automate WordPress upgrade tasks or deployments? I did, it was a big pain.
Sometimes I would find myself updating WordPress options on 54 different blogs trough the admin interface. Completely tired of it I created a little tool to automate these kind of things trough the command line interface (like every self respecting developer would do). The wp-cli project was born.
Read the rest of this entry »
As a freelancer you try to do your job as best as possible, but is that enough to compete with the other freelancers around? I have been freelancing as well, so seeing the case from both sides is quite interesting.
In the last few years we had to hire freelancers for different types of work and amongst them there was a stunning difference in style. So how can you be the perfect freelancer? It is a combination of style, communication and great work.
Read the rest of this entry »
We just updated our htaccess tester to support the HTTP_REFERER variable in your rewrite rules. To do so we simply added a new field underneath the field for the htaccess. You can type any url in this field, which will be used in the script as the HTTP_REFERER variable. The field is optional, if you leave it empty the HTTP_REFERER variable will also be empty.
Read the rest of this entry »
Last wednesday we where struggling with some complex rewrite rules. To test them we had to setup a local server and keep hitting that refresh button after each change. The only thing we could see is if the url was rewritten to the right location or not, but there was no way to actually see what’s happening. So we went on a hunt for a htaccess tester, something like Rubular which we use for regular expressions.
To our surprise there was no simple app to test rewrite rules, so we decided to dedicate our wednesday afternoon to build one, here is the result: htaccess.madewithlove.be.
Read the rest of this entry »
We are currently working on a WordPress project where visitors need to be able to upload images for a competition. Their data is stored as a custom post type but we wondered how we’d store their image uploads? We can’t upload them trough regular php and add a meta to the post linking to the image, but what about WordPress’s different image sizes and media management?
The solution turns out to be really easy if we use the WordPress function media_handle_upload. It works with the normal $_FILES array, resizes your image, and gives back the attachment id.
Read the rest of this entry »
A while ago Jonas and I where discussing hosting control panels over lunch. Most of them are unappealing and unusable for average internet users. A few web hosting companies also write their own control panels, they have no choice. This happens because every hosting environment is so unique that sometimes using an existing control panel simply isn’t viable.
About 6 years ago I remember writing a script to dynamically generate email aliases from a mysql database, on a shared server. All the members of our boys scout group could fill out out their email address in their profile and they would automatically get an alias on our domain by doing so.
About a year later I wrote a control panel for my clients on my reseller package. By using the DirectAdmin API I allowed my clients to manage their email accounts and view their usage statistics. Those where my end-clients, small business owners that would get lost in DirectAdmin itself.
Since then a lot has changed on the field of server management itself but the market of hosting control panels hasn’t changed much. We think it’s time for a change. Instead of hacking all this stuff wouldn’t it be great to, for example, be able to install a plugin on WordPress to manage your mail accounts?
Read the rest of this entry »
// @todo Merge with wp_delete_user() ?
Like they suggest in their comment the wpmu_delete_user function is not ready yet. When deleting a user, WordPress does not allow you to reassign the user’s content to another user. My rewrite below is a merge with the wp_delete_user that lets you do so.
function wpmu_delete_user($id, $reassign) {
global $wpdb;
$id = (int) $id;
do_action( 'wpmu_delete_user', $id );
$blogs = get_blogs_of_user( $id );
if ( ! empty( $blogs ) ) {
foreach ( $blogs as $blog ) {
switch_to_blog( $blog->userblog_id );
remove_user_from_blog( $id, $blog->userblog_id );
if ( 'novalue' === $reassign || null === $reassign ) {
$post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) );
if ( $post_ids ) {
foreach ( $post_ids as $post_id )
wp_delete_post($post_id);
}
// Clean links
$link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) );
if ( $link_ids ) {
foreach ( $link_ids as $link_id )
wp_delete_link($link_id);
}
} else {
$reassign = (int) $reassign;
$wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) );
$wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) );
}
restore_current_blog();
}
}
// FINALLY, delete user
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
clean_user_cache( $id );
// allow for commit transaction
do_action( 'deleted_user', $id );
return true;
}
I think it would be even better to use the wp_delete_user function in this function instead of just copying the code, by doing that the hooks would be triggered for each blog which would allow each’s plugins to do their thing.
Most web companies host their client’s websites on their own dedicated servers, managed by one of their developers. We used to do the same until we realized that it only brings problems and you end up spending a lot of time on it, reducing your profit greatly. It may sound like a way to make easy money, in the beginning, but when you run into problems, your idea will bite you back.
At madewithlove we try to only do what we are specialized in, and outsource everything else to partner companies. We’ve built a long term relationship with those partners, most of whom become friends. We give them access to documentation in our internal wiki, they know how we work and what we require from their end.
This morning we ran into troubles with a high-level client. Luckily enough, we had our partner to hold our hand. You can read the story in the full article.
Read the rest of this entry »
We don’t do designs ourselves, we receive them from our clients or partners. Because of this we work with a lot of different designers, all with their own habits which is cool, but after working like this for a few months we realized that we had to streamline this process. Since a couple of weeks we have started to ask every designer that works with us to take the following guidelines.
Read the rest of this entry »
While creating web applications at madewithlove we often encounter strange problems. Sometimes we spend hours trying to solve them and we don’t want you to have to do the same, that’s why we put the solutions here.
And, of course, sometimes we just have a crazy idea we want to test out and tell you about our findings.
That’s what this blog is about, our web development stories.