Snippets | Plugins | Themes | Hacks

Dismissing the welcome panel in wordpress multisite

I was working on a multisite project and found that everytime I create a new site and login to the new site, I was shown a wordpress welcome panel (screen) like below

WP-Multisite-dismiss-welcome-panel

Now it was a bit overwhelming for me (and hopefully it will be the same for new users). So I was searching for something that can help me remove this welcome panel. So I thought of trying my hand on writing a brand new plugin (yeah you read it correct, I am writing my first plugin)

I will update this link, once its approved on wordpress.

So basically this plugin removes the welcome panel for wordpress multisite. It will have no impact on wordpress singles sites.

Kindly comment and let me know what do you think about the plugin, this will help me to come up with more plugins in future.

Disable wordpress plugin updates

Many a times you want that the plugins you have installed should not show updates. May be because you have modified the plugin for your client’s work or you are doubtful that if the client updates the plugin, it could break the existing site. So what you can do is simply add the following code snippet into your functions.php file and you will disable wordpress plugin updates.
Remember to put the code snippet below to your functions.php without the <php> tag 🙂 as it will already be there 😉 (just mentioning this so that someone who is new to wordpres is not zapped!!)

<?php
remove_action( ‘load-update-core.php’, ‘wp_update_plugins’ );
add_filter( ‘pre_site_transient_update_plugins’, create_function( ‘$a’, “return null;” ) );
?>

Hope you liked the code snippet. More coming your way!!

Load JQuery in footer in WordPress

Those who know wordpress inside out, might be aware that by default WordPress has registered the JQuery Library to load in the header. But using the code snippet below, it changes the behaviour.

Use the following code in functions.php

<?php
    /**
     * Prints jQuery in footer on front-end.
     */
    function ds_print_jquery_in_footer( &$scripts) {
        if ( ! is_admin() )
            $scripts->add_data( ‘jquery’, ‘group’, 1 );
    }
    add_action( ‘wp_default_scripts’, ‘ds_print_jquery_in_footer’ );

 ?>

The need of loading Jquery in footer is high performance.

When we have JQuery script loading in header by default for wordpress, progressive rendering is blocked for all content below the script. Moving scripts as low in the page as possible (here we are loading it in footer) means there’s more content above the script that is renedred sooner and user experience is better.

Additionally, the other problem caused by scripts is that it blocks parallel downloads.

Hope you liked it. Some more useful code snippets coming soon!

Dynamic QR code with your WordPress post/article link

QR codes are everywhere these days. So how about having a QR code for your wordpress articles? Sounds interesting, correct? There are wordpress plugins available for doing this, but here is a simple code snippet that can help you with the same. It will work as automatic QR code generator for your wordpress articles.

Below is the code snippet:

<img src=”http://api.qrserver.com/v1/create-qr-code/?size=150×150&data=”&lt;?php the_permalink(); ?>” alt=”QR Code for <?php the_title(); ?>”/>

Just add the above snippet and get dynamic QR codes for your articles.
A few key points:

  • QRServer is a free service for personal use
  • You can select the size of your QR code. If you see in the snippet, there is a parameter as size, you can change the size there. Remember that the QR code should be square. The minimum size allowed is 10×10 and max is 1000×1000
  • If you pass a wrong/invalid value, it will by default generate a QR code with size 200×200

Simple, correct? Don’t forget to comment and share if you liked it.

WordPress Code Snippets – how to use

In my last post, Introduction to WordPress Code Snippets, I explained a bit about wordpress code snippets. Just to give you a brief overview, code snippet is a small piece of code to attain the desired functionality.

When we use a plugin, we are actually having a function to perform a desired functionality. Now some features are so small that you actually don’t need a plugin for that. Instead you can use a code snippet and get the desired functionality.

For almost every theme, there is a file called functions.php. We will have to insert the code snippet to that functions.php If your theme doesn’t have, create a new file named functions.php and start using the code snippets.

Feel free to drop a comment if you have any questions.

Enjoy!

WordPress 3.4 Beta 2 is out

All WordPress lovers might be aware of the fact that WordPress 3.4 Beta 2 is out and you can download it and test it. A word of caution though, since it’s in Beta stage, kindly don’t run it for production websites.

Since Beta versions are software that are still in development, WordPress itself don’t recommend that you run it on a production site – simply set up a test site for yourself to play around with the new version. And you know what’s to be done, if you find a bug! If you are tester, report it to WordPress and if you are developer, try to fix it! 🙂

WordPress is hoping to release WordPress 3.4 stable version in May, 2012 (if all goes well ;)) The more support WordPress will have from community, the better it will be for them to release the stable version 3.4. If you are a tester and want to help WordPress, refer the Codex article on how to report bugs for WordPress

Okay now a quick sneak peak as to what’s new:

  •     Theme Customizer with Previewer
  •     Flexible Custom Header Sizes
  •     Selecting Custom Header and Background Images from Media Library
  •     Better experience searching for and choosing a theme

There are some under-the-hood changes as well, if interested to know, click here

WordPress 3.4 Beta 1 was released just last week and more than 60 bugs were found, fixed and committed.

If you are theme/plugin developer, this is a perfect time to dive-in. You can download the WordPress 3.4 Beta 2 here

Hope you enjoyed the article!

Introduction to WordPress Code Snippets

If you are a seasoned WordPress developer, you might be aware of the fact that what is a Code Snippet for WordPress!

But if you are novice WordPress enthusiast, this post will be helpful in understanding stuff.

Most of you might be aware of  WordPress plugins and what they are for? If NOT!, then I think you should first understand that (here) and then start reading this post. I love plugins, because they make your life easier. When I started developing WordPress based websites, I found plugins for each functionality I was looking for and I was so happy! Buttttttttt…… then I understood that too many plugins are not advisable for a given website.

I don’t say that don’t use plugins (I loved them and I still love them), but use plugins only when necessary.

Many of the simple plugins are a few lines of code. So instead using a plugin, we can get that functionality using code snippets and this section is all about WordPress Code Snippets.

In my next post, I will cover the basic FAQ’s about WordPress Code Snippets and the following posts will be actual code snippets for your use.

Keep looking for the next post, it’s coming soon!!

Introduction to WPPassion

I refer to different websites and blogs to know more about WordPress, because as everybody loves wordpress, so do I! So I will jot down everything and anything interesting I find about wordpress on the internet. If you have anything that you feel should be included, feel free to let me know.

This blog will everything from basic to professional stuff about WordPress.

Just look out for the latest stuff about wordpress and happy reading!


Create your own website, free on WordPress.com.Create your own website.
Start free