-
Notifications
You must be signed in to change notification settings - Fork 12
/
lib_editor.php
62 lines (52 loc) · 2.15 KB
/
lib_editor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
* Copyright (c) 2006-2012 Oliver Seidel (email : oliver.seidel @ deliciousdays.com)
* Copyright (c) 2014-2017 Bastian Germann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** used to insert button in editor */
function cforms2_mce_button($buttons) {
array_push($buttons, "separator", "cforms");
return $buttons;
}
/** adding to TinyMCE */
function cforms2_mce($plugins) {
$plugins['cforms'] = plugin_dir_url(__FILE__) . 'js/cforms.tinymce.js';
return $plugins;
}
function cforms2_mce_translation($mce_translation) {
$mce_translation['Insert a form'] = __('Insert a form', 'cforms2');
return $mce_translation;
}
function cforms2_mce_script() {
$fns = array();
$forms = count(Cforms2\FormSettings::forms());
for ($i = 0; $i < $forms; $i++) {
$no = ($i == 0) ? '' : ($i + 1);
$fns[] = Cforms2\FormSettings::form($no)->name();
}
echo '<script type="text/javascript">// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later'
. "\ncforms2_formnames = " . json_encode($fns) . ";\n// @license-end</script>";
}
function cforms2_register_editor() {
// only insert buttons if enabled!
$cformsSettings = get_option('cforms_settings');
if ($cformsSettings['global']['cforms_show_quicktag'] && is_admin()) {
add_filter('mce_external_plugins', 'cforms2_mce');
add_filter('wp_mce_translation', 'cforms2_mce_translation');
add_filter('mce_buttons', 'cforms2_mce_button');
add_action('admin_print_scripts', 'cforms2_mce_script');
}
}