<?php
/*
Plugin Name: WP_Editor 3.3 test plugin
Plugin URI: 
Description: This plugin is only for testing the wp_editor() functionality in WordPress 3.3-beta. Add [editortest1], [editortest2] and/or [editortest3] to a post and check it out. This is probably not a good way to add an editor but is easier for testing :) <a href="?page=wp_editor_test">Admin examples</a>
Version: 1.0
Author: WordPress

Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html

	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.
*/

add_shortcode('editortest1', 'wpeditortest_shortcode_1');
function wpeditortest_shortcode_1() {
	
	echo '<form action="" method="post" target="_blank">';

	wp_editor('<p>Some content</p>', 'editortest_one' );

	echo '<p><input type="submit" value="Submit" /></p></form>';
}

add_shortcode('editortest2', 'wpeditortest_shortcode_2');
function wpeditortest_shortcode_2() {
	$settings = array(
		'wpautop' => false,
		'media_buttons' => false,
		'tinymce' => array(
			'theme_advanced_buttons1' => 'bold,italic,bullist,numlist,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,fullscreen',
			'theme_advanced_buttons2' => '',
			'theme_advanced_buttons3' => '',
			'theme_advanced_buttons4' => ''
		),
		'quicktags' => array(
			'buttons' => 'b,i,ul,ol,li,link,close'
		)
	);
	
	echo '<form action="" method="post" target="_blank">';

	wp_editor('<p>Some more content</p>', 'editortest_two', $settings );

	echo '<p><input type="submit" value="Submit" /></p></form>';
}

add_shortcode('editortest3', 'wpeditortest_shortcode_3');
function wpeditortest_shortcode_3() {
	$settings = array(
		'tinymce' => false
	);
	
	echo '<form action="" method="post" target="_blank">';

	wp_editor('<p>Even more content</p>', 'editortest_three', $settings );

	echo '<p><input type="submit" value="Submit" /></p></form>';
}

add_action( 'plugins_loaded', 'wpeditortest_submitted' );
function wpeditortest_submitted() {
	
	if ( !empty($_POST['editortest_one']) ) {
		wpeditortest_print($_POST['editortest_one']);
		exit;
	}
	
	if ( !empty($_POST['editortest_two']) ) {
		wpeditortest_print($_POST['editortest_two']);
		exit;
	}
	
	if ( !empty($_POST['editortest_three']) ) {
		wpeditortest_print($_POST['editortest_three']);
		exit;
	}
}

function wpeditortest_print($str) {
	echo '<pre>' . htmlspecialchars( stripslashes($str) ) . '</pre>';
}

function wpeditortest_admin() {
?>
<div class="wrap">
<h2>WP_Editor tests</h2>
<div style="width:90%; margin:auto;">
<h3>Example 1</h3>
<pre style="border:1px solid #ddd;padding:10px;">wp_editor('&lt;p&gt;Some content&lt;/p&gt;', 'editortest_one' );</pre>
<?php wpeditortest_shortcode_1(); ?>

<h3>Example 2</h3>
<pre style="border:1px solid #ddd;padding:10px;overflow:auto;">
$settings = array(
	'wpautop' => false,
	'media_buttons' => false,
	'tinymce' => array(
		'theme_advanced_buttons1' => 'bold,italic,bullist,numlist,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,fullscreen',
		'theme_advanced_buttons2' => '',
		'theme_advanced_buttons3' => '',
		'theme_advanced_buttons4' => ''
	),
	'quicktags' => array(
		'buttons' => 'b,i,ul,ol,li,link,close'
	)
);

wp_editor('&lt;p&gt;Some more content&lt;/p&gt;', 'editortest_two', $settings );
</pre>
<?php wpeditortest_shortcode_2(); ?>

<h3>Example 3</h3>
<pre style="border:1px solid #ddd;padding:10px;">
$settings = array(
	'tinymce' => false
);

wp_editor('&lt;p&gt;Even more content&lt;/p&gt;', 'editortest_three', $settings );
</pre>
<?php wpeditortest_shortcode_3(); ?>
	
</div>
</div>
<?php
}

add_action( 'admin_menu', 'wpeditortest_menu' );
function wpeditortest_menu() {
	add_plugins_page( 'WP_Editor tests', 'WP_Editor tests', 'manage_options', 'wp_editor_test', 'wpeditortest_admin' );
}

