How To Remove Login Shake Effect At The Time When Error Occurs
Using the following snippet will let you remove the login shake effect when error occurs. Simply paste the following code in your theme’s functions.php file and you are done.
1 2 3 4 |
function wps_login_error() { remove_action('login_head', 'wp_shake_js', 12); } add_action('login_head', 'wps_login_error'); |
Snippet Source/Credit: WordPress Support Forum
How To Automatically Add Twitter And Facebook Buttons To Your Posts
Using the following snippet, you will be able to automatically add both Twitter and Facebook buttons to your posts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
function share_this($content){ if(!is_feed() && !is_home()) { $content .= '<div class="share-this"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a> <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <div class="facebook-share-button"> <iframe src="http://www.facebook.com/plugins/like.php?href='. urlencode(get_permalink($post->ID)) .'&layout=button_count&show_faces=false&width=200&action=like&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:21px;" allowTransparency="true"></iframe> </div> </div>'; } return $content; } add_action('the_content', 'share_this'); |
Snippet Source/Credit: WPRecipes
How To Get The First Link In Post
Using the following snippet and pasting it in your theme’s functions.php file will let you grab the first link in the post.
1 2 3 4 5 6 |
function get_link_url() { $content = get_the_content(); $has_url = get_url_in_content( $content ); return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); } |
Snippet Source/Credit: Filip Stefansson
How To Get Email Alerts For 404 Pages In WordPress
Using the following snippet, you will be able to get email alerts for 404 pages in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
<?php // WP 404 ALERTS @ http://wp-mix.com/wordpress-404-email-alerts/ // set status header("HTTP/1.1 404 Not Found"); header("Status: 404 Not Found"); // site info $blog = get_bloginfo('name'); $site = get_bloginfo('url') . '/'; $email = get_bloginfo('admin_email'); // theme info if (!empty($_COOKIE["nkthemeswitch" . COOKIEHASH])) { $theme = clean($_COOKIE["nkthemeswitch" . COOKIEHASH]); } else { $theme_data = wp_get_theme(); $theme = clean($theme_data->Name); } // referrer if (isset($_SERVER['HTTP_REFERER'])) { $referer = clean($_SERVER['HTTP_REFERER']); } else { $referer = "undefined"; } // request URI if (isset($_SERVER['REQUEST_URI']) && isset($_SERVER["HTTP_HOST"])) { $request = clean('http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); } else { $request = "undefined"; } // query string if (isset($_SERVER['QUERY_STRING'])) { $string = clean($_SERVER['QUERY_STRING']); } else { $string = "undefined"; } // IP address if (isset($_SERVER['REMOTE_ADDR'])) { $address = clean($_SERVER['REMOTE_ADDR']); } else { $address = "undefined"; } // user agent if (isset($_SERVER['HTTP_USER_AGENT'])) { $agent = clean($_SERVER['HTTP_USER_AGENT']); } else { $agent = "undefined"; } // identity if (isset($_SERVER['REMOTE_IDENT'])) { $remote = clean($_SERVER['REMOTE_IDENT']); } else { $remote = "undefined"; } // log time $time = clean(date("F jS Y, h:ia", time())); // sanitize function clean($string) { $string = rtrim($string); $string = ltrim($string); $string = htmlentities($string, ENT_QUOTES); $string = str_replace("\n", "<br>", $string); if (get_magic_quotes_gpc()) { $string = stripslashes($string); } return $string; } $message = "TIME: " . $time . "\n" . "*404: " . $request . "\n" . "SITE: " . $site . "\n" . "THEME: " . $theme . "\n" . "REFERRER: " . $referer . "\n" . "QUERY STRING: " . $string . "\n" . "REMOTE ADDRESS: " . $address . "\n" . "REMOTE IDENTITY: " . $remote . "\n" . "USER AGENT: " . $agent . "\n\n\n"; mail($email, "404 Alert: " . $blog . " [" . $theme . "]", $message, "From: $email"); ?> |
Snippet Source/Credit: WP Mix
How To Display Recently Registered Users
Using the following snippet, you will be able to display recently registered users.
1 2 3 4 5 6 7 |
<ul class="recently-user"> <?php $usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5"); foreach ($usernames as $username) { echo '<li>' .get_avatar($username->comment_author_email, 45).'<a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>"; } ?> </ul> |
Snippet Source/Credit: emoticode