Defer parsing of javascript to improve performance in wordpress

Nothing for introduction, hehe! A very small snippet which will help you to defer parsing all javascript files except jquery in wordpress. Here is the code: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer "; } add_filter( 'clean_url', 'defer_parsing_of_js', […]

Continue Reading

You may also like

Why you shouldn’t use one click installer to install wordpress

Yes, you will fall at the mid-ocean, trust me! Well, most of the bloggers just maintain a simple blog so usually they don’t need to worry. They just need to keep a regular backup. But if you are planning to run a business site in wordpress and if that site is your everything, never ever use one click installer to install wordpress! You’d be better off installing it manually which may take you a few minutes longer to install. Here you can get an idea about manually installing wordpress: codex.wordpress.org/Installing_WordPress www.siteground.com/tutorials/wordpress/wordpress-installation.htm If you want to install manually, download wordpress from […]

Continue Reading

You may also like

How to convert hexadecimal color value to RGB value in php

Most of the CMS provides a color picker in admin panel to user to choose a color. And almost all of the color pickers return the color code as hexadecimal mode, e.g. #4EE4D3. So, you can just get the value and set the color in css. For example: [php] body{ background: } [/php] This is a very good practice. Problem occurs if you want to put a opacity option to the user. You can set background opacity with hexadecimal color value. You must use RGBA filter, so RGB color mode as well. Like: [css] body{ background: rgba(233, 122, 234, 0.7); […]

Continue Reading

You may also like

Get current page url in php

In an application, sometimes we need to get the current page URL in php. I mean, the URL shown in the browser. Here is how you can do it. First, we will declare and use the function as the following: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function current_page_url() { $url = 'http'; if ($_SERVER["HTTPS"] == "on") $url .= "s"; $url .= "://"; if ($_SERVER["SERVER_PORT"] != "80") […]

Continue Reading

You may also like

Reorder or rearrange buddypress menu items

Don’t like the order of BuddyPress menu items? Change it! Use the following code and organize in your way – how you want to reorder the BuddyPress menu items. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function my_change_profile_tab_order() { global $bp; $bp->bp_nav['settings']['position'] = 10; $bp->bp_nav['activity']['position'] = 20; $bp->bp_nav['friends']['position'] = 30; $bp->bp_nav['groups']['position'] = 40; $bp->bp_nav['blogs']['position'] = 50; $bp->bp_nav['messages']['position'] = 60; $bp->bp_nav['profile']['position'] = 70; } add_action( ‘bp_setup_nav’, ‘my_change_profile_tab_order’, 999 […]

Continue Reading

You may also like

Get All posts by tag in a network – wordpress multisite

If you want to show some selected posts as popular posts across the network, then this snippet is for you You can fetch posts by any tag that is available in your wordpress multisite network and show those to anywhere, maybe in the main site or in any subsite. If you want to show posts from some selected subsites, you just need to pass those blog IDs as an array parameter or if you send an empty parameter it will fetch posts from all subsites in the network. Here is the code: This file contains bidirectional Unicode text that may […]

Continue Reading

You may also like

Show posts based on user preference in wordpress

This is an interesting snippet that will help you to set a preference for the users, so that they will choose their favorite categories and they will see posts from these categories only. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php add_action( 'show_user_profile', 'extra_fields' ); add_action( 'edit_user_profile', 'extra_fields' ); add_action( 'personal_options_update', 'save_fields' ); add_action( 'edit_user_profile_update', 'save_fields' ); add_action( 'pre_get_posts', 'exclude_category' ); function extra_fields($user) { $pref_cat = explode( ',', […]

Continue Reading

You may also like