Tag Archives: How to

Make Facebook-Twitter Type Profile Address In Your BuddyPress Network

Allow yours BuddyPress site members to create their usernames in site’s root. So that their profile URL appear as domain.com/username Just like Facebook & Twitter where profile URLs are facebook.com/username and twitter.com/username
Continue reading Make Facebook-Twitter Type Profile Address In Your BuddyPress Network

How To Add Hacks In Your BuddyPress Site Without Loosing Them In The Next Update ?

Add actions and hacks without touching your theme’s function.php file. So that you don’t loose them anytime while running BuddyPress update.

Continue reading How To Add Hacks In Your BuddyPress Site Without Loosing Them In The Next Update ?

How To Restrict Other Servers From Accessing Your Files ?

If your site stores popular image files then for reducing bandwidth usage you can use this Apache hack for denying servers to access your files. Open your sites .htaccess file for editing and add the following code:

<FilesMatch “.(gif|jpe?g)$”>
SetEnvIf Referer “^http://([^/]*.)?mydomain.com/” request_ok = 1
Order Allow, Deny
Allow from env=request_ok
</FilesMatch>

This restricts other domains form accessing all GIF or JPG files in  your website.

How To Access Facebook Messages Received From Strangers ?

Facebook message which you receive from your friends are displayed in the message section but for accessing messages sent to you by strangers you have to follow these steps:

  1. Login to your Facebook account.
  2. No need to visit traditional message menu.
  3. Click Facebook Home.
  4. On the left sidebar there is a messages link under news feed
  5. Click ‘messages’ there.
  6. Click ‘others’ from the drop down.
  7. Now it will show you the messages from strangers.

Disable Comments On WordPress Media Attachments

Using WP Plugin

Download and activate Disable Comments plugin. Using this plugin admins can easily disable comments site wide or according to post type. After installation it can be accessed from settings menu of admin area dashboard.

Using WP Hack

Add this code in your theme’s function.php file:

function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == ‘attachment’ ) {
return false;
}
return $open;
}
add_filter( ‘comments_open’, ‘filter_media_comment_status’, 10 , 2 );

How To Configure Apache WebSite To Use Multiple Ports ?

  1. Open httpd.conf file in your host.
  2. Find Listen 80 and on the next line add Listen 8080
  3. Find VirtualHost section for your Site config.
  4. Add *:8080. It should look like this: <VirtualHost *:80 *:8080>
  5. Restart Apache
  6. Test your work by hitting your site to the new port number. Example: http://www.yoursite.com:8080

This would be helpful for you if your ISP is blocking any port. You can add an alternate port in your website. Here we have used port 8080 but you are free to use any other.

How To Protect wp-config.php And .htaccess Files In WordPress ?

You can block access to your site’s wp-config file from browser by adding following code in your .htaccess file:

# Block access to wp-config
<files wp-config.php>
order allow,deny
deny from all
</files>

For blocking access to your .htaccess file add this code inside your .htaccess file:

# Block access to htaccess
<files .htaccess>
order allow,deny
deny from all
</files>

Note:.htaccess file is present in your site’s root at the same place where you find wp-config file.

Latest Release Of Skype – Install Skype 4.0 in Ubuntu 12.04

If Skype is already installed then update is there for you in Update Manager. If you don’t have Skype then enabled Canonical Partners channel.

  • Visit Ubuntu Software Center
  • Then select Edit > Software Sources
  • Click  tab: ‘Other Software’
  • Check the boxes next to ‘Canonical Partners’

After updating open Software Center and search for and install ‘Skype’ package.

WP-Hack For Adding Google+ Page Badge ‘Add to Circles’ In Your WordPress Blog

Add this code in your theme’s header.php file’s head section:

<link href=”https://plus.google.com/PageID” rel=”publisher” /><script type=”text/javascript”>
(function()
{var po = document.createElement(“script”);
po.type = “text/javascript”; po.async = true;po.src = “https://apis.google.com/js/plusone.js”;
var s = document.getElementsByTagName(“script”)[0];
s.parentNode.insertBefore(po, s);
})();</script>

Replace PageID (in bold text of above code block) with your Google+ Page ID.

Now visit your blog’s wp-admin (Dashboard) >> Appearance >>Widgets and drag text widget to your sidebar.

Paste following code inside your text widget (replacing PageID) :

<g:plus href=”https://plus.google.com/PageID” size=”badge”></g:plus>

For smaller badge use:

<g:plus href=”https://plus.google.com/PageID” size=”smallbadge”></g:plus>

Note: You can get your Google Plus Page ID by visiting your page’s profile and copying the number before /posts or /about in URL.

Function For Defining Default Post Thumbnail In WordPress

Open your theme’s function.php file and add the given function editing the thumbnail image URL (given in bold text) with your own image URL.

add_action( ‘save_post’, ‘wptuts_save_thumbnail’ );
function wptuts_save_thumbnail( $post_id ) {
$post_thumbnail = get_post_meta( $post_id, $key = ‘_thumbnail_id’, $single = true );
if ( !wp_is_post_revision( $post_id ) ) {
if ( empty( $post_thumbnail ) ) {
update_post_meta( $post_id, $meta_key = ‘_thumbnail_id’, $meta_value = ‘https://sangkrit.net/thumbnail.jpg’ );
}
}
}

Restricting Image Upload Size and Upload Time Using PHP

How to Limit File Upload Size using PHP ?

For reducing high bandwidth usage network admins can limit file size  to be uploaded  on server by other users. Following script limits file size a user can upload:

<?php
if ($_FILES[“file”][“size”] < 25000)) // Max File Size: 25KB
{
echo “File size exceeds maximum.”;
}
?>

