Wednesday, 14 May 2014

Automatically spam comments with a very long url

[Wordpress hack]

Spam is definitely a problem for bloggers and most of you probably receive more than 100 spam comments per hour. Here is a simple recipe to automatically mark as spam all comments with an url longer than 50 characters.

Open your functions.php file and paste the code below in it. This code will automatically mark as spam all comments with an url longer than 50 chars. This can be changed on line 4.

function rkv_url_spamcheck( $approved , $commentdata ) {
    return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved;
  }

  add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 );

Automatically link Twitter usernames in WordPress

[Wordpress hack]
Are you using Twitter a lot? Today’s recipe is a cool piece of code to automatically link Twitter usernames on your posts, pages, and comments.

Paste the code below into your functions.php file:
function twtreplace($content) {
 $twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1@$2",$content);
 return $twtreplace;
}

add_filter('the_content', 'twtreplace');   
add_filter('comment_text', 'twtreplace');

WordPress 3.9.1 Released

After three weeks of WordPress 3.9 release, WordPress 3.9.1 is now available to download and update. This maintenance release fixed 34 bugs. This includes bugs fixes for multisite network, customizing widgets, and the updated TinyMCE editor. You can check the full list of tickets fixed in this blog at this link, and the changelog at this link.
Here’s a list of some major bugs fixes:
  • Fixes a bug with theme preview which empties sidebar widget on active theme. See#27897
  • Fixes PHP warnings in Customizer if theme has set a default image for custom header. See #27850
  • Fixes a bug with multisite where subdirectory install breaks if network path has uppercase letters. See #27866
  • TinyMCE now allows you to drag & drop text straight to the visual editor to paste it. See#27880
  • Fixes a bug which makes header image disappear after removing background image in Customizer. See #28046
You can download the WordPress 3.9.1 from this link, or head over to Dashboard > Updates and simply click “Update Now” button.