forked from bgermann/cforms2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_editor.php
More file actions
56 lines (49 loc) · 1.94 KB
/
lib_editor.php
File metadata and controls
56 lines (49 loc) · 1.94 KB
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
<?php
/*
* Copyright (c) 2006-2012 Oliver Seidel (email : oliver.seidel @ deliciousdays.com)
* Copyright (c) 2014 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', 'cforms');
return $mce_translation;
}
function cforms2_mce_script() {
$cformsSettings = get_option('cforms_settings');
$fns = array();
$forms = $cformsSettings['global']['cforms_formcount'];
for ($i=0;$i<$forms;$i++) {
$no = ($i==0)?'':($i+1);
$fns[] = $cformsSettings['form'.$no]['cforms'.$no.'_fname'];
}
echo '<script type="text/javascript">cforms2_formnames = ' . json_encode($fns) . ';</script>';
}
### only insert buttons if enabled!
if($cformsSettings['global']['cforms_show_quicktag'] == true) {
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' );
}