Wednesday 9 October 2013

Send Email Notifications When User Profile Updates In WordPress

Adding this snippet to your functions.php file will send an email to the user when the user updates their profile. It's really great way to provide more security to your users. It's also a great trick if you're running a WordPress site with BuddyPress or bbPress. It makes your website look more advance, and keeps your user secure from hackers.

Just add following to your functions.php:

function user_profile_update( $user_id ) {
        $site_url = get_bloginfo('wpurl');
        $user_info = get_userdata( $user_id );
        $to = $user_info->user_email;
        $subject = "Profile Updated: ".$site_url."";
        $message = "Hello " .$user_info->display_name . "\nYour profile has been updated!\n\nThank you for visiting\n ".$site_url."";
        wp_mail( $to, $subject, $message);
}
add_action( 'profile_update', 'user_profile_update', 10, 2);

Tuesday 8 October 2013

Restrict Access To WordPress Media Uploads

Ever wanted to restrict access WordPress media upload mime/format? Yes, that's why you guys are reading this post. You can perform this trick with directories such as /uploads/, /upgrade/, and /backups/. All you need a .htaccess file for the directory.

Create an .htaccess file for your /uploads/ directory (or use existing file if present). Add following code to the .htaccess file:

# restrict access to uploads directory
<Files ~ ".*\..*">
    Order Allow,Deny
    Deny from all
</Files>
<FilesMatch "\.(jpg|jpeg|jpe|gif|png|tif|tiff)$">
    Order Deny,Allow
    Allow from all
</FilesMatch>

The above code denies access to all files but only to the specified types of mime in the 6th line. You can also add more file types to the code such as .zip, .mp3, .mov, or anything.

You can also use same technique in other directories such as /upgrade/, /backup/, and more. Just create an .htaccess file in the directory and add the above code.

Add QR Code For Posts And Pages In WordPress

QR Code (Quick Response Code) is a great way to promote your content, and is very easy for users to use them. They can visit a webpage without even typing the entire web address. Just scan the QR Code and that's it.

The QR code system was invented in 1994 by Toyota's subsidiary, Denso Wave. Its purpose was to track vehicles during manufacture; it was designed to allow high-speed component scanning.[

Would you like to add a QR Code to your posts and pages in WordPress? It's easy just add the following snippet to your single.php file of your WordPress theme in the location you wish to display the QR.

<img src="http://api.qrserver.com/v1/create-qr-code/?size=100x100&data=<?php the_permalink(); ?>" alt="QR:  <?php the_title(); ?>"/>

To adjust the size of the QR Code just change the following within the src size=100×100.

Monday 7 October 2013

How To Hide Post View And Post Preview Buttons From WordPress Post Editor

Ever wanted to remove "preview post" & "view post" option from the WordPress' post editor? Here is the solution how to do this. Just add following snippet to your theme's functions.php file and don't forget to update the post type array in the following code:

function posttype_admin_css() {
    global $post_type;
    $post_types = array(
                        /* set post types */
                        'post_type_name',
                        'post',
                        'page',
                  );
    if(in_array($post_type, $post_types))
    echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
}
add_action( 'admin_head-post-new.php', 'posttype_admin_css' );
add_action( 'admin_head-post.php', 'posttype_admin_css' );

How To Remove URL Field From WordPress Comment Form

For some WordPress sites, such as themes, review, and all, you may want to remove Website URL field from the WordPress' comment form. Removing the field could be used for product reviews or if they created a support tickets theme that does not require a url field.

It's not much hard to remove/unset the website url from the comment form. Just add following snippet to your functions.php file and it's done:

add_filter('comment_form_default_fields', 'unset_url_field');
function unset_url_field($fields){
    if(isset($fields['url']))
       unset($fields['url']);
       return $fields;
}

Change Post Color By Status In WordPress Admin Panel

It's a great trick if you manage a WordPress site with multiple writers/contributors.It's a great trick if you manage a WordPress site with multiple writers/contributors.

Adding this snippet to your theme's functions.php file will change the background colors of the post / page within the admin based on the current status. Draft, Pending, Published, Future, Private.