How to Limit File Upload Time Using PHP ?

Other trick for network admins for reducing high bandwidth usage is to limit file upload time. For this you may edit server’s php.ini file or you can set upload time in your site:

ini_set(‘max_input_time’, 300);

WordPress Hack To Set A Custom Default Avatar

  • Create a new custom Avatar. It should be 60px*60px PNG format.
  • Name it custom-avatar.png.
  • Upload this avatar image in your /wp-content/themes/yourtheme/images directory
  • Open you theme’s functions.php file
  • Copy the following given code and paste it in your functions.php file:

if ( !function_exists(‘custom_gravatars’) ) {
function custom_gravatars( $avatar_defaults ) {
$myavatar = get_template_directory_uri() . ‘/images/custom-avatar.png’;
$avatar_defaults[$myavatar] = ‘people’;
return $avatar_defaults;
}
add_filter( ‘avatar_defaults’, ‘custom_gravatars’ );
}

  • Open your Admin Section (Dashboard)
  • Visit Settings >> Reading section and select your newly uploaded avatar as default.

Embedding SoundCloud In Your WordPress Posts

You can embed SoundCloud in your WordPress posts using WordPress feature oEmbed. It supports auto embedding until your URL breaks the line. WP oEmbed library supports Twitter, YouTube and many other popular services. SoundCloud is not yet supported by WordPress but still you have it by using oEmbed with the help of this function: wp_oembed_add_provider() 

Adding oEmbed for SoundCloud in WordPress:

Open your theme’s function.php file and add the following code:

function add_oembed_soundcloud(){
wp_oembed_add_provider( ‘http://soundcloud.com/*’, ‘http://soundcloud.com/oembed’ );
}
add_action(‘init’,’add_oembed_soundcloud’);

All done. Now you can simply paste SoundCloud URL on separate line and let oEmbed do auto-embedding.

Using WordPress Plugin:

You may also use this WordPress Plugin SoundCloud is Gold.

If you are running your blog on WordPress.Com then you may use the shortcode available for all WordPress.Com users because Sound Cloud is officially supported by WordPress.Com.

If you have a self hosted blog then you may use JetPack plugin and enable option for shortcode embeds. After doing this you can easily use the shortcode as shown here:

Verify Your Google+ Business Page

  1. Make your Google+ plus business page if you don’t have one.
  2. Your Google+ page should be authorized by your business, organization, brand or product etc.
  3. Your Google+ page’s profile should have a link to your business’s website.
  4. Your business’s website should connect to your Google+ page. This is done by adding the Google+ Badge/Code
  5. People (near about 999) must have added your Google+ page to their circles.
  6. You must be authorized as administer.
  7. Contrast your page with Google Terms of Service and Google+ Content – Conduct Policies
  8. Visit: http://support.google.com/plus/bin/request.py?hl=en&contact_type=page_verification&rd=1  fill in the request form and send it
  9. Now wait for approval.

Find A Perfect App In Chrome Web Store By Taking A Little Help From Your Google+ Friend Circles

Now Google Chrome Web Store helps you to share all your Google Chrome’s  items in your Google+ Circles. You may do so by finding them in Chrome’s Web Store and clicking +1 (located in store detail page).

And by clicking “From your circles” (located in Chrome Web Store’s category menu) you can review different apps and themes recommended by your friends. Now it is easy to find right app, you would be getting app suggestions from Chrome Web Store on the basis of all that apps +1’d by your friend circle in Google+.

How To Add Facebook Chat On Firefox Sidebar

1. Open Firefox browser.

2. Move to top navigation menu

3. Select Bookmarks >> New Bookmark

4. Place a new bookmark with following details:

  • Name it “Facebook Chat”
  • Set location at http://www.facebook.com/presence/popout.php
  • Check this “load this bookmark in sidebar”

5. Load Firefox sidebar from View >>Sidebar >> Booksmarks

Show Related Posts In Your WordPress Blog Without Using Any Plugin

Copy and Paste the given code within the loop. It may engage your blog visitors to stay for a longer time:

<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo ‘Related Posts’;
$first_tag = $tags[0]->term_id;
$args=array(
‘tag__in’ => array($first_tag),
‘post__not_in’ => array($post->ID),
‘showposts’=>5,
‘caller_get_posts’=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></p>
<?php
endwhile;
}
}
?>

This code displays posts related to current post. It is based on tags. You may change the number of posts it displays, just change ‘showposts’=>5 with your number.

Display Popular Posts In Your WordPress Blog’s Sidebar Without Using Any Plugin

You can highlight most popular content of your WordPress site in your sidebar. Copy-Paste the following code in your theme’s sidebar.php file:

<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results(“SELECT comment_count,ID,post_title
FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5″);
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href=”<?php echo get_permalink($postid); ?>” title=”<?php echo
$title ?>”>
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>
</ul>

It displays most popular posts on your site’s sidebar.

For changing the number of posts to display in your sidebar:

Look-up for this line in the above code block: FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5″); and Replace 5 with the number of posts you like to display.

Easiest Way for Displaying both Popular and Unpopular Posts in your Sidebar:

Now easiest way to do this (display popular posts) and many other similar things like displaying both popular and unpopular posts, knowing the number of post hits is to use Most and Least Read Posts Widget Plugin

Download from the link, activate it and start using it by placing its widgets in your sidebar. It gives you two different widgets one shows most read posts and the other shows least read posts and also it counts your post hits both on sidebar and in your dashboard All Posts list.