Monday 7 October 2013

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

Popular Posts

 
Powered by Blogger.