add_action('admin_footer','posts_status_color');
function posts_status_color(){
?>
<style>
.status-draft{background: #FCE3F2 !important;}
.status-pending{background: #87C5D6 !important;}
.status-publish{/* no background keep wp alternating colors */}
.status-future{background: #C6EBF5 !important;}
.status-private{background:#F2D46F;}
</style>
<?php
}

How To Login To WordPress Using Your Username Or Email Address

By default, WordPress only allows us to login to WordPress powered sites only with our username. But most of us prefer to enter our email address to login because remembering your email is more simple than usernames.

C. Bavota from bavotasan.com found a great way to allow your users to use either their username or email address to log into WordPress without any plugin. Just add following code to your functions.php file:

function login_with_email_address($username) {
    $user = get_user_by_email($username);
    if(!empty($user->user_login))
        $username = $user->user_login;
    return $username;
}
add_action('wp_authenticate','login_with_email_address');

Kevin Chard improved this trick by adding a snippet to it, which will change the text on the login page from “username” to “username / email.” Add following snippet to your functions.php just below the first code:

function change_username_wps_text($text){
       if(in_array($GLOBALS['pagenow'], array('wp-login.php'))){
         if ($text == 'Username'){$text = 'Username / Email';}
            }
                return $text;
         }
add_filter( 'gettext', 'change_username_wps_text' );

Sunday 6 October 2013

How To Change WordPress Author URL Slug


In WordPress, an author's profile is by default accessible by using the yoursite.com/author/name. But it's really easy to change the default author url slug/base. All be just need is a simple snippet.

Kevin Chard found a great code to change the default yoursite.com/author/name to yoursite.com/profile/name. Just add following snippet to your functions.php file:

add_action('init', 'cng_author_base');
function cng_author_base() {
    global $wp_rewrite;
    $author_slug = 'profile'; // change slug name
    $wp_rewrite->author_base = $author_slug;
}

Replace profile on line 4 by any slug you want.

Saturday 5 October 2013

Add Short URL Below Posts In WordPress Without Plugins


Previously I shared a post on this blog about adding a Short Link Widget Below Posts In Blogger, which is a great tutorial for Blogger admins. But I never shared anything like that for WordPress blogs. There are a lot of plugins to add this short link widget below your posts, but we're going to do this without any crappy plugin.

Plus, instead of going with one short link service, you can choose between two short links services. Both services are well known, and easy to use. These two short links services are tr.im and TinyURL.

Add Short URL Below Posts In WordPress:

Add one of the following two codes to your functions.php file:

For tr.im:

function getTrimUrl($url) { $tinyurl = file_get_contents("http://api.tr.im/api/trim_simple?url=".$url); return $tinyurl; }

For TinyURL:

function getTinyUrl($url) { $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url); return $tinyurl; }

After adding one of the above codes to your functions.php file, add following code in your single.php file, within the loop:

<?php $turl = getTinyUrl(get_permalink($post->ID)); echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>' ?>

Above code is for a hyperlink style short link. You can also add a text box style widget with the following code:

<?php $turl = getTinyUrl(get_permalink($post->ID)); echo 'Tiny Url for this post: <input readonly="true" type="text" value="'.$turl.'"/>' ?>

Save your files, and That's IT!

Friday 4 October 2013

5 Professions For Being A Good Blogger


Before moving to very specific nuances of blogging every new person in this field of Internet acting should consider certain basic things. We are talking about that skills which are greatly required for a successful blogging career. These five professions are truly advised to master for a proficient blogger.

Profession #1 A Writer:

The ability to compose a text is the most important skil for any blogger. Even if you have a photo blog, you still have to write a title and subheadings in a correct way.

Advice: There is no need to know how to write compositions on a certain topic. to know how to write advertising texts is a more important skill!

How to become a skillful writer? There is only one possible answer! You simply need to write. Yes, it will be extremely difficult at the beginning but in time you will learn how to express thoughts and feeling “on the paper.” Classic book on how to write advertising texts can be rather helpful for a new writer. For example, it will help you with an advice on how to pick headings for articles. You can also read heading of teaser advertisings to see the way genius copywriters work.  

Profession #2 A Proofreader:

Of course, you need to write without any sort of mistakes. Sometimes misprints happen with everyone, still if you are the author of a misprint it’s you who will feel embarrassed for it! It’s of vital importance not to make mistakes. 

How to become a good proofreader? The only way out here is to read without stopping. Reading classic literature works helps a lot. Why should you choose classic literature for reading? Anyone will agree that literature of the past is reach with beautiful expressions and good grammar. At the same time not every novel by modern writer is of the same literature quality as classic work.  At the moment we themselves are working on our writing quality.

Profession #3 Marketing Specialist:

To be more specific you need to become a professional Internet marketer. It’s highly recommended to have at least basic knowledge on SEO and SMM. You can use another ways of blog advertising, like writing the website on the pavements, why not? However if you choose more traditional ways of website promotion you’d better get to know more about SEO and SMM.

Profession #4 A Programmer

To make a blog using Blog hosting services doesn’t require specific skills except of browsing. In case you have a desire to create your own blog you will have to learn how to use HTML and PHP as both of them are to be useful rather frequently.  

Profession #5 You Choose:

If you are not going to write posts on such topics as “I woke up. Today is a nice weather” you need to decide on a topic of your blog. Obviously, you have to be a professional in everything concerning the topic you choose. In other words another profession is to be mastered!

Author Author - Paul Smith works at fastcustomwritinghelp.com. He likes different innovations and if you have something new and interesting to share with him, you are welcome to the site, where he is currently working. Paul can be contacted via Google+
Join Us On: Facebook Twitter

How To Change WordPress From Name And Email Address

In many actions, such as registration, password request, plugins and more, WordPress sends email to your users and readers. The default sender name is "WordPress" and the default sender email address is wordpress@yoursite.com.

If you're working on a client site, then I guess he wouldn't like WordPress' default sender name and address. However, it's extremely easy to change the default values to your custom ones. Most of us tries to look for the settings in WordPress' wp-mail.php file, but it's not there.

There settings are written in WordPress' pluggable.php file (wp-includes / pluggable.php). Find following code in line #317- #337 of your pluggable.php file:

// From email and name
// If we don't have a name from the input headers
if ( !isset( $from_name ) )
    $from_name = 'WordPress';

/* If we don't have an email from the input headers default to wordpress@$sitename
 * Some hosts will block outgoing mail from this address if it doesn't exist but
 * there's no easy alternative. Defaulting to admin_email might appear to be another
 * option but some hosts may refuse to relay mail from an unknown domain. See
 * http://trac.wordpress.org/ticket/5007.
 */

if ( !isset( $from_email ) ) {
    // Get the site domain and get rid of www.
    $sitename = strtolower( $_SERVER['SERVER_NAME'] );
    if ( substr( $sitename, 0, 4 ) == 'www.' ) {
        $sitename = substr( $sitename, 4 );
    }

    $from_email = 'wordpress@' . $sitename;
}

First red colored WordPress in above php code is your "sender name", while second red colored wordpress is the username of your email address. Just change there values with your custom ones and save the file.

Thursday 3 October 2013

How To Disable HTML In WordPress Comments



I really hate spammers. They make me sick with their spam comments with all the bold text and hyperlinks. I know that I'm not the only one with this crappy problem, since spammers are everywhere these days. Some of them should write a book about "The life of a Spammer."

You can easily disable HTML in WordPress Comments.So if someone uses the strong code, it will not bold the text etc. It's really important for a WordPresser to disable HTML comments to prevent spammers from commenting with HTML formatted comments.

Just add following code in your functions.php file:

// This will occur when the comment is posted
function plc_comment_post( $incoming_comment ) {

// convert everything in a comment to display literally
$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);

// the one exception is single quotes, which cannot be #039; because WordPress marks it as spam
$incoming_comment['comment_content'] = str_replace( "'", '&apos;', $incoming_comment['comment_content'] );

return( $incoming_comment );
}

// This will occur before a comment is displayed
function plc_comment_display( $comment_to_display ) {

// Put the single quotes back in
$comment_to_display = str_replace( '&apos;', "'", $comment_to_display );

return $comment_to_display;


That's IT!

Wednesday 2 October 2013

Prevent Image Hotlinking With .htaccess

Image courtesy of markinns.com
Ever wonder how someone stealing your images, directly taking the URL and display on their own website can effect your bandwidths? This is what we call image hotlinking. With every single view of our images on their site cost us bandwidths. Because it's called directly from our server.

Not sure about you, but I paid for this bandwidths (not for this site). Just like almost everything, there is a way to stop thieves  from stealing our bandwidths without our permission. For those who are wondering, this tutorial is also for WordPressers.

Visit your FTP/File Manager and add following to your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain2.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjentSbUVx-fuFCCSHSi_6OL0g8IjaYt5K94H5s5v8jCEd4THGRVviaGxcMc5LOVsmvIpC0AuKe1NK4yNMW6lax31b3K6hhQZM2TBblWoGtSQ_i9jK-e4SvIAw0NuU3Vo5KkO0y2n0rPZ4/s1600/Hotlinking.gif [NC,R,L]

By default all sites are blocked from hotlinking. Only those specified by you are allowed to do so. Don't forget to replace yourdomain.com in above code with your website's URL. You can add as many URLs as you want.

Also the link https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjentSbUVx-fuFCCSHSi_6OL0g8IjaYt5K94H5s5v8jCEd4THGRVviaGxcMc5LOVsmvIpC0AuKe1NK4yNMW6lax31b3K6hhQZM2TBblWoGtSQ_i9jK-e4SvIAw0NuU3Vo5KkO0y2n0rPZ4/s1600/Hotlinking.gif is to a image you’ve set, and whenever image hotlinking is detected, this image will show up. You can change it to your favorite hotlinking message or anything you want. Just make sure where this image is not hotlink protected.

Tuesday 1 October 2013

Hide Dashboard Login Errors In WordPress

In this tutorial, I'm going to show how you can easily hide login errors in WordPress. It's a great way to protect from WordPress from hackers. Whenever you login with the correct username but with the wrong password, a message appears saying "Error: Incorrect Password." WordPress has now given a clue to hacker that the username entered is in the system, and that they simply need to crack its password.

Similarly, an "Error: Invalid username" also appears when you enter an unavailable username. It's better for you to prevent hacking by hiding this error message. In order to keep this from happening, you need to add this code to your functions.php file:

add_filter('login_errors', create_function('$a', "return null;"));

This filter code will remove error message from the login page. The error box will still appear, but without any text.

How To Automatically Empty Trash In WordPress

The Trash feature was introduced in WordPress 2.7, and since then, if you click "Trash" for any item, it will be sent to the trash. It works similar to the Recycling Bin feature on Windows. By default, the content you trash remains there for 30 days before being permanently deleted. However, you can also delete items from the Trash at any time.

You can also modify the 30 day period with some simple codes. Just add this line to wp-config.php and you’re done:

define('EMPTY_TRASH_DAYS', 5 ); // Empty trash every 5 days

Monday 30 September 2013

How To Create A Custom Dashboard Widgets In WordPress


Earlier this hour I was surfing thru WordPress' official codex website and I found something very interesting to write about. Okay! I know you guys are so exited about this great trick.

The Dashboard Widgets API (added in WP 2.7) makes it very simple to add new widgets to the administration dashboard. It only takes a few minutes to create a simple dashboard widget for your blogger. It can be a great way to make your plugin and themes even more useful.

How To Create A Custom Dashboard Widgets:

 This code would go in one of your plugin's files, or in your theme's functions.php:

/**
 * Add a widget to the dashboard.
 *
 * This function is hooked into the 'wp_dashboard_setup' action below.
 */
function example_add_dashboard_widgets() {

    wp_add_dashboard_widget(
                 'example_dashboard_widget',         // Widget slug.
                 'Name of your widget',          // Title.
                 'example_dashboard_widget_function' // Display function.
        );   
}
add_action( 'wp_dashboard_setup', 'example_add_dashboard_widgets' );

/**
 * Create the function to output the contents of our Dashboard Widget.
 */
function example_dashboard_widget_function() {

    // Display whatever it is you want to show.
    echo "<p>Welcome to BWidgets! Need help? Contact the developer <a href="mailto:yourusername@gmail.com">here</a>.</p>";

That's it! Red part in the above code is the title and content area of our widget. Don't forget to leave a comment if you need any help with this tutorial.

Friday 27 September 2013

How To Add Extra Fields To WordPress User Profile Page


Yesterday I post an article about removing some extra fields (AIM, Yahoo IM, and Jabber) from WordPress' user profile page area. It's time to dig even more deeper into this trick. It's time for us to learn about adding some extra fields to user profile page.

The code below will show you how to add additional Twitter and Facebook fields, but you can use it to add any other field that you like. Add following php code to your theme's functions.php file (from theme editor):

function my_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter username (withour @';
//add Facebook
$contactmethods['facebook'] = 'Facebook';
return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);


That's it.

Thursday 26 September 2013

How To Stop Users With AdBlock In Blogger/WordPress


Don't you hate it when a crappy extension is blocking you from getting the payoff of your hard work that you put on your blog? Not sure about you, but I really really hate that. More than AJ Styles-Dixie Carter's TNA Promo that I'm watching right now, it's good. Okay, it was a creative way to end the show.

Back to topic. Antiblock.org found a great script to stop users with AdBlock from viewing your website. Don't forget to check and support their awesome project. There is no bad in stopping users with AdBlock from viewing your site because we blogger needs to earn as much as we can for our hard work. It's not easy to run and manage a full time blog without revenues from ads. Here is how to do it:

Stop Users With AdBlock In Blogger/WordPress/HTML:

First of all, you can also use this script on any other blogging/site platform. It works everywhere, even on a HTML page.

For Blogger:

  • Visit Blogger > Template > Edit HTML.
  • Press Ctrl + F and search for ]]></b:skin> and paste below code above it:

#g207{position:fixed!important;position:absolute;top:0;top:expression((t=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)+"px");left:0;width:100%;height:100%;background-color:#fff;opacity:0.9;filter:alpha(opacity=90);display:block}#g207 p{opacity:1;filter:none;font:bold 16px Verdana,Arial,sans-serif;text-align:center;margin:20% 0}#g207 p a,#g207 p i{font-size:12px}#g207 ~ *{display:none}

  • Now press Save Template.
  • Now navigate to Blogger > Layout > Add Gadget, Click on HTML/JavaScript Gadget.
  • Paste the below code into it and press Save.

<script>(function(w,u){var d=w.document,z=typeof u;function g207(){function c(c,i){var e=d.createElement('i'),b=d.body,s=b.style,l=b.childNodes.length;if(typeof i!=z){e.setAttribute('id',i);s.margin=s.padding=0;s.height='100%';l=Math.floor(Math.random()*l)+1}e.innerHTML=c;b.insertBefore(e,b.childNodes[l-1])}function g(i,t){return !t?d.getElementById(i):d.getElementsByTagName(t)};function f(v){if(!g('g207')){c('<p>Please disable your ad blocker!<br/>This site is supported by the advertisement <br/> Please disable your ad blocker to support us!!! </p>','g207')}};(function(){var a=['Adrectangle','PageLeaderAd','ad-column','advertising2','divAdBox','mochila-column-right-ad-300x250-1','searchAdSenseBox','ad','ads','adsense'],l=a.length,i,s='',e;for(i=0;i<l;i++){if(!g(a[i])){s+='<a id="'+a[i]+'"></a>'}}c(s);l=a.length;for(i=0;i<l;i++){e=g(a[i]);if(e.offsetParent==null||(w.getComputedStyle?d.defaultView.getComputedStyle(e,null).getPropertyValue('display'):e.currentStyle.display)=='none'){return f('#'+a[i])}}}());(function(){var t=g(0,'img'),a=['/adaffiliate_','/adops/ad','/adsales/ad','/adsby.','/adtest.','/ajax/ads/ad','/controller/ads/ad','/pageads/ad','/weather/ads/ad','-728x90-'],i;if(typeof t[0]!=z&&typeof t[0].src!=z){i=new Image();i.onload=function(){this.onload=z;this.onerror=function(){f(this.src)};this.src=t[0].src+'#'+a.join('')};i.src=t[0].src}}());(function(){var o={'http://pagead2.googlesyndication.com/pagead/show_ads.js':'google_ad_client','http://js.adscale.de/getads.js':'adscale_slot_id','http://get.mirando.de/mirando.js':'adPlaceId'},S=g(0,'script'),l=S.length-1,n,r,i,v,s;d.write=null;for(i=l;i>=0;--i){s=S[i];if(typeof o[s.src]!=z){n=d.createElement('script');n.type='text/javascript';n.src=s.src;v=o[s.src];w[v]=u;r=S[0];n.onload=n.onreadystatechange=function(){if(typeof w[v]==z&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){n.onload=n.onreadystatechange=null;r.parentNode.removeChild(n);w[v]=null}};r.parentNode.insertBefore(n,r);setTimeout(function(){if(w[v]!==null){f(n.src)}},2000);break}}}())}if(d.addEventListener){w.addEventListener('load',g207,false)}else{w.attachEvent('onload',g207)}})(window);</script>

That's it!

For WordPress:

It's all same for WordPress. Just add following CSS & JavaScript code to your WordPress template:

CSS:

#g207{position:fixed!important;position:absolute;top:0;top:expression((t=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)+"px");left:0;width:100%;height:100%;background-color:#fff;opacity:0.9;filter:alpha(opacity=90);display:block}#g207 p{opacity:1;filter:none;font:bold 16px Verdana,Arial,sans-serif;text-align:center;margin:20% 0}#g207 p a,#g207 p i{font-size:12px}#g207 ~ *{display:none}

JavaScript:

<script>(function(w,u){var d=w.document,z=typeof u;function g207(){function c(c,i){var e=d.createElement('i'),b=d.body,s=b.style,l=b.childNodes.length;if(typeof i!=z){e.setAttribute('id',i);s.margin=s.padding=0;s.height='100%';l=Math.floor(Math.random()*l)+1}e.innerHTML=c;b.insertBefore(e,b.childNodes[l-1])}function g(i,t){return !t?d.getElementById(i):d.getElementsByTagName(t)};function f(v){if(!g('g207')){c('<p>Please disable your ad blocker!<br/>This site is supported by the advertisement <br/> Please disable your ad blocker to support us!!! </p>','g207')}};(function(){var a=['Adrectangle','PageLeaderAd','ad-column','advertising2','divAdBox','mochila-column-right-ad-300x250-1','searchAdSenseBox','ad','ads','adsense'],l=a.length,i,s='',e;for(i=0;i<l;i++){if(!g(a[i])){s+='<a id="'+a[i]+'"></a>'}}c(s);l=a.length;for(i=0;i<l;i++){e=g(a[i]);if(e.offsetParent==null||(w.getComputedStyle?d.defaultView.getComputedStyle(e,null).getPropertyValue('display'):e.currentStyle.display)=='none'){return f('#'+a[i])}}}());(function(){var t=g(0,'img'),a=['/adaffiliate_','/adops/ad','/adsales/ad','/adsby.','/adtest.','/ajax/ads/ad','/controller/ads/ad','/pageads/ad','/weather/ads/ad','-728x90-'],i;if(typeof t[0]!=z&&typeof t[0].src!=z){i=new Image();i.onload=function(){this.onload=z;this.onerror=function(){f(this.src)};this.src=t[0].src+'#'+a.join('')};i.src=t[0].src}}());(function(){var o={'http://pagead2.googlesyndication.com/pagead/show_ads.js':'google_ad_client','http://js.adscale.de/getads.js':'adscale_slot_id','http://get.mirando.de/mirando.js':'adPlaceId'},S=g(0,'script'),l=S.length-1,n,r,i,v,s;d.write=null;for(i=l;i>=0;--i){s=S[i];if(typeof o[s.src]!=z){n=d.createElement('script');n.type='text/javascript';n.src=s.src;v=o[s.src];w[v]=u;r=S[0];n.onload=n.onreadystatechange=function(){if(typeof w[v]==z&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){n.onload=n.onreadystatechange=null;r.parentNode.removeChild(n);w[v]=null}};r.parentNode.insertBefore(n,r);setTimeout(function(){if(w[v]!==null){f(n.src)}},2000);break}}}())}if(d.addEventListener){w.addEventListener('load',g207,false)}else{w.attachEvent('onload',g207)}})(window);</script>

That's it. You can also use this plugin to stop users with AdBlock with some extra options.

After adding above listed code your blog will look something like this:

Image courtesy of HackingUniversity.in

How To Remove User Contact Info From WordPress Profile Page


After writing bunch of articles about WordPress' wp-config.php file, it's time for me to write some articles about the powerful functions.php file. And I'll start from the start. In this post, I'm sharing a very simple and useful trick for WordPressers (WordPressers :p).

Most of us never ever used three fields on the WordPress profile page and so we want to remove those fields. They are the fields for AIM, Yahoo IM, and Jabber. It's time to get rid of these fields:

Add following php code to your theme's functions.php file (from theme editor):

add_filter('user_contactmethods','hide_profile_fields',10,1);
function hide_profile_fields( $contactmethods ) {
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
unset($contactmethods['yim']);
return $contactmethods;
}


That's it..!!

Wednesday 25 September 2013

How To Change The Default WordPress Media Uploads Folder


I'm really loving all the wp-config.php tricks. We can do so much amazing stuff with just some little codes.

Before WordPress 3.5 you used to be able to change the upload directory path from the Settings menu in the dashboard. However, now you can't do anything like that from the settings option, but it’s still possible.

How to Change The Default WordPress Media Uploads Folder:

Open wp-config.php (located in root of WordPress installation) and add following code before the line that says require_once(ABSPATH.’wp-settings.php’);.

define( 'UPLOADS', 'wp-content/custom-path' );

Change wp-content/custom-path with your custom upload path. For example, you can can change it to wp-content/files. Don't forget to add the code before require_once(ABSPATH.’wp-settings.php’);.

Thursday 19 September 2013

3 Ways To Disable WordPress AutoSave


This is my second post of the day here on BWidgets, and it's also about Daniel Bryan wp-config.php file and WordPress AutoPost. This time I'll show you one three ways to disable WordPress AutoSave feature.

When editing a post, the changes you make are automatically saved every 2 minutes. You can also use our last trick to Modify AutoSave Interval.

By Editing wp-config.php File:

This is the easiest way to disable WordPress AutoSave feature. To modify autosave interval simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('AUTOSAVE_INTERVAL', 86400);

We've set WordPress AutoSave interval to 86400 seconds which is an entire day. So this effectively disables the autosave functionality. Thanks to Jacob Nicholson for the idea.

By Editing post.php File:

This is the smartest way to disable AutoSave feature without any heavy codes. Thanks to Shane G. for sharing this trick on a WordPress forum.

  • Open your wp-admin/post.php file and wp-admin/post-new.php files.
  • You will find this line of code there:

wp_enqueue_script('autosave');

  • Add // to the beginning of this code. It'll look something like this:

// wp_enqueue_script('autosave');

The AutoSave option will be disabled for your existing and new posts.

By Editing functions.php File:

Last but not the least. This is the most preferred way to disable this feature, as we don't have to re-edit our post.php and post-new.php file after every WordPress update, nor we have to adjust AutoSave interval. This trick will simple disable AutoSave feature. Thanks to Egill R. Erlendsson for sharing this trick on a WordPress forum.

Simple throw this in your functions.php file:

add_action( 'admin_init', 'disable_autosave' );
function disable_autosave() {
        wp_deregister_script( 'autosave' );
}

That's it folks. Thanks for all amazing guys that I mentioned on the article for sharing these amazing tricks around the internet. Don't forget to give us a backlink if you're sharing this article on your blog.

Modify WordPress AutoSave Interval


Here we're again! Another post about my favorite Pokemon WordPress core file. YES! YES! YES, this post is also about Daniel Bryan wp-config.php file.

When editing a post, the changes you make are automatically saved every 2 minutes. It seems bit weird, but you can actually change the setting for longer delays in between auto-saves, or decrease the setting to make sure you never lose changes.

And we don't need a crappy plugin for this simple hack. Technically, it's not even a hack, but a simple option described in original WordPress codex.

Modify WordPress AutoSave Interval:

To modify autosave interval simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('AUTOSAVE_INTERVAL', 160 );  // seconds

Replace 160 with your custom autosave interval (in seconds).

Save your config.php file & that's it!

Friday 13 September 2013

How To Disable Or Limit WordPress Post Revisions

Post Revisions are a feature introduced in WordPress 2.6. A revision is automatically stored in your database, whenever you save or draft a post or a page. Earlier this year, I posted an article about Deleting Old WordPress Post Revisions at this link.

Today we're going to learn a very simple tweak to disable or limit WordPress post revisions without installing any crappy plugin, which saves a lot of space. We just have to add a little snippet to your our config.php file.

Limit WordPress Post Revisions:

To limit Post revisions simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('WP_POST_REVISIONS', 3);

Replace 3 with maximum number of Post revisions per post/page.

Disable WordPress Post Revisions:

To disable Post revisions simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('WP_POST_REVISIONS', false );

 Save your config.php file & that's it!

Monday 9 September 2013

Editing WordPress wp-config.php File


Editing WordPress core files is a very risky and hard job, especially for WordPress beginners like me. Yea, I'm using WordPress only from last four months, but I have learned a lot from it.

The wp-config.php file is one of the most important files in WordPress. It contains the login information for WordPress to connect to your database as well as table prefix, secret keys, e.t.c. Editing wp-config.php file is very easy, but this file looks a bit scary so beginners usually keeps themselves away from it.

If you installed WordPress using your hosting provider's install wizard, then wp-config.php file will be in your root directory. If you installed WordPress using FTP, then you can find wp-config.php (named as wp-config-sample.php) file in your WordPress download. Don't forget to rename wp-config-sample.php to wp-config.php.

Adding Database Info:

To change the wp-config.php file for your installation, you will need this information:

Database Name
Database Name used by WordPress
Database Username
Username used to access Database
Database Password
Password used by Username to access Database
Database Host
The hostname of your Database Server. A port number, Unix socket file path or pipe may be needed as well. 

Find following lines in your wp-config.php file:

define( 'DB_NAME',     'database_name_here' );
define( 'DB_USER',     'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST',     'localhost' );

It's not that hard. We just have to replace above text with our database's info.

Set Database Name:

Replace 'database_name_here', with the name of your database, e.g. MyDatabaseName.

define( 'DB_NAME', 'MyDatabaseName' );

Set Database User:

Replace 'username_here', with the name of your username e.g. MyUserName.

define( 'DB_USER', 'MyUserName' );

Set Database Password:

Replace 'password_here', with the your password, e.g. MyPassWord.

define( 'DB_PASSWORD', 'MyPassWord' );

Set Database Host:

Replace 'localhost', with the name of your database host, e.g. MyDatabaseHost.
define( 'DB_HOST', 'MyDatabaseHost' );

That's it for this part. Now we have to follow one simple step to complete our wp-config.php file.

Adding Secret Keys:

Now we just have to add some unique keys to our wp-config.php file. Find following in your wp-config.php file:

define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

Put your unique keys in above spaces. You don't have to remember the keys, just make them long, random and complicated. You can change these keys at any time. You can also use WordPress' online generator to automatically generate these keys for you.

These secret key protects your site from getting hacked. A password like "password" or "facebook" is simple and easily broken. A random password such as "w<$4c$aPHmd%/*]`Oom>(hpdXW|0M=X={we6;Mphvtg+V.o<$|#_}qG(GaVDEsn,~*4i')" takes years to come up with the right combination.

That's it for this time. Now after adding/editing above details, your wp-config.php file is ready for some action. You can now save/update the file to your file manager's root directory to see it in action.

Saturday 7 September 2013

How To Embed Facebook Posts To Your Blog



Update (7/9/13):

Facebook recently announced their official plugin to embed public statuses, photos and more. It has more feature than the outdated article version. You can easily get your embed code by visiting this page.

Getting The Embed Code From A Post:

You can also get the embed code directly from the post itself.  Only public posts from Facebook Pages and profiles can be embedded. Choose 'Embed Post' from the drop down menu that appears. You will get the embed code for the post.



Original Article (9/13/13):

There are bunch of Facebook widgets to embed like buttons, like boxes, subscribe buttons, and more. But there is no way to embed a status, photo, link or video directly from Facebook to your blog. Twitter tweets always have an option to easily embed any Tweet to your blog, website, or any html document.

By embedding a status, you can easily display a status on your website, without editing any bit of it. It's really helpful in displaying images on your blog, without uploading them into your blog. It was helpful for me in this post.

How To Embed A Facebook Status:

Tired of taking screen grabs of Facebook posts? SocialDitto makes it easy to embed a Facebook status update into any article or blog. You can easily grab your embed code in less than a minute by visiting SocialDitto. It's free, safe, easy, and quick. Don't forget to leave a comment.

You can check our live demo below:
Hardeep Asrani
Eminem & The Undertaker... -_-

Friday 6 September 2013

5 Tips For Promoting Your Blog With Facebook


Facebook can help you gain a loyal following for your blog. However, you can’t just put your blog posts on Facebook and expect people to click on your links. You need to use some strategies in order to get lots of clicks.

Have a Good Image:

Facebook relies heavily on images. If your blog post doesn’t have a good image, it will likely get lost in the shuffle. Pick an image that will stand out. Also, make sure it represents your post and will resonate with your core audience. That way, it will get people’s attention and they will click to read the blog.

Interact with Your Audience:

People like to reciprocate. It’s human nature. Thus, if you interact with your fans, they will be more likely to interact with you. With that in mind, you need to take the time to read their status updates and blog posts. Comment and hit the like button from time to time. Then, people will be more apt to check your posts out.

Ask Them What they Want to Learn:

Use Facebook to ask people what they want to learn. You can create polls, or simply ask a question. Once you get some responses, let readers know that you will answer their questions in your next blog post. Then, write a blog that addresses those questions. This will attract a lot of readers. After all, people will love the fact that you created a post just for them.

Be Consistent:

Come up with a posting schedule and follow it. That way, people will know when to expect your blogs. Make sure your schedule is balanced so you don’t overwhelm people with blogs. For instance, you might want to post one to two blogs a week to your Facebook account instead of five. Five blogs will overwhelm Facebook users, but one or two blogs will grab their interest

Be Professional:

Spammers love Facebook. Because of that, it is essential that legitimate blog owners come across as professionals. That means you need a professional domain name. You also need a professional theme. Fortunately, both are easy to get. You can get a professional .com from different companies online. You can also find professional Premium WordPress templates online.

If you use these tips, you will be able to get more traffic to your blog. Then, you can create a solid following of loyal readers. Those readers will stay with you as long as you continue to provide quality content.
Author Author - Anny Solway is a dedicated writer at ThemeFuse – a leader in the Premium WordPress Themes area. She likes to discover new ideas about internet marketing, social media and blogging.
Join Us On: Facebook, Twitter, Dribbble

Wednesday 4 September 2013

How To Remove WordPress Admin Bar Without Plugin


A blogger friend asked me about removing WordPress' admin bar without any plugin because he wanted to get rid of all small plugins from his directory. So I found this amazing php code on dfactory.eu.
Put any of the following codes in your Theme's function.php file:

Disable Admin Bar For Everyone:

// Disable Admin Bar for everyone
if (!function_exists('df_disable_admin_bar')) {

    function df_disable_admin_bar() {
       
        // for the admin page
        remove_action('admin_footer', 'wp_admin_bar_render', 1000);
        // for the front-end
        remove_action('wp_footer', 'wp_admin_bar_render', 1000);
         
        // css override for the admin page
        function remove_admin_bar_style_backend() {
            echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
        }     
        add_filter('admin_head','remove_admin_bar_style_backend');
       
        // css override for the frontend
        function remove_admin_bar_style_frontend() {
            echo '<style type="text/css" media="screen">
            html { margin-top: 0px !important; }
            * html body { margin-top: 0px !important; }
            </style>';
        }
        add_filter('wp_head','remove_admin_bar_style_frontend', 99);
      }
}
add_action('init','df_disable_admin_bar');

Disable Admin Bar For Everyone But Administrators:

// Disable Admin Bar for everyone but administrators
if (!function_exists('df_disable_admin_bar')) {

    function df_disable_admin_bar() {
       
        if (!current_user_can('manage_options')) {
       
            // for the admin page
            remove_action('admin_footer', 'wp_admin_bar_render', 1000);
            // for the front-end
            remove_action('wp_footer', 'wp_admin_bar_render', 1000);
           
            // css override for the admin page
            function remove_admin_bar_style_backend() {
                echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
            }     
            add_filter('admin_head','remove_admin_bar_style_backend');
           
            // css override for the frontend
            function remove_admin_bar_style_frontend() {
                echo '<style type="text/css" media="screen">
                html { margin-top: 0px !important; }
                * html body { margin-top: 0px !important; }
                </style>';
            }
            add_filter('wp_head','remove_admin_bar_style_frontend', 99);
           
        }
      }
}
add_action('init','df_disable_admin_bar');

Disable Admin Bar For Specific Users:

// Disable Admin Bar for specific user
if (!function_exists('df_disable_admin_bar')) {

    function df_disable_admin_bar() {
       
        // we're getting current user ID
        $user = get_current_user_id();
       
        // and removeing admin bar for user with ID 123
        if ($user == 123) {
       
            // for the admin page
            remove_action('admin_footer', 'wp_admin_bar_render', 1000);
            // for the front-end
            remove_action('wp_footer', 'wp_admin_bar_render', 1000);
           
            // css override for the admin page
            function remove_admin_bar_style_backend() {
                echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
            }     
            add_filter('admin_head','remove_admin_bar_style_backend');
           
            // css override for the frontend
            function remove_admin_bar_style_frontend() {
                echo '<style type="text/css" media="screen">
                html { margin-top: 0px !important; }
                * html body { margin-top: 0px !important; }
                </style>';
            }
            add_filter('wp_head','remove_admin_bar_style_frontend', 99);
           
        }
      }
}
add_action('init','df_disable_admin_bar');

That's it!

Wednesday 28 August 2013

What Does “Great Website Architecture” Mean?

Getting a good amount of traffic for a website is something that everyone strives for, but what does one have to offer when people stumble upon a website? It is important to address several key points that make up a good website: it needs to be visually stimulating, it needs to have a comprehensive layout, it needs to allow people to get to the pages that they need without too much hassle, it needs to provide information about the blogger/artist/company and their work, showcase all that they have to offer, provide social media sharing capabilities, as well as have plenty of useful information about the niche that the blogger/artist/company is operating in.

source: documentation.ektron.com

Wow, that does sound like a lot, but it doesn’t have to be all that complicated. In fact the key is incorporating all these elements in your website design, but still managing to keep it concise and having a home page that allows quick navigation through the rest of the website. A good website is a perfect balance between utility and flashiness, with a big emphasis on content and media that provides the viewer with something to actually view. Let’s go into a bit more detail on the more important elements of effective website architecture.

The Great Homepage And Linking To Other Pages:

The homepage is you base of operations, so to speak. You will want to have links directly to your most popular pages and news of new offers, deals or events. This is where aesthetics meet functionality and where you have the opportunity to cram in colorful images and information using sliders, as well as have drop boxes that are effectively categorized to allow the viewers to find what they need. Now, a very important point is to avoid going link-crazy and having the viewer click through layers and layers of pages – everything they need should be within 2-3 clicks from the homepage.

Categorizing And Crosslinking Pages:

Being able to find what you need quickly is the most important thing for a person visiting your website, and this is where so often the designer drops the ball. Certain pages that can fit into multiple categories should be accessible through several different paths, and the categories themselves need to be effectively broken down depending on what you have to offer. For example, if you are selling cars you are hardly going to categorize them by color. In that case, you would have categories like hatchbacks, sedans, sports cars, minivans and so on. You could also have several categories based on secondary features that people are interested in - high mileage per gallon, good family cars and cars with the highest safety rating. A nice little Renault would fit into several of these categories and people would be able to get to that particular page through several different paths. Then on that Renault model page you mention that Renaults are some of the safest cars and you link to the page with all the other Renault models and the page that features the cars with the highest safety ratings. This way you make an interconnected web of relevant pages throughout the website.

The Layout Of A Good, Informative Page:

An informative page will feature all that a viewer needs – no less, no more. It is important to focus on elements that will allow the greatest usability of a page – how is it linked internally, does it link to other pages on the website are you cross-linking to other websites from the page? Within the page itself, navigation bars can help tremendously, particularly for e-commerce websites that might have several pages of products within a category and the subcategories help users find what they want without having to click through ten pages and scroll down each one. A blog page is essential for providing useful content and additional information, so that you don’t have to clutter up other pages – having access to recent and relevant posts enhances usability as well.

When looking at website architecture you need to be constantly thinking about the average user; what will they be looking for and how easy they will find it to navigate the website? Testing your website can help provide you with useful clues about optimizing your design features, but you will need a good base to begin with. So put yourself in the average Joe’s shoes and take another look at how your website is structured.

Author Author - Mark Taylor is a full time employee with Melbourne based web development company - Leading Edge Web - as a UX specialist and digital producer . Working closely with well-known brands and leading Australian companies , he helps define the optimum digital solution for their online presence. Mark also liaises with internal developers and creative teams in managing project scope
Join Us On: Facebook, Twitter, Google +

Monday 19 August 2013

How To Post Your Twitter Tweets On Your Facebook Page

Updating multiple social networks at same time is a huge headache. We all use dlvr.it and other websites to automatically publish our blog's feed to social netoworks, but sometimes we just want to post more than just blog feed.

I run a pro-wrestling news website, with a live play-by-play Twitter and Facebook coverage of the shows and pay-per-views. I don't have enough time to most on various social media platforms at the same time, so I use Twitter's build-in feature to automatically publish my tweets on my blog's Facebook Page.

Yup, there is an option on Twitter to publish your tweets on your Facebook page, without any external plugins. It's very easy. Here we go:

Automatically Publish Your Twitter Tweets On Your Facebook Page:

Login to your Twitter account, and visit on Profile Settings. On the bottom of the page, click on Login to Facebook

After logging in, mark Post to my Facebook page option, and choose your Facebook page.

That's it. Replies and direct messages will not be posted on your page. You can also mark post retweets option as well.

Tuesday 13 August 2013

How To Use Custom Post Thumbnail In Blogger


If you ever used self-hosted WordPress, then you might know about post thumbnail (featured post) feature. By using that feature, you can pick a custom image for your post's thumbnail, which is a great feature. I also use this feature on my wwefansnation.com.

I searched around the internet (just Google'd it) and found nothing like this for Blogger blogs. So I discover my own way to pick custom post thumbnail for Blogger. For this trick, we don't need any heavy JavaScript or CSS codes. It's a very little trick, even a newbie can easily use it.

By default, Blogger automatically uses first image of the article as post's thumbnail. So we'll add our thumbnail image to the top of our article, and we'll make it invisible with some CSS. Just add following html code to your post's top (in post editor's html editor):

<img src="Image-Link" style="display:none;"/>

Replace Image-Link with your image's link. Now your image will only appear as your post's thumbnail, and not in the post. This article is an example of this trick. You can visit archive pages to see this trick in action. Don't forget to post your comments.

Friday 9 August 2013

How To Screen Capture Your PSP


Many PSP gamers wants to capture screenshots of their PSP games to share them with their friends and on tutorials. Even the above picture is a screenshot of my PSP. I used screen capture for almost every PSP tutorial (two posts yet) on this blog.

Taking screenshots of your PSP screen is not a hard task, but finding and installing a perfect plugin is pretty hard for new users. Don't worry, I'm here to solve this problem.

Requirements:

  • PSP USB Cable (To transfer files)
  • Laptop/Computer (To download & transfer files)

Installing ScreenVideo Capture Module:

Download ScreenVideo Capture Module from this link. It's .zip file, so extract it to a new folder of your computer. We just need following two files from this archive - capture.prx and capture.ini.

Connect your PSP to your computer via USB cable. Copy and paste capture.prx and capture.ini in the seplugins folder on the root of your PSP's Memory Stick. If your PSP doesn't have any seplugins folder then just create one on the root of your Memory Stick.

Now add following code to your GAME.txt, VSH.txt and POPS.txt files in seplugins folder. You can also create these three files in a simple notepad document if they're not already in your PSP.

ms0:/seplugins/capture.prx 1

Now switch off your PSP. Now turn on your PSP with the R button held to go into configuration mode. Go to plugins and activate all "capture.prx" plugins. That's it.

How To Take Screenshots:

To take screenshots press note button (the music note) to take a screenshot (saved in BMP format). Don't forget to run FastRecovery file before taking screenshots. Hold R and then note to start taking a video (your game will lag a lot in while capturing videos) and press note again to stop taking the video. This will be saved in GIF format.

Additional Settings:

You can also change the location on the PSP where screenshots will be saved by editing the capture.ini file.

The default is ms0:/PSP/PHOTO

DO NOT USE flash0:/ OR flash1:/ AS THIS MAY "BRICK" YOUR PSP

Popular Posts

 
Powered by Blogger.