Saturday 26 January 2013

Add New Tab into Woocommerce and Woothemes

How to add new tab in Woo-commerce plugin & themes ?

There are mainly three tabs available in woocommerce plugin & themes like Product Description, Additional Information & Product Reviews.

If some one add new tab into product page its not available into themes or plugin with out Tab manager plugin of woo-commerce.

Here I explain you how to add extra tab in woo-commerce.

Just follow below step & you get the solution.

Copy & past the below code into your function.php file.

add_action( 'woocommerce_product_tabs', 'sb_woocommerce_new_tab', 40 );
add_action( 'woocommerce_product_tab_panels', 'sb_woocommerce_new_panel', 40 );
function sb_woocommerce_new_tab() {
 echo '<li><a href="#tab-new">' . __('New Tab', 'woocommerce') . '</a></li>';
}
function sb_woocommerce_new_panel() {
 echo '<div class="panel" id="tab-new">
 <h2>New Panel</h2>
 <p>Example content...</p>
 </div>';
}

Now, in above code change the tab name as you want, here is the New 
Panel, you can see the new tab with your name.

Connect Facebook With Wordpress

How to connect facebook with wordpress ?

To connect Facebook with WordPress Facebook announce one plugin called "FACEBOOK FOR WORDPRESS", which is available on facbook developers, click here for plugin.

Using this plugin you can connect your wordpress blog to facebook with some few clicks.


Below are the step for activating this plugins:

step :1 - Install plugin "Facebook for Wordpress"

step :2 - create facebook application credentials from https://developers.facebook.com/apps.

step :3 - now save changes & your wordpress blog will be connect with facebook.

Disable Wordpress Feed

How to disable feed in wordpress ?

Sometime we don't require feed and we want to remove from wordpress site/blog.
Here I show you, how to remove wordpress feed.

To remove wordpress feed from your wordpress website you have to copy following code into your function.php file.

  • *
  • * disable all type of feed
  • */
  • function fb_disable_feed() {
  • wp_die( __('Sorry...!!! No feed available,please visit our <a href="'. get_bloginfo('url') .'">Website/Blog</a>!') );
  • }
  • add_action('do_feed', 'fb_disable_feed', 1);
  • add_action('do_feed_rdf', 'fb_disable_feed', 1);
  • add_action('do_feed_rss', 'fb_disable_feed', 1);
  • add_action('do_feed_rss2', 'fb_disable_feed', 1);
  • add_action('do_feed_atom', 'fb_disable_feed', 1);

Above code is not delete the feed or url for feed, when some one visit the feed url of your websit it will show message like "Sorry...!!! No feed available, please visit our website/blog", which is write in above code.


Exclude post from wordpress feed

How to exclude post from wordpress feed?

Some of your posts, which you don't want to add in feed, here is the solution for that.
Here I use the filter posts_where(wp-includes/query.php), which is responsible for the output of the query.

Make sure you use the filter where you want to filter. Here it is in our feed $wp_query -> is _feed.
Otherwise it may be hide your post in post overviews.

In this function there is two parameters. In first parameter $where an extension of the my-SQL string, use for the filter of post based on ID. In bracket you have to put the posts ID which you want to filter.

  • function fb_post_exclude($where, $wp_query = NULL) {
  • global $wpdb;
  • if ( !$wp_query )
  • global $wp_query;
  • if ($wp_query->is_feed) {
  • // exclude post with id 40 and 9
  • $where .= " AND $wpdb->posts.ID NOT IN (40, 9)";
  • }
  • return $where;
  • }
  • add_filter( 'posts_where','fb_post_exclude', 1, 2 );

You can easily edit it with your requirements, function is so simple & easy to edit.

Friday 25 January 2013

Reduce the wordpress loading time

Reduce/decrease the wordpress loading time.

Some time wordpress take more time to load & execution time is more compare to normal.
for decrease the loading time wordpress website or blog you have to set SHORTINIT.

If SHORTINT is set, wordpress reduces initializing to a minimum.


  • // reduce the loading time for wordpress, set shortinit.
  • if ( SHORTINIT )
  • return false;

or you can activating in wp-config.php file via define ( 'SHORTINIT' , TRUE); is done quickly.
now, your wordpress site take minimum time to loading.

How to disable Dashboard welcome panel in wordpress?

How to disable Dashboard welcome panel in wordpress...??

In wordpress Dashboard all new release & update will be displayed. Sometimes we are not interested into this type of page, for that wordpress provide features to disable dashboard new update & release news.Therefore, a small function that suppresses the info screen and adjust the user settings, so this screen won't appear.



Add below function, after that you can't see the dashboard welcome panel in wordpress.
or you can do this also manually via "Dismiss" link, on right top of the welcom panel.

add_action( 'load-index.php', 'fb_hide_welcome_panel_for_multisite' );
function fb_hide_welcome_panel_for_multisite() {
             if ( ! is_multisite() ) // don't check, if you will use this on single install of WP 
                       return;
             if ( 2 === (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', TRUE ) )      
                      update_user_meta( get_current_user_id(), 'show_welcome_panel', 0 ); }

WordPress 3.5.1 Security Release & Maintenance


WordPress 3.5.1 is now available with solved security issue.
Wordpress 3.5.1 is the first maintenance release of 3.5,  with fixing 37 bugs. It has solution for all previous WordPress version's security issue. Here some of bug fix issue, which include:
Editor: Prevent certain HTML elements from being unexpectedly removed or modified in rare cases.
Media: Fix compatibility issues in the new media manager & a collection of minor workflow.
Networks: Suggest proper rewrite rules when creating a new network.
Prevent scheduled posts from being stripped of certain HTML, such as video embeds, when they are published.
Work around some mis-configurations that may have caused some JavaScript in the WordPress admin area to fail.
Fix some warnings that could occur when a plugin misused the database or user APIs.
Additionally, a bug affecting Windows servers running IIS can prevent updating from 3.5 to 3.5.1. If you receive the error “Destination directory for file streaming does not exist or is not writable,” you will need to follow the steps outlined on the Codex.

WordPress 3.5.1 also fix the following security issues:
A server-side request forgery vulnerability and remote port scanning using ping-backs  This vulnerability, which could potentially be used to expose information and compromise a site, affects all previous WordPress versions. 
Two instances of cross-site scripting via short-codes and post content.
A cross-site scripting vulnerability in the external library Plupload.  These issues also fixed in wordpress 3.5.1.