1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: WP_Editor 3.3 test plugin |
---|
4 | Plugin URI: |
---|
5 | 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> |
---|
6 | Version: 1.0 |
---|
7 | Author: WordPress |
---|
8 | |
---|
9 | Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html |
---|
10 | |
---|
11 | This program is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | GNU General Public License for more details. |
---|
15 | */ |
---|
16 | |
---|
17 | add_shortcode('editortest1', 'wpeditortest_shortcode_1'); |
---|
18 | function wpeditortest_shortcode_1() { |
---|
19 | |
---|
20 | echo '<form action="" method="post" target="_blank">'; |
---|
21 | |
---|
22 | wp_editor('<p>Some content</p>', 'editortest_one' ); |
---|
23 | |
---|
24 | echo '<p><input type="submit" value="Submit" /></p></form>'; |
---|
25 | } |
---|
26 | |
---|
27 | add_shortcode('editortest2', 'wpeditortest_shortcode_2'); |
---|
28 | function wpeditortest_shortcode_2() { |
---|
29 | $settings = array( |
---|
30 | 'wpautop' => false, |
---|
31 | 'media_buttons' => false, |
---|
32 | 'tinymce' => array( |
---|
33 | 'theme_advanced_buttons1' => 'bold,italic,bullist,numlist,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,fullscreen', |
---|
34 | 'theme_advanced_buttons2' => '', |
---|
35 | 'theme_advanced_buttons3' => '', |
---|
36 | 'theme_advanced_buttons4' => '' |
---|
37 | ), |
---|
38 | 'quicktags' => array( |
---|
39 | 'buttons' => 'b,i,ul,ol,li,link,close' |
---|
40 | ) |
---|
41 | ); |
---|
42 | |
---|
43 | echo '<form action="" method="post" target="_blank">'; |
---|
44 | |
---|
45 | wp_editor('<p>Some more content</p>', 'editortest_two', $settings ); |
---|
46 | |
---|
47 | echo '<p><input type="submit" value="Submit" /></p></form>'; |
---|
48 | } |
---|
49 | |
---|
50 | add_shortcode('editortest3', 'wpeditortest_shortcode_3'); |
---|
51 | function wpeditortest_shortcode_3() { |
---|
52 | $settings = array( |
---|
53 | 'tinymce' => false |
---|
54 | ); |
---|
55 | |
---|
56 | echo '<form action="" method="post" target="_blank">'; |
---|
57 | |
---|
58 | wp_editor('<p>Even more content</p>', 'editortest_three', $settings ); |
---|
59 | |
---|
60 | echo '<p><input type="submit" value="Submit" /></p></form>'; |
---|
61 | } |
---|
62 | |
---|
63 | add_action( 'plugins_loaded', 'wpeditortest_submitted' ); |
---|
64 | function wpeditortest_submitted() { |
---|
65 | |
---|
66 | if ( !empty($_POST['editortest_one']) ) { |
---|
67 | wpeditortest_print($_POST['editortest_one']); |
---|
68 | exit; |
---|
69 | } |
---|
70 | |
---|
71 | if ( !empty($_POST['editortest_two']) ) { |
---|
72 | wpeditortest_print($_POST['editortest_two']); |
---|
73 | exit; |
---|
74 | } |
---|
75 | |
---|
76 | if ( !empty($_POST['editortest_three']) ) { |
---|
77 | wpeditortest_print($_POST['editortest_three']); |
---|
78 | exit; |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | function wpeditortest_print($str) { |
---|
83 | echo '<pre>' . htmlspecialchars( stripslashes($str) ) . '</pre>'; |
---|
84 | } |
---|
85 | |
---|
86 | function wpeditortest_admin() { |
---|
87 | ?> |
---|
88 | <div class="wrap"> |
---|
89 | <h2>WP_Editor tests</h2> |
---|
90 | <div style="width:90%; margin:auto;"> |
---|
91 | <h3>Example 1</h3> |
---|
92 | <pre style="border:1px solid #ddd;padding:10px;">wp_editor('<p>Some content</p>', 'editortest_one' );</pre> |
---|
93 | <?php wpeditortest_shortcode_1(); ?> |
---|
94 | |
---|
95 | <h3>Example 2</h3> |
---|
96 | <pre style="border:1px solid #ddd;padding:10px;overflow:auto;"> |
---|
97 | $settings = array( |
---|
98 | 'wpautop' => false, |
---|
99 | 'media_buttons' => false, |
---|
100 | 'tinymce' => array( |
---|
101 | 'theme_advanced_buttons1' => 'bold,italic,bullist,numlist,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,fullscreen', |
---|
102 | 'theme_advanced_buttons2' => '', |
---|
103 | 'theme_advanced_buttons3' => '', |
---|
104 | 'theme_advanced_buttons4' => '' |
---|
105 | ), |
---|
106 | 'quicktags' => array( |
---|
107 | 'buttons' => 'b,i,ul,ol,li,link,close' |
---|
108 | ) |
---|
109 | ); |
---|
110 | |
---|
111 | wp_editor('<p>Some more content</p>', 'editortest_two', $settings ); |
---|
112 | </pre> |
---|
113 | <?php wpeditortest_shortcode_2(); ?> |
---|
114 | |
---|
115 | <h3>Example 3</h3> |
---|
116 | <pre style="border:1px solid #ddd;padding:10px;"> |
---|
117 | $settings = array( |
---|
118 | 'tinymce' => false |
---|
119 | ); |
---|
120 | |
---|
121 | wp_editor('<p>Even more content</p>', 'editortest_three', $settings ); |
---|
122 | </pre> |
---|
123 | <?php wpeditortest_shortcode_3(); ?> |
---|
124 | |
---|
125 | </div> |
---|
126 | </div> |
---|
127 | <?php |
---|
128 | } |
---|
129 | |
---|
130 | add_action( 'admin_menu', 'wpeditortest_menu' ); |
---|
131 | function wpeditortest_menu() { |
---|
132 | add_plugins_page( 'WP_Editor tests', 'WP_Editor tests', 'manage_options', 'wp_editor_test', 'wpeditortest_admin' ); |
---|
133 | } |
---|
134 | |
---|