<?php

/*
Plugin Name: Markdown Toolbar
Description: For the post editor.
Plugin URI: http://samm.dreamhosters.com/wordpress/plugins/
Author: Sam
Version: 0.1
*/

add_filter('the_editor', 'mt_print_script');
add_filter('print_scripts_array', 'mt_print_scripts_array');
add_action('init', 'mt_register');

function mt_register() {
	wp_register_script(
		'markdown_toolbar'
		, '/wp-content/plugins/'.basename(dirname(__FILE__)).'/toolbar.js'
		, array('quicktags')
	);
}

function mt_print_scripts_array($to_print) {
	if (in_array('quicktags', $to_print)) {
		$to_print[] = 'markdown_toolbar';
	}
	return $to_print;
}

function mt_print_script($the_editor) {
	// not used
	return '<a rel="help" href="http://michelf.com/projects/php-markdown/dingus/">help</a>' . $the_editor;
}

?>