Hardeep Asrani

WordPress Developer, Kanpur

β€œNeighbors bring food with death and flowers with sickness and little things in between. Boo was our neighbor. He gave us two soap dolls, a broken watch and chain, a pair of good-luck pennies, and our lives. But neighbors give in return. We never put back into the tree what we took out of it: we had given him nothing, and it made me sad.”

– Harper Lee (April 28, 1926 – February 19, 2016)

Using postMessage Transport Method For Header Image

So right now I’m making some major changes in all my themes and was stuck at header images. First I tried to use the following code to set the transport to postMessage but it didn’t work:

$wp_customize->get_setting( 'header_image' )->transport = 'postMessage';

It was still refreshing the page in the Customizer. I tried to search for a solution but it looks like no one ever posted a solution (not on the first page at least), so I tried to resolve it myself.

So I tried to look in the header image control’s file in the core, which is /wp-includes/customize/class-wp-customize-header-image-control.php

And then I tried few things to see what works out and here’s what worked out for me. In the customizer.php file of my theme, I used the following code:

function theme_customize_register($wp_customize) {
    $wp_customize->get_setting( 'header_image'  )->transport = 'postMessage';
    $wp_customize->get_setting( 'header_image_data'  )->transport = 'postMessage';
}
add_action('customize_register', 'theme_customize_register');

And in the JS file, I used this:

( function( $ ) {

    // Style > Background > Background Image
    wp.customize( 'header_image', function( value ) {
        value.bind( function( newval ) {
            $('.site-header').css( 'background-image', 'url(' +newval+')' );
        } );
    } );
    
} )( jQuery );

And it worked for me. I don’t know if it’s the best way to do this or not but it worked for me. Hope it helps you. πŸ™‚

Star Wars!!! And Some Other Stuff

Star Wars: The Force Awakens (oh boi!) is just few days away from hitting the theaters!!! Unfortunately for me, it will hit theaters here in India on 25th December, so basically I will have to avoid all the spoilers for an entire week!!

My pal created a plugin, similar to Holly Dolly, called The Force. It displays random Star Wars quotes so download it if you’re a fan. It’sA pretty cool.

Now let’s talk about what I’m up to now. Right now I’m trying to improve my programming skills and working on theme development. In last month, I released Latte (free/Pro) and redesigned DocPress theme.

And let me put this honestly, Latte theme is theme worth every penny, but with bad promotion from me. The theme is great, with bad bad bad marketing. So right now I’m giving more time to building more things and hoping to start a theme store in 2016, and I’ll focus on marketing after that.

I do everything, from designing to writing documentation, so if you’re interested in being a part of this then feel free to contact me. It’s pretty hard to manage at this point. I work for ThemeIsle, create my own themes, study, manage my new apartment and also do a little bit of blogging.

TheBlogCode.com is really slow because I don’t get much time to blog, while TricksPanda.com is pretty much dead, so if you wanna buy TricksPanda then it’s up for sale! TheBlogCode.com is a project which I’m doing just to fulfill my passion for writing, regardless of views.

So yes, my schedule is pretty much packed! Anyway, if you have any suggestions for me then feel free to contact me, or if you just wanna talk about Star Wars. Let’s wrap this blog post too! May the force be with you all! πŸ™‚

Everything Has Changed

If you look around you’ll find out that my website’s theme is completely different from what it was few hours ago. And if you dig deep, you’ll find out that this design isn’t complete. For example, there’s no comments section as I speak. So let me tell you what happened.

I was using Chun by Justin Tadlock, along side his portfolio plugin. When I logged in to my site earlier tonight I found a new update for the portfolio plugin. And that was a real mistake. As it got updated, I found out that it wasn’t compatible with Chun’s design and it ruined my entire portfolio. I tried different solution and nothing worked so I had to change the theme.

The new theme is called Latte, designed by me. I was designing it for my site it wasn’t ready to use. But I had no other options so I had to activate it. I’ll try to finish this theme as soon as possible.

Man, last few hours were terrible due to all this. Anyways, enjoy the new design. It looks great on iPad. πŸ™‚

WWE Live, We’re Coming!

WWE is coming to India after 13 years, next year in January, and I’ve booked my tickets for the event!

My friend Rubai & I are going to attend this event. This is the first time we will even meet each other, too, so I’m really looking forward to this day. It’s still two months away.

Are you going? Feel free to stop by and say hello! πŸ™‚

I’m Moving

This came as a surprise to a lot of friends (all of them, literally), but I have decided to leave Kanpur and move out to Hyderabad. I’ve a stable job, and I work from the home, so why the hell am I leaving the city where I have my everything?

There are many reasons, and I can’t write all of them here but one of the biggest reason is that I’m not going anywhere here. And I’m bored of my everyday life which has no excitement left, for now. So I’ve decided to do a little (okay, it’s not little) experiment with my life to see where it takes me. And yes, I’m scared. I have no idea what’s going to happen, but at the same time I’m excited. And if you live in Hyderabad then feel free to drop a line so we could grab a cup of coffee. πŸ™‚

Well, that’s pretty much what’s going on in my personal life. I’m moving in the first half of the November, so I’ll keep you updated.

And speaking of updates, I’ve started TheBlogCode.com – and I’m not going to write down what I’m going to do with this website, because I’ve already posted about it here. And I’m also working on an update for DocPress theme, which will pretty much change the entire look of the theme. I wasn’t satisfied with the work quality of the DocPress theme, so I decided to redesign it from the scratch.

Well that’s pretty much it. Things are going pretty slow, eh. Have a great Dusherra, if you celebrate this festival. πŸ™‚