PluginProbe ʕ •ᴥ•ʔ
Advanced Editor Tools / 3.3.9.1
Advanced Editor Tools v3.3.9.1
trunk 1.0 1.0.1 2.0 2.2 3.0 3.0.1 3.1 3.2 3.2.4 3.2.7 3.3.9 3.3.9.1 3.3.9.2 3.4.2 3.4.2.1 3.4.5 3.4.5.1 3.4.9 3.5.8 3.5.9 3.5.9.1 4.0 4.0.1 4.0.2 4.1 4.1.1 4.1.7 4.1.9 4.2.3 4.2.3.1 4.2.5 4.2.8 4.3.10 4.3.10.1 4.3.8 4.4.1 4.4.3 4.5.6 4.6.3 4.6.7 4.7.11 4.8.0 4.8.1 4.8.2 5.0.0 5.0.1 5.1.0 5.2 5.2.1 5.3 5.4.0 5.5.0 5.5.1 5.6.0 5.9.0 5.9.1 5.9.2
tinymce-advanced / tinymce-advanced.php
tinymce-advanced Last commit date
css 15 years ago images 15 years ago js 15 years ago mce 15 years ago utils 15 years ago readme.txt 15 years ago screenshot-1.png 16 years ago tadv_admin.php 15 years ago tadv_defaults.php 15 years ago tiny_mce_popup.js 15 years ago tinymce-advanced.php 15 years ago
tinymce-advanced.php
339 lines
1 <?php
2 /*
3 Plugin Name: TinyMCE Advanced
4 Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
5 Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
6 Version: 3.3.9.1-beta2
7 Author: Andrew Ozz
8 Author URI: http://www.laptoptips.ca/
9
10 Some code and ideas from WordPress (http://wordpress.org/). The options page for this plugin uses jQuery (http://jquery.com/).
11
12 Released under the GPL v.2, http://www.gnu.org/copyleft/gpl.html
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 */
19
20
21 if ( ! function_exists('tadv_paths') ) {
22 /*
23 If using domain mapping or plugins that change the path dinamically, edit these to set the proper path and URL.
24 */
25 function tadv_paths() {
26 if ( !defined('TADV_URL') )
27 define('TADV_URL', WP_PLUGIN_URL . '/tinymce-advanced/');
28
29 if ( !defined('TADV_PATH') )
30 define('TADV_PATH', WP_PLUGIN_DIR . '/tinymce-advanced/');
31 }
32 add_action( 'plugins_loaded', 'tadv_paths', 50 );
33 }
34
35
36 if ( ! function_exists('tadv_add_scripts') ) {
37 function tadv_add_scripts($page) {
38 if ( 'settings_page_tinymce-advanced' == $page ) {
39 wp_enqueue_script( 'tadv-js', TADV_URL . 'js/tadv.js', array('jquery-ui-sortable'), '3.3.9', true );
40 wp_enqueue_style( 'tadv-css', TADV_URL . 'css/tadv-styles.css', array(), '3.3.9' );
41 }
42 }
43 } // end tadv_add_scripts
44
45
46 if ( ! function_exists('tadv_load_defaults') ) {
47 function tadv_load_defaults() {
48 $tadv_options = get_option('tadv_options');
49 if ( ! empty($tadv_options) )
50 return;
51
52 @include_once('tadv_defaults.php');
53
54 if ( isset($tadv_toolbars) ) {
55 add_option( 'tadv_options', $tadv_options );
56 add_option( 'tadv_toolbars', $tadv_toolbars, '', 'no' );
57 add_option( 'tadv_plugins', $tadv_plugins, '', 'no' );
58 add_option( 'tadv_btns1', $tadv_btns1, '', 'no' );
59 add_option( 'tadv_btns2', $tadv_btns2, '', 'no' );
60 add_option( 'tadv_btns3', $tadv_btns3, '', 'no' );
61 add_option( 'tadv_btns4', $tadv_btns4, '', 'no' );
62 add_option( 'tadv_allbtns', $tadv_allbtns, '', 'no' );
63 }
64 }
65 add_action( 'admin_init', 'tadv_load_defaults' );
66 }
67
68 if ( ! function_exists('tdav_get_file') ) {
69 function tdav_get_file($path) {
70
71 if ( function_exists('realpath') )
72 $path = realpath($path);
73
74 if ( ! $path || ! @is_file($path) )
75 return '';
76
77 if ( function_exists('file_get_contents') )
78 return @file_get_contents($path);
79
80 $content = '';
81 $fp = @fopen($path, 'r');
82 if ( ! $fp )
83 return '';
84
85 while ( ! feof($fp) )
86 $content .= fgets($fp);
87
88 fclose($fp);
89 return $content;
90 }
91 }
92
93 $tadv_allbtns = array();
94 $tadv_hidden_row = 0;
95
96
97 if ( ! function_exists('tadv_mce_btns') ) {
98 function tadv_mce_btns($orig) {
99 global $tadv_allbtns, $tadv_hidden_row;
100 $tadv_btns1 = (array) get_option('tadv_btns1', array());
101 $tadv_allbtns = (array) get_option('tadv_allbtns', array());
102 $tadv_options = get_option('tadv_options', array());
103
104 if ( in_array( 'wp_adv', $tadv_btns1 ) )
105 $tadv_hidden_row = 2;
106
107 if ( is_array($orig) && ! empty($orig) ) {
108 $orig = array_diff( $orig, $tadv_allbtns );
109 $tadv_btns1 = array_merge( $tadv_btns1, $orig );
110 }
111
112 if ( $tadv_options['editorstyle'] == '1' )
113 add_editor_style(); // import user created editor-style.css
114
115 return $tadv_btns1;
116 }
117 add_filter( 'mce_buttons', 'tadv_mce_btns', 999 );
118 }
119
120
121 if ( ! function_exists('tadv_mce_btns2') ) {
122 function tadv_mce_btns2($orig) {
123 global $tadv_allbtns, $tadv_hidden_row;
124 $tadv_btns2 = (array) get_option('tadv_btns2', array());
125
126 if ( in_array( 'wp_adv', $tadv_btns2 ) )
127 $tadv_hidden_row = 3;
128
129 if ( is_array($orig) && ! empty($orig) ) {
130 $orig = array_diff( $orig, $tadv_allbtns );
131 $tadv_btns2 = array_merge( $tadv_btns2, $orig );
132 }
133 return $tadv_btns2;
134 }
135 add_filter( 'mce_buttons_2', 'tadv_mce_btns2', 999 );
136 }
137
138
139 if ( ! function_exists('tadv_mce_btns3') ) {
140 function tadv_mce_btns3($orig) {
141 global $tadv_allbtns, $tadv_hidden_row;
142 $tadv_btns3 = (array) get_option('tadv_btns3', array());
143
144 if ( in_array( 'wp_adv', $tadv_btns3 ) )
145 $tadv_hidden_row = 4;
146
147 if ( is_array($orig) && ! empty($orig) ) {
148 $orig = array_diff( $orig, $tadv_allbtns );
149 $tadv_btns3 = array_merge( $tadv_btns3, $orig );
150 }
151 return $tadv_btns3;
152 }
153 add_filter( 'mce_buttons_3', 'tadv_mce_btns3', 999 );
154 }
155
156
157 if ( ! function_exists('tadv_mce_btns4') ) {
158 function tadv_mce_btns4($orig) {
159 global $tadv_allbtns;
160 $tadv_btns4 = (array) get_option('tadv_btns4', array());
161
162 if ( is_array($orig) && ! empty($orig) ) {
163 $orig = array_diff( $orig, $tadv_allbtns );
164 $tadv_btns4 = array_merge( $tadv_btns4, $orig );
165 }
166 return $tadv_btns4;
167 }
168 add_filter( 'mce_buttons_4', 'tadv_mce_btns4', 999 );
169 }
170
171
172 if ( ! function_exists('tadv_mce_options') ) {
173 function tadv_mce_options($init) {
174 global $tadv_hidden_row;
175 $tadv_options = get_option('tadv_options', array());
176 $ext_elements = '';
177
178 if ( $tadv_hidden_row > 0 )
179 $init['wordpress_adv_toolbar'] = 'toolbar' . $tadv_hidden_row;
180 else
181 $init['wordpress_adv_hidden'] = false;
182
183 if ( isset($tadv_options['no_autop']) && $tadv_options['no_autop'] == 1 )
184 $init['apply_source_formatting'] = true;
185
186 if ( isset($tadv_options['hideclasses']) && $tadv_options['hideclasses'] == 1 )
187 $init['class_filter'] = '[function(){return false;}]';
188
189 if ( isset($tadv_options['iframe']) && $tadv_options['iframe'] == 1 )
190 $ext_elements = ',iframe[*]';
191
192 if ( isset($tadv_options['html5']) && $tadv_options['html5'] == 1 )
193 $ext_elements .= ',article[*],aside[*],audio[*],canvas[*],command[*],datalist[*],details[*],embed[*],figcaption[*],figure[*],footer[*],header[*],hgroup[*],keygen[*],mark[*],meter[*],nav[*],output[*],progress[*],section[*],source[*],summary,time[*],video[*],wbr';
194
195 if ( !empty($ext_elements) ) {
196
197 if ( !empty($init['extended_valid_elements']) )
198 $init['extended_valid_elements'] .= $ext_elements;
199 else
200 $init['extended_valid_elements'] = trim($ext_elements, ',');
201 }
202
203 return $init;
204 }
205 add_filter( 'tiny_mce_before_init', 'tadv_mce_options' );
206 }
207
208
209 if ( ! function_exists('tadv_htmledit') ) {
210 function tadv_htmledit($c) {
211 $tadv_options = get_option('tadv_options', array());
212
213 if ( isset($tadv_options['no_autop']) && $tadv_options['no_autop'] == 1 ) {
214 $c = str_replace( array('&amp;', '&lt;', '&gt;'), array('&', '<', '>'), $c );
215 $c = wpautop($c);
216 $c = htmlspecialchars($c, ENT_NOQUOTES);
217 }
218 return $c;
219 }
220 add_filter('htmledit_pre', 'tadv_htmledit', 999);
221 }
222
223
224 if ( ! function_exists('tmce_replace') ) {
225 function tmce_replace() {
226 global $merged_filters;
227 $tadv_options = get_option('tadv_options', array());
228 $tadv_plugins = get_option('tadv_plugins', array());
229
230 if ( ! array_key_exists('tiny_mce_before_init', $merged_filters) ) // we are not on a page that has the visual editor included with wp_tiny_mce()
231 return;
232
233 if ( isset($tadv_options['no_autop']) && $tadv_options['no_autop'] == 1 ) { ?>
234
235 <script type="text/javascript">
236 //<![CDATA[
237 jQuery('body').bind('afterPreWpautop', function(e, o){
238 o.data = o.unfiltered
239 .replace(/caption\]\[caption/g, 'caption] [caption')
240 .replace(/<object[\s\S]+?<\/object>/g, function(a) {
241 return a.replace(/[\r\n]+/g, ' ');
242 });
243
244 }).bind('afterWpautop', function(e, o){
245 o.data = o.unfiltered;
246 });
247 //]]>
248 </script>
249 <?php
250 }
251
252 if ( in_array('advlist', $tadv_plugins) ) {
253 $lang = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) );
254 ?>
255
256 <script type="text/javascript">
257 //<![CDATA[
258 tinyMCE.addI18n({<?php echo $lang; ?>:{
259 advlist:{
260 types:"Types",
261 def:"Default",
262 lower_alpha:"a b c",
263 lower_greek:"\u03b1 \u03b2 \u03b3",
264 lower_roman:"i ii iii",
265 upper_alpha:"A B C",
266 upper_roman:"I II III",
267 circle:"\u26aa",
268 disc:"\u26ab",
269 square:"\u25a0"
270 }}});
271 //]]>
272 </script>
273 <?php
274 }
275 }
276 add_action( 'admin_print_footer_scripts', 'tmce_replace', 50 );
277 }
278
279
280 if ( ! function_exists('tadv_load_plugins') ) {
281 function tadv_load_plugins($plug) {
282 $tadv_plugins = get_option('tadv_plugins');
283 if ( empty($tadv_plugins) || !is_array($tadv_plugins) )
284 return $plug;
285
286 $plugpath = TADV_URL . 'mce/';
287
288 $plug = (array) $plug;
289 foreach( $tadv_plugins as $plugin )
290 $plug["$plugin"] = $plugpath . $plugin . '/editor_plugin.js';
291
292 return $plug;
293 }
294 add_filter( 'mce_external_plugins', 'tadv_load_plugins', 999 );
295 }
296
297
298 if ( ! function_exists('tadv_load_langs') ) {
299 function tadv_load_langs($langs) {
300 $tadv_plugins = get_option('tadv_plugins');
301 if ( empty($tadv_plugins) || !is_array($tadv_plugins) )
302 return $langs;
303
304 $langpath = TADV_PATH . 'mce/';
305 $dolangs = array( 'advhr', 'advimage', 'advlink', 'media', 'searchreplace', 'style', 'table', 'xhtmlxtras' );
306
307 $langs = (array) $langs;
308 foreach( $tadv_plugins as $plugin ) {
309 if ( !in_array( $plugin, $dolangs ) )
310 continue;
311
312 $langs["$plugin"] = $langpath . $plugin . '/langs/langs.php';
313 }
314 return $langs;
315 }
316 add_filter( 'mce_external_languages', 'tadv_load_langs' );
317 }
318
319
320 if ( ! function_exists('tadv_page') ) {
321 function tadv_page() {
322 if ( !defined('TADV_ADMIN_PAGE') )
323 define('TADV_ADMIN_PAGE', true);
324
325 include_once( TADV_PATH . 'tadv_admin.php');
326 }
327 }
328
329 if ( ! function_exists('tadv_menu') ) {
330 function tadv_menu() {
331 if ( function_exists('add_options_page') ) {
332 add_options_page( 'TinyMCE Advanced', 'TinyMCE Advanced', 'manage_options', 'tinymce-advanced', 'tadv_page' );
333 add_action( 'admin_enqueue_scripts', 'tadv_add_scripts' );
334 }
335 }
336 add_action( 'admin_menu', 'tadv_menu' );
337 }
338
339