Disable WordPress Autosave

Add the following lines to your WordPress Theme’s template functions.php file (For example, functions.php file for a Theme named “default” would probably reside in the directory wp-content/themes/default/functions.php) or create it as a Plugin by filling the additional Standard Plugin Information:

<?php
global $pagenow; 

if (in_array($pagenow, 
	array(
		'post.php', // Edit Post
		'post-new.php', // Add New Post
		'page.php', // Edit Page
		'page-new.php' // Add New Page
	))) {	
	wp_deregister_script('autosave');
}
?>

Customize WordPress Default Protected Post Password Form

Add the following lines to your WordPress Theme’s template functions.php file (For example, functions.php file for a Theme named “default” would probably reside in the directory wp-content/themes/default/functions.php) or create it as a Plugin by filling the additional Standard Plugin Information:

<?php
function custom_password_form($form) { 
  $subs = array(
    '#<p>This post is password protected. To view it please enter your password below:</p>#' => '<p>Your own custom message.</p>',
    '#<form(.*?)>#' => '<form$1 class="passwordform">',
    '#<input(.*?)type="password"(.*?) />#' => '<input$1type="password"$2 class="text" />',
    '#<input(.*?)type="submit"(.*?) />#' => '<input$1type="submit"$2 class="button" />'
  );

  echo preg_replace(array_keys($subs), array_values($subs), $form);
}

add_filter('the_password_form', 'custom_password_form');
?>

From the snippet above, here are the changes that have been made to the original post password form:

  1. Replace “This post is password protected. To view it please enter your password below:” with “Your own custom message.”.
  2. Add class name passwordform to form element.
  3. Add class name text to input element with type attribute that has the value password.
  4. Add class name button to input element with type attribute that has the value submit.

Customize the snippet to suit your needs and preferences.

BASH Script to Update WordPress via Subversion (SVN)

Yet another BASH script that will automatically update your WordPress installation via Subversion (SVN). Run this script manually or using crontab (preferred). Really suitable if you run multiple WordPress installation in your hosting account.

Modify this script according to your WordPress installation and server preferences.

#!/bin/bash

WP_VERSION="2.7"
SVN_REPO="http://svn.automattic.com/wordpress/branches/$WP_VERSION"
ROOT_DIR=/home/user/public_html

REPO_REV=`svn info $SVN_REPO | grep -r "Last Changed Rev:" | cut -f 4 -d " "`
LOCAL_REV=`svn info $ROOT_DIR/example.com | grep -r "Last Changed Rev:" | cut -f 4 -d " "`

REPO_DB_VER=`wget -q -O - $SVN_REPO/wp-includes/version.php | grep "wp_db_version =" | cut -f 3 -d " " | sed "s/;//"`
LOCAL_DB_VER=`grep "wp_db_version =" $ROOT_DIR/example.com/wp-includes/version.php | cut -f 3 -d " " | sed "s/;//"`

BLOG_DIR=(
	"$ROOT_DIR/example.com"
	"$ROOT_DIR/example1.com"
	"$ROOT_DIR/example2.com"
)

BLOG_URL=(
	"http://example.com"
	"http://example1.com"
	"http://example2.com"
)

if [ $REPO_REV -gt $LOCAL_REV ]; then
	for ((i=0;i<${#BLOG_DIR[@]};i++)); do
		svn update ${BLOG_DIR[${i}]}
		if [ $REPO_DB_VER -gt $LOCAL_DB_VER ]; then
			wget -q -O - ${BLOG_URL[${i}]}/wp-admin/upgrade.php?step=1 > /dev/null
		fi
	done
	exit 0
fi

Remove or Unlink WordPress Comment Author URL

This code will remove or unlink comment author URL from the comment list if the comment author that left any comment is not registered or logged in (except for trackback and pingback). The original comment author URL in the database remains untouched.

Add the following lines to your WordPress Theme’s template functions.php file (For example, functions.php file for a Theme named “default” would probably reside in the directory wp-content/themes/default/functions.php) or create it as a Plugin by filling the additional Standard Plugin Information:

<?php
function unlink_comment_author_link($output) {
	global $comment;
	
	$author = get_comment_author();
	
	if ((get_comment_type() == 'comment')) {
		if ($comment->user_id > 0 && $user = get_userdata($comment->user_id))
			return $output;
		else
			return $author;
	} else {
		return $output;
	}
}

add_filter('get_comment_author_link', 'unlink_comment_author_link');
?>
Page 7 of 111234567891011