<?php
/*
Plugin Name: Classic Smilies
Description: Puts back the original smilies that got replaced with those terribly ugly ones in WordPress 2.9-rare.
Version: 0.2
Author: Otto
Author URI: http://ottodestruct.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License only.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

function classic_smilies_fixurl($text) {
	$siteurl = get_option('siteurl');
	$plugurl = plugin_dir_url(__FILE__);
	return preg_replace(
		"#<img src='{$siteurl}/wp-includes/images/smilies/#",
		"<img src='{$plugurl}classic/",
		$text
	);
}

function classic_smilies_init() {
	global $wpsmiliestrans;

	$wpsmiliestrans = array(
		':mrgreen:' => 'icon_mrgreen.gif',
		':neutral:' => 'icon_neutral.gif',
		':twisted:' => 'icon_twisted.gif',
		':arrow:' => 'icon_arrow.gif',
		':shock:' => 'icon_eek.gif',
		':smile:' => 'icon_smile.gif',
		':???:' => 'icon_confused.gif',
		':cool:' => 'icon_cool.gif',
		':evil:' => 'icon_evil.gif',
		':grin:' => 'icon_biggrin.gif',
		':idea:' => 'icon_idea.gif',
		':oops:' => 'icon_redface.gif',
		':razz:' => 'icon_razz.gif',
		':roll:' => 'icon_rolleyes.gif',
		':wink:' => 'icon_wink.gif',
		':cry:' => 'icon_cry.gif',
		':eek:' => 'icon_surprised.gif',
		':lol:' => 'icon_lol.gif',
		':mad:' => 'icon_mad.gif',
		':sad:' => 'icon_sad.gif',
		'8-)' => 'icon_cool.gif',
		'8-O' => 'icon_eek.gif',
		':-(' => 'icon_sad.gif',
		':-)' => 'icon_smile.gif',
		':-?' => 'icon_confused.gif',
		':-D' => 'icon_biggrin.gif',
		':-P' => 'icon_razz.gif',
		':-o' => 'icon_surprised.gif',
		':-x' => 'icon_mad.gif',
		':-|' => 'icon_neutral.gif',
		';-)' => 'icon_wink.gif',
		'8)' => 'icon_cool.gif',
		'8O' => 'icon_eek.gif',
		':(' => 'icon_sad.gif',
		':)' => 'icon_smile.gif',
		':?' => 'icon_confused.gif',
		':D' => 'icon_biggrin.gif',
		':P' => 'icon_razz.gif',
		':o' => 'icon_surprised.gif',
		':x' => 'icon_mad.gif',
		':|' => 'icon_neutral.gif',
		';)' => 'icon_wink.gif',
		':!:' => 'icon_exclaim.gif',
		':?:' => 'icon_question.gif',
	);

	// Content filters to fix image URLs
	add_filter('the_content', 'classic_smilies_fixurl', 10);
	add_filter('the_excerpt', 'classic_smilies_fixurl', 10);
	add_filter('comment_text', 'classic_smilies_fixurl', 30);
}

add_action('init', 'classic_smilies_init', 1);
