PluginProbe ʕ •ᴥ•ʔ
Advanced Editor Tools / 4.0.2
Advanced Editor Tools v4.0.2
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 / tadv_admin.php
tinymce-advanced Last commit date
css 12 years ago images 12 years ago js 12 years ago mce 12 years ago readme.txt 12 years ago screenshot-1.png 12 years ago screenshot-2.png 12 years ago tadv_admin.php 12 years ago tinymce-advanced.php 12 years ago uninstall.php 12 years ago
tadv_admin.php
415 lines
1 <?php
2
3 if ( ! defined( 'TADV_ADMIN_PAGE' ) ) {
4 exit;
5 }
6
7 // TODO
8 if ( ! current_user_can( 'manage_options' ) ) {
9 wp_die('Access denied');
10 }
11
12 $message = '';
13
14 // TODO admin || SA
15 if ( ! $this->check_minimum_supported_version() ) {
16 ?>
17 <div class="error" style="margin-top:30px;">
18 <p><?php _e( 'This plugin requires WordPress version 3.9 or newer. Please upgrade your WordPress installation or download an', 'tadv'); ?> <a href="http://wordpress.org/extend/plugins/tinymce-advanced/download/"><?php _e('older version of the plugin.', 'tadv'); ?></a></p>
19 </div>
20 <?php
21
22 return;
23 }
24
25 $imgpath = TADV_URL . 'images/';
26 $tadv_options_updated = false;
27 $settings = $admin_settings = array();
28
29 if ( isset( $_POST['tadv-save'] ) ) {
30 check_admin_referer( 'tadv-save-buttons-order' );
31 $options_array = $admin_settings_array = $disabled_plugins = $plugins_array = array();
32
33 // User settings
34 for ( $i = 1; $i < 5; $i++ ) {
35 $tb = 'tb' . $i;
36
37 if ( $i > 1 && ! empty( $_POST[$tb] ) && is_array( $_POST[$tb] ) &&
38 ( $wp_adv = array_search( 'wp_adv', $_POST[$tb] ) ) !== false ) {
39 // Remove the "Toolbar toggle" button from row 2, 3 or 4.
40 unset( $_POST[$tb][$wp_adv] );
41 }
42
43 $buttons = $this->parse_buttons( $tb );
44 // Layer plugin buttons??
45 $buttons = str_replace( 'insertlayer', 'insertlayer,moveforward,movebackward,absolute', $buttons );
46 $settings['toolbar_' . $i] = $buttons;
47 }
48
49 if ( ! empty( $_POST['advlist'] ) ) {
50 $options_array[] = 'advlist';
51 }
52
53 if ( ! empty( $_POST['contextmenu'] ) ) {
54 $options_array[] = 'contextmenu';
55 }
56
57 if ( ! empty( $_POST['advlink'] ) ) {
58 $options_array[] = 'advlink';
59 }
60
61 if ( ! empty( $_POST['menubar'] ) ) {
62 $options_array[] = 'menubar';
63 $plugins_array = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace', 'table', 'visualblocks', 'visualchars' );
64 }
65
66 // Admin settings, TODO
67 if ( ! empty( $_POST['importcss'] ) ) {
68 $admin_settings_array[] = 'importcss';
69 }
70
71 if ( ! empty( $_POST['no_autop'] ) ) {
72 $admin_settings_array[] = 'no_autop';
73 }
74
75 if ( ! empty( $_POST['editorstyle'] ) ) {
76 $admin_settings_array[] = 'editorstyle';
77 }
78
79 if ( ! empty( $_POST['disabled_plugins'] ) && is_array( $_POST['disabled_plugins'] ) ) {
80 foreach( $_POST['disabled_plugins'] as $plugin ) {
81 if ( in_array( $this->all_plugins, $plugin, true ) ) {
82 $disabled_plugins[] = $plugin;
83 }
84 }
85 }
86
87 // Admin options
88 $admin_settings['options'] = implode( ',', $admin_settings_array );
89 $admin_settings['disabled_plugins'] = implode( ',', $disabled_plugins );
90
91 $this->admin_settings = $admin_settings;
92 update_option( 'tadv_admin_settings', $admin_settings );
93
94 // User options
95 // TODO allow editors, authors and contributors some access
96 $this->settings = $settings;
97 $this->load_settings();
98
99 // Special case
100 if ( in_array( 'image', $this->used_buttons, true ) ) {
101 $options_array[] = 'image';
102 }
103
104 $settings['options'] = implode( ',', $options_array );
105 $this->settings = $settings;
106 $this->load_settings();
107
108 // Merge the submitted plugins and from the buttons
109 $settings['plugins'] = implode( ',', $this->get_plugins( $plugins_array ) );
110 $this->settings = $settings;
111 $this->plugins = $settings['plugins'];
112
113 // Save the new settings
114 update_option( 'tadv_settings', $settings );
115
116 } elseif ( isset( $_POST['tadv-restore-defaults'] ) ) {
117 // TODO admin || SA
118 $this->admin_settings = $this->default_admin_settings;
119 update_option( 'tadv_admin_settings', $this->default_admin_settings );
120
121 // can 'save_posts' ?
122 $this->settings = $this->default_settings;
123 update_option( 'tadv_settings', $this->default_settings );
124
125 $message = '<div class="updated"><p>' . __('Default settings restored.', 'tadv') . '</p></div>';
126 } elseif ( isset( $_POST['tadv-export-settings'] ) ) {
127 $this->load_settings();
128 $output = array( 'settings' => $this->settings );
129 // TODO admin || SA
130 $output['admin_settings'] = $this->admin_settings;
131
132 ?>
133 <div class="wrap">
134 <h2><?php _e('TinyMCE Advanced Settings Export', 'tadv'); ?></h2>
135
136 <div class="tadv-import-export">
137 <p>
138 <?php
139
140 _e( 'The settings are exported as a JSON encoded string. ', 'tadv' );
141 _e( 'Please copy the content and save it in a <b>text</b> (.txt) file, using a plain text editor like Notepad. ', 'tadv' );
142 _e( 'It is important that the export is not changed in any way, no spaces, line breaks, etc.', 'tadv' );
143
144 ?>
145 </p>
146
147 <form action="">
148 <p><textarea readonly="readonly" id="tadv-export"><?php echo json_encode( $output ); ?></textarea></p>
149 <p><button type="button" class="button" id="tadv-export-select"><?php _e( 'Select All', 'tadv' ); ?></button></p>
150 </form>
151 <p><a href=""><?php _e('Back to Editor Settings', 'tadv'); ?></a></p>
152 </div>
153 </div>
154 <?php
155
156 return;
157 } elseif ( isset( $_POST['tadv-import-settings'] ) ) {
158 // TODO ! admin && ! SA
159 ?>
160 <div class="wrap">
161 <h2><?php _e('TinyMCE Advanced Settings Import', 'tadv'); ?></h2>
162
163 <div class="tadv-import-export">
164 <p><?php
165
166 _e( 'The settings are imported from a JSON encoded string. Please paste the exported string in the textarea below.', 'tadv' );
167
168 ?></p>
169
170 <form action="" method="post">
171 <p><textarea id="tadv-import" name="tadv-import"></textarea></p>
172 <p>
173 <button type="button" class="button" id="tadv-import-verify"><?php _e( 'Verify', 'tadv' ); ?></button>
174 <input type="submit" class="button button-primary alignright" name="tadv-import-submit" value="<?php _e( 'Import', 'tadv' ); ?>" />
175 </p>
176 <?php wp_nonce_field('tadv-import'); ?>
177 <p id="tadv-import-error"></p>
178 </form>
179 <p><a href=""><?php _e('Back to Editor Settings', 'tadv'); ?></a></p>
180 </div>
181 </div>
182 <?php
183
184 return;
185 } elseif ( isset( $_POST['tadv-import-submit'] ) && ! empty( $_POST['tadv-import'] ) && is_string( $_POST['tadv-import'] ) ) {
186 check_admin_referer( 'tadv-import' );
187 $import = json_decode( trim( wp_unslash( $_POST['tadv-import'] ) ), true );
188 $settings = $admin_settings = array();
189
190 if ( is_array( $import ) ) {
191 if ( ! empty( $import['settings'] ) ) {
192 $settings = $this->sanitize_settings( $import['settings'] );
193 }
194
195 if ( ! empty( $import['admin_settings'] ) ) {
196 $admin_settings = $this->sanitize_settings( $import['admin_settings'] );
197 }
198 }
199
200 if ( empty( $settings ) ) {
201 $message = '<div class="error"><p>' . __('Importing of settings failed.', 'tadv') . '</p></div>';
202 } else {
203 $this->admin_settings = $admin_settings;
204 update_option( 'tadv_admin_settings', $admin_settings );
205
206 // User options
207 // TODO allow editors, authors and contributors some access
208 $this->settings = $settings;
209 $this->load_settings();
210
211 // Merge the submitted plugins and from the buttons
212 if ( ! empty( $settings['plugins'] ) ) {
213 $settings['plugins'] = implode( ',', $this->get_plugins( explode( ',', $settings['plugins'] ) ) );
214 }
215
216 $this->plugins = $settings['plugins'];
217
218 // Save the new settings
219 update_option( 'tadv_settings', $settings );
220 }
221 }
222
223 $this->load_settings();
224
225 if ( empty( $this->toolbar_1 ) && empty( $this->toolbar_2 ) && empty( $this->toolbar_3 ) && empty( $this->toolbar_4 ) ) {
226 $message = '<div class="error"><p>' . __('ERROR: All toolbars are empty. Default settings loaded.', 'tadv') . '</p></div>';
227
228 $this->admin_settings = $this->default_admin_settings;
229 $this->settings = $this->default_settings;
230 $this->load_settings();
231 }
232
233 $used_buttons = array_merge( $this->toolbar_1, $this->toolbar_2, $this->toolbar_3, $this->toolbar_4 );
234 $all_buttons = $this->get_all_buttons();
235
236 ?>
237 <div class="wrap" id="contain">
238 <h2><?php _e('Editor Settings', 'tadv'); ?></h2>
239 <?php
240
241 if ( isset( $_POST['tadv-save'] ) && empty( $message ) ) {
242 ?><div class="updated" id="message"><p><?php _e( 'Settings saved.', 'tadv' ); ?></p></div><?php
243 } else {
244 echo $message;
245 }
246
247 ?>
248 <form id="tadvadmin" method="post" action="">
249 <div id="tadvzones">
250
251 <p><?php _e( 'New in TinyMCE 4.0/WordPress 3.9 is the editor menu. When it is enabled, most buttons are also available as menu items.', 'tadv' ); ?></p>
252
253 <p><label>
254 <input type="checkbox" name="menubar" id="menubar" <?php if ( $this->check_setting( 'menubar' ) ) { echo ' checked="checked"'; } ?>>
255 <?php _e('Enable the editor menu.', 'tadv'); ?>
256 </label></p>
257
258 <p id="tadv-menu-img" <?php if ( $this->check_setting( 'menubar' ) ) { echo ' class="enabled"'; } ?>>&nbsp;</p>
259
260 <?php
261
262 for ( $i = 1; $i < 5; $i++ ) {
263 $toolbar = "toolbar_$i";
264
265 ?>
266 <div class="tadvdropzone">
267 <ul id="tb<?php echo $i; ?>" class="container">
268 <?php
269
270 foreach( $this->$toolbar as $button ) {
271 if ( strpos( $button, 'separator' ) !== false || in_array( $button, array( 'moveforward', 'movebackward', 'absolute' ) ) ) {
272 continue;
273 }
274
275 if ( isset( $all_buttons[$button] ) ) {
276 $name = $all_buttons[$button];
277 unset( $all_buttons[$button] );
278 } else {
279 // error?..
280 continue;
281 }
282
283 if ( strpos( $name, '<!' ) === 0 )
284 $name = '';
285
286 ?><li class="tadvmodule" id="<?php echo $button; ?>">
287 <div class="tadvitem">
288 <i class="mce-ico mce-i-<?php echo $button; ?>" title="<?php echo $name; ?>"></i>
289 <span class="descr"> <?php echo $name; ?></span>
290 <input type="hidden" class="tadv-button" name="tb<?php echo $i; ?>[]" value="<?php echo $button; ?>" />
291 </div>
292 </li><?php
293
294 }
295
296 ?>
297 </ul></div>
298 <?php
299 }
300
301 ?>
302 </div>
303
304 <p><?php _e('Drag buttons from the unused buttons below and drop them in the toolbars above, or drag the buttons in the toolbars to rearrange them.', 'tadv'); ?></p>
305
306 <div id="unuseddiv">
307 <h3><?php _e('Unused Buttons', 'tadv'); ?></h3>
308 <ul id="unused" class="container">
309 <?php
310
311 foreach( $all_buttons as $button => $name ) {
312 if ( strpos( $button, 'separator' ) !== false )
313 continue;
314
315 if ( strpos( $name, '<!' ) === 0 )
316 $name = '';
317
318 ?>
319 <li class="tadvmodule" id="<?php echo $button; ?>">
320 <div class="tadvitem">
321 <i class="mce-ico mce-i-<?php echo $button; ?>" title="<?php echo $name; ?>"></i>
322 <span class="descr"> <?php echo $name; ?></span>
323 <input type="hidden" class="tadv-button" name="unused[]" value="<?php echo $button; ?>" />
324 </div>
325 </li>
326 <?php
327
328 }
329
330 ?>
331 </ul>
332 </div>
333
334 <p class="tadv-more-plugins"><?php _e( 'Also enable:' ); ?>
335 <label>
336 <input type="checkbox" name="advlist" id="advlist" <?php if ( $this->check_setting('advlist') ) echo ' checked="checked"'; ?> />
337 <?php _e('List Style Options', 'tadv'); ?>
338 </label>
339
340 <label>
341 <input type="checkbox" name="contextmenu" id="contextmenu" <?php if ( $this->check_setting('contextmenu') ) echo ' checked="checked"'; ?> />
342 <?php _e('Context Menu', 'tadv'); ?>
343 </label>
344
345 <label>
346 <input type="checkbox" name="advlink" id="advlink" <?php if ( $this->check_setting('advlink') ) echo ' checked="checked"'; ?> />
347 <?php _e('Link (replaces the Insert/Edit Link dialog)', 'tadv'); ?>
348 </label>
349 </p>
350
351 <?php
352
353 if ( ! is_multisite() || current_user_can( 'manage_sites' ) ) {
354
355 ?>
356 <div class="advanced-options">
357 <h3><?php _e('Advanced Options', 'tadv'); ?></h3>
358 <?php
359
360 if ( ! is_multisite() && ! current_theme_supports( 'editor-style' ) ) {
361
362 ?>
363 <div>
364 <label><input type="checkbox" name="editorstyle" id="editorstyle" <?php if ( $this->check_admin_setting( 'editorstyle' ) ) echo ' checked="checked"'; ?> />
365 <?php _e('Import editor-style.css.', 'tadv'); ?></label>
366 <p><?php
367 _e('It seems your theme doesn\'t support customised styles for the editor. ', 'tadv');
368 _e('You can create a CSS file named <code>editor-style.css</code> and upload it to your theme\'s directory. ', 'tadv');
369 _e('After that, enable this setting.', 'tadv');
370 ?></p>
371 </div>
372 <?php
373 }
374
375 ?>
376 <div>
377 <label><input type="checkbox" name="importcss" id="importcss" <?php if ( $this->check_admin_setting( 'importcss' ) ) echo ' checked="checked"'; ?> />
378 <?php _e('Load the CSS classes used in editor-style.css and replace the Formats button and sub-menu.', 'tadv'); ?></label>
379 </div>
380
381 <div>
382 <label><input type="checkbox" name="no_autop" id="no_autop" <?php if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked="checked"'; ?> />
383 <?php _e('Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them in the Text editor', 'tadv'); ?></label>
384 <p><?php
385 _e('This will make it possible to use more advanced coding in the HTML editor without the back-end filtering affecting it much. ', 'tadv');
386 _e('However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. ', 'tadv');
387 _e('Line breaks in the HTML editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple &lt;br /&gt; tags.', 'tadv');
388 ?></p>
389 </div>
390 </div>
391
392 <div class="advanced-options">
393 <h3><?php _e('Administration', 'tadv'); ?></h3>
394 <div>
395 <input type="submit" class="button" name="tadv-export-settings" value="<?php _e( 'Export Settings', 'tadv' ); ?>" /> &nbsp;
396 <input type="submit" class="button" name="tadv-import-settings" value="<?php _e( 'Import Settings', 'tadv' ); ?>" />
397 </div>
398 </div>
399 <?php
400
401 }
402 ?>
403
404 <p class="tadv-submit">
405 <?php wp_nonce_field( 'tadv-save-buttons-order' ); ?>
406 <input class="button" type="submit" name="tadv-restore-defaults" value="<?php _e('Restore Default Settings', 'tadv'); ?>" />
407 <input class="button-primary button-large" type="submit" name="tadv-save" value="<?php _e('Save Changes', 'tadv'); ?>" />
408 </p>
409 </form>
410
411 <div id="wp-adv-error-message" class="tadv-error">
412 <?php _e('The "Toolbar toggle" button shows/hides the second, third, and forth button rows. It will only work when it is in the first row and there are buttons in the second row.', 'tadv'); ?>
413 </div>
414 </div><!-- /wrap -->
415